/*=========================================================


	Site Name   HTML template
	File Name   function.js

	Create Date 2008/12/04
	Update Date 2008/12/04


==========================================================*/

/*========================================================*/
/*                                                        */
/*                                                        */
/*		1. Pop Up Window Function                 */
/*                                                        */
/*		2. RollOver Images Function*              */
/*                                                        */
/*		3. External Link Function*                */
/*                                                        */
/*		* Require jquery.js                       */
/*                                                        */
/*                                                        */
/*========================================================*/

/*----------------------------------------------------------

	1. Pop Up Window Function

-----------------------------------------------------------*/

function openBrWindow(url, name, myW, myH, scrollAndResize) {
	posX = (screen.availWidth - myW) / 2;
	posY = (screen.availHeight - myH) / 2;
	window.open(url, name, "left="+posX+", top="+posY+",width="+myW+", height="+myH+", scrollbars="+scrollAndResize+", resizable="+scrollAndResize);
}

/*----------------------------------------------------------

	2. RollOver Images Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	var image_cache = new Object();

	$("img.btn").each(function(i){
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf(".");
		var imgsrc_on = this.src.substr(0, dot) + "_r" + 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;}
		);

	});
})

/*----------------------------------------------------------

	3. External Link Function (require jquery.js)

-----------------------------------------------------------*/

$(function(){
	var popupEvent = function(event){
		window.open(this.href);
		event.preventDefault();
		event.stopPropagation();
	}

	$(".externalLink").each(function(i) {
		$(this).click(popupEvent);
		$(this).keypress(popupEvent);
	});
})