var yy = "us";
var bz = "usd";
var dq = "5";
var gj = "united-states";
var lUp = "";
var lTop = "";
var nowUrl = "http://bestdesignerbootsshop.com/";
var action = "home";
var acc_mail = "Lisan@ManySize.com";
var root_path = "http://www.bestdesignerbootsshop.com/";
var style_path = "http://www.bestdesignerbootsshop.com/include/temp/";
var total = "";
var shopping_num = "";
var user = "<a href="+ root_path + yy +"/ onclick=\"alert(\'Cart is empty!\');return false;\">Show Cart</a><br /><a href="+ root_path + yy +"/user-login.html>Log In</a><br /><a href="+ root_path + yy +"/user-register.html>Sign Up</a><br /><a href="+ root_path + yy +"/msg-wholesale.html style=\"padding-bottom: 5px;display: block;\">Wholesalers?</a>";
//下拉菜单跳转动作
function JumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//搜索ID判断
function search_go(){
	var regx = /^\d{1,8}$/;		//ID正则
	var text = document.search_goods.text.value;
	if(!text || text=="0" || text=="Enter name or id ..."){
		alert("Please enter a right goods id or name!");
		return false;
	}
	if(regx.test(text)){
		window.location.href = root_path+yy+"/pro-"+ text +"/show.html";
		//window.open(root_path+yy+"/pro-"+ text +"/search-id.html",'_parent')
		//alert("Please enter a goods "+ type +"! \nFind the goods? \nPlease enter the catalog to find! Thanks you!");
		return false;
	}else{
		var text = text.replace(/([^0-9a-z]+)/ig,"-");
		var text = text.replace(/-+/,"-");
		var text = text.replace(/^-+/,"");
		var text = text.replace(/-+$/,"");
		var text = text.toLowerCase();
		window.location.href = root_path+yy+"/search/"+ text +"-1.html";
		//window.open(root_path+yy+"/search/"+ text +"-1.html",'_parent') 
		return false;    
	}
}

//询盘与订单操作按扭
function gt(type,id){
	if(type=="i"){ window.location.href = root_path+yy+"/msg-"+id+".html"; }
	if(type=="o"){ window.location.href = root_path+yy+"/cart-add/"+id+"_"+ parseInt(Math.random()*9999) +"-503-1.html"; }
	if(type=="s"){ window.location.href = root_path+yy+"/pro-"+id+"/show.html"; }
	//if(type=="i"){ window.open(root_path+yy+"/msg-"+id+".html","_parent") }
	//if(type=="o"){ window.open(root_path+yy+"/cart-add/"+id+"-1.html","_parent") }
	//if(type=="s"){ window.open(root_path+yy+"/pro-"+id+"/show.html","_parent") }
	return false;   
}

//购物车操作按扭
function toCart(type,id){
	if(id=="quickorder"){
        var qId = document.getElementById("quickorder").value;
        var regx = /^\d{1,8}$/;		//ID正则
        if(!regx.test(qId)){
            alert("Please enter a order id!");
            return false;
        }
		var toId = qId +"_"+ parseInt(Math.random()*9999) +"-503-1";
	}else if(type=="add"){
        var qty  = document.getElementById('qty').value;
        var sizeId = document.getElementById("size"+id).value;
        if(!qty){qty = 0;}
		var toId = id +"_"+ parseInt(Math.random()*9999) +"-"+ sizeId +"-"+qty;
	}else if(type=="del"){
		var toId = id +"-0-0";
	}else{
		var toId = id;
	}
	window.location.href = root_path+yy+"/cart-"+type+"/"+toId+".html";
	//window.open(root_path+yy+"/cart-"+type+"/"+toId+".html","_parent")
	return false;   
}

//提交留言
function toPostMsg(){
	var msg = document.postMsg.text.value;
	if(/^[0-9]{1,8}$/.test(pass)){
		window.location.href = root_path+yy+"/pifa-"+pass+".html";
	}else{
		alert("This password is error!!!");
		return false;
	}
	return false; 
}

//购物车操作按扭
function toWholesale(jumpLink){
	var pass = document.wholesalers.text.value;
	if(/^[0-9]{1,8}$/.test(pass)){
		window.location.href = root_path+yy+"/pifa-"+pass+".html" + jumpLink;
	}else{
		alert("This password is error!!!");
		return false;
	}
	return false;   
}

//弹窗事件开始
function OP(objId,conId,srcs,proid){
	var arrayPageSize   = getPageSize();
	var arrayPageScroll = getPageScroll();
	if (!document.getElementById("popupAddr")){
	var popupDiv = document.createElement("div");
	popupDiv.setAttribute("id","popupAddr")
	popupDiv.style.position = "absolute";
	popupDiv.style.border = "0px"; //"3px solid #666666"
	popupDiv.style.padding = "0px";
	//popupDiv.style.background = "#fff";
	popupDiv.style.zIndex = 99;
	var bodyBack = document.createElement("div");
	bodyBack.setAttribute("id","bodybg")
	bodyBack.style.position = "absolute";
	bodyBack.style.width = "100%";
	bodyBack.style.height = (arrayPageSize[1] + 35 + 'px');
	bodyBack.style.zIndex = 98;
	bodyBack.style.top = 0;
	bodyBack.style.left = 0;
	bodyBack.style.filter = "alpha(opacity=20)";
	bodyBack.style.opacity = 0.6;
	bodyBack.style.background = "#000000";
	var mybody = document.getElementById(objId);
	insertAfter(popupDiv,mybody);
	insertAfter(bodyBack,mybody);
	}
	document.getElementById("bodybg").style.display = "";
	var popObj=document.getElementById("popupAddr")
	popObj.innerHTML = document.getElementById(conId).innerHTML;
	popObj.style.display = "";
	var arrayConSize = getConSize(conId)
	popObj.style.top  = arrayPageScroll[1] + (arrayPageSize[3] - arrayConSize[1]) / 6 + 30 + 'px';
	//popObj.style.top  = arrayPageScroll[1] + (arrayPageSize[3] - arrayConSize[1]) / 6-50 + 'px';
	//arrayPageScroll[1] + (arrayPageSize[3] - arrayConSize[1]) / 6-50 + 'px';
	popObj.style.left = "30px";
	//(arrayPageSize[0] - arrayConSize[0]) / 2 - arrayPageSize[0]/3 + 'px';
	document.getElementById("pic").src =srcs;
	document.getElementById('proid').value=proid;
}
function getConSize(conId){
		var conObj=document.getElementById(conId)
		conObj.style.position = "absolute";
		conObj.style.left=-1000+"px";
		conObj.style.display="";
		var arrayConSize=[conObj.offsetWidth,conObj.offsetHeight]
		conObj.style.display="none";
		return arrayConSize;
}
function insertAfter(newElement,targetElement){
		var parent = targetElement.parentNode;
		if(parent.lastChild == targetElement){
		parent.appendChild(newElement);
		}
		else{
		parent.insertBefore(newElement,targetElement.nextSibling);
		}
}
function getPageScroll(){
		var yScroll;
		if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
		} else if (document.body) {
		yScroll = document.body.scrollTop;
		}
		arrayPageScroll = new Array('',yScroll)
		return arrayPageScroll;
}
function getPageSize(){
	var xScroll,yScroll;
	
	if (window.innerHeight && window.scrollMaxY){
	xScroll = document.body.scrollWidth;
	yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
	sScroll = document.body.scrollWidth;
	yScroll = document.body.scrollHeight;
	} else {
	xScroll = document.body.offsetWidth;
	yScroll = document.body.offsetHeight;
	}
	var windowWidth,windowHeight;
	if (self.innerHeight) {
	windowWidth = self.innerWidth;
	windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
	windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
	windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
	}
	
	var pageWidth,pageHeight
	if(yScroll < windowHeight){
	pageHeight = windowHeight;
	} else {
	pageHeight = yScroll;
	}
	if(xScroll < windowWidth) {
	pageWidth = windowWidth;
	} else {
	pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function closeLayer(){
	document.getElementById("popupAddr").style.display = "none";
	document.getElementById("bodybg").style.display = "none";
	return false;
}
//弹窗事件结束
