﻿// JavaScript Document
function getCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  {
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {	
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function setCookie(cookieName,cookieValue,DayValue)
{
	var expire = "";
	var day_value=1;
	if(DayValue!=null)
	{
		day_value=DayValue;
	}
    expire = new Date((new Date()).getTime() + day_value * 86400000);
    expire = "; expires=" + expire.toGMTString();
	document.cookie = cookieName + "=" + escape(cookieValue) +";path=/"+ expire;
}

function delCookie(cookieName)
{
	var expire = "";
    expire = new Date((new Date()).getTime() - 1 );
    expire = "; expires=" + expire.toGMTString();
	document.cookie = cookieName + "=" + escape("") +";path=/"+ expire;
	//path=/
}

function validate_customer()
{
	var customer = document.getElementById('Register2_customer').value;
	if (!Utils.isEmail(customer))
	{
		$("#customer_msg").html("用户名格式不正确");
	}
	else
	{
		$("#customer_msg").html("");
	}
}

function validate_password()
{
	var first_password = document.getElementById('Register2_first_password').value;
	first_password = first_password.toString();
	if (first_password.length < 6)
	{
		$("#password_msg").html("最少6位数字或英文字母");
	}
	else
	{
		$("#password_msg").html("");
	}
}

function validate_second_password()
{
	var first_password = document.getElementById('Register2_first_password').value;
	var second_password = document.getElementById('Register2_second_password').value;
	first_password = first_password.toString();
	second_password = second_password.toString();
	if (first_password != second_password)
	{
		$("#second_password_msg").html("两次填写的密码不相同");
	}
	else
	{
		$("#second_password_msg").html("");
	}
}

function ShowStyleCategory(styleid)
{
    if(document.getElementById("stylecategory" + styleid).style.display =="none" || document.getElementById("stylecategory" + styleid).style.display =="")
    {
        document.getElementById("stylecategory" +styleid).style.display = "block";
    }
    else
    {
        document.getElementById("stylecategory" +styleid).style.display = "none";
    }
}

function HideStyleCategory(styleid)
{
    if(document.getElementById("stylecategory" + styleid).style.display =="block")
    {
        document.getElementById("stylecategory" +styleid).style.display = "none";
    }  
}

function ShowPopUp(left,top,wid)
{
      document.getElementById(wid).style.left=(document.body.clientWidth-1024)/2 + left + "px";
      
      var Sys = {};
      var ua = navigator.userAgent.toLowerCase();
      var s;
      (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :""

      if (Sys.ie && Sys.ie =="6.0")
      {
        document.getElementById(wid).style.top= (top+20+15) +"px";
      }
      else
      {
        document.getElementById(wid).style.top= (top+15) +"px";
      }
    
      document.getElementById(wid).style.visibility = "visible";
}

function HidePopUp(wid)
{
    document.getElementById(wid).style.visibility = "hidden";
}

function CheckTextBox(text)
{ 
    if (text.value == "") 
    { 
        text.value = 0;
    }
    return true; 
} 

function CheckTextLength(text,maxLen)
{
    if (text.value.length > maxLen) 
    {
        text.value = text.value.substring(0, maxLen);
    }
}

function scrollup(o,d,c){
	if(d==c){
		var t=o.firstChild.cloneNode(true);
		o.removeChild(o.firstChild);
		o.appendChild(t);
		t.style.marginTop=o.firstChild.style.marginTop='0px';
	}
	else{
		var s=3,c=c+s,l=(c>=d?c-d:0);
		o.firstChild.style.marginTop=-c+l+'px';
		window.setTimeout(function(){scrollup(o,d,c-l)},100);
	}
}

function OpenDiv(_Dw,_Dh,_Contentfile) 
{
    $("Loading").style.display='';
    
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :""

    if (Sys.ie && Sys.ie =="6.0")
    {
       $("Loading").style.top=(_Dh-90+15)+"px";
    }
    else
    {
       $("Loading").style.top=(_Dh-110+15)+"px";
    }

    $("Loading").style.left=((document.body.clientWidth-1024)/2+_Dw+28)+"px";
    $("Loading").style.width="346px";
    $("Loading").style.height="240px";
    $("Loading").style.border="none";
    AjaxGet("./Storage/PopUpWindow/"+_Contentfile+".htm");
}

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 AjaxGet(URL) {
var xmlhttp = createXMLHttps();
xmlhttp.open("Get",URL,true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status==404) {$("Loading").innerHTML='读取页面失败,文件'+URL+'不存在!';return}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		$("Loading").innerHTML="<div class='LoadContent'>"+xmlhttp.responseText+"</div>";
		}
	}
xmlhttp.send(null);
}

function ValidateEmail(email)
{
    if (!Utils.isEmail(email))
	{
		alert('请填写正确的Email地址！');return false;
	}
	else
	{
	    return true;
	}
}

function initialize()
{
    try
    {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginajax);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endajax);
       }
    catch(error)
    {}
}

function beginajax(sender,eventArgs)
{
    try
    {
        var divwaiting=document.getElementById("divwaiting");
        divwaiting.innerHTML='<img src=../../templates/images/loading.gif>';
        divwaiting.style.visibility='visible';
    }
    catch(error)
    {}
}

function endajax(sender,eventArgs)
{
    try
    {
    var divwaiting=document.getElementById("divwaiting");
    divwaiting.innerHTML='';
    divwaiting.style.visibility='hidden';
    }
    catch(error)
    {}
}

function initialize1()
{
    try
    {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginajax1);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endajax1);
        }
    catch(error)
    {}
}

function beginajax1(sender,eventArgs)
{
    try
    {
    var divwaiting1=document.getElementById("divwaiting1");
    divwaiting1.innerHTML='<img src=../../templates/images/loading.gif>';
    divwaiting1.style.visibility='visible';
            }
    catch(error)
    {}
}

function endajax1(sender,eventArgs)
{
    try
    {
    var divwaiting1=document.getElementById("divwaiting1");
    divwaiting1.innerHTML='';
    divwaiting1.style.visibility='hidden';
               }
    catch(error)
    {}
}

function initialize2()
{
    try
    {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginajax2);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endajax2);
                   }
    catch(error)
    {}
}

function beginajax2(sender,eventArgs)
{
    try
    {
    var divwaiting2=document.getElementById("divwaiting2");
    divwaiting2.innerHTML='<img src=../../templates/images/loading.gif>';
    divwaiting2.style.visibility='visible';
                       }
    catch(error)
    {}
}

function endajax2(sender,eventArgs)
{
    try
    {
    var divwaiting2=document.getElementById("divwaiting2");
    divwaiting2.innerHTML='';
    divwaiting2.style.visibility='hidden';
                           }
    catch(error)
    {}
}

function initialize3()
{
    try
    {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginajax3);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endajax3);
                               }
    catch(error)
    {}
}

function beginajax3(sender,eventArgs)
{
    try
    {
    var divwaiting3=document.getElementById("divwaiting3");
    divwaiting3.innerHTML='<img src=../../templates/images/loading.gif>';
    divwaiting3.style.visibility='visible';
                               }
    catch(error)
    {}
}

function endajax3(sender,eventArgs)
{
    try
    {
    var divwaiting3=document.getElementById("divwaiting3");
    divwaiting3.innerHTML='';
    divwaiting3.style.visibility='hidden';
                               }
    catch(error)
    {}
}
