﻿$(function(){
    var width="100%";
    var height="100%";
    var o=$("body");
    
    $("#editors_note a").toggle(
	    function(){
	    	
	    	$(window).unbind('resize');
			
			o.append("<div id='overlay'></div>");

			width = OverlaySize()[0];
			height = OverlaySize()[1];

	        $("#overlay").css({
	                "opacity":"0",
	                "width":width,
	                "height":height - 64
	        });
	        
	        $("#overlay").fadeTo("slow", 0.35);
	        $("#editors_note_body").css({"left":$("#editors_note a").position().left - 200 + 88});
			$("#editors_note_body").slideDown("slow");
			$("#overlay").click(function(){$("#editors_note a").click()});
			
			$(window).resize(function(){
		        $("#overlay").css({
		                "width":OverlaySize()[0],
		                "height":OverlaySize()[1] - 64
		        });
		        $("#editors_note_body").css({"left":$("#editors_note a").position().left - 200 + 88});
			});
	    },
		function(){
			$("#overlay").fadeTo("slow", 0, function(){ $("#overlay").remove() } );
	        $("#btn_close").remove();
	        $("#editors_note_body").slideUp("slow");
		}
	);

    $("img.over").each(function(){
	    rolloverSrc = $(this).attr('src').replace(/(\.gif|\.jpg|\.png)$/, "_on"+"$1"); 
	　　$(this).clone().insertAfter(this) 
	      .attr('src',rolloverSrc) 
	      .css('display','none'); 
	    $(this).mouseover(function(){ 
	      $(this).hide(); 
	      $(this).next().show(); 
	    }); 
	    $(this).next().mouseout(function(){ 
	      $(this).hide(); 
	      $(this).prev().show(); 
	    }); 
    });    

	//Default
	$("#editors_note_body").css({
	   "left":$("#editors_note a").position().left - 200 + 88
	});
	ThickboxiframeSize();
	
});

function OverlaySize(){
    var xScroll, yScroll; 
    if(window.innerHeight && window.scrollMaxY){
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    }else if(document.body.scrollHeight > document.body.offsetHeight){
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    }else{
        xScroll = Math.max(document.body.offsetWidth ,document.body.scrollWidth);
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if(self.innerHeight) {
        if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight; 
    }else if(document.documentElement && document.documentElement.clientHeight){
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    }else if(document.body){
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

	return [Math.max(xScroll ,windowWidth), Math.max(yScroll ,windowHeight)];
}

function ThickboxiframeSize(){
	width = OverlaySize()[0] - 100;
	height = OverlaySize()[1] - 100;
	p001 = "375/index.html#1?keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;
	p002 = "376/index.html#1?keepThis=true&TB_iframe=true&height=" + height + "&width=" + width;

	var isIE6 = ($.browser.msie && parseInt($.browser.version.substr(0,1)) < 7);

	if(isIE6){
		$("#a001").attr('href', "375/index_iframe.html?keepThis=true&TB_iframe=true&height=" + height + "&width=" + width);
		$("#a002").attr('href', "376/index_iframe.html?keepThis=true&TB_iframe=true&height=" + height + "&width=" + width);
	}else{
		$("#a001").attr('href', p001);
		$("#a002").attr('href', p002);
	}
	
}
