﻿// JScript 文件
var PageUrl = "http://2009.eacha.com/";
String.prototype.trim = function()
{	
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
//检查是否符合规定长度的gbk汉字 
function SumGBK(Word)   
{   
    var j = 0;
    for (var i=0;i<Word.length;i++)   
    {   
        if (Word.substr(i,1).charCodeAt(0)>255)
        {
           j = j + 2; 
        }  
        else
        {
           j++
        }   
    }   
    
    return j;   
}
function GetSumGBKNum(Word,c)   
{   
    var j = 0;
    var Num = 0;
    for (var i=0;i<Word.length;i++)   
    {   
        if (Word.substr(i,1).charCodeAt(0)>255)
        {
           j = j + 2; 
        }  
        else
        {
           j++
        }
        Num++;
        if (j>=c)
        {
            break;
        }   
    }   
    
    return Num;   
}
function ShowHeaderClass(a)
{
    for (var i=1;i<=8;i++)
    {
        if (i==a)
        {
            document.getElementById("li" + i).className="active";
        }
        else
        {
            document.getElementById("li" + i).className="";
        }    
    }
}

function KeyBackCar(a,b)
{
    if(event.keyCode == 13)
    {
        if (a==1)
        {
            document.getElementById(b).click();
        }
        else if (a == 2)
        {
            document.getElementById(b).click();
        }                
        return false;
    }
}
        
function LogCheckBtn(a,Txt1,Pass1)
{
    var Txt= document.getElementById(Txt1);
    var Pass= document.getElementById(Pass1);
    var Val= document.getElementById("TxtVal");
    var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
    var oDoc = new ActiveXObject("MSXML2.DOMDocument");
    
	if (Txt.value.trim() == "") 
	{
        alert("请输入您注册的【用户名】");
        return false;
	}
	
	if (!/^[a-zA-Z][a-zA-Z0-9_]{3,19}$/.test(Txt.value.trim()))
	{
        alert("请输入正确的【用户名】");
        return false;	
	}
	
    oHttpReq.open("POST", a + "HtmlAjax.aspx?i=" + escape(Txt.value.trim()) + "&type=1", false);
    oHttpReq.send("");
    result = oHttpReq.responseText;
    oDoc.loadXML(result);
    items = oDoc.selectNodes("//NewDataSet/User");
    for (var item = items.nextNode(); item; item = items.nextNode()){
        var txt = item.selectSingleNode("UserName").nodeTypedValue;
        if (txt <= 0)
        {
            alert("【用户名】不存在");
            return false;	     
		}      
    }
     
	if (Pass.value.trim() == "") 
	{
        alert("请输入【登陆密码】");
        return false;
	}
	
	if (!/[A-Za-z0-9]{5,19}$/.test(Pass.value.trim()))
	{
        alert("请输入正确的【登陆密码】");
        return false;	
	}    
    
    var c=Txt.value.trim() + "|" + Pass.value.trim();
    oHttpReq.open("POST", a + "HtmlAjax.aspx?i=" + escape(c) + "&type=3", false);
    oHttpReq.send("");
    result = oHttpReq.responseText;
    oDoc.loadXML(result);
    items = oDoc.selectNodes("//NewDataSet/User");
    for (var item = items.nextNode(); item; item = items.nextNode()){
        var txt = item.selectSingleNode("UserNameNum").nodeTypedValue;
        if (txt <= 0)
        {
            alert("【登陆密码】错误");
            return false;	           
		}      
    } 
    
	if (Val.value.trim() == "") 
	{
        alert("请输入【验证码】");
        return false;
	}
	
	if (!/[0-9]{6}$/.test(Val.value.trim()))
	{
        alert("请输入正确的【验证码】");
        return false;	
	}    
    
    oHttpReq.open("POST", a + "HtmlAjax.aspx?i=" + escape(Val.value.trim()) + "&type=9", false);
    oHttpReq.send("");
    result = oHttpReq.responseText;
    oDoc.loadXML(result);
    items = oDoc.selectNodes("//NewDataSet/User");
    for (var item = items.nextNode(); item; item = items.nextNode()){
        var txt = item.selectSingleNode("Code").nodeTypedValue;
        if (txt != Val.value.trim())
        {
            alert("【验证码】错误");
            return false;	           
		}      
    }       
           
    return true;    	       
}

function GetCity(state,i)
{
    var drp2=i;
    drp2.options.length=0;
    var newOption = document.createElement("OPTION");
    newOption.text = "所在城市";
    newOption.value = "";
    drp2.options.add(newOption);
    if (state!= "")
    {
        ta="//NewDataSet/E_City";
        var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
        var oDoc = new ActiveXObject("MSXML2.DOMDocument");
        oHttpReq.open("POST", "../HtmlAjax.aspx?i="+ escape(state) + "&type=6", false);
        oHttpReq.send("");
        result = oHttpReq.responseText;
        oDoc.loadXML(result);
        items = oDoc.selectNodes(ta);
        for (var item = items.nextNode(); item; item = items.nextNode()){
            var txt = item.selectSingleNode("City").nodeTypedValue;
            var value = item.selectSingleNode("City").nodeTypedValue;
            var newOption = document.createElement("OPTION");
            newOption.text = txt;
            newOption.value = value;
            drp2.options.add(newOption);
        }
        newOption = document.createElement("OPTION");
        newOption.text = "其他城市";
        newOption.value = "其他城市";
        drp2.options.add(newOption);           
    }
}

function AddFav(a,b,c)
{            		
    var window_width=800;
    var window_heigh=400;
    var window_left = (screen.availWidth/2) - (window_width/2);
    var window_top = (screen.availHeight/2) - (window_heigh/2);
    var window_dimensions="width=" + window_width + "px" + 
                          ",height=" +  window_heigh + "px" +
                          ",left=" +  window_left + 
                          ",top=" +  window_top +
                          ",scrollbars=yes";                            
    window.open(a + "Action/Fav.aspx?t=" + b + "&d=" + c,"添加收藏",window_dimensions);
    return false;	
}

function SetFav(a,c)
{            		
    var window_width=800;
    var window_heigh=400;
    var window_left = (screen.availWidth/2) - (window_width/2);
    var window_top = (screen.availHeight/2) - (window_heigh/2);
    var window_dimensions="width=" + window_width + "px" + 
                          ",height=" +  window_heigh + "px" +
                          ",left=" +  window_left + 
                          ",top=" +  window_top +
                          ",scrollbars=yes";                            
    window.open(a + "User/SetFav.aspx?d=" + c,"编辑我的收藏",window_dimensions);
    return false;	
}

function PayTemplet(a,b,c)
{            		
    var window_width=600;
    var window_heigh=400;
    var window_left = (screen.availWidth/2) - (window_width/2);
    var window_top = (screen.availHeight/2) - (window_heigh/2);
    var window_dimensions="width=" + window_width + "px" + 
                          ",height=" +  window_heigh + "px" +
                          ",left=" +  window_left + 
                          ",top=" +  window_top +
                          ",scrollbars=yes";                            
    window.open(a + "Templet/Pay.aspx?d=" + b + "&t=" + c,"购买模板",window_dimensions);
    return false;	
}

function AddSMS(a,b)
{            		
    var window_width=550;
    var window_heigh=400;
    var window_left = (screen.availWidth/2) - (window_width/2);
    var window_top = (screen.availHeight/2) - (window_heigh/2);
    var window_dimensions="width=" + window_width + "px" + 
                          ",height=" +  window_heigh + "px" +
                          ",left=" +  window_left + 
                          ",top=" +  window_top +
                          ",scrollbars=yes";                            
    window.open(a + "Action/SMS.aspx?t=" + b,"问题投诉",window_dimensions);
    return false;	
}

function ChangeImg(a)
{
   document.getElementById(a).src = document.getElementById(a).src + "?";
   return false;
}

function getPosition(el) 
{ 
    for (var lx=0,ly=0;el!=null;lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent); 
     return {x:lx,y:ly} 
}

function SetCwinHeight(a)
{
    var bobo=a; //iframe id
    if (document.getElementById)
    {
        if (bobo && !window.opera)
        {
            if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight)
            {
                bobo.height = bobo.contentDocument.body.offsetHeight;
            }
            else if(bobo.Document && bobo.Document.body.scrollHeight)
            {
                bobo.height = bobo.Document.body.scrollHeight;
            }
        }
    }
}

document.onkeydown = function() {
if(event.keyCode==116) {
event.keyCode=0;
event.returnValue = false;
}
}
document.oncontextmenu = function() {event.returnValue = false;}
document.onmouseover=function() {self.status='欢迎访问易翠网！';return true;}
