﻿var IPData = new Array("110.88.115.57", "", "福建省", "福州市");
try
{
    document.write("<script src='http://fw.qq.com/ipaddress' type='text/javascript' charset='gb2312'></script>");
}catch(ex){}
var city = "";
var area = "";
//输出HEAD
function outputHead(oUserName,oUserUnitId,PassPortUrl) {

    if (!window.TJ) {
        TJ = { Domain: 'http://' + document.domain };
    }
    
    oUserName = typeof(oUserName) == 'undefined' ? "" : oUserName;
    oUserUnitId = typeof(oUserUnitId) == 'undefined' ? "" : oUserUnitId;
    //alert(oUserName);
    area = IPData[3] == "" ? IPData[2] : IPData[3];
    var v_html = '	<div class="top_l" >今天是' + showDate() + '<img src="' + TJ.Domain + '/images/tjimages/hot.gif" />' +
    '<a class="cp" id="viewlocal">' + area + '体检打折</a> <span style="margin-left:10px;">预约电话: <img src="' + TJ.Domain + '/images/tel.png" alt="400-080-3669" align="absmiddle" /></span></div>';
    
    if( oUserName == "")
    {
        v_html +=
        '<div class="top_r">'
        + '<span class="fl">  用户名:<input id="h_username" type="text" class="user" />'
        + '  密码:<input type="password" id="h_password" class="user" /> </span>'
        + '<span class="rt">  <a id="btnlogin" href="#"><img border="0" src="' + TJ.Domain + '/images/login.gif" /></a>'
        + '  <a id="btnreg" href="#"><img border="0" src="' + TJ.Domain + '/images/reg.gif" /></a> </span>'
        + '</div>';
    }
    else
    {
        v_html +=
        '   <div class="top_r">欢迎您回来：  '
        +'      <a id="currUser">'+ unescape(oUserName) +'</a>'
        +'      <a href="'+ TJ.Domain +'/member/index.html" target="_self">个人中心</a>'
        +       ( oUserUnitId != "0" ? ' <a href="'+ TJ.Domain +'/Business/index.html" target="_self">商务中心</a>' : '')
        +'      <a href="http://my.panjk.com" target="_blank">我的空间</a>'
        +'      <a href="'+ PassPortUrl +'/UserLogout.aspx?u='+ escape(oUserName) +'&returnUrl=' + window.location + '" target="_self">注销</a>'
        +'  </div>';
    }
    
    document.getElementById("TopLogin").innerHTML = v_html;
	//設置事件
    $("#btnlogin").click(function ()
	{
	    var username = Trim($("#h_username").val());
	    var password = Trim($("#h_password").val());
	    if(username != "" && password != "")
	    {
	        window.location = PassPortUrl +"/UserLogin.aspx?u=" + escape(username) + "&p=" + escape(password) + "&returnUrl=" + escape(window.location) ;
	    }
	});
	//回车提交
    if (document.all ? true : false)
	{
		document.onkeydown = function () 
		{
            if (event.keyCode == 13)
                $("#btnlogin").click();
		};
	}
	else
	{
		document.addEventListener("keydown", function (evnt) 
		{
		    if (evnt.keyCode == 13)
                $("#btnlogin").click();
        }, false);
	}
	
	$("#btnreg").click(function()
	{
	    window.location = PassPortUrl +"/UserRegister.aspx?returnUrl=" +  window.location;
	});
	
	//本地套餐地址
	$("#viewlocal").click(function()
	{
	    if(city == "")
	    {
	        var paras = "act=area&str=" + area;
	        $.ajax(
            {
                type: "POST",
                url: RootPath + "/ajax.aspx",
                data: paras,
                async: false,
                success: function(Res)
                {
                    city = Res;
                }
            }); 
	    }
	    city = city == "" ? "13" : city;
	    window.location.href = RootPath + "/combolist-" + city + TJ.urlRewritExt;
	});
}
$(function()
{
    //搜索框
    $("#keyword").val("请输入查询信息").focus(function()
	{
        if($(this).val() =="请输入查询信息")
            $(this).val("");
    }).blur(function()
	{
        if($(this).val() =="")
            $(this).val("请输入查询信息");
    });
    $("#btnkeyword").click(function()
    {
        var keyword = Trim($("#keyword").val());
        if(keyword != "" && keyword != "请输入查询信息")
        {
            window.open(TJ.Domain + "/so.html?word=" + escape(keyword) );
            return false;
        }
    });
    
    //体检单位图片默认
    $("img").each(function()
    {
        if($(this).attr("src") == "a1/titleimages/" || $(this).attr("src") == "")
            $(this).attr("src","images/zwtp.jpg");
    });
});

function showDate()
{
    var ret = "";
    var now = new Date();
    var year = now.getYear();
    var month = now.getMonth()+1;
    var day = now.getDate();
    ret = year + "年" + month + "月" + day + "日 ";
    
    now = new Date() 
    if (now.getDay() == 0) ret+= "星期日"
    if (now.getDay() == 1) ret+= "星期一"
    if (now.getDay() == 2) ret+= "星期二"
    if (now.getDay() == 3) ret+= "星期三"
    if (now.getDay() == 4) ret+= "星期四"
    if (now.getDay() == 5) ret+= "星期五"
    if (now.getDay() == 6) ret+= "星期六"
    
    return ret
}

//输出HEAD
function outputHead2(oUserName)
{
    oUserName = typeof(oUserName) == 'undefined' ? "" : unescape(oUserName);
    if(oUserName != "")
        outputHead(oUserName.split('∮')[0],oUserName.split('∮')[1],TJ.PassPortUrl);
    else
        outputHead("","",TJ.PassPortUrl);
    
    //本地套餐地址
    $("#viewlocal").unbind("click").click(function()
    {
        if(city == "")
        {
            document.domain = domain;
            
            var AjaxProxy = document.getElementById("UnitsAjaxFrame").contentWindow;
            city = AjaxProxy.jqAjax("area",area);
        }
        city = (city == ""|| city == null) ? "13" : city;
        window.location.href = TJ.Domain + "/combolist-" + city + TJ.urlRewritExt;
	    
    });
}
function eEvent(type , Url)
{
    var title = $("h2",".pic_ad").text();
    if(type == 1)
    {
        try
        {
             var clipBoardContent = Url; 
             window.clipboardData.setData("Text",clipBoardContent); 
             alert("网址复制成功，赶紧叫朋友来看看吧！");
         }
         catch(e){alert("您使用的浏览器不支持此复制功能");}
    }
    else
    {
        
        if(document.all)//IE
            window.external.addFavorite(Url,title);
        else if (window.sidebar)
            window.sidebar.addPanel(title, Url, "")
    }
}
