$(document).ready(function(){
//  $("#tab_video").tabs();

  // =================================================
  // video list
  $(".overlay_play").hide();
  $(".overlay_zoom").hide();
  $(".overlay").mouseover(function(){
       $(this).children(".overlay_play").show();
       $(this).children(".overlay_zoom").show();
  });
  $(".overlay").mouseout(function(){
       $(this).children(".overlay_play").hide();
       $(this).children(".overlay_zoom").hide();
  });

  $(".video_list dl").mouseover(function(){
    $(this).children("dt.overlay").children("a.overlay_play_s").show();
  });
  $(".video_list dl").mouseout(function(){
    $(this).children("dt.overlay").children("a.overlay_play_s").hide();
  });

  // =================================================
  // video gallery

  // =================================================
  // photo gallery
  $(".photo_gallery_dock").jScrollHorizontalPane(
    {showArrows:true,
     scrollbarHeight:15,
     arrowSize:15,
     dragMaxWidth:38}
  );

  $(".photo_gallery_dock img").click(function(){
    var src = $(this).attr("src");
    $(this).parents(".content").children(".photo_gallery_main").children("img").attr("src", src);
    $(".photo_gallery_dock li").removeClass("selected_item");
    $(this).parent("li").addClass("selected_item");
  });

  $("#feature_galleries img").mouseover(function(){
//					  $(this).addClass("zoom");
  });

  // =================================================
  // sub menu
if(document.getElementById("current_stage")){
  $(function(){
    var ow = 630;
    var obj = $("#status_bar li#current_stage p");
    var w = obj.width();
    var l = $("#status_bar li#current_stage").position().left;
    var pos = l - w/2;
    pos = (pos < 0)?0:pos;
    pos = ((l + w) > ow)?(ow - w):pos;
    obj.css("left", pos);
    obj.show();
  });
  $("#status_bar li#current_stage p").show();
  $("#status_bar li a").mouseover(function(){
    var ow = 630;
    var w = $(this).next("p").width();
//    var t = $(this).position().top;
    var l = $(this).position().left;

//    $("#debug").html(t + ":" + l);
    var pos = l - w/2;
    pos = (pos < 0)?0:pos;
    pos = ((l + w) > ow)?(ow - w):pos;
    $(this).next().css("left", pos);
    $(this).next().show();
  });
  $("#status_bar li a").mouseout(function(){
    $(this).next().hide();
    $("#status_bar li#current_stage p").show();
  });
}
  // =================================================
  // sub menu
  //$(".sub_menu ul").hide();
  $(".sub_menu ul").mouseover(function(){
       $(this).show();
  });
  $(".sub_menu ul").mouseout(function(){
       $(this).hide();
  });
  $(".sub_menu button").mouseover(function(){
       var elm = $(this).next("ul");
       //elm.fadeIn("fast");
		elm.show();
  });
  $(".sub_menu button").mouseout(function(){
       $(this).next("ul").hide();
  });

  // =================================================
  // bookmark
  $("#bookmark_links").hide();
  $("#save_to").toggle(function(){
      $("#bookmark_links").show();
    },function(){
      $("#bookmark_links").hide();
    });
  // =================================================
  //
});

var SBS={
  		_fs: "s",
  		init: function(){
    		this._fs = (jQuery.cookie('fs') == 'undefined')?"s":jQuery.cookie('fs');
    		if(this._fs == "l"){
      		this.increase();
    		}else{
      		$("img#fs").attr("src", "images/icon-font_s.png");
    		}
  		},
  		changeFontSize:function(){
    		if(this._fs == "s"){
      		this._fs = "l";
      		$(".content_block").addClass("big");
    		}else{
      		this._fs = "s";
      		$(".content_block").removeClass("big");
    		}
    		jQuery.cookie('fs', this._fs, 365);
  		},
  		expand:function(id, elm){
    		$("tbody#"+id).show();
  		},
        printPage: function(baseUrl, print_type, article_id, page) {
            /**
             * put whatever call you'd like in here, but here's a starter
             */
            w = 680;
            h = 600; 
            LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
			if(page==null)  {
  				window.open(baseUrl+'/print/'+print_type+'/'+article_id, 'print_view', 'width=680,height=600,top='+TopPosition+',left='+LeftPosition+',resizable=yes,scrollbars=yes');
  			} else {
				window.open(baseUrl+'/print/'+print_type+'/'+article_id+'/page/'+page, 'print_view', 'width=680,height=600,top='+TopPosition+',left='+LeftPosition+',resizable=yes,scrollbars=yes');
        	}
        },
        
        reportthisPage: function(baseUrl, article_id) {
            /**
             * put whatever call you'd like in here, but here's a starter
             */
             w = 675;
             h = 495;
             LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
			 TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
			window.open(baseUrl+'/reportthis/'+article_id, 'reportthis_view', 'width=675,height=495,top='+TopPosition+',left='+LeftPosition+',resizable=yes,scrollbars=auto');
        }
};

