/*rollover*/
function initRollOverImages(){
	var image_cache = new Object();//preload images
	$("img.btn").each(function(i){
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var imgsrc_on = this.src.substr(0, dot) + '_o' + this.src.substr(dot, 4);
	image_cache[this.src] = new Image();
	image_cache[this.src].src = imgsrc_on;
	$(this).hover(
		function(){ this.src = imgsrc_on; },
		function(){ this.src = imgsrc; });
	});

	var inputimage_cache = new Object();//preload images
	$("input.btn").each(function(i){
	var inputsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var inputsrc_on = this.src.substr(0, dot) + '_o' + this.src.substr(dot, 4);
	inputimage_cache[this.src] = new Image();
	inputimage_cache[this.src].src = inputsrc_on;
	$(this).hover(
		function(){ this.src = inputsrc_on; },
		function(){ this.src = inputsrc; });
	});
}
$(document).ready(initRollOverImages);




/*external link*/
function initOpenNewWindow(){
	var popupEvent = function(event){
		window.open(this.href);
		event.preventDefault();
		event.stopPropagation();
	}
	$("a.externalLink").each(function(i) {
		$(this).click(popupEvent);
		$(this).keypress(popupEvent);
	});
}
$(document).ready(initOpenNewWindow);




/*backtotop*/
function backToTop(){
	var mySpeed = 1.1;
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	if(document.documentElement){
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if (document.body){
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	var x = Math.max(x1,Math.max(x2,x3));
	var y = Math.max(y1,Math.max(y2,y3));
	window.scrollTo(Math.floor(x/mySpeed), Math.floor(y/mySpeed));
	if (x > 0 || y > 0){
		window.setTimeout("backToTop()",10);
	}
}




/*rollover*/
function initSwapBG(){
	var image_cache = new Object();//preload images
	$("img.swapBG").each(function(i){
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('btn');
	var imgsrc_on = this.src.substr(0, dot) + "naviside_" + this.src.substr(dot + 3, 7);
	var imgsrc_num = activePage.substr(10, 2);
	var imgsrc_default = this.src.substr(0, dot) + "naviside_" + imgsrc_num + ".gif";
	image_cache[imgsrc_on] = new Image();
	image_cache[imgsrc_on].src = imgsrc_on;

	$("div." + activePage).css("background-image","url(" + imgsrc_default + ")") //Set Background Image

	$(this).hover(
		function(){ $("div." + activePage).css("background-image","url(" + imgsrc_on + ")");
		},
		function(){ $("div." + activePage).css("background-image","url(" + imgsrc_default + ")");
		});
	});
}
$(document).ready(initSwapBG);




/*popup*/
function getFullscreen(thePage){
	var theWidth = screen.availWidth;
	var theHeight = screen.availHeight;
	window.open(thePage,"test01","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width="+theWidth+",height="+theHeight);
}