﻿

  //load order
function LoadOrder()
{

     if(getCookie("ratelist") == null)
    {
        setCookie("ratelist","1!1|USD|1", 1000);
    }

	var cookrateval = getCookie("ratetemp");
  	
  	if(cookrateval == null)
  	{
  	    $("ChooseCurrency").selectedIndex = 0;
  	}
  	else
  	{
  	    for(var i = 0 ; i < $("ChooseCurrency").length; i++ ) 
		{
		    var srateval =  $("ChooseCurrency").options[i].value;
		    
		    if ( srateval == cookrateval ) 
		    {
			    $("ChooseCurrency").options[i].selected = true;
		    }
	    }
  	}     

    var cookie=getCookie("orderNO");
  
    if(cookie!=null && cookie.length>=1)
    {
        window.open('youorder.html','newWindow','width=640,height=270,menubar=no,toolbar=no,location=no,status=no,scrollbars=no,dialog=yes'); 
    }
}




function getSuggCount()
{
     var result = getCookie("customerinfo");
     if(result != undefined)
     {
         if(result != null || result != "")
         {
             var user=result.split("|||");
            
             var url = "ashx/getmesscount.ashx?uid=" + user[0];
             var myAjax = new Ajax.Request(url,
                                        {
                                        method: "get",
                                        onComplete: bindcount
                                        }
                                    );
         }   
     }  
   
}

function bindcount(xmlhttp)
{
    var result=xmlhttp.responseText;

    if(result!=null)
    {
    
      var arr=result.split('|');
      
      if(arr.length==3)
      {
         var count=0;
         var mess="";
         
         var mescount=parseInt(arr[0])+parseInt(arr[1])+parseInt(arr[2]);
         
         
         if(parseInt(arr[0])>=1)
         {
            count=1;
            mess="<a href='My_Suggestion.html' style='color:Yellow'  >you have new message("+mescount+")</a>";
         }
         if(parseInt(arr[1])>=1)
         {
            count=2;
            mess="<a href='Messages_of_Customer_Rep.html' style='color:Yellow'>you have new message("+mescount+")</a>";
         }
         if(parseInt(arr[2])>=1)
         {
            count=3;
            mess="<a href='Informofnewactivities.html' style='color:Yellow'>you have new message ("+mescount+")</a>";
         }
         if($("mysugg")!=null && count>=1)
         {
            $("mysugg").innerHTML=mess;
         }
      }
    }
}

function loadweb()
{
   LoadOrder();
   setvisit();
}


function dispsns()
{
    var sns = getCookie("uname");
    if(sns =="" || sns == null) {
        if ($("ondiv") != null) {
            $("ondiv").style.display = "block";
        }
        if ($("indiv") != null)
           $("indiv").style.display="none";  
    }
    else
    {
        $("uname").innerHTML = sns;
        if ($("ondiv") != null) {
            $("ondiv").style.display = "none";
        }
        if ($("indiv") != null)
           $("indiv").style.display = "block";
    }
}


//加载汇率设置列表
function vRateset(money)
{
      var url="ashx/rate.ashx?money="+money;
	  var myAjax = new Ajax.Request(
                                    url,
                                    {
                                        method: "get",
                                        onComplete: getrate
                                    }
                                );
}

function getrate(xmlhttp)
{
     var result = xmlhttp.responseText;
    setCookie("rates", result, 1000);
    var arr=result.split("|");
    setCookie("ratelist", arr[0] + "!" + getCookie("rates"), 1000);
    reopen();
    displayRateList();
}


function clickrate()
{
   var ratetemp = $F("ChooseCurrency");
   setCookie("ratetemp", ratetemp, 1000);
   vRateset(ratetemp);
   
}


function reopen() {
    location.replace(location.href);
   // window.open(window.location.href, "_self");
}

/*RMB*/
function displayRateList() {
//    if ($("pay_type_5") != null && $("pay_type_1") != null) {
//        var ratetemp = $F("ChooseCurrency");
//        if (ratetemp == 6) {
//            $("pay_type_5").checked = true;
//            $("pay_type_1").checked = false;
//        } else {
//            $("pay_type_1").checked = true;
//            $("pay_type_5").checked = false;
//        }
 //   }
}


function disremark(index) {
    for (var i = 1; i < 6; i++) {
        if ($("li" + i) != null) {
            $("li" + i).style.display = "none";
            if(i == index) {
                $("li" + i).style.display = "";
            }
        }
    }
    $("liappliy").style.display = "none"; 
    if(index == 5) {
        $("liappliy").style.display = ""; 
    }
} 
