function LoadFlash(wmode,url,width,Height)
{ 
document.write(
'<embed src="' + url + '" wmode=' + wmode +
' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + width + 
'" height="' + Height + '"></embed>'); 
}
function DownImage(ImgD,w,h){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){//flag=true; 
	if(image.width>w){
		if(image.height*w/image.width<=h){
           if(image.width>=w){ 
               ImgD.width=w; 
               ImgD.height=(image.height*w)/image.width; 
           }else{ 
               ImgD.width=image.width; 
               ImgD.height=image.height; 
           }
		}else{
           if(image.height>=h){ 
               ImgD.height=h; 
               ImgD.width=(image.width*h)/image.height; 
           }else{ 
               ImgD.width=image.width; 
               ImgD.height=image.height; 
           }
		}
	}else{
           if(image.height>=h){ 
               ImgD.height=h; 
               ImgD.width=(image.width*h)/image.height; 
           }else{ 
               ImgD.width=image.width; 
               ImgD.height=image.height; 
           }
	}		     
    } 
}
	function changeTab(tabToShow)
	{
	    //alert ('in change tab');
	    try {
	        var tabTable = document.getElementById('tabs');
	         //alert ("tabTable = " + tabTable);
	         var tabRow = tabTable.tBodies[0].rows[0];
	         //var contentRow = tabTable.tBodies[0].rows[1];
	         
	         //alert ("tab count = " + tabRow.childNodes.length);
	         for (i=0; i<tabRow.childNodes.length; i++)
	         {
	                    //alert ("is lastchild not null?");
	            if (tabRow.childNodes[i].lastChild)
	            {
	                    //alert ("lastchild not null");
	                var tabName = tabRow.childNodes[i].lastChild.nodeValue;
	                if (tabName != "")
	                {
	                    //alert ("tabname = " + tabName);
	                    document.getElementById(tabName).style.display='none';
	                    //alert ("TabName = " + tabName + "<br>TabToShow = " + tabToShow);
                        tabRow.childNodes[i].removeAttribute('oldStyle');
	                    if (tabName == tabToShow)
	                    {   
	                        //alert ("setting as selected");
                            //tabRow.childNodes[i].className = 'tabSelected';
                            tabRow.childNodes[i].setAttribute('oldStyle', 'tabSelected');
   	                    }
   	                    else
   	                    {
 	                        //alert ("setting as unselected");
                            tabRow.childNodes[i].className = 'tabUnselected';
 	                    }
	                }
	            }
	         }
	        var theTabToShow = document.getElementById(tabToShow);
	        theTabToShow.style.display='block';
        }
	    catch(e)
	    {
	    return;
	    }
	}
 function SetWinHeight(obj)
{
 var win=obj;
 if (document.getElementById)
 {
  if (win && !window.opera)
  {
   if (win.contentDocument && win.contentDocument.body.offsetHeight) 

    win.height = win.contentDocument.body.offsetHeight; 
   else if(win.Document && win.Document.body.scrollHeight)
    win.height = win.Document.body.scrollHeight;
  }
 }
}

function checkform()
{
	if(document.searchform.searchkey.value==''){
		alert("关键词不能为空");
		document.searchform.searchkey.focus();
		return false;
	}
}

function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function checkQuery()
{
   if(checkspace(document.Supplierform.k1.value) && checkspace(document.Supplierform.k2.value)) {
    alert("请填写货号或品名！");
	return false;
  }
}
//menu 
   window.onload=cache;

function cache(id){
	/*montre1(id);
	montre2(id);
	montre3(id);*/
	if (LireCookie("menu")==null)
	{ montre4(id);}
	else
	{ montre4(LireCookie("menu"));
	changeimage(LireCookie("image"));
		}
}
	/*
function montre1(id) {
			var d = document.getElementById(id);
			for (var i = 1; i<=10; i++) {
				if (document.getElementById('smenu'+i)) {
					document.getElementById('smenu'+i).style.display='none';
				}
			}
			if (d) {d.style.display='block';}
		}
		*/
		function montre4(id) {
			var d = document.getElementById(id);
			for (var i = 1; i<=20; i++) {
				if (document.getElementById('smenud'+i)) {
					document.getElementById('smenud'+i).style.display='none';
				}
			}
			if (d) {d.style.display='';}
			EcrireCookie("menu", id);
		}
		/*
		function montre2(id) {
			var d = document.getElementById(id);
			for (var i = 1; i<=10; i++) {
				if (document.getElementById('smenuhaut'+i)) {
					document.getElementById('smenuhaut'+i).style.display='none';
				}
			}
			if (d) {d.style.display='block';}
		}
		
		function montre3(id) {
			var d = document.getElementById(id);
			for (var i = 1; i<=10; i++) {
				if (document.getElementById('smenubas'+i)) {
					document.getElementById('smenubas'+i).style.display='none';
				}
			}
			if (d) {d.style.display='block';}
		}*/
		
		function changeimage(id) {
			var d = document.getElementById(id);
			for (var i = 1; i<=10; i++){
				if (document.getElementById('image'+i)){
					document.getElementById('image'+i).src="../img/fleche.png";
				}
			}
			if(d) {d.src="../img/fleche_vide.png";}
			EcrireCookie("image", id);
		}
		
		function hover(obj){
  			if(document.all){
    			UL = obj.getElementsByTagName('ul');
    				if(UL.length > 0){
      					sousMenu = UL[0].style;
      						if(sousMenu.display == 'none' || sousMenu.display == ''){
        						sousMenu.display = 'block';
      						}else{
        						sousMenu.display = 'none';
      						}
    				}
 			 }
		}
		
		function hover2(obj){
  			if(document.all){
    			UL = obj.getElementsByTagName('ul');
    				if(UL.length > 0){
      					sousMenu = UL[0].style;
      						if(sousMenu.display == 'none' || sousMenu.display == ''){
        						sousMenu.display = 'block';
      						}else{
        						sousMenu.display = 'none';
      						}
    				}
 			 }
		}
		
	function EcrireCookie(nom, valeur)
		{
			var argv=EcrireCookie.arguments;
			var argc=EcrireCookie.arguments.length;
			var expires=(argc > 2) ? argv[2] : null;
			var path=(argc > 3) ? argv[3] : null;
			var domain=(argc > 4) ? argv[4] : null;
			var secure=(argc > 5) ? argv[5] : false;
			document.cookie=nom+"="+escape(valeur)+
			((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
			((path==null) ? "" : ("; path="+path))+
			((domain==null) ? "" : ("; domain="+domain))+
			((secure==true) ? "; secure" : "");
		}
			
	function getCookieVal(offset)
		{
			var endstr=document.cookie.indexOf (";", offset);
			if (endstr==-1) endstr=document.cookie.length;
				return unescape(document.cookie.substring(offset, endstr));
		}
		
	function LireCookie(nom)
		{
			var arg=nom+"=";
			var alen=arg.length;
			var clen=document.cookie.length;
			var i=0;
			while (i<clen)
				{
					var j=i+alen;
					if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
					i=document.cookie.indexOf(" ",i)+1;
					if (i==0) break;
				}
			return null;
		}
