﻿// JavaScript Document

function $(objname){return document.getElementById(objname)};
function h(objname){ $(objname).style.display="none";}
function setfocus()
{
	//==============================
	if($('d2_img')!=null)
	{
		var aa = $('d2_img').getElementsByTagName('li');
		for(i=0;i<aa.length;i++)
		{
			aa[i].onmouseover = function(){
				switch(this.className)
				{
					case '':this.className = 'd2img_focus';break;
					case 'z':this.className = 'd2img_focus z';break;
				}
			}
			
			aa[i].onmouseout = function(){
				switch(this.className)
				{
					case 'd2img_focus' : this.className ='';break;
					case 'd2img_focus z' : this.className ='z';break;
				}
			}
		}
	}
	
	//==========================================sj_ul
	if($('sj_ul')==null) return true;
	var a = $('sj_ul').getElementsByTagName('li');
	for(i=0;i<a.length;i++)
	{
		a[i].onmouseover = function() 
		{
			switch(this.className)
			{
				case '':this.className = 'focus';break;
				case 'z': this.className = 'z focus';break;
				case 'selected': this.className = 'selected focus';break;
				case 'selected z' : this.className = 'selected focus z';break;
				case 'img' : this.className = 'img focus'; break;
				case 'img z' : this.className = 'img focus z'; break;
				case 'hq' :this.className = 'hqfocus' ;break;
				case 'hq z' :this.className = 'hqfocus z' ;break;
				case 'hq2' :this.className = 'hqfocus2' ;break;
				case 'hq2 z' :this.className = 'hqfocus2 z';break;
				case 'hqnone' :this.className = 'hqnone_focus' ;break;
				case 'hqnone z' :this.className = 'hqnone_focus z' ;break;
				case 'none' :this.className = 'none_focus' ;break;
				case 'none z' :this.className = 'none_focus z';break;
			}
		}	
		a[i].onmouseout = function()
		{
			switch(this.className)
			{
				case 'focus' : this.className ='';break;
				case 'z focus': this.className = 'z';break;
				case 'selected focus' : this.className ='selected';break;
				case 'selected focus z' : this.className ='selected z';break;
				case 'img focus' :this.className ='img'; break;
				case 'img focus z' :this.className ='img z'; break;
				case 'hqfocus' :this.className = 'hq' ;break;
				case 'hqfocus z' :this.className = 'hq z' ;break;
				case 'hqfocus2' :this.className = 'hq2' ;break;
				case 'hqfocus2 z' :this.className = 'hq2 z' ;break;
				case 'none_focus' :this.className ='none';break;
				case 'none_focus z' :this.className ='none z';break;
				case 'hqnone_focus' :this.className = 'hqnone' ;break;
				case 'hqnone_focus z' :this.className = 'hqnone z' ;break;
			}
		}	
	}
	
	
}

var searchbar=true;
var orheight = 0;
var tempheight = 0;
var switchlock = false;
function switchdiv()
{
	if(switchlock==false)
	{
		switchlock =  true;
		$("ss").style.overflow="hidden";
		if(searchbar==true)
		{ 	
			orheight = tempheight = $("ss").scrollHeight;
			searchbar=false; $("closediv").getElementsByTagName("span")[0].className="icondown";
			for(i=0;i<(orheight/5+5);i++) setTimeout(setH,i*10);
		}
		else
		{
			$("ss").className="sc"; searchbar=true;$("closediv").getElementsByTagName("span")[0].className="iconup";
			for(i=0;i<(orheight/5+5);i++) setTimeout(setN,i*10);
		}
		setTimeout(sslocak,(orheight/5+6)*10);
	}
}
function sslocak(){switchlock=false;}

function setH(){
	try{
	if(tempheight<0){ $("ss").className="hc"; }
	else{tempheight -=5;$("ss").style.height = tempheight+"px";}}
	catch(e){}
}
function setN(){
	try{
	if(tempheight > orheight){ $("ss").style.height = orheight+"px";}
	else{tempheight +=5;$("ss").style.height = tempheight+"px";}}
	catch(e){}
}

var tooltipleft = 90;
toolTip = document.createElement("DIV"); 
toolTip.id = "toolTip"; 
title_content = ""; 
cStyle = toolTip.style; 
cStyle.position = "absolute";
cStyle.border = "1px solid #ccc"; 
cStyle.backgroundColor = "#fff"; 
cStyle.Color = "#000";
cStyle.padding = "5px"; 
cStyle.left = "-200px";
cStyle.overflow = "hidden";
  
function showTooltips(evt) 
{ 
	evt = window.event?window.event:evt; 
	srcElem = evt.srcElement?evt.srcElement:evt.target; 
	//alert(srcElem.parentNode.parentNode.className);
	if(srcElem.parentNode.parentNode){if(srcElem.parentNode.parentNode.className=="rimgbox") return;}
	
	if(srcElem.tagName.toUpperCase()=="IMG" && srcElem.src.indexOf("small")>0)
	{ 
	   toolTip.innerHTML = "<img src='"+srcElem.src+"' />";
	   pos = findPosition(srcElem); 
	   x=pos[0];y=pos[1]; 
	   cStyle.top = y + "px";
	   cStyle.left = x+tooltipleft+"px";
	  
	   cStyle.display = "block"; 
	} 
} 
  
function findPosition( oLink ) { 
  if( oLink.offsetParent ) { 
    for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) 
	{ 
      posX += oLink.offsetLeft; 
      posY += oLink.offsetTop; 
    } 
    return [ posX, posY ]; 
  } else { 
    return [ oLink.x, oLink.y ]; 
  } 
} 
  
function hideTooltips(evt) 
{ 
    evt = window.event?window.event:evt; 
    srcElem = evt.srcElement?evt.srcElement:evt.target; 
    srcElem.title= window.title_content; 
    window.title_content = ""; 
    cStyle.display = "none"; 
} 

// set nav area 

function isIE(){ //ie? 
    if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
     return true; 
    else 
     return false; 
 } 
 
 if(!isIE()){ //firefox innerText define
    HTMLElement.prototype.__defineGetter__("innerText", 
     function(){
      var anyString = "";
      var childS = this.childNodes;
      for(var i=0; i<childS.length; i++) {
       if(childS[i].nodeType==1)
        anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
       else if(childS[i].nodeType==3)
        anyString += childS[i].nodeValue;
      }
      return anyString;
     } 
    ); 
    HTMLElement.prototype.__defineSetter__("innerText", 
     function(sText){ 
      this.textContent=sText; 
     } 
    ); 
 }
 
 //---------------------------------------------------------------------------------------------------------------------------------------//

var ht=new Object();
ht["bj"]="亚运村|bold,定福庄|bold,燕莎|bold,奥运村|bk_Red,四惠|bk_Red,十里堡|bk_Red";
function setNav(cityName)
{
    var arrLi=FindLi();
    if(arrLi==null)return;
    if(!(cityName.toString() in ht))
        return;
    var arrArea = ht[cityName].split(",");
    for(var i in arrArea)
    {
        var areaInfo=arrArea[i].split("|");
        if(areaInfo.length<2)
            continue;
        var areaName = areaInfo[0];
        //alert(areaName);
        //alert(areaName in arrLi);
        if(areaName in arrLi)
        {
            arrLi[areaName].className=areaInfo[1];
        }
    }
}

function FindLi()
{
    var htLi=new Object();
    var areUl= document.getElementById("arae_listtab");
    if(areUl==null)return;
    var nodes=areUl.getElementsByTagName("li");
    for(var i =0;i<nodes.length;i++)
    {
         htLi[nodes[i].innerText]=nodes[i];
    }
    return htLi;
}



function getDivHeight()
{
	var a = document.body.scrollHeight;
	var b = window.screen.height;
	return a>b?a:b;
}

var newdiv = document.createElement("div");
var contentdiv = document.createElement("div");
function closeopendiv()
{
	newdiv.style.display="none";
	contentdiv.style.display="none";
}
function setbg(pwidth,pheight,psrc)
{
	document.body.scroll = "no";
	
	//pagewidth = pwidth;
	//pageheight= pheight;
	pagewidth = 470;
	pageheight= 265;
	
	pagesrc = psrc;
	
	contentdiv.style.display = "block";
	newdiv.style.display = "block";
	
	newdiv.id="blackbg";
	newdiv.style.position ="absolute";
	newdiv.style.zIndex='9998';
	newdiv.style.top = "0px";
	newdiv.style.left = "0px";
	newdiv.style.width="100%";
	newdiv.style.height= getDivHeight() +"px";
	newdiv.style.backgroundColor="#000";
	newdiv.style.filter="alpha(opacity=50)"; 
    newdiv.style.opacity=0.5; 
	
	
	contentdiv.id="blackcontent";
	contentdiv.style.zIndex='9999';
	contentdiv.style.margin = "-"+pageheight/2+"px 0px 0px -"+pagewidth/2+"px";
	contentdiv.style.width= pagewidth + "px";
	contentdiv.style.height= pageheight + "px";
	contentdiv.style.backgroundColor="#fff";
	
	contentdiv.innerHTML = '<div style="border-bottom:1px solid #19AEE1; line-height:18px; color:#000; padding:5px; background:#DBEAFF;"><span style="float:right"><a href="javascript:closeopendiv()">[关闭本窗口]</a></span>商家信息下载-58同城网</div><iframe scrolling="no"  src="'+pagesrc+'" frameborder="0" height="'+pageheight+'" width="'+pagewidth+'"></iframe>';
	
	document.body.appendChild(newdiv);
	document.body.appendChild(contentdiv);

}

//set nav area end

document.onmouseover = showTooltips; 
document.onmouseout = hideTooltips; 

function onloadevent()
{
	
	var timer;
	orheight = tempheight = $("ss").scrollHeight;
	if(document.all)
	{
		 if(document.readyState=="complete")
		 {
			document.body.appendChild(toolTip); 
			setfocus();
			window.clearInterval(timer);
		 }
		 else
		 {
			timer = setInterval("onloadevent",1000);
		 }	
	}
	else
	{
		document.body.appendChild(toolTip); 
		setfocus();
	}
}
