﻿var UrlRewrite = 1;

function GoList(clsid,parentid)
{
    var temp = "";
    //var path = window.location;
    //var strlist = path.split('=');
    //var str = strlist[strlist.length-1];
    switch(parentid)
    {
        case 105:
             if(clsid==148||clsid==109)
             {
                temp = GetListUrl("/wallPaper",clsid,parentid);
             }
             else if(clsid==107||clsid==108||clsid==110)
             {
                temp = GetUrl("/downloadGame");
             }
             else if(clsid==111)
             {
                temp = GetUrl("/downloadVideo");
             }
             else
             {
                temp =  "#";
             }   
            break;  
            
        case 14:            
            temp = GetListUrl("/newlist",clsid,parentid);
            break; 
        case 97:          
            temp = GetDetailUrl("/gamedate_",clsid,parentid,97);
            break;
            
        case 15:          
            temp = GetDetailUrl("/newpeople_",clsid,parentid,97); 
            break; 
    }
    window.location.href = temp;
    // window.open(temp);
}

function GetUrl(linkName)
{
   if(UrlRewrite == 1)
   {
      return linkName + ".shtml";
   }
   else
   {
      return linkName + ".aspx";
   }
}
function GetDetailUrl(linkName,clsid,parentid,topid)
{
   if(UrlRewrite == 1)
   {
      if(topid=="")
      {
        return "/detail" + linkName + "_" + clsid + "_" + parentid + ".shtml";
      }
      else
      {
        return "/detail" + linkName + "_" + clsid + "_" + parentid + "_"+ topid + ".shtml";
      }
   }
   else
   {
      if(topid=="")
      {
        return linkName.replace("_","") + ".aspx?clsid="+clsid+"&parentid="+parentid;
      }
      else
      {
        return linkName.replace("_","") + ".aspx?clsid="+clsid+"&parentid="+parentid+"&topid="+topid;
      }
   }
}
function GetListUrl(linkName,clsid,parentid)
{
   if(UrlRewrite == 1)
   {
      return "/list" + linkName + "_" + clsid + "_" + parentid + ".shtml";
   }
   else
   {
      
      return linkName.replace("_","") + ".aspx?clsid="+clsid+"&parentid="+parentid;
   }
}



function GoInfor(clsid,parentid,topid)
{
    var temp = ""; 
    temp = "/infor.aspx?clsid="+clsid+"&parentid="+parentid+"&topid="+topid;
    window.location.href = temp;
    //window.open(temp);
}


function GetRandomNum(Min,Max)
{   
var Range = Max - Min;   
var Rand = Math.random();   
return(Min + Math.round(Rand * Range));   
}   

function generateMixed(n) {
    var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
     var res = "";
     for(var i = 0; i < n ; i ++) {
         var id = Math.ceil(Math.random()*35);
         res += chars[id];
     }
     return res;
}


//获取参数KEY及值
function GetRequestParamValue()
{
  var strUrl = document.URL.toLowerCase();
  var nPos = strUrl.indexOf("?");
  var strRequestString = strUrl.substring(nPos+1); //获取url中"?"符后的字串
  var objKeyValues = new Object();  
  if(nPos!=-1)
  {
    strKeyValues = strRequestString.split("&");
    for(var nI=0;nI<strKeyValues.length;nI++)
    {
       objKeyValues[strKeyValues[nI].split("=")[0]]=unescape(strKeyValues[nI].split("=")[1]);
    }
  }
  return objKeyValues;
}



