﻿// JavaScript Document
var flag=false; 
function DrawImage(ImgD,pwidth,pheight)
{ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= pwidth/pheight){ 
   if(image.width>pwidth){
    ImgD.width=pwidth; 
    ImgD.height=(image.height*pwidth)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   ImgD.alt="点击查看详细信息..."; 
  } 
  else{ 
   if(image.height>pheight){
    ImgD.height=pheight; 
    ImgD.width=(image.width*pheight)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
   ImgD.alt="点击查看详细信息..."; 
  } 
 }
}


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;
            }
　　　　　ImgD.style.cursor= ""; //改变鼠标指针
　　　　　ImgD.onclick = function() {} //点击打开大图片
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE
　　　　　　ImgD.title = "";
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放
　　　　　 {
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100;
　　　　　　　　　　zoom += event.wheelDelta / 12;
　　　　　　　　　　if (zoom= 0)　this.style.zoom = zoom + "%";
　　　　　　　　　　//'如要鼠标滚动缩放反上面的转换这句
　　　　　　　　　　//if (zoom> 0)　this.style.zoom = zoom + "%";
　　　　　　　　　　return false;
　　　　　 }
　　　  } else { //如果不是IE
　　　　　　　     ImgD.title = "";
　　　　　　   }
    }
}

function userloginchk(theform)
{
	if(theform.userName.value.length<5)
	{
		alert("请输入正确用户名");
		theform.userName.focus();
		return false;
	}
	var chkpwd=/^[A-Za-z0-9]{6,16}$/
	if(!chkpwd.test(theform.userpwd.value))
	{
		alert("请输入正确的密码");
		theform.userpwd.focus();
		return false;
	}
}

function orderchk(theform)
{
if(theform.dpname.value==""||theform.duname.value==""||theform.duadd.value==""||theform.duemail.value=="")
{
	alert("请填写带*号的项目");
	return false;
}
}

function userregchk(theform)
{
	if(theform.uname.value!="")
	{
	if(isNaN(theform.uname.value) || theform.uname.value.length<11)
	{
	alert("请输入正确的手机号");
	theform.uname.focus();
	return false;
	}
	}
	
	if(theform.uemail.value!="")
	{
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.uemail.value))
	{
	alert("非法的电子邮箱！");
	theform.uemail.focus();
	return false;
	}
	}
	
	if(theform.uname.value=="" && theform.uemail.value=="")
	{
		alert("手机号或邮箱必须填写一项");
		theform.uname.focus();
		return false;
	}


if(theform.upwd.value!=theform.upwd1.value)
{
	alert("二次密码输入不一致");
	theform.upwd1.focus();
	return false;
}

var chkpwd=/^[A-Za-z0-9]{6,16}$/
if(!chkpwd.test(theform.upwd.value))
{
	alert("请输入6位以上的密码");
	theform.upwd.focus();
	return false;
}
}

//修改密码
function userpwdchk(theform)
{
	var chkpwd=/^[A-Za-z0-9]{6,16}$/
	if(!chkpwd.test(theform.upwd.value))
	{
		alert("请输入原密码");
		theform.upwd.focus();
		return false;
	}
	if(!chkpwd.test(theform.npwd.value))
	{
		alert("请输入新密码");
		theform.npwd.focus();
		return false;
	}
	if(!chkpwd.test(theform.npwd1.value))
	{
		alert("请输入确认密码");
		theform.npwd1.focus();
		return false;
	}
	if(theform.npwd.value!=theform.npwd1.value)
	{
		alert("二次密码输入不一致");
		theform.npwd1.focus();
		return false;
	}
	
}


function userregchk2(theform)
{
	if(theform.utruename.value.length<2)
	{
		alert("请输入您的真实姓名")
		theform.utruename.focus();
		return false;
	}
	if(theform.utel.value.length<7|| isNaN(theform.utel.value))
	{
		alert("请输入正确的电话号码")
		theform.utel.focus();
		return false;
	}
	if(theform.ufax.value.length<7|| isNaN(theform.ufax.value))
	{
		alert("请输入正确的传真号码")
		theform.utel.focus();
		return false;
	}
	if(theform.ucompany.value.length<5)
	{
		alert("请输入正确的公司名称")
		theform.ucompany.focus();
		return false;
	}
	if(theform.uadd.value.length<5)
	{
		alert("请输入正确的地址")
		theform.uadd.focus();
		return false;
	}
	if(theform.umianji.value.length<2)
	{
		alert("请正确输入贵公司的营业面积")
		theform.umianji.focus();
		return false;
	}
	if(theform.uhy.value.length<2)
	{
		alert("请正确输入贵公司主营行业")
		theform.uhy.focus();
		return false;
	}
	if(theform.ufs.value.length<2)
	{
		alert("请正确输入贵公司主营方式")
		theform.ufs.focus();
		return false;
	}
}


function ShowMe(TB)
{
	whichTB = eval("kk" + TB);
     for(i=1;i<=4;i++)
	 {
	 	eval("kk" + i + ".style.display=\"none\";");
		eval("mm" +i +".style.background=\"#3F9C70\";");
	 }
	 eval("kk" + TB + ".style.display=\"\";");
	eval("mm" +TB +".style.background=\"#28724F\";");

}

function ShowMe1(TB)
{
	whichTB = eval("kk" + TB);
     for(i=1;i<=2;i++)
	 {
	 	eval("kk" + i + ".style.display=\"none\";");
		eval("mm" +i +".style.background=\"#5BC0B1\";");
	 }
	 eval("kk" + TB + ".style.display=\"\";");
	eval("mm" +TB +".style.background='url(images/overbg.jpg)';");

}

function confirmdel(bid)
{
	if(confirm("确定删除吗?"))
	{
	window.location.href("userOrder.asp?bid="+bid+"&act=del");
	}
}

function pronochk(theform)
{
	if(theform.pno.value=="")
	{
		alert("请输入产品货号");
		theform.pno.focus();
		return false;
	}
}

function pricechk(theform)
{
	if(theform.fromprice.value=="")
	{
		alert("请输入价格上限");
		theform.fromprice.focus();
		return false;
	}

	if(theform.toprice.value=="")
	{
		alert("请输入价格下限");
		theform.toprice.focus();
		return false;
	}
}

function attachXMenu(objid){
	var tds=objid.getElementsByTagName('td');
	for(var i=0;i<tds.length;i++){
		with(tds[i]){
			onmouseover=function(){
				with(this){
					filters[0].apply();
					style.background='#C6F0EC'; //这是鼠标移上去时的背景颜色
					style.border='0px solid #ffffff'; //边框
					style.color='black'; //文字颜色
					filters[0].play();
				}
			}
			onmouseout=function(){
				with(this){
					filters[0].apply();
					style.background=''; //这是鼠标离开时的背景颜色
					style.border='0px solid #55CBBD'; //边框
					style.color='#ffffff'; //文字颜色
					filters[0].play();
				}
			}
		}
	}
}



function gueskbookchk(theform)
{
	if(theform.uname.value=="")
	{
		alert("请填写昵称");
		theform.uname.focus();
		return false;
	}
	
if(theform.uemail.value.length!=0)
 {
   if (theform.uemail.value.charAt(0)=="." ||        
		theform.uemail.value.charAt(0)=="@"||       
		theform.uemail.value.indexOf('@', 0) == -1 || 
		theform.uemail.value.indexOf('.', 0) == -1 || 
		theform.uemail.value.lastIndexOf("@")==theform.uemail.value.length-1 || 
		theform.uemail.value.lastIndexOf(".")==theform.uemail.value.length-1)
	{
	 alert("Email地址格式不正确！");
	 theform.uemail.focus();
	 return false;
	 }
  }
else
 {
  alert("Email不能为空！");
  theform.uemail.focus();
  return false;
  }
  
  if(theform.utel.value.length<7||isNaN(theform.utel.value))
  {
	  alert("请输入正确的电话号码");
	  theform.utel.focus();
	  return false;
  }
  
  	if(theform.title.value=="")
	{
		alert("请输入标题");
		theform.title.focus();
		return false;
	}
  	if(theform.content.value=="")
	{
		alert("请输入留言内容");
		theform.content.focus();
		return false;
	}
  if(theform.vcode.value.length!=4||isNaN(theform.vcode.value))
  {
	  alert("请输入正确验证码");
	  theform.vcode.focus();
	  return false;
  }

}

//上传头像
function upfujian()
{
if(fujian.style.display=="none")
	{
	fujian.style.display=""}
else
	{
	fujian.style.display="none"}
}

//信息添加检测
function infoadd(theform)
{
	if(theform.atitle.value=="")
	{
		alert("请输入标题");
		theform.atitle.focus();
		return false;
	}
	if(theform.shortcontent.value=="")
	{
		alert("请输入概述内容");
		theform.shortcontent.focus();
		return false;
	}
	if(theform.newscontent.value=="")
	{
		alert("文章内容必须超过100字");
		return false;
	}
}

//联系我们留言
function contactchk(theform)
{
	if(theform.uname.value=="")
	{
		alert("请输入您的姓名");
		theform.uname.focus();
		return false;
	}
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.uemail.value))
	{
		alert("请输入正确的Email");
		theform.uemail.focus();
		return false;
	}
	
	if(theform.utel.value==""||isNaN(theform.utel.value))
	{
		alert("请输入正确电话");
		theform.utel.focus();
		return false;
	}
	if(theform.ucontent.value=="")
	{
		alert("请正确输入留言内容");
		theform.ucontent.focus();
		return false;
	}
}

//支付确定判断
function buychk(theform)
{
	if(theform.buyname.value=="")
	{
		alert("请输入收货人姓名")
		theform.buyname.focus();
		return false;
	}
	if(theform.province.value=="")
	{
		alert("请选择所在省份")
		theform.province.focus();
		return false;
	}
	if(theform.city.value=="")
	{
		alert("请选择所在市县")
		theform.city.focus();
		return false;
	}
	if(theform.uadd.value=="")
	{
		alert("请输入详细地址")
		theform.uadd.focus();
		return false;
	}
	if(theform.ucode.value=="")
	{
		alert("请输入邮政编码")
		theform.ucode.focus();
		return false;
	}
	if(theform.utel.value=="" && theform.umobile.value=="")
	{
		alert("电话号码与手机必须填写一项")
		theform.umobile.focus();
		return false;
	}
}



function confirmdel(bid)
{
	if(confirm("确定删除吗?"))
	{
	window.location.href("userHome.asp?bid="+bid+"&act=del");
	}
}


function myemailchk(theform)
{
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.myemail.value))
	{
		alert("请输入正确的Email");
		theform.myemail.focus();
		return false;
	}
}

function getpwdchk(theform)
{
	if (theform.username1.value=="")
	{
		alert("请输入用户名");
		theform.username1.focus();
		return false;
	}
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.useremail1.value))
	{
		alert("请输入正确的Email");
		theform.useremail1.focus();
		return false;
	}
}

function getpwdchk1(theform)
{
	var chknum=/^[0-9]{11,11}$/
	if(!chknum.test(theform.uname2.value))
	{
		alert("请输入正确的电话号码");
		theform.uname2.focus();
		return false;
	}
}

function tofriend(theform)
{
	if (theform.yname.value=="")
	{
		alert("请输入您的姓名");
		theform.yname.focus();
		return false;
	}
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.yemail.value))
	{
		alert("请输入正确的Email");
		theform.yemail.focus();
		return false;
	}
	if (theform.fname.value=="")
	{
		alert("请输入好友的姓名");
		theform.fname.focus();
		return false;
	}
	var checkMail = /^(\w|-)+[@]{1}(\w|-)+[.]{1,3}(\w)+$/;
	if(!checkMail.test(theform.femail.value))
	{
		alert("请输入正确的Email");
		theform.femail.focus();
		return false;
	}

}

