

var http_request = false;

   function makeRequest(url, params, funct) {
      http_request = false;
      if (window.XMLHttpRequest) {
         http_request = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('浏览器不支持,请升级版本!');
         return false;
      }
      http_request.onreadystatechange = funct;
      http_request.open('Get', url + params, true);
      http_request.send(null);
   }
 function CheckLog()
  {     
  if(getcookie("_userid_")=='')
  {
                 document.getElementById("hidlog").value="0";
               document.getElementById("divlog").innerHTML="会员登陆后可直接留言&nbsp;<a href=\"/Admin/login.aspx\"><font color=\"blue\">登录</font></a>,如果您还不是会员&nbsp;<a href=\"/Register/Register_main.aspx\"><font color=\"blue\">注册会员</font></a>";
               document.getElementById("divmsg").innerHTML="<p><label>联 系 人：<em>*</em> </label> <input size=\"22\" type=\"text\" id=\"lianxiren\" name=\"lianxiren\" /> <label>企业名称：</label> <input size=\"22\" type=\"text\" id=\"companyname\" name=\"companyname\"/> </p>"+
                                                                "<p><label>手&nbsp;&nbsp;&nbsp;&nbsp;机：</label><em>*</em>  <input size=\"22\" type=\"text\" id=\"mobile\" name=\"mobile\"/>  <label>　 Email：</label> <input size=\"22\" type=\"text\" id=\"email\" name=\"email\" /> </p>"+
                                                                "<p><label>地　　址：</label> &nbsp;<input size=\"22\" type=\"text\" id=\"address\" name=\"address\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>QQ：</label> <input size=\"22\" type=\"text\" id=\"qq\" name=\"qq\" /> </p>"+
                                                                "<p><label>省　　份：</label><em>*</em> <select  id=\"province\" name=\"province\"  style=\"width:172px;\">"+
                                                                "<option value=\"1\">北京市</option>"+ 
                                                               "<option value=\"2\">天津市</option>"+ 
                                                               "<option value=\"3\">上海市</option>"+
                                                               "<option value=\"4\">重庆市</option>"+
                                                               "<option value=\"5\">河北省</option>"+
                                                               "<option value=\"6\">山西省</option>"+
                                                               "<option value=\"7\">台湾省</option>"+
                                                               "<option value=\"8\">辽宁省</option>"+
                                                               "<option value=\"9\">吉林省</option>"+
                                                               "<option value=\"10\">黑龙江省</option>"+
                                                               "<option value=\"11\">江苏省</option>"+
                                                               "<option value=\"12\">浙江省</option>"+
                                                               "<option value=\"13\">安徽省</option>"+
                                                               "<option value=\"14\">福建省</option>"+
                                                               "<option value=\"15\">江西省</option>"+
                                                               "<option value=\"16\">山东省</option>"+
                                                               "<option value=\"17\">河南省</option>"+
                                                               "<option value=\"18\">湖北省</option>"+
                                                               "<option value=\"19\">湖南省</option>"+
                                                               "<option value=\"20\">广东省</option>"+
                                                               "<option value=\"21\">甘肃省</option>"+
                                                               "<option value=\"22\">四川省</option>"+
                                                               "<option value=\"23\">贵州省</option>"+
                                                               "<option value=\"24\">海南省</option>"+
                                                               "<option value=\"25\">云南省</option>"+
                                                               "<option value=\"26\">青海省</option>"+
                                                               "<option value=\"27\">陕西省</option>"+
                                                               "<option value=\"28\">广西壮族自治区</option>"+
                                                               "<option value=\"29\">西藏自治区</option>"+
                                                               "<option value=\"30\">宁夏回族自治区</option>"+
                                                               "<option value=\"31\">新疆维吾尔自治区</option>"+
                                                               "<option value=\"32\">内蒙古自治区</option>"+
                                                               "<option value=\"427\">澳门特别行政区</option>"+
                                                               "<option value=\"428\">香港特别行政区</option>"+
                                                                 " <select>　城   市：</label> <em>*</em><input size=\"22\" type=\"text\" id=\"city\" name=\"city\" /> </p>"
  }
  else
  {
   document.getElementById("hidlog").value="1";
  }
      
}
function ShowWelcomeMsg()
{
if(getcookie("_userid_")=='')
{
document.write("您好，欢迎来到快易捷药品交易平台！ <a href='/Admin/Login.aspx'>[请登录]</a>　 <a href='/Register/Register_main.aspx'>[免费注册]</a>");
}
else
{
document.write("欢迎来到快易捷药品交易平台!  <a href=\"/Admin/Login.aspx\"><font color='red'> [进入会员个人后台]</font></a>　 <a href=\"/Admin/Login.aspx\"><font color='red'> [快速发布]</font></a>");

}
}
 function ShowFrontBack()
{
if(getcookie("_userid_")=='')
{
document.write("<a href='/DijiaProduct.aspx' target='_blank'><img src='/newimages/front.gif' border='1' width='409' height='50' /></a>");
}
else
{
document.write("<a href='/Admin/login.aspx' target='_blank'><img src='/newimages/back.gif' border='1' width='409' height='50' /></a>");

}
} 
//去掉左，右及全部的两边的空格
 String.prototype.Trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}	
 String.prototype.Ltrim = function(){return this.replace(/(^\s*)/g, "");}	
 String.prototype.Rtrim = function(){return this.replace(/(\s*$)/g, "");}

function xmlhttp_ajax(file,sqltype,keyword)
{
    var objXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    objXmlHttp.open("POST", file, false);
    objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    objXmlHttp.send("sqltype="+escape(sqltype).replace(/\+/g,"%2B") + "&key="+escape(keyword).replace(/\+/g,"%2B") );				
      
    if(objXmlHttp.status != 200){
	    alert("程序有异常，请与管理员联系!");
	    return false;
    }
    objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    objXmlDoc.loadXML(objXmlHttp.responseText);
    objRoot = objXmlDoc.documentElement;
    return (objRoot);
 }

function xmlhttp(file,sqlstr)
{
    var objXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    objXmlHttp.open("POST", file, false);
    objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    objXmlHttp.send("sqlstr="+escape(sqlstr).replace(/\+/g,"%2B"));				
      
    if(objXmlHttp.status != 200){
	    alert("程序有异常，请与管理员联系!");
	    return false;
    }
    objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    objXmlDoc.loadXML(objXmlHttp.responseText);
    objRoot = objXmlDoc.documentElement;
    return (objRoot);
 }

function getMaxlen(szString)
{
    var len=0;
    for (var i=0;i<szString.length;i++)
    {
        if ((szString.charCodeAt(i) < 0) || (szString.charCodeAt(i) > 255))
            len+=2;
        else
            len++;
    } 
    return len;   
}

function checkNone( oText ,caption)
{
    if(oText.value.Trim() == "" )
    {
        alert("\"" + caption + "\"的值不能空！" );
        oText.focus();
        return false;
    }
    return true;
}

function checkMaxlen( oText,caption )
{
    if( getMaxlen( oText.value.Trim() ) > oText.maxLength )
    {
        alert("\"" + caption + "\"的值长度不能超过"+oText.maxLength+"个字符或个"+(oText.maxLength/2)+"汉字！" );
        oText.focus();
        return false;
    }
    return true;
}
function pageReload(msg,href)
{
    if(msg != "")
    {
        alert(msg);
    }    
    window.location = href;
}

function table_click(oBnt,cellIndex)
{

}

function getRowIndex(oBnt)
{
    var oTr = oBnt;
    while(oTr.parentElement != null && oTr.tagName != "TR" )
    {
        oTr = oTr.parentElement;
    }
    if( oTr != null && oTr.tagName == "TR")
    {
        return oTr.rowIndex;
    }
    return -1;
}

 function showCtl(obj)
 {
    setday(obj,obj);
    setTimeout("document.all.ffDateLayer.style.display='block';",10);
 }

function openIEwindow(szUrl,width,height,winKey)
{
    width = parseInt(width);
    height = parseInt(height);
    var left= (screen.availWidth-width)/2;
    var top=  (screen.availHeight-height)/2
    var szFeatures = " width="+width+",height="+height+",left="+left+",top="+top+",scrollbars=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes";
    window.open(szUrl,winKey,szFeatures,true);
}
 function viewPicture(sUrl)
{
    window.open(sUrl);
}
function setTab(name,cursel,n){
 for(i=1;i<=n;i++){
  var menu=document.getElementById(name+i);
  var con=document.getElementById("con_"+name+"_"+i);
  menu.className=i==cursel?"hover":"";
  con.style.display=i==cursel?"block":"none";
 }
}
//end

function keep(title,url) { //添加到收藏夹   
    if (window.sidebar) {    
        window.sidebar.addPanel(title, url,"");    
    } else if( document.all ) {   
        window.external.AddFavorite( url, title);   
    } else if( window.opera && window.print ) {   
        return true;   
    }   
} 

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 checkifnum()
		{
		  var    k=window.event.keyCode;   
    if ((k==46)||(k==8)||(k==189)||(k==109)||(k==190)||(k==110)|| (k>=48 && k<=57)||(k>=96 && k<=105)||(k>=37 && k<=40)) 
    {
    }
    else if(k==13)
    {
     window.event.keyCode = 9;
    }
    else
    {
      window.event.returnValue = false;
     }
   }
   function GoToPage(obj,inputtext)
   {
    if(inputtext.value=="")
    {
    
        window.location.href="index.htm";
        return;
    
    }
 
   if(eval(inputtext.value)>eval(obj.innerText))
    {
    window.location.href="index_"+obj.innerText+".htm";
    
    }
    else
    {
     window.location.href="index_"+inputtext.value+".htm";
    
    }
   
 
   }
   function GqGoToPage(obj,inputtext)
   {
    if(inputtext.value=="")
    {
    
        window.location.href="/gq.htm";
        return;
    
    }
 
   if(eval(inputtext.value)>eval(obj.innerText))
    {
    window.location.href="/GYXX/index_"+obj.innerText+".htm";
    
    }
    else
    {
     window.location.href="/GYXX/index_"+inputtext.value+".htm";
    
    }
   
 
   }
   　function doit() 
   　{
　　document.getElementById("txtPassWord").value = base64encode(utf16to8(document.getElementById("txtPassWord").value));
　　
　　　}
　　
　　function checkcomment()
　　{
　    if(document.getElementById("content").value=="")
　    {
　      document.getElementById("content").focus();
       　return false;
　  　}
　  　
　  　return true;
　　
　　}
　　function checkhtmlcomment()
　　{
　    if(document.getElementById("content").value=="")
　    {
　      document.getElementById("content").focus();
       　return false;
　  　}
　  
　  　return true;
　　
　　}
　　
　　
　　
　　
　  function GetProductPageData()
　  { 
　   GetComment(document.getElementById('hidid').value);
　  CheckLog();
　
　  
　  
　  }
　 function checkproductname(name) 
　{
　if(name.value=="")
{
 alert("请输入产品名称");
return false; 
}
if(name.value=="请输入产品名称")
{
 alert("请输入产品名称");
return false; 
}
if(getMaxlen(name.value)<4)
{
 alert("你输入的字符太少");
return false; 
}
if(getMaxlen(name.value)>40)
{
 alert("你输入的字符太长");
return false; 
}
return true
　
　} 
function newsearch(name)
{
var flagvalue="";
if(name.value=="")
{
 alert("请输入产品名称");
return false; 
}
if(name.value=="请输入产品名称")
{
 alert("请输入产品名称");
return false; 
}
if(getMaxlen(name.value)<4)
{
 alert("请精确输入产品名称");
return false; 
}
if(getMaxlen(name.value)>30)
{
 alert("你输入的字符太长");
return false; 
}

for(var i=1;i<=6;i++)
 {
    if(document.getElementById("search"+i).checked)
    {　     
   flagvalue+= document.getElementById("search"+i).value;
    break;
    }　
}
switch(eval(flagvalue))
   {
   case 1:window.top.location.href="/SearchMedicine.aspx?name="+escape(name.value);break;
   case 2:window.top.location.href="/ypsms/smsindex.aspx?name="+escape(name.value);break;
   case 3:window.top.location.href="/Searchypbw.aspx?name="+escape(name.value);break;
   case 4:window.top.location.href="/SearchInvestment.aspx?name="+escape(name.value);break;
   case 5:window.top.location.href="/SearchMedicine.aspx?name="+escape(name.value);break;
   case 6:window.top.location.href="/DrugPrice/PriceIndex.aspx?name="+escape(name.value);break;
   default:window.top.location.href="/SearchMedicine.aspx?name="+escape(name.value);break;
   }

}　 
　
　
　  
　function checkvotemsg()
　{
　var  votetype=document.getElementById("hidvotetype").value;
　var votenum=document.getElementById("hidvotenum").value;
　var flagvalue="";
　var num=0;
　if(votetype=="0")
　{
　  for(var i=1;i<=votenum;i++)
   　{
　     if(document.getElementById("option"+i).checked)
　     {
　     
　     num++;
　    flagvalue+= document.getElementById("option"+i).value;
　     break;
　     }　
　   }
　}
　else if(votetype=="1")
　{
　  for(var i=1;i<=votenum;i++)
   　{
　     if(document.getElementById("option"+i).checked)
　     {
　      flagvalue+= document.getElementById("option"+i).value+"|"; 
　     num++;  
　     }　
　   }　
　}
　if(num==0)
　{
　alert("请选择调查选项");
　return false;
　}
   document.getElementById("hidflag").value=flagvalue;

　return true;  　
　}　
　　 function GetComment(productid) 
　　 {
      makeRequest('/GetDynamicData.aspx', '?sendtype=2&id='+productid, GetCommentContent);
     }
    　function checkLeaveMsg()
　　  {
　    if(document.getElementById("buycontent").value=="")
　    {
　      document.getElementById("buycontent").focus();
       　return false;
　  　}
　  　if(document.getElementById("hidlog").value=="0")
　  　{
　  　if(document.getElementById("lianxiren").value=="")
　  　{
　  　document.getElementById("lianxiren").focus();
　  　return false;
　  　
　  　}
　  　if(document.getElementById("mobile").value=="")
　  　{
　  　document.getElementById("mobile").focus();
　  　return false;
　  　
　  　}
　  　 　if(document.getElementById("province").value=="")
　  　{
　  　document.getElementById("province").focus();
　  　return false;
　  　
　  　}
　  　 　if(document.getElementById("city").value=="")
　  　{
　  　document.getElementById("city").focus();
　  　return false;
　  　
　  　}
　  　}
　  　return true;
　　
　　}
　　
　    　function checkSupplyMsg()
　　  {
　    if(document.getElementById("buycontent").value=="")
　    {
　      document.getElementById("buycontent").focus();
　      alert("留言内容不能为空");
       　return false;
　  　}
　 
　  　if(document.getElementById("lianxiren").value=="")
　  　{
　  　document.getElementById("lianxiren").focus();
　  　 alert("联系人不能为空");
　  　return false;
　  　
　  　}
　  　if(document.getElementById("mobile").value=="")
　  　{
　  　document.getElementById("mobile").focus();
　  　 alert("手机不能为空");
　  　return false;
　  　
　  　}
  　  if(document.getElementById("address").value=="-1")
　  　{
　  　document.getElementById("address").focus();
　  　 alert("请选择所在省份");
　  　return false;
　  　
　  　}
　  　return true;
　　
　　}

function openwin() { 
window.open ("http://www.53kf.com/company.php?arg=yp900&style=1", "在线客服", "height=475, width=700, toolbar =no, menubar=no, top=200,left=180, scrollbars=no, resizable=no, location=no, status=no")  
}
function searchmedicne(big,small,name)
{
window.location.href="/SearchMedicine.aspx?big="+escape(big.value)+"&small="+escape(small.value)+"&name="+escape(name.value);

} 
function newsearchmedicne(big,name)
{
if(name.value=="")
{
 alert("请输入产品名称");
return false; 
}
if(name.value=="请输入产品名称")
{
 alert("请输入产品名称");
return false; 
}
if(big.value=="-1")
{
 alert("请选择药品类别");
return false; 
}
else
{
window.location.href="/SearchMedicine.aspx?big="+escape(big.value)+"&name="+escape(name.value);
}

} 
function checkzjbuy()
{
 if(document.getElementById("txtbuynum").value=="")
 {
 alert("请输入件数");
 document.getElementById("txtbuynum").focus();
 return false;
 }
 return true;
}
function searchmedicne(big,small,name)
{
   var Letters = "(!@#$%^&*;':";
     var i;
     var c;
  if(name.value.charAt(0)=='-')
     return false;
  if(name.value.charAt(name.value.length - 1)== '-')
     return false;
  for( i = 0; i < name.value.length; i ++ )
     {
          c = name.value.charAt( i );
          if (Letters.indexOf( c ) > 0)
          return false;        
     }
  //return true;

  window.location.href="/SearchMedicine.aspx?big="+escape(big.value)+"&small="+escape(small.value)+"&name="+escape(name.value);

} 
function getcookie(Name) { 
var search = Name + "=" 
var returnvalue = ""; 
if (document.cookie.length > 0) { 
offset = document.cookie.indexOf(search) 
if (offset != -1) { 
offset += search.length 
end = document.cookie.indexOf(";", offset); 
if (end == -1) 
end = document.cookie.length; 
returnvalue=unescape(document.cookie.substring(offset, end)) 
} 
} 
return returnvalue; 
}
  function getAbsoluteLeft(ob){
        var mendingLeft = ob.offsetLeft;
        while( ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY" ){
            mendingLeft += ob.offsetParent.offsetLeft;
            ob = ob.offsetParent;
        }
        return mendingLeft;
    }
    function getAbsoluteTop(ob)
    {
        var mendingTop = ob.offsetTop;
        while( ob != null && ob.offsetParent != null && ob.offsetParent.tagName != "BODY" ){
            
            mendingTop += ob.offsetParent.offsetTop;
            ob = ob.offsetParent;
       }
        return mendingTop;
    }
function displaypopupmenu()
{
 var cf=document.getElementById('popupcontent');
cf.style.top=getAbsoluteTop(document.getElementById('lblshowhidecontent')) + document.getElementById('lblshowhidecontent').offsetHeight+8;//(document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height;
cf.style.left=getAbsoluteLeft(document.getElementById('lblshowhidecontent'))-230;
 cf.style.display='block';

} 
 function displayourchengnuo()
{
 var cf=document.getElementById('popupcontent');
cf.style.top=getAbsoluteTop(document.getElementById('newourchengnuo')) + document.getElementById('newourchengnuo').offsetHeight-78;//(document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height;
cf.style.left=getAbsoluteLeft(document.getElementById('newourchengnuo'))+120;
 cf.style.display='block';

}    
function  but(){

document.getElementById("popupcontent").style.display='none'; 

}

   function checkbookall()
   {

        var name =  document.getElementById("txtname");
        var tel = document.getElementById("txttel");
        var title = document.getElementById("txttitle");
        var content = document.getElementById("txtcontents");
       
        if(name.value=="")
        {
            alert("请写下您的姓名");
            name.focus();
         return false;
        }
        if(tel.value=="")
        {
            alert("请写下您的联系方式!");
            tel.focus();      
             return false;
        }
      if (document.getElementById("ddl_province").value=="-1")
    	{
		 alert("请选择所属省份!");
		document.getElementById("ddl_province").focus();
		 return false;
	  }
        if(title.value=="")
        {
           alert("请写下您的留言标题");
            title.focus();
          return false;
        }
        if(content.value=="")
        {
            alert("留言内容不能为空!");
            content.focus();
          return false;
        }

   return true;

   }

//新版注册首页
  function selectchange()
{
   var t = document.getElementById("select");
   if(t.options[0].selected)
   {
      alert("请选择您要注册的会员类型!");
      return false;
   }
   if(t.options[1].selected)
   {
      window.location = "Register.aspx?id=0";
   }
   if(t.options[2].selected)
   {
      window.location = "RegisterSecond.aspx?id=1";
   }
   if(t.options[3].selected)
   {
      window.location = "RegisterSecond.aspx?id=2";
   }
   if(t.options[4].selected)
   {
      window.location = "../yghy/Zcyghy.aspx";
   }

}