var newWindow = null
var reQuantity = /^[0-9]{1,}\.?[0-9]{0,1}$/;
var rePrice = /^[0-9]{1,}\.?[0-9]{0,2}$/;
var reNumber = /^[0-9]{1,}$/;
var reNo = /^[0-9a-zA-Z]+$/;

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name != 'SelAll')
		{
			e.checked = form.SelAll.checked;
		}
	}
}

function CheckOne(obj)
{
	if( obj.checked == false)
	{
		document.getElementsByName("SelAll")[0].checked = obj.chcked;
		document.getElementsByName("SelAll2")[0].checked = obj.chcked;
	}
}


function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
    newWindow=window.open(theURL,winName,features);
    newWindow.focus();
}


function Delete(form, msg, url){
   if(confirm(msg)){
	 form.action = url;
	 form.submit();
   }
}

function sel_ad_img(ad_img, ProductPictureID){
    document.all.ad_img.src=ad_img;
}


var cartWindow = null
function OpenCartWindow(theURL) 
{ //v2.0
  	cartWindow=window.open(theURL,"ShoppingCart","top=0,left=0,width=720,height=500,scrollbars=no");
  	cartWindow.focus();
}

function SelectOne(tagobj,productID){
	for (i=0;i<tagobj.length;i++){
		if(tagobj(i).value == productID){
			tagobj(i).checked=true;
		}	
		else
		{
			tagobj(i).checked=false;
		}
	}
}

function CheckCheckBox(form) {
	var cked = false;
	for(var i=0;i<form.SelCheckbox.length;i++)
	{
		if(form.SelCheckbox[i].checked) 
		{
		   cked=true;
		   break;
		}
	}
	if(!cked) 
	{
	   	alert("Please select one!");
	   	return false;
	}
	else
	{
		return true;
	}
}

function FixImgWin(url)
{
  var imgwin = window.open('','img','top=100,left=100,width=50,height=50');
  imgwin.focus();
  var HTML = "<html>\r\n<head>\r\n<title>Picture</title>\r\n</head>\r\n<body leftmargin=\"0\" topmargin=\"0\">\r\n<img src=\""+url+"\" onload=\"window.resizeTo(this.width+10,this.height+29);window.moveTo((screen.width-this.width)/2,(screen.height-this.height)/2)\">\r\n</body>\r\n</html>";
  var doc = imgwin.document;
  doc.open("text/html","replace");
  doc.write(HTML);
  doc.close();
}


function RowClick(obj)
{
	//obj.style.backgroundColor=obj.style.backgroundColor=='#d7e8fa'?'#ffffff':'#d7e8fa';
}
function RowChange(obj, bChange)
{
	if(obj.style.backgroundColor!='#d7e8fa')
	{
		if(bChange == "over")
     		obj.style.backgroundColor = "#ffffe1";
		if(bChange == "out")
     		obj.style.backgroundColor = "#eff6fd";
	}
}

function Loading()
{
	document.write("<div id=\"Loading\" style=\"width=100%;height=100%;\">");
	document.write("<table width=\"100%\" height=\"100%\" bgcolor=\"#ffffff\"><tr><td vAlign=\"middle\">");
	document.write("<table align=\"center\"><tr>");
	document.write("<td><IMG src=\"../../Images/loading.gif\" border=\"0\"></td>");
	document.write("<td>Loading...</td>");
	document.write("</tr></table>");
	document.write("</td></tr></table>");
	document.write("</div>");
}

function UnLoading()
{
	document.all['Loading'].style.display="none";
}

function CheckNull(object, msg)
{
  if(object.value==""){
	  alert(msg);
	  object.focus();
	  return false;
  }
  else{
	  return true;
  }
}

function CheckCompare(object, object2, msg)
{
  if(object.value != object2.value){
	  alert(msg);
	  object.focus();
	  return false;
  }
  else{
	  return true;
  }
}

function CheckFormat(object, msg, re)
{
  if (object.value!=""){
    if (!re.test(object.value)){
      alert(msg);
	  object.focus();
	  return false;
    }
	else{
		return true;
	}
  }
  else{
	  return true;
  }
}

function CheckEmail(object, msg)
{
  if (object.value!=""){
    if(!isEmail(object.value)){
      alert(msg);
      object.focus();
      return false;
  	}
	else{
		return true;
	}
  }
  else{
	  return true;
  }
}

function isEmail(theStr)
{
  	var atIndex=theStr.indexOf('@');
  	var doIndex=theStr.indexOf('.',atIndex);
  	var flag=true;
  	theSub=theStr.substring(0,doIndex+1)
  	if((atIndex<1)||(atIndex!=theStr.lastIndexOf('@'))||(doIndex<atIndex+2)||(theStr.length<=theSub.length))
  	{ 
     	flag=false;
  	}
  	else
  	{
    	flag=true;
  	}
  	return(flag);
}

function SetValueAndCloseWin(strValue)
{
	opener.document.all.ProductNo.value=strValue;
	opener.document.all.ProductNo.focus();
	window.close();
}

function resizeImage(img, width, height){  
    var image = new Image();  
    image.src = img.src;  
    if(image.width > 0  && image.height > 0){  
        if(image.width / image.height >= width / height){  
            if(image.width > width){      
                img.width = width;  
                img.height = (image.height * width) / image.width;  
            }else{  
                img.width = image.width;      
                img.height = image.height;  
            }  
        }  
        else{  
            if(image.height > height){      
                img.height = height;  
         		img.width = (image.width * height) / image.height;            
         	}else{  
         		img.width = image.width;      
         		img.height = image.height;  
         	}  
    	}  
	}
}

/*插入flash*/
function insertFlash(elm, url, w, h) {
    if (!document.getElementById(elm)) return;
    var str = '';
    str += '<object width="' + w + '" height="' + h + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
    str += '<param name="movie" value="' + url + '">';
    str += '<param name="wmode" value="opaque">';
    str += '<param name="quality" value="autohigh">';
    str += '<embed width="' + w + '" height="' + h + '" src="' + url + '" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
    str += '</object>';
    document.getElementById(elm).innerHTML = str;
}

/*弹出广告后自动关闭*/
/*
var time = 71;
var h = 0;
function addCount() {
    if (time > 0) {
        time--;
        h = h + 5;
    }
    else {
        return;
    }
    if (h > 71)  //高度
    {
        return;
    }
    document.getElementById("divAd").style.display = "";
    document.getElementById("divAd").style.height = h + "px";
    setTimeout("addCount()", 30);
}


window.onload = function showAds() {
    addCount();
    setTimeout("noneAds()", 7000); //停留时间自己适当调整
}

var T = 71;
var N = 71; //高度
function noneAds() {
    if (T > 0) {
        T--;
        N = N - 5;
    }
    else {
        return;
    }
    if (N < 0) {
        document.getElementById("divAd").style.display = "none";
        return;
    }

    document.getElementById("divAd").style.height = N + "px";
    setTimeout("noneAds()", 30);
}
*/
/*弹出广告后自动关闭*/

/*弹出广告后自动关闭*/
function changediv() {
    document.getElementById('hiddenLayer').style.display = "block";
    document.getElementById('interstitialFrame').src = adInterPath;
    setTimeout("hidediv()", 20000)   //5000为毫秒  是页面停留的时间间隔 你可以设定适当的数字
}
function hidediv() {
    document.getElementById('hiddenLayer').style.display = "none";
    SYtag = 2;
}
function showfull() {
    setTimeout("changediv()", 2000);
}
/*弹出广告后自动关闭*/

