﻿var compareDate=function(date1,date2)
{
    if(date1<=date2)
        return true;
    else
        return false;
}

function checkJump(o,n)
{
    var nextObj;
    switch(o.id)
    {
        case "P1":
            nextObj="P2";
            break;
        case "P2":
            nextObj="P3";
            break;
        case "P3":
            nextObj="P3";
            break;
    }
    if(o.value.length==n)
    {
        document.getElementById(nextObj).focus();
    }
}
/*
function checkKey()
{
      var ns4 = (document.layers) ? true : false;
      var ie4 = (document.all) ? true : false;
      if(ie4)
      {
        if((event.keyCode>=48 && event.keyCode<=57) || event.keyCode==8 || event.keyCode==46 || (event.keyCode>=96 && event.keyCode<=105))
        
        {
        alert(event.keyCode);
            event.returnValue=true;
        }
        else
        {
            event.returnValue=false;
        }
      }
      
      if(ns4)
      {
      alert("dd");
        if((event.which>=48 && event.which<=57) || event.which==8 || event.which==46 || (event.which>=96 && event.which<=105))
        {
            event.returnValue=true;
        }
        else
        {
            event.returnValue=false;
        }
      }
}*/

/*function clearSEL(obj)
{
    obj.options.length=0;
}



function reBuildSEL(obj,xd,s)
{
        
    var myFind=true;
    obj.options.add(new Option("select a server",0)); 
    
    if(ie4)
    {xd.setProperty("SelectionLanguage","XPath");}
    
    

        if(s.length==0)
        {
            var root=xd.selectNodes("//Server");
        }
        if(s.length==1)
        {
            s=s.toUpperCase();
            var root=xd.selectNodes("//Server[starts-with(@name,'" + s + "')]");
        }
        if(s.length>1)
        {
            s = s.substring(0,1).toUpperCase() + s.substring(1,s.length).toLowerCase();
            var root=xd.selectNodes("//Server[starts-with(@name,'" + s + "')]");
        }
        if(root.length==0)
        {
            root=xd.selectNodes("//Server");
            myFind=false;
        }
    if(ie4)
    {
        for(var i=0;i<root.length;i++)
        {
            var op = document.createElement("OPTION");
            op.text=root(i).attributes(1).value;
            op.value=root(i).attributes(0).value;
            obj.add(op);
            if(i==0 && myFind)
            {
                obj.selectedIndex = i+1;
            }
        }
    }
    else
    {
        for(var i=0;i<root.length;i++)
        {
            obj.options.add(new Option(root[i].attributes[1].value,root[i].attributes[0].value)); 
            if(i==0 && myFind)
            {
                obj.selectedIndex = i+1;
            }
        }
    }
}*/
function voidMethod()
{}



function accountChecker()
{
    dataURL="DataSupply.aspx?Act=CheckAccount&Account=" + document.getElementById("MailAccount").value;//获取数据地址

    
    this.doGetTimeSpan=function()
    {
        var ns4 = (document.layers) ? true : false;
        var ie4 = (document.all) ? true : false;
        
    	var outHTML="";
    	
    	if(ie4)
        {
            var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
		    xmlDoc.async = false;
		    xmlDoc.load(dataURL);
		
		    var root = xmlDoc.selectNodes("/root");
		    var str;
		    switch(root(0).text)
		    {
		        case "0":
		            str="<font color='green'>The account is available for registration.</font>";
		            break;
		        case "1":
		            str="<font color='red'>The account has been already registered.</font>";
		            break;
		        default:
		            str="<font color='red'>System error, Please try later</font>";
		            break;
		    }
	        document.getElementById("divAccountCon").innerHTML= str;
	    }
	    
	    else
	    {
        
            
            Node.prototype.selectNodes=function(xPath)
	        {
		        var xresult=this.evaluate(xPath,this,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
		        var nod=null,nods=[],k=0;
		        while((nod=xresult.iterateNext())!=null)
		        {
			        nods[k++]=nod;
		        }
		        return nods;
	        }

            var XmlDom=document.implementation.createDocument('','',null);
            XmlDom.async=0;

            XmlDom.load(dataURL);
            var root=XmlDom.selectNodes("/root");
            var str;
            switch( root[0].textContent )
		    {
		        case "0":
		            str="<font color='green'>The account is available for registration.</font>";
		            break;
		        case "1":
		            str="<font color='red'>The account has been already registered.</font>";
		            break;
		        default:
		            str="<font color='red'>System error, Please try later</font>";
		            break;
		    }
            document.getElementById("divAccountCon").innerHTML = str ;    
           
	    }
		
    }


}


function inputSelection()
{
    var txtObj      = null;  //text input
    var selObj      = null;  //options container :div
    var xd          = null;  //data source typed xmldom
    var pstIdObj    = null;  //obj for post id
    var pstNameObj  = null;  //obj for post name
    var selXPath    = null;  //
    var selAttributeName = null;
    var callMethod = null;
    var idIndex = 0;
    var txtIndex = 1;

    this.clearSEL=function()
    {
        this.selObj.innerHTML = "";
        this.pstIdObj.value = "";
        this.pstNameObj.value = "";
    }



    this.reBuildSEL=function()
    {
   
        var s = this.txtObj.value;
        var outHTML = "";

        if(ie4)
        {this.xd.setProperty("SelectionLanguage","XPath");}
    
    
        //text input .value is null, then list all servers
        if(s.length==0)
        {
            var root=this.xd.selectNodes(this.selXPath);

        }
        else
        {
            //var root=this.xd.selectNodes(this.selXPath + "[starts-with(@" + this.selAttributeName + ",'" + s + "')]");
            var root=this.xd.selectNodes(this.selXPath + "[starts-with(translate(@" + this.selAttributeName + ",'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'" + s.toUpperCase()  + "')]");

        }
        
        //no server available,then list all servers
        /*if(root.length==0)
        {
            root=this.xd.selectNodes("//server");
            var root=this.xd.selectNodes(this.selXPath);
        }*/

        if(ie4)
        {
            for(var i=0;i<root.length;i++)
            {
                
                outHTML += "<a href='#'><div style='cursor:hand;width:182;text-decoration:none;color:#333;' onmouseover='this.style.backgroundColor=\"#98CDCD\"' onmouseout='this.style.backgroundColor=\"\"' id=\"li_" + root(i).attributes(this.idIndex).value + "\" onclick='javascript:document.getElementById(\"" + this.txtObj.id + "\").value=this.innerText;document.getElementById(\"" + this.pstIdObj.id + "\").value=this.id.substring(this.id.indexOf(\"_\")+1,this.id.length);document.getElementById(\"" + this.pstNameObj.id + "\").value=this.innerText;document.getElementById(\"" + this.selObj.id + "\").style.display=\"none\";" + (this.callMethod == null ? "" : this.callMethod + ";") + "'>" + root(i).attributes(1).value + "</div></a>";
            }
        }
        else
        {
            for(var i=0;i<root.length;i++)
            {
                
                outHTML += "<a href='javascript:void(0)'><div style='height:20px;width:182px;text-decoration:none;color:#333;' onmouseover='this.style.backgroundColor=\"#98CDCD\"' onmouseout='this.style.backgroundColor=\"\"' id=\"li_" + root[i].attributes[this.idIndex].value + "\" onclick='document.getElementById(\"" + this.txtObj.id + "\").value=this.textContent;document.getElementById(\"" + this.pstIdObj.id + "\").value=this.id.substring(this.id.indexOf(\"_\")+1,this.id.length);document.getElementById(\"" + this.pstNameObj.id + "\").value=this.textContent;document.getElementById(\"" + this.selObj.id + "\").style.display=\"none\";" + (this.callMethod == null ? "" : this.callMethod + ";") + "'>" + root[i].attributes[this.txtIndex].value + "</div></a>";
                
            }
        }
        //alert(this.callMethod);
        if(outHTML == "")
        {
            outHTML = "<br/>";
        }
        i= i==0 ? 1 : i;
        //var mObj = document.getElementById("divMother");
        //mObj.position="absolute";
        //mObj.style.left = 0;
        //mObj.width = "100%";
        this.selObj.innerHTML = outHTML;
        //this.selObj.insertAdjacentHTML("afterBegin",outHTML);
        this.selObj.style.position="absolute";
        //this.selObj.style.left=event.srcElement.offsetLeft;
        //this.selObj.style.left = event.srcElement.style.left;
        //this.selObj.style.left = screen.width/2 - 90;
        this.selObj.style.height = 20 * i > 200 ? 200 : 20 * i;
        this.selObj.style.display = "";
    }
    

}



function setIamOnline(orderid,fid)
{
//          var xhttp = jb();
//          xhttp.open("POST","dataSupply.aspx?Act=Online&OrderID=" + orderid, false);
//          xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//          xhttp.send(null);
//          alert("Setting I am online ok");
        var ns4 = (document.layers) ? true : false;
        var ie4 = (document.all) ? true : false;
        if(ie4)
        {
            var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
		    xmlDoc.async = false;
		    xmlDoc.load("dataSupply.aspx?Act=Online&OrderID=" + orderid);
		    document.getElementById("td_trade_pass_" + orderid).innerHTML = "<font color='blue'>" + xmlDoc.selectNodes("//TradePassword")(0).text + "</font>";
		    document.getElementById("td_delivery_pass_" + orderid).innerHTML = "<font color='blue'>" + xmlDoc.selectNodes("//ContactPassword")(0).text + "</font>";
		    document.getElementById("tr_href_" + orderid).style.display="none";
		    xmlDoc = null;
		    //alert("OK");
		}
		else
		{
		     Node.prototype.selectNodes=function(xPath)
	        {
		        var xresult=this.evaluate(xPath,this,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
		        var nod=null,nods=[],k=0;
		        while((nod=xresult.iterateNext())!=null)
		        {
			        nods[k++]=nod;
		        }
		        return nods;
	        }
		    var XmlDom=document.implementation.createDocument('','',null);
            XmlDom.async=0;

            XmlDom.load("dataSupply.aspx?Act=Online&OrderID=" + orderid);
		    document.getElementById("td_trade_pass_" + orderid).innerHTML = "<font color='blue'>" + XmlDom.selectNodes("//TradePassword")[0].textContent + "</font>";
		    document.getElementById("td_delivery_pass_" + orderid).innerHTML = "<font color='blue'>" + XmlDom.selectNodes("//ContactPassword")[0].textContent + "</font>";
		    document.getElementById("tr_href_" + orderid).style.display="none";
		    XmlDom = null;
		    //alert("OK");
		}
		//alert("Setting I am online ok");
		//window.location.reload();
				
		//document.getElementById('tr_href_' + orderid).style.display='none';
		//location = "myorder.aspx?OrderID=" + fid;   

}

function jb()
{
          var A=null;
          try
          {
            A=new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch(e)
          {
            try
            {
                A=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(oc)
            {
                A=null;
            }
          }

          if ( !A && typeof XMLHttpRequest != "undefined" )
          {
            A=new XMLHttpRequest();
          }
          return A;
}




function setTab(name,cursel,n)
{
    for(i=1;i<=n;i++)
    {
        var menu=document.getElementById(name+i);
        var con=document.getElementById("con_"+name+"_"+i);
        menu.className=i==cursel?"hover":"";
        con.style.display=i==cursel?"block":"none";
        document.getElementById("mycentertype").value=cursel;
    }
}

function if_view(OrderID)
{
    document.getElementById("tbItem_"+OrderID+"").style.display = document.getElementById("tbItem_"+OrderID+"").style.display == ''?'none':'';
    document.getElementById("sendItem_"+OrderID+"").style.display='none';

}
function if_send(OrderID)
{
  document.getElementById("sendItem_"+OrderID+"").style.display = document.getElementById("sendItem_"+OrderID+"").style.display == ''?'none':'';
  document.getElementById("tbItem_"+OrderID+"").style.display ='none';
//  	var webFileUrl = "DataSupply.aspx?Act=OnSend&OrderID="+OrderID;
//　　			var result = "";
//　　				var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
//　　				xmlHttp.open("POST", webFileUrl, false);
//　　				xmlHttp.send("");
//　　				result = xmlHttp.responseText;
  executPost("Act=OnSend&OrderID="+OrderID,'DataSupply.aspx',true,'onTrade');
}

function onTrade()
{
    var str="";
//	if(xmlHttp.status==1)
//	{
//	   str="<table width='100%'><tr><td width='25%'>Order ID</td><td width='25%'>Amount</td><td width='25%'>Time</td><td width='25%'>Status</td></tr>";
//	}
//	else
//	{
//	 str="<table width='100%'><tr><td width='25%'>Bestell-ID</td><td width='25%'>Bestrag</td><td width='25%'>Zeit</td><td width='25%'>Status</td></tr>";
//	}
	var a=xmlHttp.status;
	 switch(a)
    {
        case 800:
            str="<table width='100%'><tr><td width='25%'>Transaction ID #</td><td width='25%'>Amount</td><td width='25%'>Time</td><td width='25%'>Status</td></tr>";
            break;
        case 801:
             str="<table width='100%'><tr><td width='25%'>Handelsnummer #</td><td width='25%'>Bestrag</td><td width='25%'>Zeit</td><td width='25%'>Status</td></tr>";
            break;
    }
  var d=eval(xmlHttp.responseText);

　var OrderID="";
　  for(var i=0;i<d.length;i++)
    {
    var data=d[i];
	if(data.length<=0)return;
	str=str+"<tr>";
	str=str+"<td>"+data[0]+"</td>";
	str=str+"<td>"+data[1]+"</td>";
	str=str+"<td>"+data[2]+"</td>";
	str=str+"<td>"+data[3]+"</td>";
	str=str+"</tr>";
	OrderID=""+data[4]+"";
	}
	str=str+"</table>";
	var obj = document.getElementById("div_sendItem_"+OrderID+""); 
　　obj.innerHTML = str;
	return;
}

function Scroll_Images(j)
{  
//    if(j==1) document.getElementById("right_yello_line_picture3").style.backgroundImage = "url(images/welcome.gif)";
//    else  document.getElementById("right_yello_line_picture3").style.backgroundImage = "url(images/bgyun_03.jpg)"; 
    for(var i=1;i<7;i++)
    {
        if(i!=j)
        {
        document.getElementById("right"+i+"").style.display = 'none';
        document.getElementById("yun_vcsale_"+i+"").src = "http://vcsale.21cge.com/images/yun_vcsale_"+i+".jpg"; 
        }
        else
        {
        document.getElementById("right"+i+"").style.display = 'block';
        document.getElementById("yun_vcsale_"+i+"").src = "http://vcsale.21cge.com/images/heheha_"+i+".jpg"; 
        }
    }

}

function live_chat()
{  
window.open('http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=68544&amp;configID=74236&amp;jid=3357655909','','height=430,width=575,top=150,left=200,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no');
}


 function goURL()
       {
                  var type=document.getElementById("mycentertype").value;
                  var year=document.getElementById("ServerYear").value;
                  var month=document.getElementById("ServerMonth").value;
                  if(year==0)
                  {
                       alert('year wählen');
                       return;
                  }
                  window.location="MyOrder.aspx?Year="+year+"&Month="+month+"";

}

