﻿/* ■■ common.js ■■ */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {
}

// <a href="#Header" onclick="ReturnToTop(); return false;">TOP</a>
function ReturnToTop(pos,now) {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = y4 = 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));
	if (!pos) {
		
		window.scrollTo(Math.floor(x / 1.25), Math.floor(y / 1.25));
		if (x > 0 || y > 0) {
			window.setTimeout("ReturnToTop()", 25);
		}
	} else {
		
		if (window.opera) {
			
			var usrAge = navigator.userAgent;
			var posStart = usrAge.indexOf("Opera",0);
			var posEnd = usrAge.indexOf(" ",posStart+6);
			if (posEnd <= 0) posEnd = usrAge.length;
			var AgeVer = usrAge.substring(posStart+6,posEnd);
			if (AgeVer < 9) {
				window.open("#"+pos,"_self")
				return false;
			}
		}
		var isMSIE = /*@cc_on!@*/false;
		var targetEle = document.getElementById(pos);

		while( targetEle ){
			y4 += targetEle.offsetTop;
			targetEle = targetEle.offsetParent;
			//IE revision
			if ((targetEle) && (isMSIE)) {
				y4 += (parseInt(getElementStyle(targetEle,"borderTopWidth","border-top-width")) || 0);
			}
		}

		var y5 = y4-y;
		y += Math.floor(y5 / 5);
		window.scrollTo(x, y);
		if ((!now || now != y)&&(y > y4-5 || y < y4-5)) {
			window.setTimeout('ReturnToTop("'+pos+'","'+y+'")', 25);
		}
	}
}
function getElementStyle(targetElm,IEStyleProp,CSSStyleProp) {
	var elem = targetElm;
	if (elem.currentStyle) {
		return elem.currentStyle[IEStyleProp];
	} else if (window.getComputedStyle) {
		var compStyle = window.getComputedStyle(elem,"");
		return compStyle.getPropertyValue(CSSStyleProp);
	}
}

// ■□ RollOver
// Standards Compliant Rollover Script
// Author : Daniel Nolan
// http://www.bleedingego.co.uk/webdev.php

function RollOver() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_ro'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_ro'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

try{
  window.addEventListener("load", RollOver,false);
    }catch(e){
  window.attachEvent("onload", RollOver);
}

function resetRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if (images[i].className == 'rollover') {
				if(images[i].getAttribute("src").match("_ro.")) {
					images[i].setAttribute("src", images[i].getAttribute("src").replace("_ro.", "."));
				}
			}
		}
	}
}


// ■□ ResetValue
function ResetValue(pos,dflt){
	if(pos.value == dflt){
		pos.value = "";
		pos.style.color = "#000000";
	}
}

// ■□ SetValue
function SetValue(pos,dflt){
	if(pos.value == ''){
		pos.value = dflt;
		pos.style.color = "#999999";
	}
}

// ■□ CheckDefault
function CheckDefault(pos,dflt){
	if(document.getElementById(pos).value == dflt || document.getElementById(pos).value == ""){
		document.getElementById(pos).value = "";
		document.getElementById(pos).select() ; return false;
	}
}


// ■□ PopupLink
function PopupLink(url,option) {
	if(option){
		window.open(url,"_blank",option);
	}else{
		window.open(url,"_blank");
	}
}


////////////////////////////////////////////////
//making orignal

function setHeight(){
	//download
	j$('.p-list').css('height','0px');
	j$('.p-list').css('overflow','hidden');
	//FAQ
	j$('.a-section').css('height','0px');
	j$('.a-section').css('overflow','hidden');
}

function showAtxt(index){
 var VarUsrAgt = navigator.userAgent.toLowerCase();
 $cildArray = j$('.faqbox').children('.a-section');
 if(j$($cildArray[index]).height() > 0){
 if(VarUsrAgt.indexOf("safari/5") != -1){
 j$($cildArray[index]).css({
 height:"0px", overflow:"hidden"
 });
 }else{
 j$($cildArray[index]).animate({
 height:"0px"
 },300,function(){document.getElementById('footer').style.bottom = "0";});
 }
 }else{
 j$($cildArray[index]).animate({
 height:j$($cildArray[index]).find('.box').height() + 23 + "px"
 },300,function(){document.getElementById('footer').style.bottom = "0";});
 }
} 

function showPlist(index){
 var VarUsrAgt = navigator.userAgent.toLowerCase();
 $cildArray = j$('.printbox').children('.p-list');
 if(j$($cildArray[index]).height() > 0){
 if(VarUsrAgt.indexOf("safari/5") != -1){
 j$($cildArray[index]).css({
 height:"0px", overflow:"hidden"
 });
 }else{
 j$($cildArray[index]).animate({
 height:"0px"
 },300,function(){document.getElementById('footer').style.bottom = "0";});
 }
 }else{
 j$($cildArray[index]).animate({
 height:j$($cildArray[index]).find('.box').height() + 3 + "px"
 },300,function(){document.getElementById('footer').style.bottom = "0";});
 }
 
}

function mailSpamProtection(){
var s="&+#,LZ/&3\"/0H},H\'-",r="";for(i=0;i<s.length;i++)r+=String.fromCharCode((s.charCodeAt(i)+34)%93+33);document.write(r);
}

function flash_inner(){
	if(document.getElementById('inner')){
		document.getElementById('inner').style.display = 'none'; 
	}
}

function top_flash(){
	
	var so = new SWFObject("swf/top/main-bnr.swf", "mainexternal", "100%", "100%", "9", "#FFFFFF",true);
	so.addParam("allowScriptAccess", "always");
	so.addParam("quality", "high");
	so.addParam("scale", "noscale");
	so.addParam("base", ".");	
	
	if(so.installedVer.major >= 9){
		so.write("flashexternal");
	}else{
		document.getElementById('inner').style.display = 'block'; 
	}
}

function whats_flash(){
	var so = new SWFObject("../../swf/whats.swf", "whatsexternal", "100%", "100%", "9", "#FFFFFF",true);
	so.addParam("allowScriptAccess", "always");
	so.addParam("quality", "high");
	so.addParam("scale", "noscale");
	so.addParam("base", ".");
	if(so.installedVer.major >= 9){
		so.write("flashexternal");
	}else{
		document.getElementById('inner').style.display = 'block'; 
	}
}





