var http = getHTTPObject();
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var marked_row = new Array;
var timerShowTime = null
var showTimeRunning = false;
var timerQueue = null
var timerRunning = true;
var timerHold = null
var timerHoldRunning = true;
var selectedTab = null;x
function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}
function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;
 
   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   Input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}
function url_encode(_data){   
    var i = 0;
    var eStr = "";
    var c, cc, n;
    
    while (i < _data.length)
    {
        c = _data.charAt(i++);
        
        if (c == "\x20") eStr += "\x2b";
        else if (c.match(/[a-zA-Z0-9._-]/) != null) eStr += c;
        else
        {
            cc = c.charCodeAt(0);
            
            if (cc <= 0x7f) 
                eStr += (cc <= 0xf ? "%0":"%")+ cc.toString(16);
            else
            {
                n = (cc <= 0x7ff)? 1 : (cc <= 0xffff)? 2: 3;
                eStr += "%"+ ( [0, 0xc0, 0xe0, 0xf0][n] ^ (cc >> (6*n)) ).toString(16);
                
                while (n--)
                    eStr += "%"+ ( 0x80 ^ ( 0x3f & (cc >> (6*n)) ) ).toString(16);
            }
        }
    }       
    return eStr;
} 
function url_decode(_data){
    var dStr = "";
    var mask  = new Array ( null, 0x1f, 0x0f, 0x07, 0x03, 0x01 );
    var i, n, c, hNum, cn, bFlag;
    
    for (i=0; i<_data.length; i++)
    {
        c = _data.charAt(i);
        
        if (c == "\x2b") dStr += "\x20";
        else if (c != "\x25") dStr += c;
        else
        {
            hNum = parseInt( _data.substr(i+1, 2), 16 );
            i += 2;
            
            if (hNum <= 0x7f) cn = hNum;
            else
            {
                bFlag = 0x20;
                n = 1;
                while (hNum & bFlag && n++) bFlag >>= 1;
                cn = hNum & mask[n];
                
                while (n--)
                {
                    i += 2;
                    hNum = parseInt( _data.substr(i++, 2), 16 );
                    cn <<= 6;
                    cn ^= hNum & 0x3f;
                }
            }
            dStr += String.fromCharCode(cn); 
        }
    }
    return dStr;
}
 function handleHttpResponse() {
  if (http.readyState == 4) {
    results = http.responseText;
    try {  
           eval(results);
    }     
    catch(e){ 
        alert(results);    
        //alert(e+" : "+(e.number & 0xFFFF)+" : "+e.description); 
    }       
 }
}
function getHTTPObject() {
  //var xmlhttp;
   /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/  
  /*
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  
  return xmlhttp;
  */
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
        /* if (http_request.overrideMimeType) {
             // set type accordingly to anticipated content type
                //http_request.overrideMimeType('text/xml');
                http_request.overrideMimeType('text/html');
                //alert(9);
         }*/
    } else if (window.ActiveXObject) { // IE
         try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
                try {
                       http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
         }
         //alert(http_request);
    }
  
      return http_request;
}
function update(URL,data) {
  http.open("GET", URL , true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
  return true;
}
function update2(URL,data) {
  http.open("POST", URL , true);
  http.onreadystatechange = handleHttpResponse;
  http.send(data);
  return true;
}
function xajax_avatarShopBuyFunction(dressup_id,type,typemode){
    URL='ajax_buyavatar.php?dressup_id='+dressup_id+'&type='+type+'&mode='+typemode;
    //alert(URL);
    update(URL);
} 
function xajax_viewProduct(div_name,dressup_imgchar,dressup_imgback){
    document.getElementById('loading').style.display='';
    URL='../api_center/dressup/xajax_viewProduct.php?div_name='+div_name+'&dressup_imgchar='+dressup_imgchar+'&dressup_imgback='+dressup_imgback;
    update(URL);
}
function xajax_buyAvatar(dressup_id,div_name,dressup_imgchar,dressup_imgback,type,typemode){
    document.getElementById('loading').style.display='';
    URL='../api_center/dressup/xajax_buyAvatar.php?dressup_id='+dressup_id+'&div_name='+div_name+'&dressup_imgchar='+dressup_imgchar+'&dressup_imgback='+dressup_imgback+'&type='+type+'&mode='+typemode;
    update(URL);    
}
function xajax_clearAvatar(){
    document.getElementById('loading').style.display='';
    URL='../api_center/dressup/xajax_clearAvatar.php';
    update(URL);    
}
function xajax_buyProduct(){
    //not ajax
    document.getElementById('xLayer1').style.display='';
    document.getElementById('xLayer2').style.display='none';  
}
function xajax_sellProduct(){
    document.getElementById('loading').style.display='';
    document.getElementById('xLayer1').style.display='none';
    document.getElementById('xLayer2').style.display='';
    
    URL='../api_center/dressup/xajax_sellProduct.php';
    update(URL);    
}
function xajax_sellAvatar(dressup_id,div_name,dressup_imgchar,dressup_imgback,type,typemode){
    document.getElementById('loading').style.display='';
    URL='../api_center/dressup/xajax_sellAvatar.php?dressup_id='+dressup_id+'&div_name='+div_name+'&dressup_imgchar='+dressup_imgchar+'&dressup_imgback='+dressup_imgback+'&type='+type+'&mode='+typemode;
    update(URL);    
}
function xajax_buyFood(code,type,typemode){  
    URL='api_center/dressup/xajax_buyFood.php?code='+code+'&type='+type+'&mode='+typemode;
    update(URL);    
}
function xajax_sellFood(id,code,type,typemode){
    URL='api_center/dressup/xajax_sellFood.php?code='+code+'&type='+type+'&mode='+typemode+'&id='+id;
    //alert(URL);
    update(URL);    
}
function xajax_listBuyFood(){
    //not ajax
    document.getElementById('xLayer1').style.display='';
    document.getElementById('xLayer2').style.display='none';
}
function xajax_listSellFood(){ 
    document.getElementById('xLayer1').style.display='none';
    document.getElementById('xLayer2').style.display='';
    
    URL='api_center/dressup/xajax_listSellFood.php';
    update(URL);    
}
function xajax_itemfoodtoEat(code){ 
    URL='api_center/dressup/xajax_itemfoodtoEat.php?code='+code;
    //alert(URL);
    update(URL);    
}
function xajax_itemfoodtoFriend(code,myzheza){ 
    URL='api_center/dressup/xajax_itemfoodtoFriend.php?code='+code+'&myzheza='+myzheza;
    update(URL);    
}
function xajax_itemfoodtoLover(code){ 
    URL='api_center/dressup/xajax_itemfoodtoLover.php?code='+code; 
    update(URL);    
}
function my_redeemFunction(code,type,path){
    if(type=='z' || type=='Z'){
        path=path+'dressup/';
        URL=path+'xajax_redeemFunction_z.php?code='+code+'&codetype='+type; 
    }else{
        path=path+'zheza/';
        URL=path+'xajax_redeemFunction_zf.php?code='+code+'&codetype='+type; 
    }
    update2(URL); 
       
}


