var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var is_safari = (userAgent.indexOf('webkit') != -1 || userAgent.indexOf('safari') != -1);
function location_url(url)
{
	window.location.href = url;
}
function D(ele)
{
    return document.getElementById(ele);
}
function strlen(str) 
{
	return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
function reallen(str)
{
	var register_strlength=0;
	for (i=0;i<str.length;i++)
	{
	 if (str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94)
	 {
	    register_strlength=register_strlength + 2;
	 }
	 else
	 {
	    register_strlength=register_strlength + 1;
	 }
	}
	return register_strlength;
}
function text_counter(obj, showid, maxlimit) {
	//var len = str_len(obj.value);
	var len = obj.value.length;
	var showobj = D(showid);
	if(len > maxlimit) {
		obj.value = get_strbylen(obj.value, maxlimit);
		showobj.innerHTML = '0';
	} else {
		//showobj.innerHTML = Math.ceil((maxlimit - len)/2);
		showobj.innerHTML =  maxlimit - len;
	}
	if(maxlimit - len > 0) {
		showobj.parentNode.style.color = "";
	} else {
		showobj.parentNode.style.color = "red";
	}
	
}
function get_strbylen(str, len) 
{
	var num = 0;
	var strlen = 0;
	var newstr = "";
	/*var obj_value_arr = str.split("");
	
	for(var i = 0; i < obj_value_arr.length; i ++) {
		if(i < len && num + byte_length(obj_value_arr[i]) <= len) {
			num += byte_length(obj_value_arr[i]);
			strlen = i + 1;
		}
	}
	*/
	strlen = str.length;
	if(str.length > len) {
		newstr = str.substr(0, len);
	} else {
		newstr = str;
	}
	return newstr;
}
function byte_length (sStr) 
{
	aMatch = sStr.match(/[^\x00-\x80]/g);
	return (sStr.length + (! aMatch ? 0 : aMatch.length));
}
function str_len(str) 
{
	return str.length
	/*
	var charset = document.charset; 
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == "utf-8" ? 3 : 2) : 1;
	}
	return len;
	*/
}
function isUndefined(variable) 
{
	return typeof variable == 'undefined' ? true : false;
}
function set_feed(feed_type, uid, touid, game)
{
    if(typeof touid == 'undefined')
    {
        touid = 0;
    }
    jQuery.ajax({
    		type:"POST",
    		url:'index.php?control=feed&action=hxm',
            data: 'feed_type='+ feed_type + '&uid='+ uid + '&touid='+touid + '&game='+game,
    		dataType: 'json',
    		success : function(msg){}
    		}
    	);
}
function set_notification(uid, touid, type, note)
{
    if(uid != '' && touid != '' && type != '' && note != '')
    {
        jQuery.ajax({
            type: "POST",
            url : "index.php?control=feed&action=note",
            data: "uid=" + uid + "&touid=" + touid + "&type="+ type + "&note="+escape(note),
            dateType : 'html',
            success: function(msg){}
        });
    }
}
var user_info = "";
var popUp = new Array();
popUp.push('   <div class="con" style="z-index:9;">');
popUp.push('     <div class="alert_title">');
popUp.push('	     <h5>{title}</h5>');
popUp.push('		 <span onclick="javascript:jQuery.closePopupLayer(\'myStaticPopup\');" title="關閉">X</span>');
popUp.push('		 </div>');
popUp.push('		    <div class="alert_sendmessage"><p>{contents}</p></div>');
popUp.push('		 </div>');
var popUpDiv = popUp.join('');
var popLogin = new Array();
popLogin.push('<style type="text/css">');
popLogin.push('input{margin:0;padding:0;}');
popLogin.push('.container{background:#232323;padding:105px 0 215px 0 ;width:1000px;margin:0 auto;}');
popLogin.push('.log_t{height:30px;background:url(/images/new/title/title_bg10.gif) 0 0 repeat-x;}');
popLogin.push('.loginto{width:337px;margin:0 auto;font-size:13px;background:#373737;}');
popLogin.push('.login_inpp{height:22px;padding-top:10px;width:284px;padding-left:43px;}');
popLogin.push('.login_inpp input{height:12px;padding:5px 0;width:198px;}');
popLogin.push('.login_inpp2{height:22px;padding-top:10px;padding-left:43px;}');
popLogin.push('.login_inpp2 input{margin-right:5px;}');
popLogin.push('.tright{text-align:right;maargin:0px;padding:0 10px 10px 0;}');
popLogin.push('.loginto p{padding:15px 0 0 43px;}');
popLogin.push('</style>');
popLogin.push('   <div class="loginto" style="z-index:9;">');
popLogin.push('      	<div class="alert_title">	<span onclick="javascript:jQuery.closePopupLayer(\'myStaticPopup\');" title="關閉">X</span></div>');
popLogin.push('	     <p>歡迎歡迎，您來了</p>');
popLogin.push('			   <div class="login_inpp">');
popLogin.push('				  <input type="text" name="pop_up_email" id="pop_up_email" value="請輸入郵箱地址" onclick="if(this.value==\'請輸入郵箱地址\'){this.value=\'\';}" onfocus="if(this.value==\'請輸入郵箱地址\'){this.value=\'\';}" onkeyup="document.getElementById(\'email\').value=this.value;" onblur="if(this.value==\'\'){this.value=\'請輸入郵箱地址\';}" onkeydown="enter_login(event, \'pop_up_email\',\'pop_up_user_password\');" class="n_login_inp" />');
popLogin.push('			   </div>');
popLogin.push('			   <div class="login_inpp">');
popLogin.push('				  <input type="password" name="pop_up_user_password" id="pop_up_user_password" value="请输入你的密码" onclick="if(this.value==\'请输入你的密码\'){this.value=\'\';}" onfocus="if(this.value==\'请输入你的密码\'){this.value=\'\';}" onkeyup="document.getElementById(\'user_password\').value=this.value;" onblur="if(this.value==\'\'){this.value=\'请输入你的密码\';}" onkeydown="enter_login(event, \'pop_up_email\',\'pop_up_user_password\');" class="n_login_inp"/>');
popLogin.push('			   </div>');
popLogin.push('			   <div class="login_inpp2">');
popLogin.push('			      <span><a href="javascript:login(\'pop_up_email\', \'pop_up_user_password\');"><img src="/images/new/btn/login1.gif"/></a></span>');
popLogin.push('				  <span><a href="javascript:ajax_url(\'/index.php?control=user&action=forgot\');"><img src="/images/new/btn/login2.gif"/></a></span>');
popLogin.push('			   </div>');
popLogin.push('	     <div class="tright"><a href="/index.php?control=user&action=register"><img src="/images/new/btn/login3.gif"/></a></div>');
popLogin.push('   </div>');
popLoginDiv = popLogin.join('');
function replacePopUp(msg)
{
    return  popUpDiv.replace('{contents}', msg.content).replace('{title}', msg.title);
}
function openStaticPopup(ext, msg, popUpDiv, isrefersh, tag)
{
	var hidden = document.createElement('DIV');
    if(msg.title != 'login')
    {
	    tmp_popUpDiv = replacePopUp(msg);
        //;popUpDiv.replace('{contents}', msg.content).replace('{title}', msg.title)
    }
    else
    {
        tmp_popUpDiv = popUpDiv;
    }
    var href=window.location.href;
    if(typeof tag != 'undefined')
	{
		if(href.indexOf(tag) == -1)
		{
			href = href + tag;
		}
	}
	jQuery.openPopupLayer({
	name: "myStaticPopup",
	width: 550,
	target: "myHiddenDiv"+ext,
    afterClose: function(){if (typeof isrefersh != 'undefined' && isrefersh == 1){window.location.href = href;}}
	});
    jQuery('#popupLayer_myStaticPopup').html(tmp_popUpDiv);
    if(typeof msg.title == 'undefined' || msg.title=='')
    {
    	jQuery('#new_pop_title').css({'height':'0px', 'line-height':'0px'});
    }
    fix_png();
}
function get_client_time()
{
    localtime=new Date();
    var cyear=localtime.getFullYear();
    var cmonth=localtime.getMonth()+1;
    var cdate=localtime.getDate();
    var chour=localtime.getHours();
    var cminu=localtime.getMinutes();
    var cseco=localtime.getSeconds();

    ccyear=add_zero(cyear);
    ccmonth=add_zero(cmonth);
    ccdate=add_zero(cdate);
    cchour=add_zero(chour);
    ccminu=add_zero(cminu);
    ccseco=add_zero(cseco);
    return ccyear+"-"+ccmonth+"-"+ccdate+" "+cchour+":"+ccminu+":"+ccseco;
}
function add_zero(num) 
{
    num=Math.floor(num);
    return ((num <= 9) ? ("0" + num) : num);
}
function login_by_send_mail(email)
{
	var url = "/index.php?control=user&action=retry_by_email_single&email=" + email;
	jQuery.ajax({
		type:"GET",
		url:url,
		dataType: 'html',
		success : function(msg){openStaticPopup('_login', {title:'', content: msg}, popUpDiv);}
		});
}
function login(email, user_password)
{  
	var rnd = Math.random();
	var email_val = jQuery('#'+email).attr('value');
	var user_password_val =  jQuery('#'+user_password).attr('value');
	var mailArray = email_val.split("@");
	var especial = {"gmail.com" : "http://mail.google.com", "hotmail.com" : "http://www.hotmail.com"};
	if(especial[mailArray[1]])
	{
		var url = especial[mailArray[1]];
	}
	else
	{
		var url = "http://mail." + mailArray[1];
	}
	var msg_array = {'-1':'用戶名或密碼為空', '-3':'你的帳號尚未啟用，<span class="text_link11"><a href="'+url+'" target="_blank">前往您的郵箱</a></span>。<span class="text_link11"><a href="javascript:;" onclick="login_by_send_mail(\''+email_val+'\');">重新發送郵件</a></span>', '1': '登入成功', '-2':'用戶名或密碼錯誤'};
	if(email_val == '' || email_val == '請輸入郵箱地址')
	{
		//jQuery('#'+email).focus();
	}
	else if(user_password_val == '' || user_password_val == '请输入你的密码')
	{
		//jQuery('#'+user_password).focus();
	}
	else
	{
		jQuery.ajax({
		 type: "POST",
		 url: "/index.php?control=user&action=login&time="+escape(get_client_time())+"&rnd=" + rnd,
		 data:   "email="+email_val+"&user_password="+user_password_val,
		 success: function(msg){var msg = eval(msg);if(msg == 1){$.closePopupLayer('myStaticPopup');change_user_info();}else{openStaticPopup('_login_msg', {title:'', content: msg_array[msg]}, popUpDiv);} } 
		});
	}
}
function cut_str(str, len)
{
	str_len = str.length;
	if(str_len > len)
	{
		return str.substr(0,len) + "..";
	}
	return str;
}
function logout()
{
	var rnd = Math.random();
	jQuery.ajax({
		 type: "POST",
		 url: "/index.php?control=user&action=logout&isAjax=1&rnd=" + rnd,
		 data: "",
		 success: function(msg){change_user_info();if(window.location.href.indexOf('control=user&action=modify') != -1){location.replace('/index.php');}} 
		});
}
function change_user_info()
{
	var uid = jQuery.cookie('goyeah_uid');
	var url = window.location.href;
	var reg = new RegExp("(\\?|&)btid=([^&]*)(&|$)","gi");  
    var matches = url.match(reg);
	if(matches != null && uid > 0 && matches[0].indexOf("btid=ip") != -1)
	{
		url = setUrlParam(url, 'btid', uid);
	}
    window.location.href = url;
}
function float_login()
{
	var user_name = jQuery.cookie('goyeah_user_name');
	var uid = jQuery.cookie('goyeah_uid');
	if(user_name == null && uid  == null)
	{
                jQuery.openPopupLayer({
        		name: "myStaticPopup",
        		width: 550,
        		target: "_ajax_div"
      	});
    	jQuery('#popupLayer_myStaticPopup').html(popLoginDiv);
    	fix_png();
    	return false;
	}
	else
	{
		return true;
	}		
}
function enter_login(event, email, user_password)
{
	if (event.keyCode == 13)
    {
        event.returnValue=false;
        event.cancel = true;
        login(email,user_password);;
    }
}
function find_password(forget_email, forget_code)
{	
	var email_exp = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/;
    var rnd = Math.random();
    var email = jQuery("#"+forget_email).attr("value");
    var code = jQuery("#"+forget_code).attr("value");
    if(email == '' || !email_exp.test(email))
    {
    	jQuery("#"+forget_email).focus();
    }
    else if(code == '')
    {
    	jQuery("#"+forget_code).focus();
    }
    else if(jQuery.cookie('code') != code.toUpperCase())
    {
    	jQuery("#"+forget_code).focus();
    }
    else
    {
	    jQuery.ajax(
	    {
	        type:"get",
	        url:"/index.php?control=user&action=send_password&email="+email+"&"+rnd,
	        date:"",
	        dateType:"html",
	        success:function(msg){
	                    jQuery.openPopupLayer({
	                    	name: "myStaticPopup",
	                    	width: 550,
	                    	target: "_ajax_div"
		              });
	                jQuery('#popupLayer_myStaticPopup').html(replacePopUp({title:'', content: msg}));
				    if(typeof msg.title == 'undefined' || msg.title=='')
				    {
				    	jQuery('#new_pop_title').css({'height':'0px', 'line-height':'0px'});
				    }
	                fix_png();
	        }
	    });
    }
}
function iframeAutoHeight(iframeid) {
   var obj=document.getElementById(iframeid); //iframe id
   if (document.getElementById){
       if (obj.contentDocument && obj.contentDocument.documentElement.offsetHeight){
            obj.height = obj.contentDocument.documentElement.offsetHeight+"px";
       }else if(obj.document && obj.contentWindow.document.documentElement){
            obj.height = obj.contentWindow.document.documentElement.scrollHeight+"px";
       }
   }
}
function ajax_iframe(url, width, height)
{
    var user_name = jQuery.cookie('goyeah_user_name');
	var uid = jQuery.cookie('goyeah_uid');
	if(user_name == null && uid  == null)
	{
        openStaticPopup('_login', {title:'login'}, popLoginDiv);
    }
    else
    {
        var rnd = Math.random();
        if(url.indexOf('?') != -1)
        {
               symbol = '&';
        }
        else
        {
             symbol = '?';
        }
        url = url + symbol + rnd;
        jQuery.openPopupLayer({
        	name: "myStaticPopup",
        	width: width,
            height : height,
        	target: "_ajax_div"
        });
        jQuery('#popupLayer_myStaticPopup').html("<iframe src='"+url+"' id='iframe_popup' width='"+width+"' height='"+height+"' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' onload='javascript:iframeAutoHeight(this.id);'></iframe>");
    }
}
function ajax_iframe_hide() {
	jQuery('#popupLayer_myStaticPopup').html('');
	jQuery.closePopupLayer("myStaticPopup");
}
function ajax_url(url)
{
    var rnd = Math.random();
    if(url.indexOf('?') != -1)
    {
           symbol = '&';
    }
    else
    {
         symbol = '?';
    }
    jQuery.ajax(
    {
        type:"get",
        url: url + symbol + 'rnd=' + rnd,
        data:"",
        dataType:"html",
        success:function(msg){
                    jQuery.openPopupLayer({
                    	name: "myStaticPopup",
                    	width: 550,
                    	target: "_ajax_div"
	              });
                jQuery('#popupLayer_myStaticPopup').html(msg);
                fix_png();
        }
    }
    );
}
function ajax_get(url, ele)
{
    if(url.indexOf('?') != -1)
    {
           symbol = '&';
    }
    else
    {
         symbol = '?';
    }
    jQuery.ajax(
    {
        type:"get",
        url: url + symbol,
        data:"",
        dataType:"json",
        success:function(msg){
                jQuery('#'+ele).html(msg['data']);
                jQuery('#page_'+msg['page_name']+'_box').html(msg['page']);
                //jQuery('#'+ele).html(msg);
                fix_png();
        }
    }
    );
}
function set_current_page(page, page_end, page_name, page_prev, page_next)
{
    jQuery('#page_box li > a').removeClass('current');
    jQuery('#page_'+page).addClass('current');
    if(page == 1)
    {
        jQuery('#ajax_'+page_name+'_prev').hide();
    }
    else
    {
        jQuery('#ajax_'+page_name+'_prev').show();
    }
    if(page_end == page)
    {
        jQuery('#ajax_'+page_name+'_next').hide();
    }
    else
    {
        jQuery('#ajax_'+page_name+'_next').show();
    }
    jQuery('#ajax_'+page_name+'_prev').attr('href', 'javascript:ajax_get(\'' + page_prev + '\')');
    jQuery('#ajax_'+page_name+'_next').attr('href', 'javascript:ajax_get(\'' + page_next + '\')');
}
function switch_comic(id, bool)
{
    if(bool === true)
    {
        jQuery('#play_' +id).show();
         jQuery('#mark_' +id).hide();
    }
    else
    {
         jQuery('#play_' +id).hide(); 
         jQuery('#mark_' +id).show();
    }
}
function setUrlParam(oldurl,paramname,pvalue){  
      var   reg   =   new   RegExp("(\\?|&)"+   paramname   +"=([^&]*)(&|$)","gi");  
      var   pst=oldurl.match(reg);  
      if((pst==undefined)   ||   (pst==null)){ 
		return   oldurl+((oldurl.indexOf("?")==-1)?"?":"&")+paramname+"="+pvalue;  
	  }
      var   t=pst[0];  
      var   retxt=t.substring(0,t.indexOf("=")+1)+pvalue;  
      if(t.charAt(t.length-1)=='&')   retxt+="&";  
      return   oldurl.replace(reg,retxt);  
}
function page_options(url, page_count, div, page_number, page_name)
{
	if(typeof page_name == 'undefined')
	{
		page_name = 'page';
	}
	if(page_count)
	{
		var page = new Array();
		page.push("<ul>");
		for(i = 1; i <= page_count; i++)
		{
			page.push("<li style='margin-left:8px;'><a href="+setUrlParam("/" + url, page_name, i)+">"+i+"</a></li>");
		}
		page.push("</ul>");
		jQuery("#"+div).html(page.join(""));
		if(jQuery("#"+div).css('display') == 'none')
		{
			jQuery("#"+div).show();
		}
		else
		{
			jQuery("#"+div).hide();
		}
	}
	
	jQuery(document).bind('click', function(){	jQuery("#" + div).css('display', 'none');});
}
function eiser_track(s, page_id, title)
{
	/*try
	{
		url = eiser_tracking_sys.eiser_server + eiser_tracking_sys.eiser_interface + "&idsite=1&eiser_ext="+ encodeURIComponent("s="+s+"|page_id="+page_id+"|title="+title);
		document.getElementById('_hidden_form').src = url;
	}catch(e){}*/
}
function fix_png()
{
	var pic_space="images/header/blank.gif";
	if(jQuery.browser.msie && jQuery.browser.version=="6.0")
	{
		jQuery("img[src*=png]").each(function(){
			var s=this.src;
			var iWidth=this.width;
			var iHeight=this.height;
			this.src=pic_space;
			this.width=iWidth;
			this.height=iHeight;
			this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+s+", sizingmethod=scale)";
		});
	}
}
function show_play_ico(id, show)
{
	if(show)
	{
		jQuery('#'+id).show();
	}
	else
	{
		jQuery('#'+id).hide();
	}
}
jQuery(document).ready(function(){
var movieArray= [];
//电影
movieArray['index'] 		= '電影名稱、導演、演員、分類等';
movieArray['category'] 		= '電影名稱、導演、演員、分類等';
movieArray['play'] 			= '電影名稱、導演、演員、分類等';
movieArray['detail'] 		= '電影名稱、導演、演員、分類等';
movieArray['movie'] 		= '電影名稱、導演、演員、分類等';
//短片
movieArray['short'] 		= '視頻名稱、標籤等';
//yeahtv
movieArray['yeahtv'] 		= '視頻名稱、主持、標籤等';
//动漫
movieArray['cartoon'] 		= '動漫名稱、導演、標籤等';
//分享网址
movieArray['urlshare']		= '網站名字、標籤等';

//日誌分享和日誌一樣
movieArray['blog'] 			= '日誌標題、內容等';
movieArray['blogshare'] 	= '日誌標題、內容等';
//相冊分享和相冊一樣
movieArray['album'] 		= '相簿名、相片介紹等';
movieArray['albumshare']	= '相簿名、相片介紹等';
//星掌门
movieArray['staractivity'] 	= '明星名字等';
movieArray['star'] 			= '明星名字等';
movieArray['star2'] 		= '明星名字等';
//群組相關頁
movieArray['snsgroup'] 		= '群組名稱、簡介、話題等';
movieArray['groupshare'] 	= '群組名稱、簡介、話題等';
//群組相關頁
movieArray['game'] 			= '遊戲名稱、簡介、相關明星等';
movieArray['game_raider'] 	= '遊戲名稱、簡介、相關明星等';
movieArray['flashgame']		= '遊戲名稱、簡介、相關明星等';
//活动
movieArray['activity'] 		= '活動名稱、介紹等';
//分享视频
movieArray['videoshare'] 	= '視頻名稱、標籤等';
//收藏、記錄、好友、消息 
movieArray['favorite'] 		= '全站搜索功能已經提供';
movieArray['doing'] 		= '全站搜索功能已經提供';
movieArray['friend'] 		= '全站搜索功能已經提供';
movieArray['invite'] 		= '全站搜索功能已經提供';
movieArray['pm'] 			= '全站搜索功能已經提供';
movieArray['notice'] 		= '全站搜索功能已經提供';


var keywords_t = jQuery('#keywords').attr('keywords_t');
//alert(movieArray[keywords_t]);
var keywords_show=movieArray[keywords_t];
if(keywords_show==null || keywords_show==''){
		keywords_show='全站搜索功能已經提供';
	}
	
var   regu   =   "/ecomm/";     
var   re   =   new   RegExp(regu);     
   if   (window.location.href.search(re)   !=   -1)      
    {     
          keywords_show='產品名稱、簡介等';  
    }     
      
	
	
   jQuery("#keywords").Watermark(keywords_show,"#999");
   
	jQuery('#search_form').bind("submit",{},gy_syncActivity);
	function gy_syncActivity(){
//		alert("sfsfsfs");
		var taValue = jQuery('#keywords').val();
		if(taValue!=keywords_show){
			taValue = taValue.replace(/(^\s*)/g,"");
			 var len = taValue.replace(/[^\x00-\xff]/g, 'xx').length;
			if (len > 60) { 
				openStaticPopup('searchd_id',{title:'', content: '搜索的關鍵字太長了，請縮短後再試。'});
				return false;
			}
			if(len<=0){
				openStaticPopup('searchd_id',{title:'', content: '請輸入關鍵字再查詢！'});
				return false;
			}
		}else{
				openStaticPopup('searchd_id',{title:'', content: '請輸入關鍵字再查詢！'});
				return false;
			}
	}     
});

function intval(v) {
    v = parseInt(v);
    return isNaN(v) ? 0 : v;
}
// 获取元素信息
function getPos(e) {
    var l = 0;
    var t = 0;
    var w = intval(e.style.width);
    var h = intval(e.style.height);
    var wb = e.offsetWidth;
    var hb = e.offsetHeight;
    while (e.offsetParent) {
        l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);
        t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);
        e = e.offsetParent;
    }
    l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);
    t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);
    return {
        x: l,
        y: t,
        w: w,
        h: h,
        wb: wb,
        hb: hb
    };
}

// 获取滚动条信息
function getScroll() {
    var t, l, w, h;
    if (document.documentElement && document.documentElement.scrollTop) {
        t = document.documentElement.scrollTop;
        l = document.documentElement.scrollLeft;
        w = document.documentElement.scrollWidth;
        h = document.documentElement.scrollHeight;
    } else if (document.body) {
        t = document.body.scrollTop;
        l = document.body.scrollLeft;
        w = document.body.scrollWidth;
        h = document.body.scrollHeight;
    }
    return {
        t: t,
        l: l,
        w: w,
        h: h
    };
}
// 锚点(Anchor)间平滑跳转 
function scrollAnchor(el, duration) {
    if (typeof el != 'object') {
        el = document.getElementById(el);
    }
    if (!el) return;
    var z = this;
    z.el = el;
    z.p = getPos(el);
    z.s = getScroll();
    z.clear = function() {
        window.clearInterval(z.timer);
        z.timer = null
    };
    z.t = (new Date).getTime();
    z.step = function() {
        var t = (new Date).getTime();
        var p = (t - z.t) / duration;
        if (t >= duration + z.t) {
            z.clear();
            window.setTimeout(function() {
                z.scroll(z.p.y, z.p.x)
            },
            13);
        } else {
            st = (( - Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t;
            sl = (( - Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l;
            z.scroll(st, sl);
        }
    };
    z.scroll = function(t, l) {
        window.scrollTo(l, t)
    };
    z.timer = window.setInterval(function() {
        z.step();
    },
    13);
}

(function($) {
	var map=new Array();
	$.Watermark = {
		ShowAll:function(){
			for (var i=0;i<map.length;i++){
				if(map[i].obj.val()==""){
					map[i].obj.val(map[i].text);					
					map[i].obj.css("color",map[i].WatermarkColor);
				}else{
				    map[i].obj.css("color",map[i].DefaultColor);
				}
			}
		},
		HideAll:function(){
			for (var i=0;i<map.length;i++){
				if(map[i].obj.val()==map[i].text)
					map[i].obj.val("");					
			}
		}
	}
	
	$.fn.Watermark = function(text,color) {
		if(!color)
			color="#aaa";
		return this.each(
			function(){		
				var input=$(this);
				var defaultColor=input.css("color");
				map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
				function clearMessage(){
					if(input.val()==text)
						input.val("");
					input.css("color",defaultColor);
				}

				function insertMessage(){
					if(input.val().length==0 || input.val()==text){
						input.val(text);
						input.css("color",color);	
					}else
						input.css("color",defaultColor);				
				}

				input.focus(clearMessage);
				input.blur(insertMessage);								
				input.change(insertMessage);
				
				insertMessage();
			}
		);
	};
})(jQuery);

//check pm
function checkPM()
{
	jQuery.ajax(
	    {
	        type:"get",
	        url:"/sns/space.php?do=checkpm&rnd=" + Math.random(),
	        date:"",
	        dateType: "json",
	        success:function(msg){
	        		   if(msg)
	        		   {
							jQuery('#ajax_newpm').html(msg);
							if(msg*1== 0){
							jQuery('#head_num').css('display','none');
							jQuery('#ajax_newpm').css('color','#2D2D2D');
							}else{
								jQuery('#ajax_newpm').css('color','red');
								jQuery('#head_num').html(msg);
								jQuery('#head_num').css('display','block');
							}
							
	                   }
	                   else
	                   {
							jQuery('#head_num').css('display','none');
	                   		jQuery('#ajax_newpm').html(0);
	                   		jQuery('#ajax_newpm').css('color','#2D2D2D');
	                   }
	    			   setTimeout(checkPM, 60000);
	        }
	    });
}
//checkMSG();
jQuery(document).ready(function(){
	checkPM();
});
