
function loadJiuaimaiTop()
{

	function jiuaimaiTopStyle( )
	{

	   var str = '<style type="text/css">';
	     
		  str += '#jiuaimai_popup_bg{display:none;position:absolute;z-index:10001;width:100%;background-color:#666666;filter:alpha(opacity=20); -moz-opacity: 0.8;opacity: 0.8; }';
		  str += '.jiuaimai_popup{display:none;position:absolute;z-index:10001;left:50%;background-color:#FFFFFF;}';
		  str += ' .jiuaimai_popup #jiuaimai_popup_bar{height:35px;background-color:#FF3682;color:#FFFFFF;}';
		  str += ' #jiuaimai_popup_title{float:left;font-size:14px; margin-left:10px; margin-top:10px; font-weight:bold;}';
		  str += ' #jiuaimai_popup_close{float:right;text-align:right; margin-top:6px; padding-right:10px;}';
		  str += ' #jiuaimai_popup_close img{cursor:pointer;}';
		  
	
          str += '.jiuaiimai_top_tip{width:161px;position:absolute;right:85px;top:42px;_top:45px; z-index:300;}';
          str += '.jiuaimai_top_tip_top{background:url(\'http://image.9imai.com/www/top/tip.gif\');height:17px;width:161px;font-size:0px;}';
          str += '.jiuaimai_top_tip_body{width:159px;overflow:hidden; border-left:1px #E1D9B4 solid; border-right:1px #E1D9B4 solid; background-color:#FDFFE7; color:#FE3E89;}';
          str += '.jiuaimai_top_tip_body div{ padding-left:6px; padding-right:6px; padding-bottom:6px;}';
          str += '.jiuaimai_top_tip_foot{background:url(\'http://image.9imai.com/www/top/tip.gif\'); background-position:0px -18px; height:2px; width:161px; font-size:0px; font-size:0px;}';
		  str += '.jiuaimai_top_tip_close{ font-size:0px; float:right ; margin-right:4px; width:7px; height:7px; margin-top:8px; cursor:pointer;}';
		  
		
	      str += '.jiuaimai_top{width:100%;height:70px;font-size:12px;	z-index:100000}';
		  str += '.jiuaimai_top .jiuaimai_home{float:left;}';
		  str += '.jiuaimai_top .jiuaimai_home img{margin-top:1px;}';
		 
	
          str += '.jiuaimai_user_info{ float:right; line-height:28px;  }';
		  str += '.jiuaimai_user_info img{border:1px #999999 solid; display:block}';
		  
		  
		  str += '.jiuaimai_like_btn{ text-align:right;  width:250px; float:right; padding-top:5px ; line-height:28px; }';
		  
          str += '.jiuaimai_icon{height:22px; margin-top:2px; border-bottom:1px #EFEFEF solid; background:url(http://image.9imai.com/www/top/icon.gif);background-repeat:no-repeat;padding-left:11px;}';
          str += '.jiuaimai_password{  background-position:0 -18px;}';	
          str += '.jiuaimai_profile{  background-position:0 -36px;}';	
          str += '.jiuaimai_bind{  background-position:0 -200px;}';	
          str += '.jiuaimai_alipay{  background-position:0 -218px;}';	
          str += '.jiuaimai_money{  background-position:0 -54px;}';				  
          str += '.jiuaimai_order{  background-position:0 -72px;}';
          str += '.jiuaimai_wangwang{ background-position:0 -90px;}';
          str += '.jiuaimai_qq{ background-position:0 -108px;}';
          str += '.jiuaimai_homepage{ background-position:0 -126px;}';	
          str += '.jiuaimai_dapei{ background-position:0 -144px;}';	
          str += '.jiuaimai_share{ background-position:0 -162px;}';		
          str += '.jiuaimai_shouchang{ background-position:0 -180px;}';			  
		 
		  str += '.jiuaimai_top .jiuaimai_top_menu{width:980px;margin-left:auto;margin-right:auto; padding:10px; padding-right:0px;z-index:10000; position:relative;}';
		  str += '.jiuaimai_top ul li{float:right;height:20px;list-style:none;line-height:30px;position:relative;z-index:999;}';
		  str += '.jiuaimai_top ul li a{padding:0px 10px 0px 10px; }';
		  str += '.jiuaimai_top ul li a img { margin-right:3px;  padding:0px;  }';
		  
		  str += '.jiuaimai_top a{text-decoration:none; outline:none;}';
		  str += '.jiuaimai_top a:link{color:#666666;text-decoration: none;}';
          str += '.jiuaimai_top a:visited{color:#666666;text-decoration: none;}';
          str += '.jiuaimai_top a:hover{color:#F30060;text-decoration: none;}';
          str += '.jiuaimai_top  .link_o{text-decoration:none;color:#FF0000;}';
          str += '.jiuaimai_top .quick-menu li,  .jiuaimai_top .menu-bd s.lt, .jiuaimai_top .jiuaimai_menu:hover, .jiuaimai_top .hover .jiuaimai_menu, .jiuaimai_top .jiuaimai_menu:hover .menu-hd{background:url("http://image.9imai.com/www/top/top_tag_bg_v2.png") no-repeat scroll 999em 0 transparent;}';
          str += '.jiuaimai_top .quick-menu {padding:0px;margin:0px; margin-top:8px}';
          str += '.jiuaimai_top .menu-hd {color:#666666;cursor:pointer;display:block;_display:inline-block;height:26px;padding:0 22px 0 10px;position:relative;}';
          str += '.jiuaimai_top .menu-hd b {border-color:#666666 #FFFFFF #FFFFFF #FFFFFF;border-style:solid;border-width:4px;font-size:0;height:0;line-height:0;position:absolute;right:10px;width:0;margin-top:12px;*margin-top:4px;}';
          str += '.jiuaimai_top  .quick-menu li {background-position:right -22px;margin-left:-1px;}';
          str += '.jiuaimai_top .menu-bd {margin-top:4px ; background:none repeat scroll 0 0 #FFFFFF;border:1px solid #BFBFBF;display:none;position:absolute;top:22px; left:0px; z-index:99999;}';
       	  
		  
		  str += '';
		  
        
          str += '.jiuaimai_top .menu-bd-panel {padding:10px 10px 6px; z-index:1000}';
		  str += '.jiuaimai_top .menu-bd-panel dl{padding:0px;margin-left:0px;margin-bottom:5px; overflow:hidden;clear:right;clear:left;border-bottom:1px #EFEFEF solid;}';
		  str += '.jiuaimai_top .menu-bd-panel dl dt{font-weight:bold;}';
		  str += '.jiuaimai_top .menu-bd-panel dd{margin:0px;clear:right;}';
		  str += '.jiuaimai_top .menu-bd-panel  .nav-a{padding:0px;margin-right:5px;}';
          str += '.jiuaimai_top .menu-item-opp .menu-bd s.rt {left:0;}';
          str += '.jiuaimai_top .menu-item-opp .menu-bd s.lt {background-position:-87px -55px;left:auto;right:-2px;}'
          //str += '.jiuaimai_top .jiuaimai_menu:hover, .jiuaimai_top .hover .jiuaimai_menu {background-position:right 3px;position:relative;}';

          str += '.jiuaimai_top .jiuaimai_menu:hover .menu-bd, .jiuaimai_top .hover .menu-bd {display:block;}';
          str += '.jiuaimai_top .jiuaimai_menu:hover .menu-hd b, .jiuaimai_top .hover .menu-hd b {border-color:#FFFFFF #FFFFFF #666666  #FFFFFF;margin-top:7px;*margin-top:0px;*width:2px;}';
          str += '.jiuaimai_top .listItem .menu-bd {height:57px;line-height:1.7;width:94px;}';
          str += '.jiuaimai_top .listItem .menu-bd-panel {padding:8px 10px;}';
          str += '.jiuaimai_top .jiuaimai_top_menu .quick-menu .last {background:none;}';
		  
		  str += '.jiuaimai_list_item{  height:23px; padding:0px; }';
		  str += '.jiuaimai_login_item{ padding:0px 0px 0px 0px}';
		  str += '#jiuaimai_other_login div{ float:left;}';
		  str += '#jiuaimai_other_login div img{margin-top:5px;}';
		  str += '#jiuaimai_other_login b{ *margin-top:10px; height:0px; }';

		  str += '</style>';
		  
		  return str;
	}
	
	function jiuaimaiTopHtml()
	{
		var html = '';
		
		html += '<div id="jiuaimai_popup_bg"></div>';
		html += '<div id="jiuaimai_popup" class="jiuaimai_popup"><div id="jiuaimai_popup_bar"><div id="jiuaimai_popup_title"></div><div id="jiuaimai_popup_close"><img src="http://image.9imai.com/www/top/popup_close.jpg" title="关闭" alt="关闭" onClick="jiuaimai_popup_close()"/></div></div><div id="jiuaimai_popup_body"></div></div>'
		
        html += '<div id="jiuaimai_set_email" style="height:30px; display:none; line-height:30px; background-color:#FDF1E1; padding-left:180px; color:red; ">您的账号还没有填写邮箱地址，填写完后马上就能用邮箱登录就爱买哦！<a href="http://my.9imai.com/?option=index&task=editpass" target="_blank">马上设置</a> <a href="javascript:void(0);" onclick="setCookie(\'setEmail\',1,10);JIM(\'jiuaimai_set_email\').style.display=\'none\';">  <font color="red">[不提示]</font></a></div>';				
		
		
		//html += '<div id="jiuaimai_set_email" style="height:30px; line-height:30px; background-color:#FDF1E1; padding-left:180px; color:red; ">计划于2011年6月2日0点至6点对服务器系统进行升级，到时将不能访问就爱买网站，由此造成的不便敬请谅解。有其它疑问请咨询客服。</div>';			
		//html += '<div id="jiuaimai_set_email" style="height:37px; display:none; font-size:12px;line-height:30px; padding-left:140px; color:#CDCDCD;  background-image:url(http://image.9imai.com/www/top/top_tip_bg.jpg); background-repeat:repeat-x ">您的账号还没有填写邮箱地址，填写完后马上就能用邮箱登录就爱买哦！<a href="http://my.9imai.com/?option=index&task=editpass" target="_blank"><img src="http://image.9imai.com/www/top/set_mail.jpg" align="absmiddle" /></a>&nbsp;&nbsp; <a href="javascript:void(0);" onclick="setCookie(\'setEmail\',1,10);JIM(\'jiuaimai_set_email\').style.display=\'none\';"><font color="#CDCDCD">不设置</font></a></div>';		

		
		html += '<div class="jiuaimai_top">';
	
		html +=	'<div class="jiuaimai_top_menu">';
		
		html +=	'<div class="jiuaimai_home"><div><a href="http://www.9imai.com" title="返回首页">&nbsp;<img align="absmiddle" src="http://image.9imai.com/www/top/logo.jpg" border="0"/></a></div></div>';		
		
		html += '  <ul  class="quick-menu">';
		
		html += '		<li class="last" id="jiuaimai_logout_btn" style="display:none;"><a href="'+jiuaimai_logout_url+'" style="padding-right:3px">[退出]</a></li> ';
			
		html += '		<li style="_padding-top:7px;" class="last" id="add_book_mark"><a  href="javascript:void(0)" onclick="addBookmark(\'http://www.9imai.com\',\'就爱买\')"><img src="http://image.9imai.com/www/top/menu_icon_sc.png" border="0" align="absmiddle"/>收藏</a></li> ';	
		
		html += '		<li style="_padding-top:7px;" class="listItem" onmouseover="this.className = \'listItem hover\';" onmouseout="this.className = \'listItem\';"> ';
		html += '				<div class="jiuaimai_menu"> ';
		html += '					<a target="_top" href="#" class="menu-hd"><img src="http://image.9imai.com/www/top/menu_icon_help.png" border="0" align="absmiddle"/>客服<b></b></a> ';
		html += '					<div class="menu-bd" style="width: 100px;height:65px;"> ';
		html += '						<div class="menu-bd-panel"> ';
		html += '							<div class="jiuaimai_icon jiuaimai_wangwang"> <a href="http://amos1.taobao.com/msg.ww?v=2&uid=9imaicom&s=1" target="_blank">旺旺客服</a></div>';
		html += '							<div class="jiuaimai_icon jiuaimai_qq"> <a target="_blank" href="http://sighttp.qq.com/authd?IDKEY=241fb3b32377a0df95063451ed8111460e2bbbd343e0c748">QQ客服</a></div>';
		html += '						</div> ';
		html += '						<s class="r"></s><s class="rt"></s><s class="lt"></s><s class="b"></s><s class="b b2"></s><s class="rb"></s><s class="lb"></s> ';
		html += '					</div> ';
		html += '				</div> ';
					
		html += '			</li> ';
		
		html += '		<li style="_padding-top:7px;"><a href="http://my.9imai.com/?option=pm" id="jiuaimai_menu_message" style="display:none"><img src="http://image.9imai.com/www/top/menu_icon_msg.png" border="0" align="absmiddle"/>消息</a></li> ';
		
		
			
		html += '			<li class="listItem" id="jiuaimai_my_user" style="display:none" onmouseover="this.className = \'listItem hover\';" onmouseout="this.className = \'listItem\';"> ';
		html += '				<div class="jiuaimai_menu"> ';
		html += '					<a target="_top" href="http://my.9imai.com" class="menu-hd">设置<b></b></a> ';
		html += '					<div class="menu-bd" style="width:130px;height:138px;"> ';
		html += '						<div class="menu-bd-panel"> ';
        html += '                         <div class="jiuaimai_icon"><a href="http://my.9imai.com/?option=avatar">修改头像</a></div>';		
        html += '                         <div class="jiuaimai_icon jiuaimai_password"><a href="http://my.9imai.com/?option=index&task=editpass">修改密码</a></div>';		
        html += '                         <div class="jiuaimai_icon jiuaimai_profile"><a href="http://my.9imai.com/?option=index&task=profile">修改个人资料</a></div>';
        html += '                         <div class="jiuaimai_icon jiuaimai_bind"><a href="http://my.9imai.com/?option=connection">帐号绑定</a></div>';
        html += '                         <div class="jiuaimai_icon jiuaimai_alipay"><a href="http://my.9imai.com/?option=index&task=alipay">支付宝设置</a></div>';		
		html += '						</div> ';
		html += '						<s class="r"></s><s class="rt"></s><s class="lt"></s><s class="b"></s><s class="b b2"></s><s class="rb"></s><s class="lb"></s> ';
		html += '					</div> ';
		html += '				</div> ';
					
		html += '			</li> ';
		
		
		html += '			<li class="listItem" id="jiuaimai_my_profile" style="display:none" onmouseover="this.className = \'listItem hover\';" onmouseout="this.className = \'listItem\';"> ';
		html += '				<div class="jiuaimai_menu"> ';
		html += '					<a target="_top" style=" padding-left:0px"  href="http://www.9imai.com/t/myhome" class="menu-hd" id="jiuaimai_user_center"></a> ';
		html += '					<div class="menu-bd" style="width:100px;height:165px;"> ';
		html += '						<div class="menu-bd-panel"> ';
        html += '                         <div class="jiuaimai_icon jiuaimai_homepage"><a href="http://www.9imai.com/index.php?mod=other&code=jump&target=home">我的主页</a></div>';		
        html += '                         <div class="jiuaimai_icon jiuaimai_dapei"><a href="http://www.9imai.com/index.php?mod=other&code=jump&target=dapei">我的搭配</a></div>';
        html += '                         <div class="jiuaimai_icon jiuaimai_share"><a href="http://www.9imai.com/index.php?mod=other&code=jump&target=share">我的分享</a></div>';
        html += '                         <div class="jiuaimai_icon jiuaimai_shouchang"><a href="http://www.9imai.com/t/mylike">我喜欢的</a></div>';		
		
        html += '                         <div class="jiuaimai_icon jiuaimai_money"><a href="http://my.9imai.com/?option=fanhuan">我的金额</a></div>';		
        html += '                         <div class="jiuaimai_icon jiuaimai_order"><a href="http://my.9imai.com/?option=fanhuan&task=order">我的订单</a></div>';			
		html += '						</div> ';
		html += '						<s class="r"></s><s class="rt"></s><s class="lt"></s><s class="b"></s><s class="b b2"></s><s class="rb"></s><s class="lb"></s> ';
		html += '					</div> ';
		html += '				</div> ';
					
		html += '			</li> ';		
		

		html += '			<li class="listItem" id="jiuaimai_other_login"  onmouseover="this.className = \'listItem hover\';" onmouseout="this.className = \'listItem\';"> ';
		html += '				<div class="jiuaimai_menu"> ';
		html += '					<a href="'+jiuaimai_sina_login+'" class="menu-hd" id="jiuaimai_other_login"><img src="http://image.9imai.com/www/top/other_login.gif" border="0" align="absmiddle"><b></b></a> ';
		html += '					<div class="menu-bd" style="width:130px;height:85px;"> ';
		html += '						<div class="menu-bd-panel"> ';
        html += '                         <div class="jiuaimai_list_item"><a href="javascript:void(0);" onclick="jiuaimai_qq_login_pop();return false;" style="padding:0px" ><img src="http://image.9imai.com/www/top/qq_login.png" border="0"/></a></div>';		
        html += '                         <div class="jiuaimai_list_item"><a href="javascript:void(0);" onclick="jiuaimai_sina_login_pop();return false;" style="padding:0px" ><img src="http://image.9imai.com/www/top/sina_login.png" border="0"/></a></div>';
        html += '                         <div class="jiuaimai_list_item"><a href="javascript:void(0);" onclick="jiuaimai_taobao_login_pop();return false;" style="padding:0px""><img src="http://image.9imai.com/www/top/taobao_login.png" border="0"/></a></div>';	
		html += '						</div> ';
		html += '						<s class="r"></s><s class="rt"></s><s class="lt"></s><s class="b"></s><s class="b b2"></s><s class="rb"></s><s class="lb"></s> ';
		html += '					</div> ';
		html += '				</div> ';
					
		html += '			</li> ';	
		
	
		//html += '	<li>&nbsp;&nbsp;</li> ';
		
		html += '	</ul> ';
		
		html += '    <div class="jiuaimai_user_info" id="jiuaimai_user_info">用户信息加载中...   </div> ';
		
		html += '    <div class="jiuaimai_like_btn" id="jiuaimai_like_btn"></div> ';
		
		html +=  ' <div class="jiuaiimai_top_tip" style="display:none" id="jiuaiimai_top_tip"><div class="jiuaimai_top_tip_top"><div class="jiuaimai_top_tip_close" title="关闭" onclick="jiuaimai_close_tip();"></div></div>';
		html +=  '  <div class="jiuaimai_top_tip_body" id="jiuaimai_top_tip_body">';
	
		html +=	 '	</div><div class="jiuaimai_top_tip_foot"></div></div>';		
		html += '	</div> ';

		html += '</div>		';
		
		//html += ' <a href="http://www.9imai.com/contest/invite/" target="_blank"> <div id="invitead" style="display:none ;margin-left:auto; width:980px; height:60px; margin-right:auto; background-image:url(http://image.9imai.com/www/top/top1.jpg)"><div style="margin-top:2px; margin-left:962px;  cursor:pointer" onclick="JIM(\'invitead\').style.display=\'none\';setCookie(\'invite_ad\',1,3);"><img src="http://image.9imai.com/www/top/cancel.png" title="关闭"/></div></div></a>';
	
		return html;
	}
	
	document.write(jiuaimaiTopStyle() + jiuaimaiTopHtml());
	showJiuaimaiUserInfo();
}


var jiuaimai_old_domain  = document.domain; 

var jiuaimai_domainext  = jiuaimai_old_domain.substring(jiuaimai_old_domain.lastIndexOf('.')+1,jiuaimai_old_domain.length);


var jiuaimai_ucenter_url = "http://my.9imai."+jiuaimai_domainext+"/center/";			
var jiuaimai_my_url      = "http://my.9imai."+jiuaimai_domainext+"/";
var jiuaimai_reg_url     = "http://passport.9imai."+jiuaimai_domainext+"/?task=reg"; 
var jiuaimai_logout_url  = "http://passport.9imai."+jiuaimai_domainext+"/?task=logout&url="+escape( location.href );
var jiuaimai_login_url   = "http://passport.9imai."+jiuaimai_domainext+"/?task=login&url="+escape( location.href );  
var jiuaimai_mini_login  = "http://passport.9imai."+jiuaimai_domainext+"/?task=login&t=minilogin" ;
var jiuaimai_mini_reg    = "http://passport.9imai."+jiuaimai_domainext+"/?task=reg&t=minireg" ;

var jiuaimai_svc_url     = "http://my.9imai."+jiuaimai_domainext+"/interface/?option=topuserinfo&task=userinfo";	

var jiuaimai_sina_login  = "http://passport.9imai."+jiuaimai_domainext+"/?option=sina&url="+escape( location.href );
var jiuaimai_taobao_login= "http://passport.9imai."+jiuaimai_domainext+"/?option=taobao&url="+escape( location.href );
var jiuaimai_qq_login = "http://passport.9imai."+jiuaimai_domainext+"/?option=qq&url="+escape( location.href );

var jiuaimai_getmsg_url = "http://www.9imai."+jiuaimai_domainext+"/interface/User.php?task=getusermsgcount";
var jiuaimai_emptymsg_url = "http://www.9imai."+jiuaimai_domainext+"/interface/User.php?task=emptyusermag";

var jiuaimai_uid ;


function showJiuaimaiUserInfo() {
    try {
        url = jiuaimai_svc_url + '&task=userinfo&s=' + (new Date()).getTime();
        requestSvc('bookmarkJs', url, 'callbackShowJiuaimaiUserInfo');
    } catch(err) {
    }
}


onload = function (){

	JIM('jiuaimai_like_btn').innerHTML = '<div style="float:left"><iframe width="136" height="24" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0" scrolling="no" frameborder="No" border="0" src="http://widget.weibo.com/relationship/followbutton.php?width=136&height=24&uid=1785130085&style=2&btn=light&dpc=1"></iframe></div><div style="float:left"> <iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F976774486&type=button_num&width=100&height=30" allowtransparency="true" scrolling="no" border="0" frameborder="0" style="width:100px;height:30px;border:none;overflow:hidden;"></iframe></div>'
	//checkInvite();
}


function callbackShowJiuaimaiUserInfo(s) {
    var sJson = s.toString();
    eval("var oJson = " + sJson + ";");
    var res = oJson.status;
    if ('0' == res) {

        showLogingUserPannel();
        return;
    } else if ('1' == res) {
        showLogedUserPannel(oJson.uid, oJson.nick_name, oJson.money  , oJson.email);
    } else {
        alert('error occured');
    }
}


function showLogingUserPannel()
{
	JIM('jiuaimai_my_user').style.display="none";

    try {
      
		var inner = ' 您好，欢迎来到就爱买 &nbsp;<a href="javascript:void(0)" onclick="jiuaimai_login();return false;">[登录]</a> <a href="'+jiuaimai_reg_url+'">[<span class="link_o">注册</span>]</a>';
		document.getElementById('jiuaimai_user_info').innerHTML= inner;
    } 
	catch(err) 
    {
    }		
}


function showLogedUserPannel(uid , nickname , money  , email)
{
   jiuaimai_uid = uid;
   JIM('jiuaimai_my_user').style.display="";
   JIM('jiuaimai_my_profile').style.display = '';
   JIM('add_book_mark').className = '';
   JIM('jiuaimai_logout_btn').style.display = '';
   JIM('jiuaimai_other_login').style.display = 'none';
   JIM('jiuaimai_menu_message').style.display = '';
   
   if( email == '' )
   {
	   	var setEmail = getCookie('setEmail');

		if (setEmail==null || setEmail=="")
		{
			JIM('jiuaimai_set_email').style.display = '';
		}
	   
   }
   
   try {
        var inner = '';
        inner += '<div style="float:left; margin-top:5px;margin-right:3px"><img width="18" align="absmiddle" border="0" src="'+jiuaimai_ucenter_url+'avatar.php?uid='+uid+'&size=small" style="border:1px #CCCCCC solid"/></div><span class="link_o">'+nickname+'</span><b></b>';
        JIM('jiuaimai_user_info').style.display = 'none';
		JIM('jiuaimai_user_center').innerHTML= inner;
		
    } 
	catch(err) 
    {
    }	
	
	requestSvc('bookmarkJs', jiuaimai_getmsg_url+'&uid='+uid, 'callbackShowJiuaimaiUserMsg');
	setInterval(function(){requestSvc('bookmarkJs', jiuaimai_getmsg_url+'&uid='+uid, 'callbackShowJiuaimaiUserMsg');} , 60000);
	
}

function callbackShowJiuaimaiUserMsg(s) {
    
	JIM('jiuaimai_top_tip_body').innerHTML = '';
	var sJson = s.toString();
    eval("var oJson = " + sJson + ";");
    var res = oJson.status;

    if ('1' == res) 
	{
		if( oJson.at_new !=0 && oJson.at_new != null  )
		{
		    jiuaimai_add_tip('<a href="http://www.9imai.com/t/myat"><font color="red">'+oJson.at_new+'人@提到我</font>,查看详情</a>');
		}
		
		if( oJson.comment_new !=0 && oJson.comment_new != null  )
		{
		    jiuaimai_add_tip('<a href="http://www.9imai.com/t/mycomment"><font color="red">'+oJson.comment_new+'条新评论</font>,查看详情</a>');
		}
		
		if( oJson.fans_new !=0 && oJson.fans_new != null  )
		{
		    jiuaimai_add_tip('<a href="http://www.9imai.com/u/'+oJson.username+'/fans"><font color="red">'+oJson.fans_new+'人关注了我</font>,查看详情</a>');
		}
		
		if( oJson.favoritemy_new !=0 && oJson.favoritemy_new != null  )
		{
		    jiuaimai_add_tip('<a href="http://www.9imai.com/t/favoritemy"><font color="red">'+oJson.favoritemy_new+'人收藏了我</font>,查看详情</a>');
		}
		
		if( oJson.group_new !=0 && oJson.group_new != null  )
		{
		    jiuaimai_add_tip('<a href="http://www.9imai.com/t/newgroup"><font color="red">'+oJson.group_new+'条新主题回复</font>,查看详情</a>');
		}
        
		if( oJson.pmnum != 0 && oJson.pmnum != null)
		{
           jiuaimai_add_tip('<a href="http://my.9imai.com/?option=pm"><font color="red">'+oJson.pmnum+'条最新消息</font>,查看私信</a>');
		}
		
		if( oJson.annpm != 0 && oJson.annpm != null)
		{
           jiuaimai_add_tip('<a href="http://my.9imai.com/?option=pm&task=publicpm"><font color="red">'+oJson.annpm+'条公共消息</font>,查看信息</a>');
		}		
        
    } else {
      //  alert('error occured');
    }
}



function jiuaimai_add_tip( msg )
{
	JIM('jiuaiimai_top_tip').style.display='';
	JIM('jiuaimai_top_tip_body').innerHTML += '<div>'+msg+'</div>';
}

function jiuaimai_close_tip()
{
	requestSvc('bookmarkJs', jiuaimai_emptymsg_url+'&uid='+jiuaimai_uid, 'callbackShowJiuaimaiUserMsg')
	JIM('jiuaiimai_top_tip').style.display = 'none';
}


function callbackFunc(s) {}
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, '');
}
function requestSvc(id, url, funcName) {
    if (typeof(funcName) == 'undefined') {
        funcName = 'callbackFunc';
    }
    url += '&funcname=' + funcName;
    oScript = document.getElementById(id);
    var head = document.getElementsByTagName("head").item(0);
    if (oScript) {
        head.removeChild(oScript);
    }
    oScript = document.createElement("script");
    oScript.setAttribute("src", url);
    oScript.setAttribute("id", id);
    oScript.setAttribute("type", "text/javascript");
    oScript.setAttribute("language", "javascript");
    head.appendChild(oScript);
    return oScript;
}

 function JIM( id )
 {
	return  document.getElementById( id );
 }
 

 function jiuaimai_login()
 {
	 jiuaimai_popup('登录就爱买' , jiuaimai_mini_login , 655 , 300);
 }
 

 function jiuaimai_reg()
 {
	 jiuaimai_popup( '注册就爱买' , jiuaimai_mini_reg , 655 ,450 );
 }
 
 var qqLoginPop ;
 function jiuaimai_qq_login_pop()
 {
	 document.domain = '9imai.'+jiuaimai_domainext;
	 jiuaimai_popup_close();
     qqLoginPop=window.open( jiuaimai_qq_login , "用QQ账号登录","width=570,height=465,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1");	
	// return false;
 }
 
 function jiuaimai_sina_login_pop()
 {
	 jiuaimai_popup_close();
     jiuaimai_popup('用新浪微博登录',jiuaimai_sina_login, 600 , 400); 
	 return false;	 
 } 
 
 function jiuaimai_taobao_login_pop()
 {
	 jiuaimai_popup_close();
     jiuaimai_popup('用淘宝账号登录',jiuaimai_taobao_login, 500 , 520); 
	 JIM('jiuaimai_popup').style.top        = (getScrollTop()+getClientHeight()/2)-(520/2)+'px';
	 return false;	 
 }  
 
 function jiuaimai_qqlogin_succeed( url )
 {
	 qqLoginPop.close();
	 location.href= url;
	 document.domain =  jiuaimai_old_domain;
 }
 

 function jiuaimai_popup(title , url ,  width ,  height  )
 {
	 
	 
	document.domain = '9imai.'+jiuaimai_domainext;
	 
	JIM('jiuaimai_popup_bg').style.display = 'block';
	JIM('jiuaimai_popup_bg').style.height  = document.body.scrollHeight+'px';//getScrollTop()+getClientHeight()+'px';
	
	JIM('jiuaimai_popup_title').innerHTML = title;
	
	JIM('jiuaimai_popup').style.display    = 'block';
	JIM('jiuaimai_popup').style.top        = (getScrollTop()+getClientHeight()/2)-(300/2)+'px';
	JIM('jiuaimai_popup').style.width      =  width+'px';
	JIM('jiuaimai_popup').style.height     =  height+'px';
	JIM('jiuaimai_popup').style.marginLeft = '-'+width/2+'px';
	
	//JIM('jiuaimai_popup_body').innerHTML  = '<iframe scrolling="no" frameborder="0" width="'+width+'" height="'+(height-35)+'" src="http://image.9imai.com/www/top/loading.html" id="jiuaimai_popup_frame"></iframe>';
	//JIM('jiuaimai_popup_frame').src = url+'&domain='+document.domain+'&url='+escape(location.href);
	
    JIM('jiuaimai_popup_body').innerHTML  = '<div style="width:160px; margin:auto; margin-top:100px" id="jiuaimai_popup_load"><img src="http://image.9imai.com/www/top/loading.gif" /></div>';	
	
	var iframe = document.createElement("iframe");
	iframe.src = url+'&domain='+document.domain+'&url='+escape(location.href);
	iframe.style.display = 'none';
	iframe.width = width ;
	iframe.height = height-35;
	iframe.scrolling = 'no';
	iframe.frameBorder = 0;


	if (iframe.attachEvent){
		iframe.attachEvent("onload", function(){
			JIM('jiuaimai_popup_load').style.display='none';								  
			iframe.style.display = 'block';
		});
	} else {
		iframe.onload = function(){
			JIM('jiuaimai_popup_load').style.display='none';		
			iframe.style.display = 'block';
		};
	}
	
	JIM('jiuaimai_popup_body').appendChild(iframe);

	 window.onscroll = function()
	 {
		 JIM('jiuaimai_popup').style.top        = (getScrollTop()+getClientHeight()/2)-(300/2)+'px';
		 //JIM('jiuaimai_popup_bg').style.height  = getScrollTop()+getClientHeight()+'px';
	 }
 }
 

 function jiuaimai_login_succeed()
 {
	jiuaimai_popup_close();
	showJiuaimaiUserInfo();
	loginCallBack();
	document.domain =  jiuaimai_old_domain;
 }
 
 function loginCallBack()
 {
 }
 

 function jiuaimai_reg_succeed()
 {
	jiuaimai_popup_close();
	
	alert('注册成功，快去登入吧');
	
    document.domain =  jiuaimai_old_domain;

 }
 

 function jiuaimai_popup_close()
 {
	JIM('jiuaimai_popup_bg').style.display = 'none';
	JIM('jiuaimai_popup').style.display    = 'none';
	window.onscroll = function(){};
 }
 

function getClientHeight()
{
	var clientHeight=0;
	if(document.body.clientHeight&&document.documentElement.clientHeight)
	{
		var clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
	}
	else
	{
		var clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;    
	}
	return clientHeight;
}

function getScrollTop()
{
	var scrollTop=0;
	if(document.documentElement&&document.documentElement.scrollTop)
	{
		scrollTop=document.documentElement.scrollTop;
		
	}
	else if(document.body)
	{
		scrollTop=document.body.scrollTop;
	}
	return scrollTop;
}

function addBookmark(url, title) {
	try {
		window.external.AddFavorite(url, title);
		return false;
	} catch(e) {
		try {
			window.sidebar.addPanel(title, url, "");
			return false;
		} catch(err) {
			//alert('暂不支持此浏览器');
			return false;
		}
	}
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1 
		c_end=document.cookie.indexOf(";",c_start)
		if (c_end==-1) c_end=document.cookie.length
		return unescape(document.cookie.substring(c_start,c_end))
		} 
	  }
	return ""
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";domain=9imai."+jiuaimai_domainext)
}

//判断是否显示广告
function checkInvite()
{
	if( showAd() )
	{
		var invite_ad = getCookie('invite_ad');
	
		if (invite_ad==null || invite_ad=="")
		{
			JIM('invitead').style.display = '';
		}
	}
}

function showAd()
{
	return true;
}

///////////////获取推广信息/////////////////

//获取推广码
var recommend = getRecommendCode();
if( recommend != '' )
{
   setCookie('9imai_track_recommend' , recommend , 1);
}

var toUrl = getCookie( '9imai_track_tourl' );

if( toUrl == '' )
{
	//着陆URL
	var toUrl = location.href;
	setCookie('9imai_track_tourl' , toUrl , 1);  
	
	
	//来路URL
	var fromUrl=document.referrer;
	//保存来路URL
	if( fromUrl != '' && fromUrl != null  && fromUrl != 'undefined' )
	{
	  setCookie('9imai_track_fromurl' , fromUrl , 1);
	
	  //来路域名
	  var fromDomain = getHost( fromUrl );
	  setCookie('9imai_track_fromdomain' , fromDomain , 1);  
	  
	  saveSearch( fromUrl );
	  
	}

}

function saveSearch( url )
{
   
	 var google   = "google.com"; //q= utf8
	 var baidu    = "baidu.com"; //wd= gbk
	 var yahoo    = "yahoo.cn"; //q= utf8
	 var sogou    = "sogou.com"; //query= gbk
	 var soso     = "soso.com"; //w= gbk
	 var bing     = "bing.com"; //q= utf8
	 var youdao   = "youdao.com"; //q= utf8
	
	 var searchType = '';
	 var keyword    = '';
	 
	 if( url.match( baidu ) )
	 {
		searchType = 'baidu';
		keyword    =  request(url , 'wd');
		if( keyword == '' )
		{
			keyword    =  request(url , 'word');
		}		
	 }
	 else if ( url.match( google ) )
	 {
		searchType = 'google';
		keyword    =  request(url , 'q');
	 }
	 else if ( url.match( yahoo ) )
	 {
		searchType = 'yahoo';
		keyword    =  request(url , 'q');
	 }
	 else if ( url.match( sogou ) )
	 {
		searchType = 'sogou';
		keyword    =  request(url , 'query');
	 }
	 else if ( url.match( soso ) )
	 {
		searchType = 'soso';
		keyword    =  request(url , 'w');
	 }
	 else if ( url.match( bing ) )
	 {
		searchType = 'bing';
		keyword    =  request(url , 'q');
	 }
	 else if ( url.match( youdao ) )
	 {
		searchType = 'youdao';
		keyword    =  request(url , 'q');
	 }		 		 	 		 	 	 

	 setCookie('9imai_track_search' , searchType , 1);  
	 setCookie('9imai_track_keyword' , keyword , 1);  
}

//获取URL中的域名
function getHost(url) 
{
        var host = "null";
        if(typeof url == "undefined"
                        || null == url)
                url = window.location.href;
        var regex = /.*\:\/\/([^\/]*).*/;
        var match = url.match(regex);
        if(typeof match != "undefined" && null != match)
		{
            host = match[1];
		}
        return host;
}

//推广代码
function getRecommendCode()
{
    var recommend = '';
	
	var href = window.location.href.split("#");

	if (href.length==2) 
	{
		if (href[1].substring(0,1)!='_') 
		{
		   recommend = decodeURI(href[1]);
		  
		}
	}
	
	return recommend;	

}

function request( url ,  paras)
{ 
   var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
   var paraObj = {} 
   for (i=0; j=paraString[i]; i++){ 
     paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
   } 
   var returnValue = paraObj[paras.toLowerCase()]; 
   if(typeof(returnValue)=="undefined"){ 
     return ""; 
   }else{ 
      return returnValue; 
   } 
} 

////////////////////

