/**
 * 页面导航条js类
 * @copyright      (C), 2006, yima. Co., Ltd.
 * @Author         dora(邝达峰)
 * @email          dorowork@163.com  
 * @Version        1.0     
*/
var nowHostname=document.location.hostname;
nowHostname2=nowHostname.split('.')
if(isNaN(nowHostname2[0]) && nowHostname2[0]!='www')
{
	nowHostname='www.boogu.com';
}else
{
	nowHostname=nowHostname;
}
var navBarWebRoot='http://'+nowHostname+'/';
var navBar =
{
	init:function()//初始化函数
	{	
		this.getNowCityName();
	},
	cleanSearchText:function ()//清理输入框的值
	{
	  var searchText = document.getElementById("page_focus");	
	  if(searchText.value == '')
	  {
		 searchText.value = searchText.title
		 return false;
	  }    
    },
	showSearchMenu:function()//显示搜索菜单
	{
		var searchDownImage = document.getElementById("searchDownImage");
		var searchMenu = document.getElementById("popH2");
		searchMenu.style.display="inline";
		searchDownImage.src=navBarWebRoot+"images/navBar/search_up.gif";
	},
	hideSearchMenu:function()//隐藏搜索菜单
	{
		var searchDownImage = document.getElementById("searchDownImage");
		var searchMenu = document.getElementById("popH2");
		searchMenu.style.display="none";
		searchDownImage.src=navBarWebRoot+"images/navBar/search.gif";
	},
	showUserMenu:function()//显示用户菜单
	{
	    var userMenu = document.getElementById("popH");
		userMenu.style.display="inline";
		var userMemuImage = document.getElementById("userMemuImage");
		userMemuImage.src=navBarWebRoot+"images/navBar/arrow2.gif";
	},
	hideUserMenu:function()//显示用户菜单
	{
		var userMenu = document.getElementById("popH");
		userMenu.style.display="none";
		var userMemuImage = document.getElementById("userMemuImage");
		userMemuImage.src=navBarWebRoot+"images/navBar/arrow.gif";
	}, 
	showGotoMenu:function()//显示我要去菜单
	{
		var gotoMenu = document.getElementById("gotoMenu");
		gotoMenu.style.display="inline";
	},
	hideGotoMenu:function()//隐藏示我要去菜单
	{
		var gotoMenu = document.getElementById("gotoMenu");
		gotoMenu.style.display="none";
	},
	selectSearchOption:function(sDoValue,opValue,voValue)
	{
		var sDo = document.getElementById("sDo");
		var op = document.getElementById("op");
		var co = document.getElementById("co");
		sDo.value=sDoValue;
		op.value=opValue;
		co.value=voValue;
		this.hideSearchMenu();
		this.submitSearch();
	},
	submitSearch:function()
	{
		var searchForm = document.getElementById("searchForm");
		searchForm.submit();
	},
	getNowCityName:function()
	{
		var time = 	new Date().getTime();
		var rand = Math.round(Math.random() * 10000);
		var tUrl=navBarWebRoot+"index.html";
		var pars="module=business&action=cityCut&do=nowCityName&r="+rand+time;
		this.ajaxRequest(tUrl,pars,'get',true);
	},
	ajaxRequest:function(url,pars,method,asynchronous)  
    {
         var xmlHttp;  
         if(window.ActiveXObject)  
            {  
                try  
                {  
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");  
                }  
                catch(e)  
                {  
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
                }  
            }
            else if(window.XMLHttpRequest)  
            {  
                xmlHttp = new XMLHttpRequest();  
            }    
          
            if(method.toLowerCase() == "get")  
            {  
                url = url+"?"+pars;  
                xmlHttp.open("GET",url,asynchronous);  
                xmlHttp.send(null);  
            }else{  
                xmlHttp.open("POST",url,asynchronous);
                xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
                xmlHttp.send(pars);  
            }
            
			
			xmlHttp.onreadystatechange = function()  
            {
                if(xmlHttp.readyState == 4 && xmlHttp.status == 200)  
                {   
				    var noeCityName=xmlHttp.responseText;
				    var cityHome=document.getElementById("cityHome");
				    cityHome.title='浏览'+noeCityName+'所有家';
				    var cityCm=document.getElementById("cityCm");
				    cityCm.title='浏览'+noeCityName+'所有小区圈';
				    var cityBc=document.getElementById("cityBc");
				    cityBc.title='浏览'+noeCityName+'所有片区圈';
				    var cityShop=document.getElementById("cityShop");
				    cityShop.title='浏览'+noeCityName+'所有商铺';	
                }  
            }
			
      }	
}
navBar.init();
//弹出短消息中心
function pmwin(action, param) {
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.body.clientWidth;
		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		var pmwidth = 800;
		var pmheight = clientHeight * 0.9;
		if(!$('pmlayer')) {
			div = document.createElement('div');div.id = 'pmlayer';
			div.style.width = pmwidth + 'px';
			div.style.height = pmheight + 'px';
			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.zIndex = '999';
			$('append_parent').appendChild(div);
			$('pmlayer').innerHTML = '<div style="width: 800px; background: #666666; margin: 5px auto; text-align: left">' +
				'<div style="width: 800px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 1px solid #7597B8; position: relative; left: -6px; top: -3px" freedrag="yes">' +
				'<div onmousedown="drag(event||window.event)" style="cursor: move; position: relative; left: 0px; top: 0px; width: 800px; height: 30px; margin-bottom: -30px;"></div>' +
				'<a style="text-decoration:none" href="###" onclick="pmwin(\'close\')"><font style="position: absolute; right: 20px; top: 10px; font-size:14px; cursor:pointer;color:#000000;"><b>×</b></font></a>' +
				'<div id="pmwinmask" style="margin-top: 30px; position: absolute; width: 100%; height: 100%; display: none"></div><iframe id="pmframe" name="pmframe" style="width:' + pmwidth + 'px;height:100%" allowTransparency="true" frameborder="0"></iframe></div></div>';
		}
		$('pmlayer').style.display = '';
		$('pmlayer').style.top = ((clientHeight - pmheight) / 2 + scrollTop) + 'px';
		if(!param) {
			pmframe.location = navBarWebRoot+INDEX+'?module=pms&action=Pms&do=inbox';
		} else {
			pmframe.location = navBarWebRoot+INDEX+'?module=pms&action=Pms&do=' + param;
		}
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
				objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		hiddenobj = new Array();
		$('pmlayer').style.display = 'none';
	}
}