$(document).ready(function() {
	//Examples of how to assign the ColorBox event to elements
	$(".login1").colorbox({innerWidth:650, innerHeight:330, iframe:true});
	$(".login2").colorbox({innerWidth:770, innerHeight:310, iframe:true});	
	$(".apply1").colorbox({innerWidth:882, innerHeight:470, iframe:true});
	$(".apply2").colorbox({innerWidth:882, innerHeight:434, iframe:true});
	$(".mvplayer").colorbox({innerWidth:700, innerHeight:550, iframe:true});
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function()
	{ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
});
function toggle(targetid)
{
    if (document.getElementById)
	{
        target=document.getElementById(targetid);
		if (target.style.display=="block")
		{
			target.style.display="none";
		}
		else
		{
			target.style.display="block";
		}
    }
}
jQuery(document).ready(function(){
	jQuery("ul.scrollMenu").sh_scrollMenu();
});
(function(){
	jQuery.fn.sh_scrollMenu = function(){
		return jQuery(this).each(function()
		{
			jQuery(this).css("overflow","hidden");
			jQuery(this).mousemove(function(e)
			{
				sh_autoScroll(e,this);
			});
			jQuery(this).click(function()
			{
				sh_lockScroll(this);
			});
		});
	};
})();
//設於 onmouseover(event,this)中, 以做為操作頁上下滑動用.
function sh_autoScroll(e,ob)
{
	var sh_lastClientYValue = 0;
	if(ob.getAttribute("sh_lock") != "on")
	{
		if(ob.getAttribute("sh_lastClientYValue") == null)
		{
			ob.setAttribute("sh_lastClientYValue",sh_lastClientYValue);
		}
		else
		{
			sh_lastClientYValue = ob.getAttribute("sh_lastClientYValue");
		}
		var tempScrollTop = eval(ob.scrollTop);
		var jumpValue = eval(ob.scrollHeight/ob.offsetHeight);
		var jumpElements = Math.abs(eval(sh_lastClientYValue - e.clientY));
		if(jumpElements >= 5){
			if(e.clientY < sh_lastClientYValue){
				if(tempScrollTop - jumpValue * jumpElements >= 0){
					ob.scrollTop = tempScrollTop - (jumpValue * jumpElements);
				}else
				{
					ob.scrollTop = 0;
				}
			}else
			{
				if(tempScrollTop + jumpValue * jumpElements <= ob.scrollHeight)
				{
					ob.scrollTop = tempScrollTop + (jumpValue * jumpElements);
				}
				else
				{
					ob.scrollTop = ob.scrollHeight;
				}
			}
			ob.setAttribute("sh_lastClientYValue",e.clientY);
		}
	}
}
