var IS_LOGIN = "您还未登录，现在登陆吗？";
var IS_DEL = "是否删除？";
var IS_DEBUG = false;
var HIDDEN_ERROR = false;
IE4 = (document.all) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
ver4 = (IE4 || NS4) ? 1 : 0;
var IE = (navigator.userAgent.indexOf('MSIE ') != -1);
var IE6 = (navigator.userAgent.indexOf('MSIE 6.0') != -1);
var IE7 = (navigator.userAgent.indexOf('MSIE 7.0') != -1);
var FF = (navigator.userAgent.indexOf('Firefox/') != -1);
var FF2 = (navigator.userAgent.indexOf('Firefox/2.0') != -1);
var OPERA = (navigator.userAgent.indexOf('Opera') >= 0);
var DOMAIN = "http://"+document.domain+"/";
function keyDownSubmitLogin(event)
{
    if (eventKeyCode(event) == 13)
        submitForm();
}

function displayElement(divId)
{//切换标签是否显示
	
    var this_div = document.getElementById(divId);
	if ("none" == this_div.style.display)
		this_div.style.display = "block";
	else
		this_div.style.display = "none";
}

function showMe(elementTag)
{//显示标签
	elementTag.style.display = "block";
}

function hiddenMe(elementTag)
{//隐藏标签
	elementTag.style.display = "none";
}

function trimPx(px_value)
{//去掉宽和高的PX
    if (px_value == "") 
    	return 0;
    else
	    return parseFloat(px_value.substring(0, px_value.length - 2));
}

function getEventX(event)
{//当前鼠标所在位置的X值
	if (IE4)
		return window.event.clientX;
	else
		return event.clientX;
}

function getEventY(event)
{//当前鼠标所在的位置的Y值
	if (IE4)
		return window.event.clientY;
	else
		return event.clientY;
}

function getEventElementId(event)
{//当前鼠标所在的位置标签的ID
	if (IE4)
		return window.event.srcElement.id;
	else
		return event.target.id;
}
function eventKeyCode(event)
{//按键值
	return event.keyCode;
}

function closeThis(tagId)
{//不显示这个ID的东西
	var obj = document.getElementById(tagId);
	obj.style.display = "none";
}
function removeThis(tagId)
{
	var obj = document.getElementById(tagId);
	obj.parentNode.removeChild(obj);
}

function goBack()
{
	window.history.back();
}

function imgOver(tag , url)
{
	tag.src = url;
}

function changeApp(tagId , imageId)
{
    var tagId = document.getElementById(tagId);
    var chageImageId = document.getElementById(imageId);
    if("none" == tagId.style.display)
    {
        tagId.style.display = "block";
        chageImageId.src = image_up; 
    }
    else
    {
        tagId.style.display = "none";
        chageImageId.src = image_down; 
    }
}

function hiddenUserMenuList(eventDiv)
{    
    var chageImageId = document.getElementById("changeImageId");
    if(eventDiv.style.display == "block")
    {
       var changeTime = setTimeout(function(){eventDiv.style.display = "none";chageImageId.src = image_down;},10000);
    }
}

function showUserMenuList(eventDiv)
{   
    var chageImageId = document.getElementById("changeImageId");
    if(eventDiv.style.display == "block")
    {           
        clearTimeout(changeTime);
        chageImageId.src = image_up; 
    }
}

function changeDiv(thisButton , thisContentId)
{
    /************设置按钮***********************************/
	var brotherButton = thisButton.parentNode.getElementsByTagName("li");
	try{
		for (var i = 0; i < brotherButton.length; i++)
		{
			if (brotherButton[i].id == thisButton.id)
			{
				brotherButton[i].className = "tabtitleactive";
				brotherButton[i].onmouseover = function(){};
				brotherButton[i].onmouseout = function(){};
			}
			else
			{
				brotherButton[i].className = "tabtitlehidden";
                brotherButton[i].onmouseover = function() {this.className = 'tabtitlemover'};
                brotherButton[i].onmouseout = function() {this.className = 'tabtitlehidden'};
			}
			
		}
	}
	catch(e){}
	/***************************************内容**********************************/
	var brotherContent = document.getElementById(thisContentId).parentNode.getElementsByTagName("div");
	try{
		for(var i=0; i < brotherContent.length; i++)
		{
			if ("listactive" == brotherContent[i].className || "listhidden" == brotherContent[i].className)
			{
				if (brotherContent[i].id == thisContentId)
				{
					brotherContent[i].className = "listactive";
				}
				else
				{
					brotherContent[i].className = "listhidden";
				}
			}
		}
	}
	catch(e){}
}

function backDiv(thisContactId , thisContentId)
{
	/************设置按钮***********************************/
	var brotherButton = document.getElementById(thisContactId).parentNode.getElementsByTagName("li");
	try{
		for (var i = 0; i < brotherButton.length; i++)
		{
			if (brotherButton[i].id == thisContactId)
			{
				brotherButton[i].className = "tabtitleactive";
				brotherButton[i].onmouseover = function(){};
				brotherButton[i].onmouseout = function(){};
			}
			else
			{
				brotherButton[i].className = "tabtitlehidden";
				brotherButton[i].onmouseover = function(){this.className = "tabtitlemover"};
				brotherButton[i].onmouseout = function(){this.className = "tabtitlehidden"};
			}
			
		}
	}
	catch(e){}
	/***************************************内容**********************************/
	var brotherContent = document.getElementById(thisContentId).parentNode.getElementsByTagName("div");
	try{
		for(var i=0; i < brotherContent.length; i++)
		{
			if ("listactive" == brotherContent[i].className || "listhidden" == brotherContent[i].className)
			{
				if (brotherContent[i].id == thisContentId)
				{
					brotherContent[i].className = "listactive";
				}
				else
				{
					brotherContent[i].className = "listhidden";
				}
			}
		}
	}
	catch(e){}
}


function get(ID)
{
	return document.getElementById(ID);
}

//图片等比收缩
function DrawImage(ImgD,width,height)
{  
       var  image=new Image();  
       image.src=ImgD.src;  
       height += 800;
       if(image.width>0 && image.height>0)
       {  
         if(image.width/image.height>= width/height)
         {  
           if(image.width>width)
           {      
           		ImgD.width=width;  
           		ImgD.height=(image.height*width)/image.width;  
           }
           else
           {  
           		ImgD.width=image.width;      
           		ImgD.height=image.height;  
           }  
         }  
         else
         {  
           if(image.height>height)
           {
           		ImgD.height=height;  
           		ImgD.width=(image.width*height)/image.height;            
           }
           else
           {  
           		ImgD.width=image.width;      
           		ImgD.height=image.height;  
           }  
         }  
     } 
}
/***********判断请求信息************/
function matchEmail(email)
{//判断Email格式是否正确
	//var emailPattern =  /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;  
	var emailPattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if (emailPattern.test(email)==false)
		return false;
	else
		return true;	
}

function checkEmail()
{
    var email = document.getElementById("email");
    var err_email = document.getElementById("err_email");
    if (!matchEmail(email.value))
    {
        err_email.style.display = "block";
        err_email.innerHTML = "E-mail格式不正确！";
    }
    else
    {
        err_email.innerHTML = "";
    }
}

function checkPassword()
{
     var password = document.getElementById("password");
     var err_password = document.getElementById("err_password");
     if (1>password.value.length || password.value.length>16)
     {
         err_password.style.display = "block";
         err_password.innerHTML = "密码长度为1到16位！";
     }
     else
     {
         err_password.innerHTML = "";
     }
}

/******added by kevin*****/
function popDiv(elementID , divW , divH)
{//弹出层
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight;
    var alpha_hidden_div = document.getElementById("alpha_hidden_div");
	if(alpha_hidden_div)
	{
		document.getElementById("alpha_hidden_div").style.display = "block";
	}
	else
	{
		var bgObj = document.createElement("div");
		bgObj.id = "alpha_hidden_div"; 
		bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=10);background-color:#ffffff;opacity:0.3;z-index:900;";
		document.body.appendChild(bgObj);
	}
	
	var popdiv_parent = document.getElementById(elementID);
	
	var dde = document.documentElement;
    if (window.innerWidth) 
    {
	      var ww = window.innerWidth;
	      var wh = window.innerHeight;
	      var bgX = window.pageXOffset;
	      var bgY = window.pageYOffset;
    } 
    else
    {
	      var ww = dde.offsetWidth;
	      var wh = dde.offsetHeight;
	      var bgX = dde.scrollLeft;
	      var bgY = dde.scrollTop;
    }    
    var t_DiglogX = (bgX + ((ww - divW)/2));
    var t_DiglogY = (bgY + ((wh - divH)/2)); 

	popdiv_parent.style.top = t_DiglogY + "px";
	popdiv_parent.style.left = t_DiglogX + "px";
	
	popdiv_parent.style.display = "block";
}


/*******************************/

/**********add by zjt***********************/
function headSearchFormSubmit(type)
{
    //var formobj=get('sform');
    var keyobj=get('searchConId');
    var mobj=get("allm");
    var aobj=get("alla");
    var stobj=get("allst");
    var stypeobj=get('allstype');
    var searchTypeobj=get('searchType');
    for(var i=0; i<document.forms["sform"]['searchType'].length; i++)
    {
        if(document.forms["sform"]['searchType'][i].checked)
            type = document.forms["sform"]['searchType'][i].value
    }
    //document.forms["sform"]['searchType'][1].value);
    if("Hy" == type)
    {
        keyobj.name="search_key";
        mobj.name="m";
        aobj.name="a";
        mobj.value="search";
        aobj.value="user";
    }
    else if("Ht" == type)
    { 
        keyobj.name="sf";
        mobj.name="m";
        aobj.name="a";
        mobj.value="search";
        aobj.value="comment";
        stypeobj.name='stype';
        stypeobj.value='thread';
        //stobj.name="st";
        //stobj.value="ht"
    }
    else if("Fx" == type)
    {
        keyobj.name="sf";
        mobj.name="m";
        aobj.name="a";
        mobj.value="search";
        aobj.value="comment";
        stypeobj.name='stype';
        stypeobj.value='comment';
        //stobj.name="st";

    }
    else if("club" == type)
    {
        keyobj.name="sf";
        mobj.name="m";
        aobj.name="a";
        mobj.value="search";
        aobj.value="comment";
        stypeobj.name='stype';
        stypeobj.value='club';
        //stobj.name="st";
        //stobj.value="bl"
    
    }
    else if("brand" == type  || "active" == type || "movie" == type || "music" == type || "book" == type )
    {
       keyobj.name="sf";
       mobj.name="m";
       aobj.name="a";
       mobj.value="search";
       aobj.value="source";
       stypeobj.name="stype";
       stypeobj.value= type;
    }
    else
    {
        keyobj.name="tag";
        mobj.name="m";
        aobj.name="a";
        mobj.value="search";
        aobj.value="index";
        stypeobj.name="stype";
        stypeobj.value="All";
        document.forms["sform"].submit();
    }
    removeThis('allst');
    document.forms["sform"].submit();
}
function hidesearchFormDiv()
{
    get('headSearchDiv').style.display="none";
}
//yh 于2008-06-26 17：43
  function bookmark(metroer_link)
	{if (document.all)
	//检查浏览器是否为IE，如果是，则执行下面的语句
	window.external.AddFavorite(metroer_link, "METROER都市客");
	//调用AddFavorite（）函数，把网站加入到收藏夹里
	}

//add by finn
function noBgGroudDiv(elementID , divW , divH)
{//弹出层
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight;
    var alpha_hidden_div = document.getElementById("alpha_hidden_div");
	if(alpha_hidden_div)
	{
		document.getElementById("alpha_hidden_div").style.display = "block";
	}
	else
	{
		var bgObj = document.createElement("div");
		bgObj.id = "alpha_hidden_div"; 
		bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;z-index:900;";
		document.body.appendChild(bgObj);
	}
	
	var popdiv_parent = document.getElementById(elementID);
	
	var dde = document.documentElement;
    if (window.innerWidth) 
    {
	      var ww = window.innerWidth;
	      var wh = window.innerHeight;
	      var bgX = window.pageXOffset;
	      var bgY = window.pageYOffset;
    } 
    else
    {
	      var ww = dde.offsetWidth;
	      var wh = dde.offsetHeight;
	      var bgX = dde.scrollLeft;
	      var bgY = dde.scrollTop;
    }    
    var t_DiglogX = (bgX + ((ww - divW)/2));
    var t_DiglogY = (bgY + ((wh - divH)/2)); 

	popdiv_parent.style.top = t_DiglogY + "px";
	popdiv_parent.style.left = t_DiglogX + "px";
	
	popdiv_parent.style.display = "block";
}

/*********************浮动广告********************************/
function loadFloat()
{
	judgeFloat();
	moveFloat();
}
function moveFloat() 
{
	judgeFloat();
	setTimeout("moveFloat();",80);
}
function judgeFloat()
{
	//取当前滚动的高度
	var scrollTop = document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
	//取当前客户端的分辨率
	if (NS)
	{
		var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight;
		var clientWidth = (document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth;
	}
	if (IE)
	{
		var clientHeight = (document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight;
		var clientWidth = (document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth;
	}
	//如果有左边广告设置广告位置
	if (adLeftDiv != "") 
	{
		adLeftDiv.style.top =  scrollTop + marginTop + 'px';
		adLeftDiv.style.left = marginLeft + 'px';
	}
	//如果有右边广告设置广告位置
	if (adRightDiv != "") 
	{
		adRightDiv.style.top =  scrollTop + marginTop + 'px';
		adRightDiv.style.left = clientWidth - adWidth - marginLeft + 'px';
	}
	//如果有底部右边广告位置
	if ("" != adFootRightDiv)
	{
		adFootRightDiv.style.top = scrollTop + clientHeight - 26 - marginFoot + 'px';
		adFootRightDiv.style.left = clientWidth - adWidth - 280 - marginLeft + 'px';
	}
	
	//如果有右边中间广告位置
	if (adMiddleDiv != "") 
	{
		adMiddleDiv.style.top =  scrollTop + clientHeight/2 + 'px';
		adMiddleDiv.style.left = clientWidth - adWidth - 36 - marginLeft + 'px';
	}
}
/*********************浮动广告END********************************/

function confirmJoinClub(hasLogin , cid , reUrl)
{
    if (confirm("您不是此部落成员，不能发表或回复话题。点击确定加入部落！"))
    {
        joinClub2(hasLogin  ,cid , reUrl);
    }
    else
    {
        return false;
    }
}
function joinClub2(hasLogin , cid , reUrl)
{
	if (hasLogin == "1")
	{
		$.post('index.php?m=club&a=validate' , {'type' : 'joinClub' , 'club_id' : cid }, function(data) {
			if (data == 0)
			{
				//
                alert("您已经加入了这个部落！");
			}
			else if (data == 1)
			{
                if ("" != reUrl)
                    window.location.href=reUrl;
			}
		});
	}
	else if (hasLogin == "0")
	{
		$("#err_tempLoginForm").html("");
		joinClubPanel();
	}	
}
function joinClub(hasLogin , cid)
{
	if (hasLogin == "1")
	{
		$.post('index.php?m=club&a=validate' , {'type' : 'joinClub' , 'club_id' : cid }, function(data) {
			if (data == 0)
			{
				//
                alert("您已经加入了这个部落！");
			}
			else if (data == 1)
			{
				window.location.reload();
			}
		});
	}
	else if (hasLogin == "0")
	{
		$("#err_tempLoginForm").html("");
		joinClubPanel();
	}	
}
function person_menu(id1,id2)
{
    var menuobj=get(id1);
    var imgobj=get(id2);
    if(menuobj.className == "none")
    {
        menuobj.className="normal";
        imgobj.src=image_up;
    }
    else
    {
        menuobj.className="none";
        imgobj.src=image_down;
    }
    

}
function showDiv(k, j, num)
{
    for(var i=0; i<num; i++)
    {
        var ui_id = "toupiao_" + k + i;
        var p_id = "tp_aniu_" + k + i;
        var this_ul = document.getElementById(ui_id);
        var this_p = document.getElementById(p_id);
        if(i == j)
        {
            this_ul.style.display = "block";
            this_p.style.display = "block";
        }
        else
        {
            this_ul.style.display = "none";
            this_p.style.display = "none";
        }

    }

}
/*************************置顶富媒体广告***************************************************/
  var time_out = 8000;
  function log_start()
  {
  document.getElementById("miman").style.visibility="visible";
  window.setTimeout( "real_log_start()", time_out ); 
  return false;
  }
  function real_log_start()
  {
	  document.getElementById("miman").style.display="none";
	  if(document.getElementById("adMiddleDiv"))
	  	document.getElementById("adMiddleDiv").style.display="block";
  }
  /*************************置顶富媒体广告END***************************************************/
