//加入收藏夹
function AddFavorite(sURL, sTitle)
{
   try
   {
       window.external.addFavorite(sURL, sTitle);
   }
   catch (e)
   {
       try
       {
           window.sidebar.addPanel(sTitle, sURL, "");
       }
       catch (e)
       {
           alert("加入收藏失败，请使用Ctrl+D进行添加");
       }
   }
}

//Ajax实例
  function InitAjax(){
      var ajax = false;
    try{
        ajax = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            ajax=new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            ajax=false;
        }
    }
    if(!ajax && typeof XMLHttpRequest!='undefined'){
        ajax=new XMLHttpRequest();
    }
    return ajax;
  }
//Ajax留言管理  
function liuyan1(){
    var mail = document.getElementById("mailbox").value;
    if(mail==""){
      alert('邮箱不能为空！');
    }else if(mail.match(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/)==null)
    {
      alert('邮箱格式不正确！');
    }else if(document.getElementById("message").value==""){
      alert('留言不能为空！');
    }else { 
		  var mailbox = document.getElementById("mailbox").value;
		  var message = document.getElementById("message").value;
		 
		  var ajax = InitAjax();

		  ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("liuyanjieguo").style.display='block';
					document.getElementById("liuyanjieguo").innerHTML=ajax.responseText;
					document.getElementById("mailbox").value='';
					document.getElementById("message").value='';
					setTimeout(function(){document.getElementById("liuyanjieguo").style.display='none';},3000);
				}else{
					alert('服务器返回状态'+ajax.status.Text);
				}
			}else{
				document.getElementById("liuyanjieguo").innerHTML="正在提交...";
			}
		  }
		  var postStr="mailbox="+mailbox+"&message="+message;
		  ajax.open("POST","/x/mailto.php",true);
		  ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		  ajax.send(postStr);
    }
  }
function menustyle(){
    var pageUrl=""; 
    pageUrl = window.location;
    pageUrl = pageUrl.toString();
    fileName   =   pageUrl.split("//")[1].split("/");   
    var strPage = fileName[fileName.length-1];
    if(strPage=="service.php"){document.getElementById("service").className='service1';}
    else if(strPage=="product.php"){document.getElementById("product").className='product1';}
    else if(strPage=="career.php"){document.getElementById("career").className='job1';}
    else if(strPage=="about.php"){document.getElementById("about").className='us1';}
    else {document.getElementById("index").className='shouye1';}
} 
function menustyle2(){
    var pageUrl=""; 
    pageUrl = window.location;
    pageUrl = pageUrl.toString();
    fileName   =   pageUrl.split("//")[1].split("/");   
    var strPage = fileName[fileName.length-1];
    if(strPage=="product.php"){document.getElementById("myweb").className='myweb';
                                      document.getElementById("product").className='product1';}
    else if(strPage=="product.php?type=2"){document.getElementById("mymobile").className='mymobile';
                                           document.getElementById("product").className='product1';}
    else {document.getElementById("myweb").className='myweb';
          document.getElementById("product").className='product1';}
} 
