﻿//FLASH免激活
function FreeFlash(elm, url, w, h) { 
if (!document.getElementById(elm)) return; 
var str = ''; 
str += '<object width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">'; 
str += '<param name="movie" value="'+ url +'">'; 
str += '<param name="wmode" value="transparent">'; 
str += '<param name="quality" value="autohigh">'; 
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'; 
str += '</object>'; 
document.getElementById(elm).innerHTML = str; 
} 
// 控制图片等比例缩放
var flag=false;
function DrawImage(ImgD,WidthD,HeightD){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= WidthD/HeightD){
     if(image.width>WidthD){
     ImgD.width=WidthD;
     ImgD.height=(image.height*WidthD)/image.width;
     }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>HeightD){
     ImgD.height=HeightD;
     ImgD.width=(image.width*HeightD)/image.height;
     }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    }
}
//会员登陆页面
function CheckLoginNull(){
if (document.lgform.UserName.value==""){
	alert("用户名不能为空!");
	document.lgform.UserName.focus()
	return false;
}
if (document.lgform.Password.value==""){
	alert("密码不能为空!");
	document.lgform.Password.focus()
	return false;
}
return true;
}
//注册页面
function CheckRegNull(){
if (document.regform.UserName.value==""){
	alert("帐号不能为空!");
	document.regform.UserName.focus()
	return false;
}
if (document.regform.Password.value==""){
	alert("密码不能为空!");
	document.regform.Password.focus()
	return false;
}
if (document.regform.ChkPassword.value==""){
	alert("确认密码不能为空!");
	document.regform.ChkPassword.focus()
	return false;
}
if (document.regform.Password.value != document.regform.ChkPassword.value){
	alert("两次密码不一致!");
	document.regform.ChkPassword.focus()
	return false;
}
if(document.regform.Email.value.length!=0){
if (document.regform.Email.value.charAt(0)=="." ||        
	document.regform.Email.value.charAt(0)=="@"||       
	document.regform.Email.value.indexOf('@', 0) == -1 || 
	document.regform.Email.value.indexOf('.', 0) == -1 || 
	document.regform.Email.value.lastIndexOf("@")==document.regform.Email.value.length-1 || 
	document.regform.Email.value.lastIndexOf(".")==document.regform.Email.value.length-1)
{
	alert("Email的格式不正确！");
	document.regform.Email.focus();
	return false;
	}
}
else
{
	alert("Email不能为空！");
	document.regform.Email.focus();
	return false;
}
if (document.regform.Tel1.value==""){
	alert("区号不能为空!");
	document.regform.Tel1.focus()
	return false;
}
if (document.regform.Tel2.value==""){
	alert("电话号码不能为空!");
	document.regform.Tel2.focus()
	return false;
}
if (document.regform.Address.value==""){
	alert("送货地址不能为空!");
	document.regform.Address.focus()
	return false;
}
return true;
}
//资料修改页面
function EidtUserNull(){
if (document.editform.IsEdit.checked==true){
if (document.editform.Password.value==""){
	alert("新的密码不能为空!");
	document.editform.Password.focus()
	return false;
}
}
if(document.editform.Email.value.length!=0){
if (document.editform.Email.value.charAt(0)=="." ||        
	document.editform.Email.value.charAt(0)=="@"||       
	document.editform.Email.value.indexOf('@', 0) == -1 || 
	document.editform.Email.value.indexOf('.', 0) == -1 || 
	document.editform.Email.value.lastIndexOf("@")==document.editform.Email.value.length-1 || 
	document.editform.Email.value.lastIndexOf(".")==document.editform.Email.value.length-1)
{
	alert("Email的格式不正确！");
	document.editform.Email.focus();
	return false;
	}
}
else
{
	alert("Email不能为空！");
	document.editform.Email.focus();
	return false;
}
if (document.editform.LinkTel.value==""){
	alert("联系电话不能为空!");
	document.editform.LinkTel.focus();
	return false;
}
if (document.editform.Address.value==""){
	alert("送货地址不能为空!");
	document.editform.Address.focus();
	return false;
}
return true;
}
//收货人信息
function AddressNull(){
if (document.form.LinkMan.value==""){
	alert("收货人不能为空!");
	document.form.LinkMan.focus();
	return false;
}
if (document.form.Address.value==""){
	alert("收货地址不能为空!");
	document.form.Address.focus();
	return false;
}
if (document.form.LinkTel.value==""){
	alert("固定电话不能为空!");
	document.editform.LinkTel.focus();
	return false;
}
return true;
}
//弹出窗口居中
function openWin(u, w, h) { 
	var l = (screen.width - w) / 2; 
	var t = (screen.height - h) / 3; 
	var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
	s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no'; 
	open(u, 'oWin', s); 
} 
//订单提交
function GotoUrl(){ 
if (document.myform.PayMode.value==1){
if(confirm('您确定线下支付吗？')){	
	document.myform.action="OrderForm.asp?Action=addok";
	document.myform.submit();
}
return false;
}else{
if(confirm('您确定快钱支付吗？')){	
	document.myform.action="Send.asp";
	document.myform.submit();
	window.resizeTo(580,300);
}
return false;
}
} 

