// -------------------------------------------------------------------
document.write("<div id='mdq_result' style='border:1px solid #bed2e4;position:absolute;background-color:#FFFFFF;'></div>");
function ppkCreate(name, value, days) {
    var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/;domain=.51mdq.com";
}
function ppkRead(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function ppkErase(name){
	ppkCreate(name,'',-1);
}
document.writeln("<div id=\"IndexTop\">");
document.writeln("<div id=\"logo\"><a href=\"/\" target=\"_blank\"><img src=\"http://static.51mdq.com/images/Toplogo.jpg\" border=\"0\" /></a></div>");
document.writeln("<div id=\"MenuText\"><div class=\"Top\"><div class=\"List\"><a href=\"/shop/help/help.html\" target=\"_blank\" class=\"cDGray\">帮助中心</a></div><div class=\"List\"><a href=\"/project/\" target=\"_blank\" class=\"cDGray\">工程案例</a></div><div class=\"List2\"><a href=\"/shop/Suggestion.aspx\" target=\"_blank\" class=\"cDGray\">投诉建议</a></div>");
document.writeln("<div class=\"List3\" id=\"oSpanLogin\">[<a href=\"/user/login.aspx\" class=\"cDGray\">登录</a>/<a class=\"cDGray\" href=\"javascript:;\" target=\"_parent\" onclick=\"Uexit()\">退出</a>]</div>");
document.writeln("<div class=\"List4\" style=\"max-height:38px;\"><div id=\"Map\">");		
document.writeln("<div id=\"showArea\" class=\"MapBox\" style=\"margin-top:-3px;margin-left:-4px; display:none; z-index:980;\" onmouseover=\"jQuery('#showArea').show();\" onmouseout=\"jQuery('#showArea').hide();\"><h1>切换到其他站点</h1>");
document.writeln("<div class=\"MapPicBox\">");
document.writeln("<ul><li><a href='/index.html'>北京站</a></li><li><a href='/sh'>上海站</a></li>");
document.writeln("<li><a href='/nj'>南京站</a></li><li><a href='/gz'>广州站</a></li>");
document.writeln("<li><a href='/sz'>深圳站</a></li><li><a href='/xm'>厦门站</a></li></ul></div>");
document.writeln("<div class=\"h2\"><a href='/map.html'>查看服务地区划分</a></div></div>");
document.writeln("</div><font id=\"addName\"></font>电话:400-888-0909,<span id='spanTel' style='color:#333366;'></span></div>");
document.writeln("<div class=\"MapPic\" onmouseover=\"jQuery('#showArea').show();\" onmouseout=\"jQuery('#showArea').hide();\"><span>切换站点</span></div>");
document.writeln("<div class=\"clear\"></div></div>");
document.writeln("<div id=\"MenuNow\" class=\"Box\">");
document.writeln("<div class=\"MenuNow\"><a href=\"/\" class=\"f13px cWhite\" id='aHome'>首页</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/ShopGuide/\" id='aTv'>电视</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/shop/index_10001_270.aspx\" id='aAv'>影音</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/ShopGuide/kt.html\" id='aKt'>空调</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/ShopGuide/icebox.html\" id='aBx'>冰箱</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/ShopGuide/washing.html\" id='aXyj'>洗衣机</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/shop/index_10001_290.aspx\" id='aMobile'>手机</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/new/news\">资讯</a></div>");
document.writeln("<div class=\"Menu\"><a href=\"/act\">促销</a></div>");
document.write("<script src=\"/js/index.js\"></scr"+"ipt>");
document.writeln("</div>");
document.writeln("</div>");
document.writeln("<div class=\"clear\"></div>");
document.writeln("<div id=\"Search\">");
document.writeln("<div class=\"Text\">");
document.writeln("<div class=\"serch\"><div class=\"floatZi\">查找商品：</div><div class=\"floatSelect\">");
document.writeln("<select id=\"selType\">");
document.writeln("<option value=\"\">全部商品</option>");
document.writeln("<option value=\"230\">电视</option>");
document.writeln("<option value=\"270\">影音</option>");
document.writeln("<option value=\"280\">空调</option>");
document.writeln("<option value=\"250\">冰箱</option>");
document.writeln("<option value=\"260\">洗衣机</option>");
document.writeln("<option value=\"290\">手机</option>");
document.writeln("<option value=\"300\">小家电</option>");
document.writeln("</select>");
document.writeln("</div>");
document.writeln("<input type=\"hidden\" id=\"hidSiteid\" name=\"hidSiteid\" value='10001' />");
document.writeln("<div class=\"floatInput\"><input  id=\"keyword\" onkeyup='searchDown(event,this);' type=\"text\" name=\"keyword\" autocomplete=\"off\"/ size=\"57\">");
document.writeln("</div>");
document.writeln("<div class=\"floatButton\"><img src=\"http://static.51mdq.com/images/search_button.jpg\" style=\"cursor:pointer\"  onclick=\"searchSubmit('10001',document.getElementById('selType').value)\" /></div><div class=\"clear\"></div></div>");
document.writeln("</div>");
if (ppkRead("siteid")) {
    document.writeln("  <div class=\"BuyButton\"><a href=\"/shop/cart.aspx?siteid=" + ppkRead("siteid") + "\">购物车</a></div>");
} else {
    document.writeln("  <div class=\"BuyButton\"><a href=\"/shop/cart.aspx\">购物车</a></div>");
}
document.writeln("<div id=\"time\"></div>");
document.writeln("</div>");
document.writeln("</div>");
// -------------------------------------------------------------------

	var cok=ppkRead('UserInfo');
	var oLogin=document.getElementById("oSpanLogin");
	if(cok)
	{
		var ca=cok.split('&');
		var fname="UserName=";
		var Cuser="";
		for(var i=0;i<ca.length;i++){
			var c=ca[i];
			while(c.charAt(0)==' ') c=c.substring(1);
			if(c.indexOf(fname)>-1) {Cuser=c.substring(fname.length);break;}
		}
		oLogin.innerHTML=oLogin.innerHTML.replace("登录",Cuser).replace("/user/login.aspx","/user/usercenter");
	}
	else{
		oLogin.innerHTML="[<a href=\"javascript:clickLogin();\" target=\"_parent\" class=\"cDGray\">登录</a>/<a target=\"_parent\" class=\"cDGray\" href=\"/user/Register.aspx\">注册</a>]";
	}
	function Uexit(){
		ppkErase('UserInfo');
		var cok1=ppkRead('UserInfo');
		if(cok1)
		{
			var ca=cok1.split('&');
			var fname="UserName=";
			var Cuser="";
			for(var i=0;i<ca.length;i++){
				var c=ca[i];
				while(c.charAt(0)==' ') c=c.substring(1);
				if(c.indexOf(fname)>-1) {Cuser=c.substring(fname.length);break;}
			}
			oLogin.innerHTML=oLogin.innerHTML.replace("登录",Cuser).replace("/user/login.aspx","/user/usercenter");;
		}
		else{
			oLogin.innerHTML="[<a href=\"javascript:clickLogin();\" target=\"_parent\" class=\"cDGray\">登录</a>/<a class=\"cDGray\" target=\"_parent\" href=\"/user/Register.aspx\">注册</a>]";
		}
	}
	function clickLogin()
	{
		var weblocation=location.href;
		if (weblocation.indexOf("login.aspx")!=-1)
		{
		top.location="/user/login.aspx";
		}
		else
		{
		top.location="/user/login.aspx?ReturnUrl="+location.href;
		}
		
		if (weblocation.indexOf("ForgetPass.aspx")!=-1)
		{
		top.location="/user/login.aspx";
		}
		
}
var CoCity = new Array();
CoCity["10001"] = "北京站";
CoCity["10002"] = "上海站";
CoCity["10003"] = "广州站";
CoCity["10004"] = "新疆站";
CoCity["10005"] = "郑州站";
CoCity["10006"] = "厦门站";
CoCity["10007"] = "南京站";
CoCity["10008"] = "深圳站";

function toUrl(url) {
    ppkCreate("siteid", url, 30);
    top.location.href = getHomePage(url);
}
function getHomePage(siteid) {
    var url = "";
    switch (siteid) {
        case "10001":
            url = "/index.html";
            break;
        case "10002":
            url = "/sh";
            break;
        case "10003":
            url = "/gz";
            break;
        case "10004":
            break;
        case "10005":
            break;
        case "10006":
            url = "/xm";
            break;
        case "10007":
            url = "/nj";
            break;
        case "10008":
            url = "/sz";
            break;
        default:
            url = "/";
            break;
    }
    return url;
}
function changeLinks(siteid) {
    var $ = jQuery;
    $("#aHome").attr("href", getHomePage(siteid));
    $("#aTv").attr("href", "/shop/index_" + siteid + "_230.aspx");
    $("#aAv").attr("href", "/shop/index_" + siteid + "_270.aspx");
    $("#aKt").attr("href", "/shop/index_" + siteid + "_280.aspx");
    $("#aBx").attr("href", "/shop/index_" + siteid + "_250.aspx");
    $("#aXyj").attr("href", "/shop/index_" + siteid + "_260.aspx");
    $("#aMobile").attr("href", "/shop/index_" + siteid + "_290.aspx");
    if (siteid == "10006" && document.getElementById("time")) {
        document.getElementById("time").style.backgroundImage = 'url(http://static.51mdq.com/images/timexm.jpg)';
    }
}
var siteid = ppkRead("siteid");
if (!siteid) {
    
    $.get("/config/IpAjax.aspx", function(res) {
    siteid = res;
    ppkCreate("siteid", siteid, 30);
    });
    
    
}
changeLinks(siteid);
document.getElementById("spanTel").innerHTML = getTelephone(siteid);
document.getElementById("addName").innerHTML = CoCity[siteid];
function getTelephone(siteid) {
    var tel = "";
    switch (siteid) {
        case "10001":
            tel = "010-51268180";
            break;
        case "10002":
            tel = "021-31269886";
            break;
        case "10003":
            tel = "020-62335122"; //"020-38886552" ;
            break;
        case "10006":
            tel = "0592-3886999";
            break;
        case "10007":
            tel = "025-86872120";
            break;
        case "10008":
            tel = "0755-61672167"; //"0755-83494354";
            break;
    }
    return tel;
}