﻿//window scrollTo
var winHref=window.location.href;
window.onload=function(){
    window.scrollTo(0,300); 
    Fun_Picbydomainname();
}

/*function Fun_Picbydomainname(){
    var divPicforjs=document.getElementById("divPicforjs");
    if(divPicforjs!=null){
        var hostname=window.location.href;
        if(hostname.indexOf("lvshou.me")>=0||hostname.indexOf("lvshou66.com")>=0||hostname.indexOf("localhost")>=0){
            divPicforjs.style.background="url(http://www.lvshou28.com/lvshouStatic2/tempframe2/images/lv_052.gif) no-repeat right top";
        }
    }
}*/

function Fun_Amount(){
    var form1 = document.getElementById("form1");
    var reg=/^\d+$/;
    if(!reg.test(form1.Quantity.value)){
        alert("数量格式不正确，请重新输入");
        form1.Quantity.value="";
        form1.Quantity.focus();
        return;
    }
    var aa=document.getElementsByName("ProductName");
    if(aa[0].checked){            
        form1.Amount.value=form1.Quantity.value*299;
    }
    if(aa[1].checked){            
        form1.Amount.value=form1.Quantity.value*499;
    }
    if(aa[2].checked){            
        form1.Amount.value=form1.Quantity.value*699;
    }
    if(aa[3].checked){            
        form1.Amount.value=form1.Quantity.value*1299;
    }if(aa[4].checked){            
        form1.Amount.value=form1.Quantity.value*396;
    }if(aa[5].checked){            
        form1.Amount.value=form1.Quantity.value*796;
    }
    if(aa[6].checked){            
        form1.Amount.value=0;
    }
}

function LoadTopAll(){
    var homeStatic=window.location.href;
    if(homeStatic.indexOf("localhost")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547009&web_id=2547009&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Ff5b0e516bb635da95ca6c4d230800d44' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou.org")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547009&web_id=2547009&show=pic\" language=\"JavaScript\"><\/script>");
    }
    if(homeStatic.indexOf("lvshou.me")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547413&web_id=2547413&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F3039bf75f34b4e8ddba1a333411d0c85' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou28.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547129&web_id=2547129&show=pic\" language=\"JavaScript\"><\/script>");
    }
    if(homeStatic.indexOf("lvshou99.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=1577266&web_id=1577266&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F563ff75e73e760bededaf88cbd271666' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou88.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=1577982&web_id=1577982&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F322d830da1130169fb4ca1c7543799d0' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou.cc")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547361&web_id=2547361&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F7bd2ec1070a8d228fdf3a367a5c7a71e' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou.hk")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547368&web_id=2547368&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F088b678d78f67b183253985cba9318e3' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou.com.cn")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547379&web_id=2547379&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhm_top = 0;
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        var _bdhm_tim = new Image(1,1);
//        _bdhm_tim.id = "bdhmPerimg";
//        _bdhm_tim.src = _bdhmProtocol + "hm.baidu.com/_tt.gif?si=ac71e0079799a57cc6616312cbbbaf84&rnd=" + Math.round(Math.random()*2147483647);
//        _bdhm_tim.onload=function(){_bdhm_top = 1;}
    }else if(homeStatic.indexOf("lvshou.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547374&web_id=2547374&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fa28d22eb609755aca38fbe94efbf2f8e' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou66.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=1576957&web_id=1576957&show=pic\" language=\"JavaScript\"><\/script>");
//        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Ff5b0e516bb635da95ca6c4d230800d44' type='text/javascript'%3E%3C/script%3E"));
    }
    if(homeStatic.indexOf("lvshou68.com")>=0){
        document.write("<script src=\"http://s6.cnzz.com/stat.php?id=2547395&web_id=2547395&show=pic\" language=\"JavaScript\"><\/script>");
    }    
}

function LoadJS(){
    var headObj = document.getElementsByTagName("head")[0];
    var srciptObj = document.createElement("script");
    srciptObj.language = "javaScript";
    srciptObj.type = "text/JavaScript";
    srciptObj.src="";
    //var floatStat=window.location.hostname;
    if(winHref.indexOf("lvshou.org")>=0){
        srciptObj.src="http://s6.cnzz.com/stat.php?id=2547009&web_id=2547009";
    }
    headObj.appendChild(srciptObj);
} 

////IE
//window.onbeforeunload=function(){
//if(event.clientX>document.body.clientWidth && event.clientY < 0 || event.altKey){
//    if(winHref.indexOf("lvshou66")<0){
//    window.external.addFavorite("http://"+location.hostname,"绿瘦首页收藏!");
//    }
//}
//}
////FF
//window.onunload=function(){
//    if(window.sidebar){
//        if(document.body.clientWidth==0){    
//            if(winHref.indexOf("lvshou66")<0){
//                window.sidebar.addPanel("绿瘦首页收藏!","http://"+location.hostname, "");
//            }
//        }
//    }
//}

//银行和信用卡div的显示和隐藏
function ShowBankAndXin(obj){
//    alert(obj.value);
    var Li_bank=document.getElementById("bank");
    var Li_xin=document.getElementById("xin");
    if(obj.value=="IndexOrderBill"){
        Li_bank.style.display="block";
        Li_xin.style.display="none";
        return;
    }
    if(obj.value=="IndeOrderXin"){
        Li_bank.style.display="none";
        Li_xin.style.display="block";
        return;
    }
    Li_bank.style.display="none";
    Li_xin.style.display="none";    
}

//公告滚动
var tt1;
    function start(){
        demo=document.getElementById("xdemo");
        demo1=document.getElementById("xdemo1");
        demo2=document.getElementById("xdemo2");
        if(demo2==null){
            return;
        }
        
        ShowNum();
        clearTimeout(tt1);
        
        demo2.innerHTML=demo1.innerHTML;
        function mar(){
            if(demo.scrollTop>=demo2.offsetHeight){
                 demo.scrollTop=0;
            }else{
                demo.scrollTop++;
            }
        }
        var tt2=setInterval(mar,20);
        demo.onmousemove=function(){
            clearInterval(tt2);
        }
        demo.onmouseout=function(){
            tt2=setInterval(mar,20);
        }
        
    }
tt1=setTimeout(start,1000);


//订单提交验证xxx-----
function checkRadio()
{        
        var form1 = document.getElementById("form1");
        
        var aa=document.getElementsByName("ProductName");
        for(var i=0;i<aa.length;i++){
            if(aa[i].value=="配方"&&aa[i].checked)
            {
                if(trim(form1.ProductName2.value)==""){
                    alert("请输入配方");
                    form1.ProductName2.focus();
                    return false;
                }
            }
        }
             
/*        if(trim(form1.Quantity.value) == "")
        {
            alert("请输入订购的数量");
            form1.Quantity.focus();
            return  false;
        } 
        if(!validateInt(trim(form1.Quantity.value)))
        {
            alert("请输入正确的数量");
            form1.Quantity.select();
            form1.Quantity.focus();
            return  false;
        }
        if(trim(form1.Quantity.value)=="0")
        {
            alert("数量不能为0");
            form1.Quantity.select();
            form1.Quantity.focus();
            return  false;
        }
            
        if(trim(form1.Amount.value) == "")
        {
            alert("请输入总价");
            form1.Amount.focus();
            return  false;
        }
        
        if(!validateInt(form1.Amount.value)){
            alert("请输入正确的总价");            
            form1.Amount.select();
            form1.Amount.focus();
            return false;
        }
        if(trim(form1.Amount.value)=="0")
        {
            alert("总价不能为0");
            form1.Amount.select();
            form1.Amount.focus();
            return  false;
        }*/
        
        if(trim(form1.Customer.value) == "")
        {
            alert("请输入收货人姓名");
            form1.Customer.focus();
            return  false;
        }
        
        if(trim(form1.Customer.value) == "")
        {
            alert("请输入收货人姓名");
            form1.Customer.focus();
            return  false;
        }
        if(trim(form1.Customer.value).length <2)
        {
            alert("收货人姓名长度要大于1");
            form1.Customer.focus();
            return  false;
        }
        
        if(trim(form1.Address.value) == "")
        {
            alert("请输入收货地址");
            form1.Address.focus();
            return  false;
        }
        
        if(trim(form1.Address.value).length <2)
        {
            alert("收货地址符长度要大于1");
            form1.Address.focus();
            return  false;
        }
        
        if(trim(form1.Post.value) == "")
        {
            alert("请输入邮政编码");
            form1.Post.focus();
            return  false;
        }
        
        if(!validateInt(form1.Post.value)){
            alert("请输入正确的邮政编码");            
            form1.Post.select();
            form1.Post.focus();
            return false;
        }
        
        
        if(trim(form1.Phone.value) == "")
        {
            alert("请输入联系电话");
            form1.Phone.focus();
            return  false;  
//            var myreg = /^(((13[0-9]{1})|159|(15[0-9]{1}))+\d{8})$/;
//            if(!myreg.test(mobile))
//            {
//                alert('请输入合法的手机号码！');
//                document.getElementsByName("Phone")[0].focus();
//                return false;
//            }
             
        }
        if(form1.Phone.value.length!=11)
        {
             alert('请输入合法的手机号码！');
             form1.Phone.focus();
             return false;
        } 
        
        var aa=document.getElementsByName("indexOrder");
        for(var i=0;i<aa.length;i++)
        {
         if(aa[i].checked)
         {
            if(aa[i].value=='indexOrder'||aa[i].value=='IndexOrderAlipay')
            {
               form1.action='#';
            }
            else if(aa[i].value=='IndexOrderBill'||aa[i].value=='IndeOrderXin')
            {
                if(aa[i].value=='IndeOrderXin')
                {
                 var obj=document.getElementsByName("province")[0];
                 var obj1=document.getElementsByName("city")[0];
     
                 document.getElementById("STATE").value=obj.options[obj.selectedIndex].text;
                 document.getElementById("CITYS").value=obj1.options[obj1.selectedIndex].text;

                    if(trim(document.getElementsByName("IDNUMBER")[0].value) == "" )
                    {
                        alert("请输入身份证号码");
                        document.getElementsByName("IDNUMBER")[0].focus();
                        return  false;
                    }
                    if(!(/^[0-9]{15}$/.test(document.getElementsByName("IDNUMBER")[0].value)==true||/^[0-9]{18}$/.test(document.getElementsByName("IDNUMBER")[0].value)==true))
                    {
                        alert("请输入正确的身份证号码");
                        document.getElementsByName("IDNUMBER")[0].focus();
                        return  false;
                    }

//                    if(document.getElementById("city").value==""||document.getElementById("city").value=="请选择")
//                    {
//                        alert("请选择城市");
//                        return  false;
//                    }
//                    if(document.getElementById("STATE").value==""||document.getElementById("STATE").value=="请选择")
//                    {
//                        alert("请选择省");
//                        return  false;
//                    }

                    if(document.getElementById("province")[document.getElementById("province").selectedIndex].text=="请选择")
                    {
                        alert("请选择省份");
                        return  false;
                    }
                    if(document.getElementById("city")[document.getElementById("city").selectedIndex].text=="请选择")
                    {
                        alert("请选择城市");
                        return  false;
                    }
                }
                form1.action='alipayto.asp';
            }
         }
        }
        form1.submit();
        return true;  
}
 
//订单重置xxx------------
function IndexOrderReset()
{
    document.getElementById("form1").reset();
    return false;
}


//用户留言xxx-------------
function MessageSave()
{
//    var pidname=document.getElementsByName("pidname");
//    alert(pidname[1].checked);
//    return;
    if(trim( document.getElementById("txtCustomer").value) == "")
    {
        alert("请输入您的姓名");
        document.getElementById("txtCustomer").focus();
        return  false;
    }
    
    if(document.getElementsByName("radPid")[1].checked && trim( document.getElementById("txtTel").value) == "")
    {
        alert("请输入您的联系方式");
        document.getElementById("txtTel").focus();
        return  false;
    }
    
    if(trim( document.getElementById("txtWord").value) == "")
    {
        alert("请输入咨询内容");
        document.getElementById("txtWord").focus();
        return  false;
    }
    
   if(trim( document.getElementById("txtVail").value) == "")
    {
        alert("请输入验证码");
        document.getElementById("txtVail").focus();
        return  false;
    }
   var form2=document.getElementById("form2");
   form2.action='http://www.lvshou28.com/lvshouStatic2/message-form.aspx';
   form2.submit();
    
    
}
//用户留言xxx------------
function MessageReset()
{
    document.getElementById("txtCustomer").value = "";
    document.getElementById("txtVail").value = "";
    document.getElementById("txtWord").value = "";

    return false;
}

   
//咨询验证-----------
function consultationSave()
{
    if(trim(document.getElementById("txtcustomer").value) == "")
    {
        alert("请输入您的姓名");
        document.getElementById("txtcustomer").focus();
        return  false;
    }
    if(trim(document.getElementById("problem").value) == "")
    {
        alert("请输入咨询内容");
        document.getElementById("problem").focus();
        return  false;
    }
    if(trim(document.getElementById("txtVail").value) == "")
    {
        alert("请输入验证码");
        document.getElementById("txtVail").focus();
        return  false;
    }
    
    var aaa=document.getElementById("formconsultation");
    aaa.action="http://www.lvshou28.com/lvshouStatic2/consultation-form.aspx";
    aaa.submit()
}

//咨询重置-----------
function consultationreset()
{
    document.getElementById("formconsultation").reset();
}


//产品防伪查询
function AntifakeQuery()
{
    var theform = document.form1;
    if(trim(theform.message.value) == "")
    {
        alert("请输入您要查询的防伪码");
        theform.message.focus();
        return  false;
    } 
    if(trim(theform.message.value).length< 20)
    {
        alert("您输入的20位防伪码位数不足，请仔细核对");
        theform.message.focus();
        return  false;
    } 
    if(!validateInt(trim(theform.message.value)))
    {
        alert("请输入正确的防伪码");
        theform.message.focus();
        theform.message.select();
        return  false;
    }
    form1.action='http://www.12365.gov.cn/re_query.asp';
	form1.submit();
}


//增值服务
function incrementSave()
{
    var form1=document.getElementById("form1");
    if(trim(form1.customer.value)== "")
    {
        alert("请输入您的姓名");
        return  false;
    }
    if(trim(form1.address.value)== "")
    {
        alert("请输入地址");
        return  false;
    }
    
     if(trim(form1.phone.value)== "")
    {
        alert("请输入电话号码");
        return  false;
    }
      if(trim(form1.securitycode.value)== "")
    {
        alert("请输入绿瘦产品防伪码");
        return  false;
    }
    if(trim(form1.txtVail.value)== "")
    {
        alert("请输入验证码");
        return  false;
    }
    
    form1.action="http://www.lvshou28.com/lvshouStatic2/increment-form.aspx";
    form1.submit();
    
    
   
}
//增值服务
function incrementReset()
{
    document.getElementById("form1").reset();
    return false;
}



function BASEreal_len(theText){ 
	  var real_len=0;
	  text_val=theText.value;
	  text_len=theText.value.length;
	  for(i=0;i<text_len;i++){
	    if (text_val.charCodeAt(i)>127){
		  real_len=real_len+2;
		}
	    else{
		  real_len++;
		}
  	  }
	  return(real_len);
}
///是否为整型数字
function validateInt(ss)
{
	var s;
	s=trim(ss)
	if(s=="")
	{
		return false;
	}
   	var toCompare="0123456789";
   	var compare;
	for (var i=0;i<s.length;i++)
	{
	  compare=s.charAt(i);
	  if (toCompare.indexOf(compare)==-1)
	    {
		  return false;
	    }
	}
	return true;
}

///去掉空格
function trim(s)
{
	var i;
	var ss;
	var nlen;
	ss="";
	if(s==null)
	{
		return ss;
	}
	if(s.toString()=="")
	{
		return ss;
	}
	nlen=s.length;
	ss=s;
	for(i=0;i<nlen;i++)
	{
		if(escape(ss.charAt(i))!="%20")
		{
			ss=ss.substr(i,ss.length-i);
			break;
		}
	}
	if(i==nlen)
	{
		ss="";
		return ss;
	}
	nlen=ss.length-1;
	for(i=nlen;i>=0;i--)
	{
		if(escape(ss.charAt(i))!="%20")
		{
			nlen=i+1;
			ss=ss.substr(0,nlen);
			break;
		}	
	}
	return ss;
}

//随机返回数组中的某个值
function CreateRecord(obj){
    return obj[Math.floor(Math.random()*obj.length)];
}

//取得当前日期 格式 yyyy-MM-dd
function GetNowTime(){
    var nowtime=new Date();
    var nowstr=nowtime.getFullYear()+"-";
    var nowmonth=nowtime.getMonth()+1;
    if(nowmonth<10){
        nowmonth="0"+nowmonth;
    }
    var nowdate=nowtime.getDate();
    if(nowdate<10){
        nowdate="0"+nowdate; 
    }
    nowstr+=nowmonth+"-"+nowdate;        
    return nowstr;
}

//返回字符串
function ShowNum(){
    var mycars=new Array("张小姐 ","钟小姐 ","潘小姐 ","梁先生 ","吕小姐 ","傅小姐 ","曹小姐 ","冯小姐 ","魏小姐 ","郭先生 ",
        "金小姐 ","张先生 ","伍小姐 ","黄小姐 ","余小姐 ","顾先生 ","胡小姐 ","万小姐 ","欧小姐 ","魏先生 ","宋小姐 ","曲小姐 ",
        "田先生 ","孟小姐 ","龙小姐 ","方先生 ","蒲先生 ","冉小姐 ","穆小姐 ","吴小姐 ","赵小姐 ","姚小姐 ");    
    var mycars2=new Array("安徽马鞍山市  ","山东滨州市 ","辽宁沈阳市 ","江西南昌市 ","湖南张家界市 ","湖北天门市 ","黑龙鸡西市 ","河北邢台市 ",
    "浙江省绍兴市 ","辽宁省沈阳市 ","浙江省温州市 ","江苏省连云港 ","河南省郑州市 ","重庆市南川区 ","吉林省长春市 ","山东省烟台市 ","海南省海口市 ",
    "广东省东莞市 ","山西省太原市 ","辽宁省沈阳市 ","广西河池市 ","广东肇庆市 ","甘肃天水市 ","福建莆田市 ","北京门头沟 ","陕西铜川市 ");
//    var mycars1=new Array("13","15","18");    
    var str="<ul>";
    for(var i =0;i<mycars.length;i++){
        var ph1=Math.floor(Math.random()*10);
        str+="<li>"+CreateRecord(mycars)+CreateRecord(mycars2)+" 已发货</li>";
    }
    str+="</ul>";
    document.getElementById("xdemo1").innerHTML=str;
}
//电话后4位的生成
function ReturnPhone(){
    var mastr=Math.floor(Math.random()*10000);
    if(mastr<=1000){
        mastr=ReturnPhone();
    }
    return mastr;
}
