﻿function show_down(pic_url,title,fbl,down_url)
{
	document.getElementById("big_img").src=pic_url;
	document.getElementById("big_title").innerHTML=title;
	document.getElementById("big_title2").innerHTML="["+fbl+"]";
	document.getElementById("big_url").href=down_url;
}

function correctPNG()
{
   for(var i=0; i<document.images.length; i++)
   {
   var img = document.images[i]
   var imgName = img.src.toUpperCase()
   if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
   {
   var imgID = (img.id) ? "id='" + img.id + "' " : ""
   var imgClass = (img.className) ? "class='" + img.className + "' " : ""
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
   var imgStyle = "display:inline-block;" + img.style.cssText
   if (img.align == "left") imgStyle = "float:left;" + imgStyle
   if (img.align == "right") imgStyle = "float:right;" + imgStyle
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
   var strNewHTML = "<span " + imgID + imgClass + imgTitle
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
   img.outerHTML = strNewHTML
   i = i-1
   };
   };
};

if(navigator.userAgent.indexOf("MSIE")>-1)
{
window.attachEvent("onload", correctPNG);
};

function change_img(imgsrc,linkid)
{
	document.getElementById("smallpic").src=imgsrc;
	document.getElementById("bigpic").src=imgsrc;
	for(var i=1;i<7;i++)
	{
		if(document.getElementById("alink_"+i)!=null)
		 {
			document.getElementById("alink_"+i).className=""; 
			document.getElementById("aspan_"+i).className="";
		 }
	}
	document.getElementById("alink_"+linkid).className="noLinkIcon"; 
	document.getElementById("aspan_"+linkid).className="noLink";
}

function change_imglist_sp(colorid,pid)
{
	for(var i=1;i<7;i++)
	{
		if(document.getElementById("tlink_"+i)!=null)
		 {
			document.getElementById("tlink_"+i).className=""; 
			document.getElementById("tspan_"+i).className="";
		 }
	}
	document.getElementById("tlink_"+colorid).className="noLinkIcon"; 
	document.getElementById("tspan_"+colorid).className="noLink";
	ajax("spanish/getlist.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"jiaodulist");
	ajax_img("spanish/getlist_img.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"smallpic");
	ajax_img("spanish/getlist_img.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"bigpic");
	document.getElementById("color").value=colorid;
}

function change_imglist(colorid,pid)
{
	for(var i=1;i<7;i++)
	{
		if(document.getElementById("tlink_"+i)!=null)
		 {
			document.getElementById("tlink_"+i).className=""; 
			document.getElementById("tspan_"+i).className="";
		 }
	}
	document.getElementById("tlink_"+colorid).className="noLinkIcon"; 
	document.getElementById("tspan_"+colorid).className="noLink";
	ajax("getlist.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"jiaodulist");
	ajax_img("getlist_img.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"smallpic");
	ajax_img("getlist_img.asp?id="+pid+"&color="+colorid+"&r="+Math.random(),"bigpic");
	document.getElementById("color").value=colorid;
}

function createXMLHttps()
{
    var ret = null;
    try {
        ret = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try {
            ret = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (ee) {
            ret = null;
        }
    }
    if (!ret && typeof XMLHttpRequest != 'undefined')
        ret = new XMLHttpRequest();
    return ret;
}

function ajax(URL,DIVID)
{
var obj_div=document.getElementById(DIVID);
var script="";
if(obj_div)
{
	var xmlhttp = createXMLHttps();
	xmlhttp.open("GET",URL,true);
	xmlhttp.onreadystatechange = function(){
 	if   (xmlhttp.readyState   ==   4)   {  
 	if   (xmlhttp.status   ==   200)   {   
 	document.getElementById(DIVID).innerHTML = xmlhttp.responseText;
	}  
 else   
 {   
alert( "您所请求的页面有异常。 "); 
} 
} 
}
	xmlhttp.send(null);
}
}

function ajax_img(URL,DIVID)
{
var obj_div=document.getElementById(DIVID);
var script="";
if(obj_div)
{
	var xmlhttp = createXMLHttps();
	xmlhttp.open("GET",URL,true);
	xmlhttp.onreadystatechange = function(){
 	if   (xmlhttp.readyState   ==   4)   {  
 	if   (xmlhttp.status   ==   200)   {   
 	document.getElementById(DIVID).src = xmlhttp.responseText;
	}  
 else   
 {   
alert( "您所请求的页面有异常。 "); 
} 
} 
}
	xmlhttp.send(null);
}
}


function gettotal()
{
   var t1=document.getElementById("num1").value;
   var t2=document.getElementById("num2").value;
   var t3=document.getElementById("num3").value;
   var t4=document.getElementById("num4").value;
   var t5=document.getElementById("num5").value;
   var total=0;
   if (isNaN(t1)==true||isNaN(t2)==true||isNaN(t3)==true||isNaN(t4)==true||isNaN(t5)==true)
   {
	   alert("Please enter a figure!");
   }
   else
   {
	  if(t1<0||t1<0||t1<0||t1<0||t1<0) 
	  {
		  alert("Please enter a positive number!");
	  }
	  else
	  {
		  total=parseInt(t1)+parseInt(t2)+parseInt(t3)+parseInt(t4)+parseInt(t5);
		  total=ForDight(total*parseFloat(document.getElementById("selfprice").value),2);
		  document.getElementById("total_num").innerHTML="Total:$"+total;
	  }
   }
}

function ForDight(Dight,How)

 { 

var Dight = Math.round (Dight*Math.pow(10,How))/Math.pow(10,How); 

return Dight; 

} 
function gettotal2()
{
   var t1=document.getElementById("num").value;
   var total=0;
   if (isNaN(t1)==true)
   {
	   alert("Please enter a figure!");
   }
   else
   {
	  if(t1<0||t1<0||t1<0||t1<0||t1<0) 
	  {
		  alert("Please enter a positive number!");
	  }
	  else
	  {
		  total=parseInt(t1);
		  total=ForDight(total*parseFloat(document.getElementById("selfprice").value),2);
		  document.getElementById("total_num").innerHTML="Total:$"+total;
	  }
   }
}


function subformlist()
{
   var t1=document.getElementById("num1").value;
   var t2=document.getElementById("num2").value;
   var t3=document.getElementById("num3").value;
   var t4=document.getElementById("num4").value;
   var t5=document.getElementById("num5").value;
   var total=0;
   if (isNaN(t1)==true||isNaN(t2)==true||isNaN(t3)==true||isNaN(t4)==true||isNaN(t5)==true)
   {
	   alert("Please enter a figure!");
   }
   else
   {
	  if(t1<0||t1<0||t1<0||t1<0||t1<0) 
	  {
		  alert("Please enter a positive number!");
	  }
	  else
	  {
		  total=parseInt(t1)+parseInt(t2)+parseInt(t3)+parseInt(t4)+parseInt(t5);
		  if(total>0)
		  {
			  document.getElementById("num").value=total;
			  var id=document.getElementById("pid").value;
			  var color=document.getElementById("color").value;
			  var url="save_cart.asp?pid="+id+"&color="+color+"&num1="+t1+"&num2="+t2+"&num3="+t3+"&num4="+t4+"&num5="+t5+"&num="+total;
			  location.href=url;
		  }
		  else
		  {
			  alert("Product quantity must be greater than 0!");
		  }
	  }
   }
}


function subform()
{
	var t1=document.getElementById("num").value;
   var total=0;
   if (isNaN(t1)==true)
   {
	   alert("Please enter a figure!");
   }
   else
   {
	  if(t1<0) 
	  {
		  alert("Please enter a positive number!");
	  }
	  else
	  {
		  total=parseInt(t1);
		  if(total>0)
		  {
			  var id=document.getElementById("pid").value;
			  var color=document.getElementById("color").value;
			  var url="save_cart.asp?pid="+id+"&color="+color+"&num="+total;
			  location.href=url;
		  }
		  else
		  {
			  alert("Product quantity must be greater than 0!");
		  }
	  }
   }
}

function adduser()
{
	var username=document.getElementById("username").value;
	if(checkspace_self(username) || username.length < 0)
	{
	   document.getElementById("username").focus();
       alert("Personnel Name should not be empty, please re-enter!");
	}
	else
	{
	  ajax("getuserc.asp?username="+username+"&r="+Math.random(),"userlist");
	}
}

function adduser_list(id)
{
	var username=escape(document.getElementById("username").value);
	if(checkspace_self(username) || username.length < 0)
	{
	   document.getElementById("username").focus();
       alert("Personnel Name should not be empty, please re-enter!");
	}
	else
	{
	  ajax("getuserlist.asp?id="+id+"&username="+username+"&r="+Math.random(),"userlist");
	  document.getElementById("circlelist").src="design_circle_mamage_content.asp?id="+id+"&r="+Math.random();
	}
}

function checkspace_self(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}


var scorall=1
function scroll(n,total)
{
	if(n==-1)
	{
		scorall=scorall-1;
		if(scorall==0)
		{
			scorall=1;
			return ;
		}
		for(i=1;i<=total;i++)
		{
			if(i!=scorall&&i!=scorall+1&&i!=scorall+2&&i!=scorall+3)
			document.getElementById("div_M"+i).style.display="none";
			else
			document.getElementById("div_M"+i).style.display="block";
		}
		
	}
	else
	{
		scorall=scorall+1;
		if(scorall>=total-2)
		{
			scorall=scorall-1;
			return ;
		}
		for(i=1;i<=total;i++)
		{
			if(i!=scorall&&i!=(scorall+1)&&i!=(scorall+2)&&i!=(scorall+3))
			{
				document.getElementById("div_M"+i).style.display="none";
			}
			else
			document.getElementById("div_M"+i).style.display="block";
		}
		
	}
}



var scorall2=1
function scroll2(n,total)
{
	if(n==-1)
	{
		scorall2=scorall2-1;
		if(scorall2==0)
		{
			scorall2=1;
			return ;
		}
		for(i=1;i<=total;i++)
		{
			if(i!=scorall2&&i!=scorall2+1&&i!=scorall2+2&&i!=scorall2+3&&i!=scorall2+4)
			document.getElementById("div_M"+i).style.display="none";
			else
			document.getElementById("div_M"+i).style.display="block";
		}
		
	}
	else
	{
		scorall2=scorall2+1;
		if(scorall2>=total-3)
		{
			scorall2=scorall2-1;
			return ;
		}
		for(i=1;i<=total;i++)
		{
			if(i!=scorall2&&i!=(scorall2+1)&&i!=(scorall2+2)&&i!=(scorall2+3)&&i!=(scorall2+4))
			{
				document.getElementById("div_M"+i).style.display="none";
			}
			else
			document.getElementById("div_M"+i).style.display="block";
		}
		
	}
}




function change_Big(n,b)
{
	document.getElementById("big_link").href=b;
	document.getElementById("big_img").src=n;
}



function check_comments()
{
var check=true;
if(document.getElementById("username").value.length==0)
{
	alert("请输入姓名!");
    document.getElementById("username").focus();
    check=false;
	return false;
}
if(document.getElementById("username").value.length>30)
{
	alert("姓名不能大于30个字符!");
    document.getElementById("username").focus();
    check=false;
	return false;
}
if(document.getElementById("title").value.length==0)
{
	alert("请输入咨询标题!");
    document.getElementById("title").focus();
    check=false;
	return false;
}
if(document.getElementById("title").value.length>30)
{
	alert("咨询标题不能大于30个字符!");
    document.getElementById("title").focus();
    check=false;
	return false;
}
if(document.getElementById("content").value.length==0)
{
	alert("请输入咨询内容!");
    document.getElementById("content").focus();
    check=false;
	return false;
}
if(document.getElementById("content").value.length>600)
{
	alert("咨询内容不能大于600个字符!");
    document.getElementById("content").focus();
    check=false;
	return false;
}
if(check==true)
return true;
}

function index_top_email_onblur()
{
	if(document.getElementById('apply_email').value=='')
	  document.getElementById('apply_email').value='请输入您的E-mail';
}

function index_top_email_onfocus()
{
	if(document.getElementById('apply_email').value=='请输入您的E-mail')
	  document.getElementById('apply_email').value='';
}

function apply_email_upload()
{
  var check=true;
  if(document.getElementById("apply_email").value.length==0)
  {
   alert("请输入您的E-mail")
   document.getElementById("apply_email").focus();
   check=false;
   }
  if(document.getElementById("apply_email").value.length!=0)
  {
    if (document.getElementById("apply_email").value.charAt(0)=="." ||        
         document.getElementById("apply_email").value.charAt(0)=="@"||       
         document.getElementById("apply_email").value.indexOf('@', 0) == -1 || 
         document.getElementById("apply_email").value.indexOf('.', 0) == -1 || 
         document.getElementById("apply_email").value.lastIndexOf("@")==document.getElementById("apply_email").value.length-1 || 
         document.getElementById("apply_email").value.lastIndexOf(".")==document.getElementById("apply_email").value.length-1)
     {
      alert("邮箱格式错误!");
      document.getElementById("apply_email").focus();
      check=false;
      }
   }
   if(check==true)
   {
	    var xmlhttp = createXMLHttps();
	    xmlhttp.open("GET","save_apply.aspx?email="+document.getElementById("apply_email").value+"&r="+Math.random(),true);
		xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState   ==   4)   {  
		if   (xmlhttp.status   ==   200)
		{  
			string_S=xmlhttp.responseText;
			if(string_S=="1")
			alert("电子期刊订阅成功，我们会将期刊定时发送至您的邮箱！");
			else
			{
				alert("订阅失败，请重新提交！");
		   		document.getElementById("apply_email").value="";
			}
		}  
		else   
		{  alert("请求异常，稍后再再试！");
		   document.getElementById("apply_email").value="";
		} 
		}
		};
		xmlhttp.send(null);
   }
   return false;
}


function check_apply()
{
 var check=true;
if(document.getElementById('province_select').options[document.getElementById('province_select').selectedIndex].value=="-1")
  {
	  alert("请选择所在地省份!");
	  check=false;
	  return false;
  }
if(document.getElementById('city_select').options[document.getElementById('city_select').selectedIndex].value=="-1")
  {
	  alert("请选择所在地城市!");
	  check=false;
	  return false;
   }
if(document.getElementById("company").value.length==0)
{
	alert("请输入美容院名称!");
    document.getElementById("company").focus();
    check=false;
	return false;
}
if(document.getElementById("companyuser").value.length==0)
{
	alert("请输入法人代表!");
    document.getElementById("companyuser").focus();
    check=false;
	return false;
}
if(document.getElementById("address").value.length==0)
{
	alert("请输入详细地址!");
    document.getElementById("address").focus();
    check=false;
	return false;
}
if(document.getElementById("tel").value.length==0)
{
	alert("请输入电话!");
    document.getElementById("tel").focus();
    check=false;
	return false;
}
if(document.getElementById("code").value.length==0)
{
	alert("请输入邮编!");
    document.getElementById("code").focus();
    check=false;
	return false;
}
if(document.getElementById("checknum").value=="")
{
	alert("请输入验证码!");
	document.getElementById("checknum").focus();
	check=false;
	return false;
}
 if(check==true)
 return true;
}
