﻿/*--------互信汽车网2010五周年改版---试一口啵---QQ：372179867---人生自古谁无屎，屎中自有屎中屎--------*/

if(navigator.appName!="Microsoft Internet Explorer"){
    window.status=("您使用的不是IE浏览器，可能某些地方显示不正常。请最好使用IE浏览器浏览本站");
}
//预加载些背景图片
var bover1,bover2,bout1,bout2
bover1=new Image();
bover2=new Image();
bout1=new Image();
bout2=new Image();
bover1.src="/images/nv_bgover1.gif";
bover2.src="/images/nv_bgover2.gif";
bout1.src="/images/nv_bg1.gif";
bout2.src="/images/nv_bg2.gif";

function _over(obj,bgnumber){
    if(MzBrowser.ie){
        if(MzBrowser.version<=6){
            return;
        }
    }
    if(bgnumber==1){
        obj.style.backgroundImage="url("+bover1.src+")";
    }
    if(bgnumber==2){
        obj.style.backgroundImage="url("+bover2.src+")";
    }
}
function _out(obj,bgnumber){
    if(MzBrowser.ie){
        if(MzBrowser.version<=6){
            return;
        }
    }
    if(bgnumber==1){
        obj.style.backgroundImage="url("+bout1.src+")";
    }
    if(bgnumber==2){
        obj.style.backgroundImage="url("+bout2.src+")";
    }
}
//得到N条二手车文字信息
function Getcarinfo_Text(CityRef, Special, OrderBy, Rows, divname){
    runajax("/app.aspx?t_cityref="+CityRef+"&t_special="+encodeURI(Special)+"&t_orderby="+OrderBy+"&t_rows="+Rows,"GET",divname,null,null);
}
//得到N条二手车文字信息-带随机
function Getcarinfo_Text_R(CityRef, Special, OrderBy, Rows, r_Rows, divname){
    runajax("/app.aspx?t_cityref="+CityRef+"&t_special="+encodeURI(Special)+"&t_orderby="+OrderBy+"&t_rows="+Rows+"&t_r_rows="+r_Rows,"GET",divname,null,null);
}
//首页上部轮回广告加载
function loadAD(){
    ad1=new Image();
    ad2=new Image();
    ad1.src="/images/ad/千里发广告.jpg";
    ad2.src="/images/ad/首页389_160.gif";
    window.setTimeout('filterPlay(\'home_ad1\',ad1,ad2)',3000);
}
//得到地区
function getDqList(divname){
    runajax("/app.aspx?getdq=1","GET",divname,null,null);
}
//选择地区前
function s_this(obj){
    if(obj.options[obj.selectedIndex].value=='21'){
        return;
    }
    for(i=0;i<obj.options.length;i++){
        if(obj.options[i].value=='21'){
            obj.selectedIndex=i;
            break;
        }
    }
}
//得到制造商
function getFacture(df_id,divname){
    runajax("/app.aspx?getzzs=1&df_id="+df_id,"GET",divname,null,null);
}
//得到品牌
function getMark(fid,divname){
    runajax("/app.aspx?_width=120&fid="+fid+"&divname="+divname,"GET",divname,null,null);
}
//得到型号 
function getModel(mid,divname){
    runajax("/app.aspx?_width=120&mid="+mid,"GET",divname,null,null);
}
//8随机经销商LOGO
function get8Dealer(){
    runajax("/app.aspx?dealer_8=1","GET","div_dealer8",null,null)
}
//6随机已售信息
function get6Selled(){
    runajax("/app.aspx?auto_selled=1","GET","div_selled",null,null)
}
//打开一辆车
function opencar(carid){
    window.open("/car/" + carid + ".htm","_blank");
}
//打开评估页面
function openpg(){
	itop=(window.screen.availHeight-185)/2;
	ileft =(window.screen.availWidth -391)/2;
	window.open("/pg.htm","_blank","left="+ileft+",top="+itop+",width=391,height=185");
}

//打开某条求购信息
function openmsg(cid){
	itop=(window.screen.availHeight-184)/2;
	ileft =(window.screen.availWidth -390)/2;
	window.open("/buyCar.htm?cid="+cid,"_blank","left="+ileft+",top="+itop+",width=390,height=184");
}
/***关键字搜索MENU***/
var intDelay=1; //设置显示速度
var intcloseDelay=1; //设置隐藏速度
var intInterval=50;//透明度步长

function setXY(obj,obj_div,left_step,top_step){
    itop = 0;
    ileft = 0;
    iv_left=2;
    iv_top=2;
    var oTmp = obj;
    do {
           ileft += oTmp.offsetLeft;
           itop += oTmp.offsetTop;
           oTmp = oTmp.offsetParent;
    } while(oTmp.tagName!="BODY");
    if(MzBrowser.ie){
        if(MzBrowser.version>7){
            iv_left=0;
            iv_top=0;
        }else{
            iv_left=-3;
        }
    }
    obj_div.style.left=(ileft+left_step+iv_left)+"px";
    obj_div.style.top=(itop+top_step+1+iv_top)+"px";
}
function box_keyword_Click(){                
    if(document.getElementById("keyword")!=tempdealer){
        document.getElementById("keyword_div").filters.alpha.opacity=0;
        document.getElementById("keyword_div").style.display="";
        GradientShow();
    }
}
function GradientShow()
{
    document.getElementById("keyword_div").filters.alpha.opacity+=intInterval;
    if (document.getElementById("keyword_div").filters.alpha.opacity<100)
    {
        window.setTimeout("GradientShow()",intDelay);
    }
}
function GradientClose() {
    document.getElementById("keyword_div").filters.alpha.opacity-=intInterval;
    if (document.getElementById("keyword_div").filters.alpha.opacity>0){
        window.setTimeout("GradientClose()",intcloseDelay);
    }
    else
    {            
        document.getElementById("keyword_div").style.display="none";
    }
}

/***经销商显示 MENU***/
var dealer_intDelay=1; //设置显示速度
var dealer_intcloseDelay=1; //设置隐藏速度
var dealer_intInterval=25;//设置透明步长值
var tempdealer=null;//临时OVER对象
function dealer_menu_move(obj){                
    if(obj!=tempdealer){
        document.getElementById("dealermenu_div").filters.alpha.opacity=0;
        document.getElementById("dealermenu_div").style.display="";
        dealer_GradientShow();
    }
    if(tempdealer){
        tempdealer.className='dealer_menu1';
    }
    tempdealer=obj;
}
function dealer_GradientShow()
{
    document.getElementById("dealermenu_div").filters.alpha.opacity+=dealer_intInterval;
    if (document.getElementById("dealermenu_div").filters.alpha.opacity<100)
    {
        window.setTimeout("dealer_GradientShow()",dealer_intDelay);
    }
}
function dealer_GradientClose() {
    document.getElementById("dealermenu_div").filters.alpha.opacity-=dealer_intInterval;
    if (document.getElementById("dealermenu_div").filters.alpha.opacity>0){
        window.setTimeout("dealer_GradientClose()",dealer_intcloseDelay);
    }
    else
    {            
        document.getElementById("dealermenu_div").style.display="none";
    }
    if(document.getElementById("dealermenu_div").filters.alpha.opacity<=0){
        document.getElementById("dealermenu_div").style.display="none";        
    }
    if(tempdealer){      
        tempdealer.className="dealer_menu1";tempdealer=null;
    }
}

document.onclick=function(){
    if(document.getElementById("keyword_div")){
        if(document.getElementById("keyword_div").filters.alpha.opacity>0){
            GradientClose();
        }
    }
    if(document.getElementById("dealermenu_div")){
        if(document.getElementById("dealermenu_div").filters.alpha.opacity>0){
            dealer_GradientClose();    
        }
    }
}


//判断浏览器和版本
window["MzBrowser"]={};(function()
{
if(MzBrowser.platform) return;
var ua = window.navigator.userAgent;
MzBrowser.platform = window.navigator.platform;

MzBrowser.firefox = ua.indexOf("Firefox")>0;
MzBrowser.opera = typeof(window.opera)=="object";
MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE")>0;
MzBrowser.mozilla = window.navigator.product == "Gecko";
MzBrowser.netscape= window.navigator.vendor=="Netscape";
MzBrowser.safari= ua.indexOf("Safari")>-1;

if(MzBrowser.firefox) var re = /Firefox(\s|\/)(\d+(\.\d+)?)/;
else if(MzBrowser.ie) var re = /MSIE( )(\d+(\.\d+)?)/;
else if(MzBrowser.opera) var re = /Opera(\s|\/)(\d+(\.\d+)?)/;
else if(MzBrowser.netscape) var re = /Netscape(\s|\/)(\d+(\.\d+)?)/;
else if(MzBrowser.safari) var re = /Version(\/)(\d+(\.\d+)?)/;
else if(MzBrowser.mozilla) var re = /rv(\:)(\d+(\.\d+)?)/;

if("undefined"!=typeof(re)&&re.test(ua))
MzBrowser.version = parseFloat(RegExp.$2);
})(); 


/*一个AJAX的完整调用,兼容微软IE和火狐狸FIREFOX*/
//url:请求的地址
//method:请求的方法GET或POST或HEAD
//sid:一个页面DIV的ID号
//func:委托调用
//data:POST要发送的数据，当method为GET或HEAD时默认此参数为NULL
function runajax(url,method,sid,func,data)
{
	/*建立一个兼容IE和FIREFOX的XMLHTTP对象*/
	var xmlobj = null;
    try {
        xmlobj = new XMLHttpRequest();
    } catch (e) {
        try {
            xmlobj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (ee) {
            xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
	if (!xmlobj) {
        //alert("抱歉，你的浏览器不支持AJAX。");
        return;
    }

	/*开始发送请求到url*/
	var _data = null;	 
    xmlobj.open(method, url, true);
    if (method.toUpperCase() == "POST") {
        _data = data;
        xmlobj.setRequestHeader("Content-Length", _data.Length());  
        xmlobj.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
    }
    xmlobj.send(_data);
	/*xmlobj异步请求的回调函数*/
	xmlobj.onreadystatechange = function(){
	  	if(xmlobj.readyState==4){
			if (xmlobj.status==200) 
			{
				if(typeof(sid)=="string"){
					document.getElementById(sid).innerHTML=xmlobj.responseText;
				}
				if(typeof(func)=="function"){
					func(xmlobj.responseText);
				}
				xmlobj=null;
			}
		}else{
			return;
		}
    }
}

//搜索车辆
function doSearch(){
	var searchstr="?saleType=1";
	if(document.getElementById("styleref").selectedIndex>0){
		searchstr+="&styleRef="+document.getElementById("styleref").options[document.getElementById("styleref").selectedIndex].value;
	}
	if(document.getElementById("licensedate").selectedIndex>0){
		searchstr+="&LicenseDate="+document.getElementById("licensedate").options[document.getElementById("licensedate").selectedIndex].value;
	}
	if(document.getElementById("c_facture").selectedIndex>0){
	    searchstr+="&zzsList="+document.getElementById("c_facture").options[document.getElementById("c_facture").selectedIndex].value;
	    if(document.getElementById("c_mark").selectedIndex>0){
	        searchstr+="&ppList="+document.getElementById("c_mark").options[document.getElementById("c_mark").selectedIndex].value;
	    }
	}
	if(document.getElementById("cityref").options[document.getElementById("cityref").selectedIndex].value!=""){
		searchstr+="&cityList="+document.getElementById("cityref").options[document.getElementById("cityref").selectedIndex].value;
	}
	if(!isnull(document.getElementById("keyword").value)){
		searchstr+="&keyword="+document.getElementById("keyword").value;
	}
	if(document.getElementById("price").selectedIndex>0){	    
		switch(document.getElementById("price").selectedIndex){
		    case 1:
		    searchstr+="&price1=0.01&price2=1";
		    break;
		    case 2:
		    searchstr+="&price1=1&price2=5";
		    break;   
		    case 3:
		    searchstr+="&price1=5&price2=10";
		    break;  
		    case 4:
		    searchstr+="&price1=10&price2=20";
		    break; 
		    case 5:
		    searchstr+="&price1=20&price2=50";
		    break; 
		    case 6:
		    searchstr+="&price1=50&price2=500";
		    break; 
		}
	}		
	if(window.location.href.indexOf("searchcar")!=-1){
	    window.location.href=("/searchcar.aspx"+encodeURI(searchstr));
	}else{
	    window.open(("/searchcar.aspx"+encodeURI(searchstr)));
	}
	
}
//对比车辆
function ccar(){
    s=document.getElementsByTagName("INPUT").length;
    carstr=new String();
    for(i=0;i<s;i++){
        if(document.body.getElementsByTagName("input")[i].checked){
            carstr+=document.body.getElementsByTagName("input")[i].value+",";
        }
    }
    cars=carstr.substring(0,carstr.length-1).split(",");
    if(cars.length<2||cars.length>6){
        alert("请在图片前选择2台车以上,6台车以下进行对比");
        return;
    }
    window.open("compareCar.aspx?ids="+cars.toString(),"_blank");
}
//当用户输入关键字时
function getKeywords(_value){
    runajax("/app.aspx?_keyword="+encodeURI(_value),"GET","keyword_div",showKeyword_div,null); 
}
//如果服务器返回了匹配的关键字
function showKeyword_div(rspText){
    if(document.getElementById("keyword_div").innerText!=""){
        _left=0;
        if(MzBrowser.version<7){
            _left=-1;
        }
        setXY(document.getElementById("keyword"),document.getElementById("keyword_div"),_left,document.getElementById("keyword").offsetHeight);
        box_keyword_Click();
    }else{
        GradientClose()
    }
    
}
//根据地区名返回经销商列表
function getDealers(dq){
    runajax("/app.aspx?dealer_cityname="+encodeURI(dq),"GET","dealermenu_div",null,null);
}
//是否为空字符
function isnull(str){
	for(i=0;i<str.length;i++){
		if(str.charAt(i)!=" "){
			return false;
		}
	}
	return true;
}

//滤镜显示
function filterPlay(imgid,imgobj1,imgobj2)
{
    eval("document.getElementById('"+imgid+"')").filters[0].apply();
    if(eval("document.getElementById('"+imgid+"')").src==imgobj1.src){
        eval("document.getElementById('"+imgid+"')").src=imgobj2.src;
    }else{
        eval("document.getElementById('"+imgid+"')").src=imgobj1.src;
    }
    eval("document.getElementById('"+imgid+"')").filters[0].play();
    eval("setTimeout(\"filterPlay('home_ad1',ad1,ad2)\",8000)");
}



function ad_tourl(theurl){
	if(theurl.indexOf("千里发")!=-1){

		window.open("http://www.qianlifa.com","_blank");

	}else{

		window.open("http://www.hx-car.com/zsjj.html");

	}
}


function BASEisNotNum(theNum){
//判断是否为数字
    if (theNum=="")
        return true;
    for(var i=0;i<theNum.length;i++){
        oneNum=theNum.substring(i,i+1);
        if (oneNum<"0" || oneNum>"9")
          return true;
    }
    return false;
}
