﻿
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' class='fontc_red1' >you have new message("+mescount+")</a>";
         }
         if(parseInt(arr[1])>=1)
         {
            count=2;
            mess="<a href='Messages_of_Customer_Rep.html'  class='fontc_red1' >you have new message("+mescount+")</a>";
         }
         if(parseInt(arr[2])>=1)
         {
            count=3;
            mess="<a href='Informofnewactivities.html'  class='fontc_red1' >you have new message ("+mescount+")</a>";
         }
         if($("mysugg")!=null && count>=1)
         {
            $("mysugg").innerHTML=mess;
         }
      }
    }
}



  //load order
function LoadOrder()
{
    if(getCookie("ratesel") == null)
    {
        setCookie("ratelist","1!1|USD|1", 1);
    }
	var cookrateval = getCookie("ratesel");
  	if(cookrateval != null)
    {
       $("q1").className = "fl hand";
       $("q2").className = "fl hand";
       $("q3").className = "fl hand";
       $("q4").className = "fl hand";
       $("q5").className = "fl hand";
       $("q" + cookrateval).className = "fontc_red fl";
   }

    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 loadweb()
{
   LoadOrder();
  // vRateset();
   setvisit();
}


function dispsns()
{
    var sns = getCookie("uname");
    if(sns =="" || sns == null)
    {
        $("ondiv").style.display="block";
        $("indiv").style.display="none";  
    }
    else
    {
        $("uname").innerHTML=sns;
        $("ondiv").style.display="none";
        $("indiv").style.display="block";
    }
}

//加载汇率设置列表
function vRateset(money)
{
     if(money == null || money == "")
     {
        money =1;
     }
	  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, 1);
    var arr=result.split("|");
    setCookie("ratelist", arr[0] + "!" + getCookie("rates"), 1);
    
       $("q1").className = "fl hand";
       $("q2").className = "fl hand";
       $("q3").className = "fl hand";
       $("q4").className = "fl hand";
       $("q5").className = "fl hand";
       $("q" + arr[0]).className = "fontc_red fl";

       reopen();
}


function clickrate(moneytyp)
{  
    setCookie("ratesel", moneytyp, 1);

    vRateset(moneytyp);
}



function reopen()
{
    window.open(window.location.href, "_self");
}


