var kfCallObj;
function getRadio(names)
{
	var chkObjs = document.getElementsByName(names);
    for(var i=0;i<chkObjs.length;i++)
	{
          if(chkObjs[i].checked)
		  {
                return chkObjs[i].value;
          }
     }
}

function ceElement(elementId,elementValue)
{
  	var objElement=document.getElementById(elementId);
  	var lenElement=objElement.options.length;
  	for(i=0;i<lenElement;i++){
  		if(objElement[i].value==elementValue){
			objElement[i].selected=true;
		}
  	}
}
function ckRadio(name,value)
{
	var oRadio=document.getElementsByName(name);
	for(var i=0;i<oRadio.length;i++)
	{
		if(oRadio[i].value==value)
		{
			oRadio[i]. checked="checked";
		}
	}
}

function ckSelect(name,value)
{
	var oRadio=document.getElementsByName(name);
	if(oRadio.length>0)
	{
		for(var i=0;i<oRadio[0].length;i++)
		{
			if(oRadio[0][i].value==value)
			{
				oRadio[0][i]. selected="selected";
			}
		}
	}
}

function valiUpPic(picInputId,picId,picValue)
  {
	if(document.getElementById(picInputId)!=null)
	{
  		document.getElementById(picInputId).value=picValue;
		
		
	}
	if(document.getElementById(picId)!=null)
	{
		if(picValue!="")
		{
			document.getElementById(picId).src="/"+picValue;
		}
		else
		{
			document.getElementById(picId).src="/images/nopic.png";
		}
	}
	
  }

function q$(obj){return document.getElementById(obj);}
function setNavLink(sLink)
{
    kfCallObj.value=sLink;
    q$("sortDiv").style.display="none";
}
function showNavLink(obj) {
    var pos=getElementPos(obj);
	q$("sortDiv").style.top=(pos.y+30)+"px";
	q$("sortDiv").style.left=pos.x+"px";
	q$("sortDiv").style.display="block";
	kfCallObj=obj;
}
function showSortInfo(obj,text)
{
	var pos=getElementPos(obj);
	q$("sortInfo").style.top=(pos.y+20)+"px";
	q$("sortInfo").style.left=pos.x+"px";
	q$("sortInfo").style.display="block";
	q$("sortInfo").innerHTML=text;
}
function hidSortInfo(obj)
{
	q$("sortInfo").style.display="none";
	q$("sortInfo").innerHTML="";
}


function getElementPos(elementId){     
    var ua = navigator.userAgent.toLowerCase();     
    var isOpera = (ua.indexOf('opera') != -1);     
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof     
    var el = elementId;     
    if (el.parentNode === null || el.style.display == 'none') {     
        return false;     
    }     
    var parent = null;     
    var pos = [];     
    var box;     
    if (el.getBoundingClientRect) //IE     
    {     
        box = el.getBoundingClientRect();     
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);     
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);     
        return {     
            x: box.left + scrollLeft,     
            y: box.top + scrollTop     
        };     
    }     
    else     
        if (document.getBoxObjectFor) // gecko         
        {     
            box = document.getBoxObjectFor(el);     
            var borderLeft = (el.style.borderLeftWidth) ? parseInt(el.style.borderLeftWidth) : 0;     
            var borderTop = (el.style.borderTopWidth) ? parseInt(el.style.borderTopWidth) : 0;     
            pos = [box.x - borderLeft, box.y - borderTop];     
        }     
        else // safari & opera         
        {     
            pos = [el.offsetLeft, el.offsetTop];     
            parent = el.offsetParent;     
            if (parent != el) {     
                while (parent) {     
                    pos[0] += parent.offsetLeft;     
                    pos[1] += parent.offsetTop;     
                    parent = parent.offsetParent;     
                }     
            }     
            if (ua.indexOf('opera') != -1 || (ua.indexOf('safari') != -1 && el.style.position == 'absolute'))  
  
{     
                pos[0] -= document.body.offsetLeft;     
                pos[1] -= document.body.offsetTop;     
            }     
        }     
    if (el.parentNode) {     
        parent = el.parentNode;     
    }     
    else {     
        parent = null;     
    }     
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled  
  
ancestors     
        pos[0] -= parent.scrollLeft;     
        pos[1] -= parent.scrollTop;     
        if (parent.parentNode) {     
            parent = parent.parentNode;     
        }     
        else {     
            parent = null;     
        }     
    }     
    return {     
        x: pos[0],     
        y: pos[1]     
    };     
}




var searchReq=createAjaxObj();
var cityClass="1";
var iKeyCount=0,isIE= (document.all) ? true:false;
function createAjaxObj()
{
	var httprequest=false;
	if(window.XMLHttpRequest)
	{
		httprequest=new XMLHttpRequest();
		if(httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject)
	{
		//IE
		try
		{
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
			}
		}
	}
	return httprequest
}

function fTelInfo(obj,ac)
{
	if(ac==1)
	{
		var xd = getElementPos(obj);
		q$("telInfo").style.display="block";
		q$("telInfo").style.top=(18+xd.y)+"px";
		q$("telInfo").style.left=(xd.x-35)+"px";
		q$("telInfo").innerHTML="资料载入中……";
		var xmlhttp;
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
 		 	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("telInfo").innerHTML="<span>所在地：</span>"+xmlhttp.responseText;
    		}
  		}
		xmlhttp.open("GET","/action/?s=cha&k="+obj.innerHTML,true);
		xmlhttp.send();
	}
	if(ac==2)
	{
		q$("telInfo").style.display="none";
		q$("telInfo").style.top="-100px";
		q$("telInfo").style.left="-100px";
	}
}


function getElementPos(elementId){     
    var ua = navigator.userAgent.toLowerCase();     
    var isOpera = (ua.indexOf('opera') != -1);     
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof     
    var el = elementId;     
    if (el.parentNode === null || el.style.display == 'none') {     
        return false;     
    }     
    var parent = null;     
    var pos = [];     
    var box;     
    if (el.getBoundingClientRect) //IE     
    {     
        box = el.getBoundingClientRect();     
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);     
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);     
        return {     
            x: box.left + scrollLeft,     
            y: box.top + scrollTop     
        };     
    }     
    else     
        if (document.getBoxObjectFor) // gecko         
        {     
            box = document.getBoxObjectFor(el);     
            var borderLeft = (el.style.borderLeftWidth) ? parseInt(el.style.borderLeftWidth) : 0;     
            var borderTop = (el.style.borderTopWidth) ? parseInt(el.style.borderTopWidth) : 0;     
            pos = [box.x - borderLeft, box.y - borderTop];     
        }     
        else // safari & opera         
        {     
            pos = [el.offsetLeft, el.offsetTop];     
            parent = el.offsetParent;     
            if (parent != el) {     
                while (parent) {     
                    pos[0] += parent.offsetLeft;     
                    pos[1] += parent.offsetTop;     
                    parent = parent.offsetParent;     
                }     
            }     
            if (ua.indexOf('opera') != -1 || (ua.indexOf('safari') != -1 && el.style.position == 'absolute'))  
  
{     
                pos[0] -= document.body.offsetLeft;     
                pos[1] -= document.body.offsetTop;     
            }     
        }     
    if (el.parentNode) {     
        parent = el.parentNode;     
    }     
    else {     
        parent = null;     
    }     
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled  
  
ancestors     
        pos[0] -= parent.scrollLeft;     
        pos[1] -= parent.scrollTop;     
        if (parent.parentNode) {     
            parent = parent.parentNode;     
        }     
        else {     
            parent = null;     
        }     
    }     
    return {     
        x: pos[0],     
        y: pos[1]     
    };     
}