// ROLLOVER
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');
	var aInputs = document.getElementsByTagName('input');

	doRollover(aImages);
	doRollover(aInputs);

	function doRollover(array) {
		for (var i = 0; i < array.length; i++) {
			if (array[i].className == 'rollover') {
				var src = array[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_on'+ftype);

				array[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				array[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}
				
				array[i].onmouseout = function() {
					if (this.className != '') {
						if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
						this.setAttribute('src', sTempSrc);
					}
				}

			}
		}
	}
}
window.onload = initRollovers;

// PAGETOP
function backToTop() {
	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 / 2), Math.floor(y / 2));
	if (x > 0 || y > 0) {
	window.setTimeout("backToTop()", 25);
	}
}


// Window Open
var WinLoad2 = window.onload;
window.onload = function(e){
	if(WinLoad2){ WinLoad2(e); }
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}



// SearchBox
function onFocus(formName,elementName){
	var target = document.forms[formName].elements[elementName];
	if(target.value == target.defaultValue){
		target.value = "";
		target.style.color='#000000';
	}
}

function onBlur(formName,elementName){
	var target = document.forms[formName].elements[elementName];
	if(target.value == target.defaultValue || target.value == ""){
		target.value = target.defaultValue;
		target.style.color='#999999';
	}
}


function openwindow(id){
	var url = "http://"+window.location.host+"/unitprice/init.do?pageid=" + id;
//	var url = "http://"+window.location.host+"/products/unit.html"; 
	
	var winobj = window.open( url , 'unitprice' , "width=800,height=600,resizable=yes,scrollbars=yes,status=yes,screenX=0,screenY=0,left=0,top=0");
	winobj.focus();
}

function assetURL(id){
	var url = "http://"+window.location.host+"/assetalc/fundSelecteInit.do?pageid=" + id;
	var winobj = window.open( url , 'assetalc' , "width=800,height=600,resizable=yes,scrollbars=yes,status=yes,screenX=0,screenY=0,left=0,top=0");
	winobj.focus();
}

function contractURL() {
	window.open("https://"+window.location.host+"/red/zjbcm0000.do", "kokyaku", "width=900, height=700, resizable=1, scrollbars=1, status=0, location=0, directories=0, menubar=0, toolbar=0");
}

