//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) / 2; 
	var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
	s += ', toolbar=no, scrollbars=yes, menubar=no, location=no, resizable=yes'; 
	open(u, 'oWin', s); 
} 
//订单提交
function GotoUrl(){ 
if (confirm('确定快钱支付？')){
	document.myform.action="Send.asp";
	document.myform.submit();
}else{
	document.myform.action="OrderForm.asp?Action=addok";
	document.myform.submit();
}
} 
//菜单效果
function at_display(x)
{
  win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight - 3 -18 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +50 : 218;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
function at_show()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}
function at_hide()
{
  c = document.getElementById(this["at_child"]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 33);
}
function at_click()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";

  return false;
}
function at_attach(parent, child, showtype, position, cursor)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
