﻿function customer_submit()
{
   var ct=new customer();
   ct.goldoad2();
}

function customer()
{
    this.goldoad2=function()
    {
        goldoad();
    }
}


//预载页面信息 Gold
function goldoad()
{
    var result = getCookie("customerinfo");
    var arr;
    
    if(result != null && result != "")
    {
        arr = result.split("|||");

        if (arr.length>1 || arr.length == 11)
        {
            $("fullname").value = arr[2];
            $("youremail").value = arr[1];
            
            var arr2 = arr[3].split("-");
            if(arr2.length == 3)
            {
                $("usphone1").value = arr2[0];
                $("usphone2").value = arr2[1];
                $("usphone3").value = arr2[2];
            }
            
            $("nonus").value = arr[4];
            
        }
    }
}
//预载页面信息 POWER
function cdk_load()
{ 
  
    var result = getCookie("customerinfo");
    var arr;
    
    if(result != null && result != "")
    {
        arr = result.split("|||");
        
        if(arr.length == 11)
        {
            $("txtname").value = arr[2];
            $("txtemail").value = arr[1];
            
            var arr2 = arr[3].split("-");
            if(arr2.length == 3)
            {
                $("txtus1").value = arr2[0];
                $("txtus2").value = arr2[1];
                $("txtus3").value = arr2[2];
            }
            
            $("txtnous").value = arr[4];
            
        }
    }
}
 
//查找密码

function find_pass()
{
    var email = $F("femailtb").strip();
    
    if(email == "")
    {
        alert("Please fill Email!");
        return;
    }
    var res = /^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-]+(\.[0-9a-zA-Z_\-]+)*$/;  
    var re = new RegExp(res);
    if(!re.test(email))
    {
        alert("Please check email");
        return;
    } 
    
    var xmlStr = "<loginfo>";
    xmlStr += "<email>" + escape(email) + "</email>";
    xmlStr += "</loginfo>";
       
//    var getxml=new XML();
//    
//    var reginkey="email";
//    var reginvalue=escape(email);
//    var arrlogin=new Array(reginkey,reginvalue);
//    
//    var xmlStr = getxml.TestXml(arrlogin);
    
    var url = "/ashx/findpassword.ashx";
    
    var myAjax = new Ajax.Request
                (   
                    url,   
                    {
                        method: "post", 
                        postBody: xmlStr, 
                        onComplete: findpassDo
                    }   
                );  
}

function findpassDo(xmlhttp)
{
    var result = xmlhttp.responseText;
    
    if(result == "0")
    {
//        $("div1").style.display = "";
//        $("div2").style.display = "";
//        $("div3").style.display = "none";
          alert("Email don't exists!Please Check!");
    }
    
    if(result == "yes")
    {
//        $("div1").style.display = "none";
//        $("div2").style.display = "none";
//        $("div3").style.display = "";
        alert("Email have send!Please Check!");
    }
    
    if(result == "no")
    {
//        $("div1").style.display = "";
//        $("div2").style.display = "none";
//        $("div3").style.display = "none";
        
        alert("Send Eamil failed,please try again!");
    }
}


/* FIFA */




function getNewSubmitForms(sid)
 {      
    var submitForm = document.createElement("form");

    document.body.appendChild(submitForm);

    submitForm.id=sid;                                

    submitForm.method = "POST";               

    submitForm.target="_blank";

    return submitForm;

}

function createNewFormElements(inputForm, elementName, elementValue)
{

     var newElement = document.createElement("input");
     newElement.setAttribute("name", elementName);
     newElement.setAttribute("type", "hidden");
     newElement.value = elementValue;

     inputForm.appendChild(newElement);

     return newElement;
}

function FIFA()
{
    var result = getCookie("customerinfo");
    if(result != null)
    {
         var arr = result.split("|||");
         var useremail = arr[1];
         var ps=arr[0];
         if(useremail==undefined || useremail=="")
         {
             alert("please login in");
             return;
         }
         
         
        var submitForm = getNewSubmitForms("server");
        createNewFormElements(submitForm, "useremail", useremail);
        createNewFormElements(submitForm, "ps", ps);
        submitForm.action= "server.aspx";
        submitForm.submit();
         
//          var url = "ashx/getcustomer.ashx?web="+useremail;
//             
//          var myAjax = new Ajax.Request
//                                   (
//                                        url,
//                                        {
//                                           method: "get",
//                                           onComplete: geturl
//                                        }
//                                    );
   }
}

//function geturl(xmlhttp)
//{
//    if(xmlhttp.responseText != "<NewDataSet />")
//    {
//         var code = xmlhttp.responseText;
//         document.location = "http://www.ballguess.com/index.html?" + code);
//    }else
//    {
//         alert("please login in");
//    }
//}
