﻿//显示跟隐藏
function showsubmenu(sid)
{
whichEl = eval("submenu" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display=\"\";");
document.getElementById("pic"+sid).src="images/open.gif";
}
else
{
eval("submenu" + sid + ".style.display=\"none\";");
document.getElementById("pic"+sid).src="images/close.gif";
}
}

//快速跳转分页
function FP_jumpMenu(el,frm,sel) {//v1.0
 var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
 if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
}

function ProductPicker_Submit()
{
	if(document.myform.KeyWords.value=="")
	{
		window.alert("please enter search condition！");
		document.myform.KeyWords.focus();
		return false;
	}
}

function $() {return document.getElementById(arguments[0]);}	//兼容FF浏览器 
//加入收藏
function AddFavorite(sURL, sTitle)
{
	try
	{
		window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
		try
		{
		   window.sidebar.addPanel(sTitle, sURL, "");
		}
		catch (e)
		{
		   alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}

//设为主页
function SetHome(obj,vrl)
{
	try
	{
	   obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e)
	{
	   if(window.netscape) 
	   {
		 try {
		  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		 } 
		 catch (e) { 
		  alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
		 }
		 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		 prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}

//图片按比例缩放,可输入参数设定初始大小
function resizeimg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0)
	 {
        if(image.width/image.height>= iwidth/iheight)
		{
           if(image.width>iwidth){
               ImgD.width=iwidth;
               ImgD.height=(image.height*iwidth)/image.width;
           }else{
                  ImgD.width=image.width;
                  ImgD.height=image.height;
                }
               //ImgD.alt="宽×高:"+image.width+"×"+image.height;
        }
        else
		{
                if(image.height>iheight){
                       ImgD.height=iheight;
                       ImgD.width=(image.width*iheight)/image.height;
                }else{
                        ImgD.width=image.width;
                        ImgD.height=image.height;
                     }
                //ImgD.alt="宽×高:"+image.width+"×"+image.height;
         }
    }
}

//图片按比例缩放,可输入参数设定初始大小 

//检测空字符
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//检测空字符

function CheckEmail(email)
{
	var RegExpStr = /^([\w\_\-\.]{1,})(@)([\w\-\.]{1,})(\.)([a-zA-Z\.]{1,})$/;
	return RegExpStr.test(email);
}


function change_type(locationid)
{  
	var ss="number,name,description";
	var mm="product_num,product_name_cn,content_cn"
	s=ss.split(",");
	m=mm.split(",");
	document.myform.sort_id.length = 0; 
	for(var i=0;i<s.length;i++)
	{
		document.myform.sort_id.options[i] = new Option(s[i],m[i]);      
	}
} 


 function check()
 {
  if(document.submitform.name.value=="")
  {
   window.alert("Fill in your name");
   document.submitform.name.focus();
   return false;
  }
  if(document.submitform.company.value=="")
  {
   window.alert("Fill in your company name");
   document.submitform.company.focus();
   return false;
  }
  if(document.submitform.call.value=="")
  {
   window.alert("Fill your phone");
   document.submitform.call.focus();
   return false;
  }
  if(document.submitform.email.value=="")
  {
   window.alert("Fill in your email address");
   document.submitform.email.focus();
   return false;
  }
  if(isEmail(document.submitform.email.value)==false)
  {
   window.alert("Please fill in the correct mail address");
   document.submitform.email.focus();
   document.submitform.email.select();
   return false;  
  }
  if(document.submitform.content.value=="")
  {
   window.alert("Fill your voice content");
   document.submitform.content.focus();
   return false;
  }
 document.submitform.tHtml.value=document.submitform.innerHTML; 
 return true;

 }