﻿function getcity() {return [ 
             { id: "110000",name:"北京",url:"http://www.gotoms.com/"},
             { id: "130181",name:"湖南",url:"http://hn.gotoms.com/"},
             { id: "130182",name:"上海",url:"http://www.gotoms.com"},
             { id: "130183",name:"深圳",url:"http://www.gotoms.com/"},
             { id: "130184",name:"广州",url:"http://www..gotoms.com/"},
             { id: "130185",name:"杭州",url:"http://www.gotoms.com/"},
             { id: "130200",name:"苏州",url:"http://www.gotoms.com/"},
             { id: "130281",name:"宁波",url:"http://www.gotoms.com/"},
             { id: "130283",name:"无锡",url:"http://www.gotoms.com/"},
             { id: "130300",name:"常州",url:"http://www.gotoms.com/"},
             { id: "130400",name:"天津",url:"http://www.gotoms.com/"},
             { id: "130481",name:"西安",url:"http://www.gotoms.com/"},
             { id: "130400",name:"武汉",url:"http://www.gotoms.com/"},
             { id: "130481",name:"南京",url:"http://www.gotoms.com/"},
             { id: "130400",name:"成都",url:"http://www.gotoms.com/"},
             { id: "130400",name:"大连",url:"http://www.gotoms.com/"},
             { id: "130481",name:"山东",url:"http://www.gotoms.com/"},
             { id: "130481",name:"福建",url:"http://www.gotoms.com/"},
             { id: "130300",name:"重庆",url:"http://www.gotoms.com/"},
             { id: "130400",name:"郑州",url:"http://www.gotoms.com/"},
             { id: "130481",name:"沈阳",url:"http://www.gotoms.com/"},
             { id: "130400",name:"太原",url:"http://www.gotoms.com/"},
             { id: "130481",name:"合肥",url:"http://www.gotoms.com/"},
             { id: "130400",name:"河北",url:"http://www.gotoms.com/"},
             { id: "130481",name:"佛山",url:"http://www.gotoms.com/"},
             { id: "130400",name:"全国",url:"http://www.gotoms.com/"}]};

function getcitysite()
{
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
	{
	    var aCrumb = aCookie[i].split("=");
		for(var j = 0; j < aCrumb.length; j++)
		{
			if ("citysite" == aCrumb[j])
			{
				return aCrumb[j+1].split("&")[0];
			}
		}
	}
	return null;
}

function  setcitysite(objcityvalue)
{
     setcookie('citysite',objcityvalue,31536000);
}
function getsite()
{
  var siteaddress=getcitysite();
  if(siteaddress!=undefined&&siteaddress!="undefined")
  {
     
     setcitysite(siteaddress);
  }else
  {
    var d=new Date();
    jQuery.ajax({type:"post",url: "/ajax/visitorsfrom.aspx?methodtype=citynamebyip&d="+d.getTime()+"",data:{},
             success:function(data){
               var citys= getcity();
               if(data==0)
               {
                 ///没拿到城市
                  var host = window.location.host;
                   for(var i=0;i<citys.length;i++)
                     {
                      if (citys[i].url.indexOf(host) > -1) 
                        {
                           setcitysite(citys[i].name);
                           window.top.location.href=citys[i].url;
                        }
                 
                      }
               }else
               {
                 ///对应的城市ip
                  for(var i=0;i<citys.length;i++)
                   {
                     if(data.indexOf(citys[i].name)>-1)
                     {
                        
                        setcitysite(citys[i].name);
                        window.top.location.href=citys[i].url;
                     }
                   }
               }
               
      }});
  }
  
}
function checkUrlName(objarr,objtype,objvalue)
{
  

}


function test(host){
       var value="";
       var citys= getcity();
        for(var i=0;i<citys.length;i++)
        {
         y = citys[i].url.indexOf(host);
        if (citys[i].url.indexOf(host) > -1) {
            chanage(citys[i].name);
            value += "<li><a href=\"" + citys[i].url + "\">" + citys[i].name + "</a></li>";
        }
        else {
            value += "<li><a href=\"" + citys[i].url + "\">" + citys[i].name  + "</a></li>";
        }
        }
         jQuery("#cityul").html(value);
       
     }
function cancelEvent(e) {
        if (!e) e = window.event;
        if (e.preventDefault) {
            e.stopPropagation();
            e.preventDefault();
        } else {
            e.cancelBubble = true;
            e.returnValue = false;
        }
   }
  
   function gotomout() {
    if (!!window.find) {
        HTMLElement.prototype.contains = function(B) {
            return this.compareDocumentPosition(B) - 19 > 0
        }
    }
//if (document.getElementById("goto").contains(event.toElement))
//return;
    setTimeout("document.getElementById('goto').style.display='none'", 500);
  }
  
  function getfullhost()
  {
    var host = window.location.host;
    var host2=document.domain; 
    var url = window.location.href;
   return host;
  }
  function chanage(name)
  {   if(document.getElementById('citytext')!=undefined&&document.getElementById('citytext')!=null){
      jQuery("#citytext").html(name);}
      jQuery("#citytextli").html(name+"站")
  }
function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}
var cookiedomain = isUndefined(cookiedomain) ? '' : cookiedomain;
var cookiepath = typeof forumpath == 'undefined' ? '' : forumpath;
function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
	var expires = new Date();
	expires.setTime(expires.getTime() + seconds * 1000);
	domain = !domain ? cookiedomain : domain;
	path = !path ? cookiepath : path;
	
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '/')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}
