function sAlert(txt,title){
       var eSrc=(document.all)?window.event.srcElement:arguments[1];
       var shield = document.createElement("DIV");
       shield.id = "shield";
       shield.style.position = "absolute";
       shield.style.left = "0px";
       shield.style.top = "0px";
       shield.style.width = "100%";
       shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
       shield.style.background = "#333";
       shield.style.textAlign = "center";
       shield.style.zIndex = "10000";
       shield.style.filter = "alpha(opacity=0)";
       shield.style.opacity = 0;
       var alertFram = document.createElement("DIV");
       alertFram.id="alertFram";
       alertFram.style.position = "absolute";
       alertFram.style.left = "50%";
       alertFram.style.top = "50%";
       alertFram.style.marginLeft = "-225px" ;
       alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
       alertFram.style.width = "450px";
       alertFram.style.height = "150px";
       alertFram.style.background = "#ccc";
       alertFram.style.textAlign = "center";
       alertFram.style.lineHeight = "150px";
       alertFram.style.zIndex = "10001";
	   if(title==null||title==""){title="Tips";}
       strHtml  = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
       strHtml += "       <li style=\"font-family: Arial, Helvetica, sans-serif;background:#B9D67D;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:25px;line-height:25px;border:1px solid #B9D67D;\">"+title+"</li>\n";
       strHtml += "       <li style=\"font-family: Arial, Helvetica, sans-serif;background:#ffffff;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:120px;line-height:25px;border:1px solid #B9D67D;\">"+txt+"</li>\n";
       strHtml += "       <li style=\"font-family: Arial, Helvetica, sans-serif;background:#B9D67D;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #B9D67D;\"><input type=\"button\" value=\"Ok\" id=\"do_OK\" onclick=\"doOk()\" /></li>\n";
       strHtml += "</ul>\n";
       alertFram.innerHTML = strHtml;
       document.body.appendChild(alertFram);
       document.body.appendChild(shield);
       this.setOpacity = function(obj,opacity){
              if(opacity>=1)opacity=opacity/100;
              try{ obj.style.opacity=opacity; }catch(e){}
              try{ 
                     if(obj.filters.length>0&&obj.filters("alpha")){
                            obj.filters("alpha").opacity=opacity*100;
                     }else{
                            obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
                     }
              }catch(e){}
       }
       var c = 0;
       this.doAlpha = function(){
              if (++c > 20){clearInterval(ad);return 0;}
              setOpacity(shield,c);
       }
       var ad = setInterval("doAlpha()",1);
       this.doOk = function(){
              //alertFram.style.display = "none";
              //shield.style.display = "none";
              document.body.removeChild(alertFram);
              document.body.removeChild(shield);
              //eSrc.focus();
              document.body.onselectstart = function(){return true;}
              document.body.oncontextmenu = function(){return true;}
       }
       document.getElementById("do_OK").focus();
       //eSrc.blur();
       document.body.onselectstart = function(){return false;}
       document.body.oncontextmenu = function(){return false;}
}


function changeLanguage(language)
{
	var path = parent.location + "";
	var index = path.indexOf("language");
	var str = "";
	if(parseInt(index) > 0)
	{
		var replace_index = index + 9;  //get the replace index
		str = path.substr(0, replace_index) + language + path.substring(replace_index + 1, path.length); 
	}
	else 
	{
		index = path.indexOf("?");
		if(parseInt(index) > 0)
		{
			str = path + "&language=" + language;
		}
		else
		{
			str = path + "?language=" + language;
		}
		
	}
	parent.location.href = str;
}

function changesession(cd)
{
	var str = cd.split('/');
	parent.location.href="include/firstpage.php?ch=include/web/"+str[str.length-1];

}

function changeSrc(src)  //reset the url for main when refresh
{
	var str = src.split('/');
	var url = localUrl() + "include/changeSrc.php?ch=include/web/"+str[str.length-1];
	//window.alert('URL:'+url);
	//window.alert('str[str.length-1]:'+str[str.length-1]);
	createXMLHttpRequest();
	xmlHttp.open("GET",url,false);
	//xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	// window.alert("send ok");
	xmlHttp.onreadystatechange = handleSession;
	xmlHttp.send(null);
}
function handleSession()  //did anything,but for the ajax
{
	if(xmlHttp.readyState == 4)
	  {
		  if(xmlHttp.status == 200)
		    {
			  //divMsg.innerHTML = xmlHttp.responseText;
			}
	  }
}

function openModulUrl() //open new url
{
	//var search_txt = document.getElementByName("keywords").value;
	var search_txt=document.getElementById("keywords").value;
	if(search_txt == 'ex : aiguilles')
	{
       alert('Please input the value which you need to search!');
	}
	else
	//parent.mainFrame.location = modulUrl;
	{
        parent.mainFrame.location = 'include/web/a.html';
	}

}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function replaceModulUrl(modulUrl)  //change the url 
{
	parent.mainFrame.location =  modulUrl;
}


var xmlHttp;
var divMsg;
var xmlHttp2;
var divMsg2;
function createXMLHttpRequest()  //create XMLHTTPREQUEST
 {
	if(window.XMLHttpRequest)
		{
			xmlHttp = new XMLHttpRequest();
			//window.alert("create1");
			if (xmlHttp.overrideMimeType)
				{
					xmlHttp.overrideMimeType("text/xml");
					//window.alert("override");
				}
		}
	else if(window.ActiveXObject)
		{
			var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
			for(var i=0;i<msxml.length;i++)
				{
					try
						{
							xmlHttp = new ActiveXObject(msxml[i]);
							//window.alert("create2");
							break;
						}
					catch(e)
						{
							
						}
				}
		}
	if (!xmlHttp)
		{
			window.alert("Your Internet Explore can't support Ajax£¬please update it£¡");
			return false;
		}
 }
 function createXMLHttpRequest3()  //create XMLHTTPREQUEST
 {
	var newxmlHttp = null;
	if(window.XMLHttpRequest)
		{
			newxmlHttp = new XMLHttpRequest();
			//window.alert("create1");
			if (newxmlHttp.overrideMimeType)
				{
					newxmlHttp.overrideMimeType("text/xml");
					//window.alert("override");
				}
		}
	else if(window.ActiveXObject)
		{
			var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
			for(var i=0;i<msxml.length;i++)
				{
					try
						{
							newxmlHttp = new ActiveXObject(msxml[i]);
							//window.alert("create2");
							break;
						}
					catch(e)
						{
							
						}
				}
		}
	if (!newxmlHttp)
		{
			window.alert("Your Internet Explore can't support Ajax£¬please update it£¡");
			return false;
		}
	return newxmlHttp;
 }
 function createXMLHttpRequest2()  //create XMLHTTPREQUEST
 {
	if(window.XMLHttpRequest)
		{
			xmlHttp2 = new XMLHttpRequest();
			//window.alert("create1");
			if (xmlHttp2.overrideMimeType)
				{
					xmlHttp2.overrideMimeType("text/xml");
					//window.alert("override");
				}
		}
	else if(window.ActiveXObject)
		{
			var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
			for(var i=0;i<msxml.length;i++)
				{
					try
						{
							xmlHttp2 = new ActiveXObject(msxml[i]);
							//window.alert("create2");
							break;
						}
					catch(e)
						{
							
						}
				}
		}
	if (!xmlHttp2)
		{
			window.alert("Your Internet Explore can't support Ajax£¬please update it£¡");
			return false;
		}
 }
function localUrl()  //get the root url
{
	var local = parent.location+"";
	var return_str = local.substring(0,local.lastIndexOf('index.php'));
	//window.alert(return_str);
	return return_str;
}
function localRootUrl()  //get the root url
{
	var local = parent.location+"";
	var return_str = local.substring(0,local.lastIndexOf('/'));
	//window.alert(return_str);
	return return_str;
}

function changeMenuBack(index,menuChildId,indexURL) //menu changed
{
	//window.alert("index=" + index);
	var url = "include/changeMenuBack.php?menuId=" + index + "&childMenuId=" + menuChildId;
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						//var newUrl = localRootUrl() + "/" + indexURL;
						//window.alert(newUrl);
						parent.location.href = indexURL;  
					}
			}
	
	};
	xmlHTTPRequest.send(null);

}
function record_path(path)  //for login
{
	window.alert("currectPath:" + path) ;
	
	var url = localRootUrl() + "/include/record_path.php?currentPath=" + path;
	//window.alert(url);
	createXMLHttpRequest();
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = handleSession;
	//window.alert("sending1...");
	xmlHttp.send("aa");

}
function logout(msg)  //logout,clean the login session
{
  if(window.confirm(msg))
  {
	//parent.location ='include/logout.php';
	var url = localRootUrl() + "/logout.php";
	createXMLHttpRequest();
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = handleSession;
	//window.alert("sending1...");
	xmlHttp.send(null);
	removeSubcategory();  //remove the category and subcategory which the client choose before
	document.location.replace(url);
	//var local = parent.location + "";
	//parent.location = local.substring(0,local.lastIndexOf('/')) + "/index.php";  //LOGOUT,GO TO HOME PAGE
  }
}
function loadSubcategory(language)  //load subcategory
{
	//var url = "http://dvpc1/wanghai/MTM10/include/showSubcategory.php?categoryId="+selectedID+"&language="+language;
	
	var selectedID = document.getElementById('m2').value;
	var showID = document.getElementById('subrecherche');
	var url = localUrl() + "include/showSubcategory.php?categoryId="+selectedID+"&language="+language;
	dosendAjax(showID,url);
}

function dosendAjax(showID,URL)  //ajax for total
{
	divMsg = showID;
	//window.alert("dosendAjax");
	createXMLHttpRequest();
	xmlHttp.open("GET",URL,true);
	xmlHttp.onreadystatechange = handleStage;
	//window.alert("sending1...");
	xmlHttp.send("aa");
	//window.alert("over...");
}
function dosendAjax2(showID,URL)  //ajax for total
{
	divMsg2 = showID;
	//window.alert("wainting...");
	//window.alert("dosendAjax2");
	createXMLHttpRequest2();
	//xmlHttp2 = xmlHttp;
	xmlHttp2.open("GET",URL,true);
	xmlHttp2.onreadystatechange = handleStage2;
	//window.alert("sending1...");
	xmlHttp2.send(null);
	//window.alert("over...");
}

function handleStage()//add the get message on the div
 {
	//window.alert("handle...");
	if(xmlHttp.readyState == 4)
	  {
		  if(xmlHttp.status == 200)
		    {
			 // window.alert("showing1...");
			  divMsg.innerHTML = xmlHttp.responseText;
			  divMsg.style.cssText = "visibility:visible"; //IE
			  divMsg.setAttribute("style","visibility:visible"); //FF
			}
	  }
 }
function handleStage2()//add the get message on the div
 {
	//window.alert("handle...");
	if(xmlHttp2.readyState == 4)
	  {
		  if(xmlHttp2.status == 200)
		    {
			  //window.alert("showing2...");
			  divMsg2.innerHTML = xmlHttp2.responseText;
			  divMsg2.style.cssText = "visibility:visible"; //IE
			  divMsg2.setAttribute("style","visibility:visible"); //FF
			}
	  }
 }
function searchhelper(showid,word) //pass the keyword for the searchhelper
{
	var url = localUrl() + "include/searchhelper.php?searchLetters=" + word;
	dosendAjax(showid,url);
}

function loadCategory(language) //load category,rembersign 0:no 1:yes,for refreshing
{
	var selectedID = document.getElementById('m1').value;
	var showID = document.getElementById('m3');
    //window.alert(selectedID);
	//window.alert(showID);
	var url = "include/showCategory.php?codeId=" + selectedID + "&language=" + language;
	//window.alert(url);
	dosendAjax(showID,url);
	
	
}

function reloadSubcategory1(language) //reload subcategory when change the branch
{
	//window.alert("b");
	var selectedID = document.getElementById('m1').value;
	var showID = document.getElementById('subrecherche');
	//window.alert(showID);
	var url = localUrl() + "include/reloadSubcategory.php?codeId="+selectedID+"&language="+language;
	//window.alert(url);
	dosendAjax2(showID,url);
	//window.alert("send over");
}
function reloadSubcategory_f(language)  //loading at onload
{
	var selectedID = "";
	var showID = document.getElementById('subrecherche');
	var url = localUrl() + "include/showSubcategory.php?language=" + language + "&categoryId=" + selectedID;
	//window.alert("URL1:" + url);
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						showID.innerHTML = xmlHTTPRequest.responseText;
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}

function removeSubcategory()  //loading at onload
{
	var showID = document.getElementById('subrecherche');
	var url = localUrl() + "include/removeshowSubcategory.php";
	//window.alert("URL1:" + url);
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					{
						showID.innerHTML = "";
					}
			}
	
	};
	xmlHTTPRequest.send(null);
	

}
function reloadSubcategory(language) //reload subcategory when change the branch
{
	var selectedID = document.getElementById('m1').value;
	var showID = document.getElementById('subrecherche');
	var url = localUrl() + "include/reloadSubcategory.php?codeId="+selectedID+"&language="+language;
	var xmlHTTPRequest2 = createXMLHttpRequest3();
	//window.alert("xmlHTTPRequest:" + xmlHTTPRequest);
	xmlHTTPRequest2.open("GET",url,true);
	xmlHTTPRequest2.onreadystatechange = function(){
		if(xmlHTTPRequest2.readyState == 4)
			{
				 if(xmlHTTPRequest2.status == 200)
					 {
						showID.innerHTML = xmlHTTPRequest2.responseText;
						getHeightOf();
					}
			}
	
	};
	xmlHTTPRequest2.send(null);
}

function loadCutproduct(language,type)
{
	var selectID = document.getElementById('m1').value;
	var showID = document.getElementById("mboxTD");
	var url = "include/getSpecialProduct.php?branchId=" + selectID + "&language=" + language+ "&type=" + type;
	var xmlHTTPRequest = createXMLHttpRequest3();
	
	//xmlHttpRequest.abort();//È¡ÏûAJAX
	
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 1)
			{
				var label;
				label="<img src=\"images/ajax-loader.gif\" align=\"middle\"  border=\"0\" width=\"512\"\">";
				label+="<br><b><font size=\"24px\">Loading</font></b>";
   			 showID.innerHTML=label;
		}
		
		
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {						
						//window.alert("Loading");
						//showID.innerHTML = "Loading";
						
						showID.innerHTML = "";
						showID.innerHTML = xmlHTTPRequest.responseText;
						getHeightOf();
						
						
						//window.alert("finished");
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}

function loadProduct(language,type)
{
	var selectID = document.getElementById('m2').value;
	if(parseInt(selectID) > 0)
	{
		var showID = document.getElementById("mboxTD");
		//window.alert(type);
		var url = localUrl() + "include/randomProduct.php?categoryId="+selectID+"&language="+language+"&type="+type;
		var xmlHTTPRequest = createXMLHttpRequest3();
		//window.alert("xmlHTTPRequest:" + xmlHTTPRequest);
		//xmlHttpRequest.abort();
		
		xmlHTTPRequest.open("GET",url,true);
		xmlHTTPRequest.onreadystatechange = function(){
			if(xmlHTTPRequest.readyState == 1)
			{
				var label;
				label="<img src=\"images/ajax-loader.gif\" align=\"middle\"  border=\"0\" width=\"512\"\">";
				label+="<br><b><font size=\"24px\">Loading</font></b>";
   			 showID.innerHTML=label;
		}
			
			
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						//window.alert("showing2...");
						showID.innerHTML = xmlHTTPRequest.responseText;
					}
			}
	
		};
		xmlHTTPRequest.send(null);
	}
}

function selected_category(selected,language,subcategoryID,display_style)  //record selected category
{
	//var selected_c = selected;
	var url = "include/recordCategory.php?categoryId="+ selected +"&language=" + language;
	//window.alert(display_style);
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						 if(display_style=='all'){
						parent.location = "pgroupShow.php?pgsId=" + subcategoryID + "&language=" + language;
						 }else if(display_style=='pic')
						 {parent.location = "pgroupShowpic.php?pgsId=" + subcategoryID + "&language=" + language;
						 }else
						 {parent.location = "pgroupShowtxt.php?pgsId=" + subcategoryID + "&language=" + language;}
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}

function login(language,sign)     //remeber the old url before login,for go back when the client login
{
	var oldUrl = parent.location + "";
	var url = "";
	if(parseInt(sign))
	{
		url =  localRootUrl() + "/include/record_path.php?currentPath=confirminformation.php?language=" + language; 
	}
	else url = localRootUrl() + "/include/record_path.php?currentPath=" + oldUrl;
	//window.alert("URL:" + url);
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						var newUrl = localRootUrl() + "/login.php?language=" + language;
						//window.alert(newUrl);
						parent.location.href = newUrl;  //href to login page
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}

function viewcart(index)  //go to viewcart page,and record the history page for turning back
{
	var oldUrl = parent.location + "";
//	var url = localRootUrl() + "/include/record_history.php?currentPath=" + oldUrl;
	var url = "include/record_history.php?currentPath=" + oldUrl;
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						//var newUrl = localRootUrl() + "/" + index;
						var newUrl = index;
						//window.alert("newurl:" + newUrl);
						parent.location.href = newUrl;  //href to login page
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}

function unshow(showID)  //unshow the subcategory
{
	//window.alert(showID);
	divMsg = showID;
	divMsg.innerHTML = "";
}

function addtobascate(productid,qty,price) //add product into the bascate
{
	var url = "include/addToBascate.php?productID=" + productid + "&productNum=" + qty+ "&productprice=" + price;
	createXMLHttpRequest();
	xmlHttp.open("GET",url,false);
	//window.alert("success");
	xmlHttp.onreadystatechange = handleSession;
	xmlHttp.send(null);
}

function faqShow(faq_id,total,ID)  //ID:selected id    
{							//total:the number of question
    var i = 1;
	var num = parseInt(total);
	//window.alert("id:" + ID + "\NUM:" + num);
	for(;i<=num;i++)
	{
		var unshowID = document.getElementById("showDIV" + i);
		unshowID.setAttribute("style","visibility:hidden");
		unshowID.style.cssText = "visibility:hidden"; //IE
		unshowID.innerHTML = "";
	}
	var showID = document.getElementById("showDIV" + ID);
	showID.setAttribute("style","visibility:visible");
	showID.style.cssText = "visibility:visible"; //IE

	var url = localRootUrl() + "/include/showFaq.php?id=" + faq_id;
	var xmlHTTPRequest = createXMLHttpRequest3();
	xmlHTTPRequest.open("GET",url,true);
	xmlHTTPRequest.onreadystatechange = function(){
		if(xmlHTTPRequest.readyState == 4)
			{
				 if(xmlHTTPRequest.status == 200)
					 {
						//window.alert("before");
						getHeightOf();
						showID.innerHTML = xmlHTTPRequest.responseText;
						//window.alert("after");
						getHeightOf();
					}
			}
	
	};
	xmlHTTPRequest.send(null);
}
function deleteByIndex(index) //in viewcart page,delete some product
{
	window.location = localRootUrl() + "/viewcart.php?deleteID="+index;
}

function DateDemo()  //GET THE SYSTEM DATE
{
   var s="";
   d = new Date();
   var newyear = d.getYear();
   if(newyear<1900)//FOR THE MISTAKE OF FIRFOX,SUCH AS "108-2-15"
	{
	   newyear = newyear + 1900;
   }
   s += newyear + "-";
  // window.alert("year:"+s);
   s += (d.getMonth() + 1) + "-";
 //  window.alert("moth:"+s);
   s += d.getDate();
   //window.alert("date:"+s);
   return s;
}

function order()  //ADD THE PRODUCT TO ORDER
{
	var date = DateDemo();
	//window.alert("date1:"+date);
	var url = localRootUrl() + "/include/addToOrder.php?date="+date;
	createXMLHttpRequest();
	xmlHttp.open("GET",url,false);
	//window.alert("success");
	xmlHttp.onreadystatechange = handleSession;
	xmlHttp.send(null);
	deleteByIndex('0');//flush
	//window.alert('Order finished,welcome again!');
}
function order_confirm(language)
{
	parent.location.href = localRootUrl() + "/confirminformation.php?language=" + language;
}
function neworder(index,qty)//VIEWCART
{
	window.location = localRootUrl() + "/viewcart.php?index="+index+"&newqty="+qty;
}

function redirect(index,language)//redirect for selecting subcategory,refresh the webpage if the height is became larger
{
	window.location = localRootUrl() + "/pgroupShow.php?pgsId=" + index + "&language=" + language;
}

function ismail(mail,warning)
{
  var sign=(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
  if(!sign)
	  {
		//window.alert('The email is wrong!');
		window.alert(warning);
	  }
}
function checkpassword(warning)
{
	var pass1 = document.getElementById('password').value;
	var pass2 = document.getElementById('password2').value;
	if(pass1!=pass2)
	{
		//window.alert('The two password is not same');
		window.alert(warning);
		return false;
	}
	return true;
}
function isnumber(num,warning)
{
  var sign=(new RegExp(/^\d+$/).test(num));
  if(!sign)
	  {
		//window.alert('The postnum is wrong!');
		window.alert(warning);
	  }
}
function istelephone(tel,warning)
{
	 var sign=(new RegExp(/^\d|(d+[-])+$/).test(tel));
  		if(!sign)
	  {
		//window.alert('The telephone is wrong!');
		window.alert(warning);
	  }

}

function setbgcolor(id)  //set the new account page
{
	var  input = document.getElementById(id);
	input.setAttribute("style","background: #C8D3E5"); //FF
	input.style.cssText = "background-color: #C8D3E5";//IE

}
function resetbgcolor(id)
{
	var  input = document.getElementById(id); //RESET THE BACKCOLOR
	input.setAttribute("style","background-color:#ffffff,border-style:solid"); //firefox
	input.style.cssText = "background-color:#ffffff,border-style:solid";  //ie
}

function show()
{
	var disID = document.getElementById('searchhelper');//SHOW THE SEARCH HELPER
	disID.setAttribute("style","visibility:visible"); //FF
	disID.style.cssText = "visibility:visible"; //IE
}
function disappear()
{
	var disID = document.getElementById('searchhelper');
	disID.setAttribute("style","visibility:hidden");//FF
	disID.style.cssText = "visibility:hidden"; //IE
}

function setIndex(index)  //FOR THE TOPMENU WITH Internet Explore6.0
{
	//window.alert('index:'+index);
	var newsetName = "child"+index;
	for(var i=1;i<=6;i++)
	{
		if(i!=index)
		{
			var setName = "child"+i;
			//window.alert("Name:"+setName);
			var divName = document.getElementById(setName);
			divName.style.cssText = "visibility:hidden"; //IE
			divName.setAttribute("style","visibility:hidden"); //FF
		}
	}
	var showName = document.getElementById(newsetName);
	showName.style.cssText = "visibility:visible"; //IE
	showName.style.cssText = "z-index:1000"; //IE
	showName.setAttribute("style","z-index:1000"); //FF
	showName.setAttribute("style","visibility:visible"); //FF
	
	
}

function IsAccountUse()
{
	var email = document.getElementById("email").value;
	var url = localRootUrl() + "/include/checkAccount.php?email=" + email;
	var showID = document.getElementById("showMsg");
	//showID.innerHTML = account;
	dosendAjax(showID,url);
}

function getWindowHeight()
{
	if (window.innerWidth)
	{
		theHeight = window.innerHeight;
	}
	else if (document.compatMode=='CSS1Compat')
	{
		theHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		theHeight = document.body.clientHeight;
	}
	return theHeight;
}
function getWindowWidth()
{
	if (window.innerWidth)
	{
		theWidth = window.innerWidth;
	}
	else if (document.compatMode=='CSS1Compat')
	{
		theWidth = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		theWidth = document.body.clientWidth;
	}
	return theWidth;
}

function getHeightOf()
{

	var height1 = document.getElementById("mbox");   //get the height of the content,and set the style of the page
	var height2 = document.getElementById("rightBox");   //get the height of the rightbar,and set the style of the page
	var height = parseInt(height1.clientHeight) > parseInt(height2.clientHeight)?height1:height2;  //get the larger height
	//window.alert("mbox Height:" + height.clientHeight);
	var leftbar = document.getElementById("leftbar");
	//window.alert("leftbar:" + leftbar.clientHeight);
	var main = document.getElementById("main");
	//window.alert("Main" + main.clientHeight);
	var content = document.getElementById("content");
	//window.alert("contentHeight:" + content.clientHeight);
	var rightbar = document.getElementById("menuright");
	
	var windowHeight = getWindowHeight();
	//window.alert(height1);
	//window.alert("theHeight10:" + windowHeight);
	if(height.clientHeight > windowHeight - 225)
	{
		//alert('1');
		var oldHeight = height.clientHeight - content.clientHeight;
		var newHeight = height.clientHeight;
		
		var newmain = newHeight + 180;
		main.setAttribute("style","height:" + newmain + "px");
		main.style.cssText = "height:" + newmain + "px";
		var newright = newHeight + 20;
		rightbar.setAttribute("style","height:" + newright + "px");
		rightbar.style.cssText = "height:" + newright + "px";
        var newleft = newHeight + 80;
		leftbar.setAttribute("style","height:" + newleft + "px");
		leftbar.style.cssText = "height:" + newleft + "px";

	}
	else
	{
		var newmain = windowHeight - 35;
		
		main.setAttribute("style","height:" + newmain + "px");
		main.style.cssText = "height:" + newmain + "px";
		var newright = newmain - 160;
		rightbar.setAttribute("style","height:" + newright + "px");
		rightbar.style.cssText = "height:" + newright + "px";
        var newleft = newmain - 100;
		leftbar.setAttribute("style","height:" + newleft + "px");
		leftbar.style.cssText = "height:" + newleft + "px";
	}

	//window.alert("height:" + getWindowHeight());
	//window.alert("width:" + getWindowWidth());
	//window.resizeTo(getWindowWidth() + 12,getWindowHeight() + 200);

}




/*

function getHeightOfLeft()
{

	var height1 = document.getElementById("mbox");   //get the height of the content,and set the style of the page
	var height2 = document.getElementById("LeftBox");   //get the height of the rightbar,and set the style of the page
	var height = parseInt(height1.clientHeight) > parseInt(height2.clientHeight)?height1:height2;  //get the larger height
	//window.alert("mbox Height:" + height.clientHeight);
	var leftbar = document.getElementById("leftbar");
	//window.alert("leftbar:" + leftbar.clientHeight);
	var main = document.getElementById("main");
	//window.alert("Main" + main.clientHeight);
	var content = document.getElementById("content");
	//window.alert("contentHeight:" + content.clientHeight);
	var rightbar = document.getElementById("menuright");
	
	var windowHeight = getWindowHeight();
	//window.alert(height1);
	//window.alert("theHeight10:" + windowHeight);
	if(height.clientHeight > windowHeight - 225)
	{
		//alert('1');
		var oldHeight = height.clientHeight - content.clientHeight;
		var newHeight = height.clientHeight;
		
		var newmain = newHeight + 180;
		main.setAttribute("style","height:" + newmain + "px");
		main.style.cssText = "height:" + newmain + "px";
		var newright = newHeight + 20;
		rightbar.setAttribute("style","height:" + newright + "px");
		rightbar.style.cssText = "height:" + newright + "px";
        var newleft = newHeight + 80;
		leftbar.setAttribute("style","height:" + newleft + "px");
		leftbar.style.cssText = "height:" + newleft + "px";

	}
	else
	{
		var newmain = windowHeight - 35;
		
		main.setAttribute("style","height:" + newmain + "px");
		main.style.cssText = "height:" + newmain + "px";
		var newright = newmain - 160;
		rightbar.setAttribute("style","height:" + newright + "px");
		rightbar.style.cssText = "height:" + newright + "px";
        var newleft = newmain - 100;
		leftbar.setAttribute("style","height:" + newleft + "px");
		leftbar.style.cssText = "height:" + newleft + "px";
	}

	//window.alert("height:" + getWindowHeight());
	//window.alert("width:" + getWindowWidth());
	//window.resizeTo(getWindowWidth() + 12,getWindowHeight() + 200);

}


*/






//for show the price of the cart in the head
/*
function showHi(index)
{
  if (index.length==0)
    {
    document.getElementById("txtHint").innerHTML="";
    return;
    }
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
    {
    alert ("Can't support AJAX£¡");
    return;
    }
  var url="include/calctotal.php";
  var product_index = parseInt(index) - 1;
  var productID = null;
  var qty = null;
  url=url+"?q="+index;
  url=url+"&sid="+Math.random()+"&productID="+productID+"&qty="+qty;
  //window.alert(url) ;
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
return xmlHttp;
}
*/




function NiftyCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
if(Array.prototype.push==null){Array.prototype.push=function(){
      this[this.length]=arguments[0]; return(this.length);}}
return(true);
}

function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){
    cn+="a";
    ecolor=Mix(bk,color);
    }
if(opt && opt.indexOf("small")>=0) cn+="s";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");
        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){
            el.childNodes[i].style.borderLeft="1px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
else return(document.createElement(x));
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
} 
