﻿// JScript 文件
var CarList=null;
var UseList=null;
var PriceList=null;
var RecommandList=null;
var search='';
 
function ShowBrandList(updateElemID)
{ 
    search=document.getElementById('ucCarlist_hdurlsearch').value;
     var url = "/ajaxPage/searchResponse.ashx";
     var pars = (search=='')?'?type=cartype':('?'+search) +'&type=cartype';
     $(updateElemID).update('正在生成列表...');
     //loadJS.push(url+pars,"utf-8", function(){InitBrandList(updateElemID)});
     new Ajax.Request(url+pars, {method:"get", onComplete:function(request){InitBrandList(request,updateElemID)},evalScripts:true,asynchronous:true} ); 
}
function InitBrandList(request,updateElemID)
{
    CarList= eval('['+request.responseText+']');
    var strdiv="";
    var __pathpart = document.location.href.split('?')[0];
    if(CarList==null || CarList.length <= 0)
    {
        $(updateElemID).style.display="none";
        return;
    }
    
    if(GetIntValue(DecodeUrlParameter('pid')) > 0)//单品牌时 冒泡排序
    {
        var i,j;
        for(i=CarList.length-1;i>= 0;i--){
            for(j=0;j<= i-1;j++){
                if(CarList[j].carcount < CarList[j + 1].carcount){
                  var temp=CarList[j];
                  CarList[j]=CarList[j + 1];
                  CarList[j + 1]=temp;
                }
             }
        }
    }
    strdiv+="<h2 class=\"mclb_tit1\">按品牌选择</h2>";
    strdiv+="<ul>";
    for(var i=0;i<CarList.length;i++)
    {  
        var parapart = document.location.search;
        parapart = parapart.replace(/^\?+/, '').replace(/#+$/, '');
        var arrparas = parapart.split('&');
        var ___iterator_;
        var temp='';
        for (___iterator_ = 0; ___iterator_ < arrparas.length; ++___iterator_)
        {
            var urlparacomp = arrparas[___iterator_].split('=');
            if (urlparacomp[0] != 'pid' && urlparacomp[0] != 'bid'&&urlparacomp[0] != 'brandIds'&&urlparacomp[0] != 'productIds'){
            temp += '&' + urlparacomp[0]+ '='+ urlparacomp[1];
            }
         }
        strdiv+="<li>";
        strdiv+="<a class=\"mc_cola\" href ='" +__pathpart+"?pid=" +CarList[i].ProducerId+"&bid=" + CarList[i].BrandId + "&cid="+CarList[i].CarId+temp+"' target=\"_self\">"+CarList[i].name +"</a> (" + CarList[i].carcount+")";
        strdiv+="</li>";
    }   
    strdiv+="</ul>";
    strdiv+="<div class=\"clear\"></div>";
    
    $(updateElemID).update(strdiv);
}

function ShowUseYearList(updateElemID)
{
    var url = "/ajaxPage/searchResponse.ashx";
    var pars = (search=='')?'?type=useyear':('?'+search) +'&type=useyear';
    $(updateElemID).update('正在生成列表...');
    new Ajax.Request(url+pars, {method:"get", onComplete:function(response){InitUseYearList(response,updateElemID)},evalScripts:true,asynchronous:true} ); 
}
function InitUseYearList(request,updateElemID)
{
    UseList= eval('['+request.responseText+']');
    if(UseList==null)
    {
        return;
    }
    var strdiv="";
    for(var i=0;i<UseList.length;i++)
    {
        if(UseList[i].carcount > 0)
        {
            strdiv+="<li>";
            strdiv+="<a class=\"mc_cola\" href ='" +DecodeUrlParameters('ca',UseList[i].ca)+"' target=\"_self\">"+UseList[i].name +"</a> (" + UseList[i].carcount+")";
            strdiv+="</li>";
        }
    }
    $(updateElemID).update(strdiv);
    if(strdiv == '')
    {
         $('divUseYearList').style.display='none';
    }
}
function ShowCarpriceList(updateElemID)
{
    var url = "/ajaxPage/searchResponse.ashx";
    var pars = (search=='')?'?type=price':('?'+search) +'&type=price';
    $(updateElemID).update('正在生成列表...');
    new Ajax.Request(url+pars, {method:"get", onComplete:function(response){InitpriceList(response,updateElemID)},evalScripts:true,asynchronous:true});
}
function InitpriceList(request,updateElemID)
{
    PriceList= eval('['+request.responseText+']');
    if(PriceList == null)
    {
        $('divPriceList').style.display='none';
        return;
    }
    var strdiv="";
    var __pathpart = document.location.href.split('?')[0];
    for(var i=0;i<PriceList.length;i++)
    {
        if(PriceList[i].carcount > 0)
        {
            var parapart = document.location.search;
            parapart = parapart.replace(/^\?+/, '').replace(/#+$/, '');
            var arrparas = parapart.split('&');
            var ___iterator_;
            var temp='';
            for (___iterator_ = 0; ___iterator_ < arrparas.length; ++___iterator_)
            {
                var urlparacomp = arrparas[___iterator_].split('=');
                 if (urlparacomp[0] != 'lp' && urlparacomp[0] != 'hp'&&urlparacomp.length==2){
                temp += '&' + urlparacomp[0]+ '='+ urlparacomp[1];
                }
             }
            strdiv+="<li>";
            strdiv+="<a class=\"mc_cola\"  href ='" + __pathpart + "?lp=" +PriceList[i].lp + "&hp=" + PriceList[i].hp  + temp +"' target=\"_self\">"+PriceList[i].name +"</a> (" + PriceList[i].carcount+")";
            strdiv+="</li>";
        }
    }
    $(updateElemID).update(strdiv);
    if(strdiv == '')
    {
         $('divPriceList').style.display='none';
    }
}

var _Ucar_ResponseSearch = 
{
   attachEvent:function(o,name,fun){
		return document.all ? o.attachEvent(name,fun) : o.addEventListener(name.substr(2),fun,false);
	},
	
    DynamicLoadJavaScript:  function(spcount)
    {
       if($(spcount).innerHTML!='0')
       {
           ShowBrandList('divBrand');
           ShowCarpriceList('divPrice');
           ShowUseYearList('divUseYear');
       }
       else
       {
            $('divBrand').style.display="none";
            $('divUseYearList').style.display='none';
            $('divPriceList').style.display='none';
       }
    },
    
    AppendHTML: function() 
    {
        this.DynamicLoadJavaScript();
        this.attachEvent(window,"onload",InniteCarList);
        //this.attachEvent(window,"onload",this.DynamicLoadJavaScript);
    }
}
//_Ucar_ResponseSearch.AppendHTML();
function SelectChangeCarList(__parameter,id)
{
    window.location.href = DecodeUrlParameters(__parameter,$(id).value);
}
function SearcheCarList(__parameter,_value)
{
    window.location.href = DecodeUrlParameters(__parameter,_value);
}
function searchByVirtualDDL(obj)
{   
    var objId = $(obj).id;
    var para = objId.toString().substr(0,3);
    var id = objId.toString().substr(3);
    window.location.href = DecodeUrlParameters(para, id);
}
function DecodeUrlParameters(_key,_value)
{
     var _Parameter= {productIds:'',brandIds:'',pid:'0',bid:'0',cid:'0',pvid:'0',ctid:'0',order:'0',pagecount:'15',IsPic:'0',cartype:'0',cc:'',y:'',ca:'',us:'',dm:'',lp:'',hp:'',p:'',t:'',e:'',pt:'',gb:'',c:'',userid:'0',tvid:'0',kw:''};
     for(var i in _Parameter)
     {
       _Parameter[i]= DecodeUrlParameter(i);
     }
     _Parameter[_key] = _value;
     if(_key== 'pid')
     {
        _Parameter['bid']=0;
        _Parameter['cid']=0;
        _Parameter['brandIds']=0;
        _Parameter['productIds']=0;
     }
     else if(_key== 'bid')
     {
        _Parameter['cid']=0;
        _Parameter['brandIds']=0;
        _Parameter['productIds']=0;
     }
     else if(_key == "pvid")
     {
         _Parameter['ctid']=0;
     }
     else if(_key == "ctid")
     {
        if(_value==0)
        {
            _Parameter['pvid']=$("selprov").value;
        }
     }
     var _parapart ='';
     for(var a in _Parameter)
     {if(_Parameter[a]!=null &_Parameter[a]!= '' ){
        _parapart += a + "=" + _Parameter[a] + "&";
        }
     }
    var __oriurlparts = document.location.href.split('?');
    var __pathpart = __oriurlparts[0];
    return __pathpart+"?"+_parapart.substring(0 ,_parapart.length -1 );
}
function SortImgInfo()
{
   Sort=Class.create() 
   Sort.down='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/mclb_down.gif';
   Sort.up ='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/mclb_up.gif';
   Sort.priceDown='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/pricedown.gif';
   Sort.priceUp='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/priceup.gif';
   Sort.timeDown='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/timedown.gif';
   Sort.timeUp='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/timeup.gif';
   Sort.downb='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/mclb_downb.gif';
   Sort.upb ='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/mclb_upb.gif';
   Sort.priceDownb='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/pricedownb.gif';
   Sort.priceUpb='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/priceupb.gif';
   Sort.timeDownb='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/timedownb.gif';
   Sort.timeUpb='http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/timeupb.gif';
   return Sort;
 
}

function InniteCarList()
{
    var order = GetIntValue(DecodeUrlParameter('order'));
    var pid= GetIntValue(DecodeUrlParameter('pid'));
    var pid= GetIntValue(DecodeUrlParameter('pid'));
    var bid= GetIntValue(DecodeUrlParameter('bid'));
    var cid= GetIntValue(DecodeUrlParameter('cid'));
    var pvid= GetIntValue(DecodeUrlParameter('pvid'));
    var ctid= GetIntValue(DecodeUrlParameter('ctid'));
    var cartype =  GetIntValue(DecodeUrlParameter('cartype'));
    var pagecount= GetIntValue(DecodeUrlParameter('pagecount'));
    var isPic = GetIntValue(DecodeUrlParameter('IsPic'));
    if(isPic==1)
    {
      $('hfpic').className = "mclb_yout";
      $('hfpic'). href="javascript:SearcheCarList('IsPic','0');"
    }
    if(pid > 0)
    {
       $('divSerial').disabled=false;
    }
    if(bid > 0)
    {
     $('divCar').disabled=false;
    }
    if(_pid > 0)
    {
        $('selcity').disabled=false;
    }
    if(cartype >= 0)
    {
       for(var i=0;i<4;i++)
       {
           var temp = i+1;
           if(cartype == i)
           {
                $('tab2'+temp).className = "dj2_0"+temp;
           }
           else
           {
             $('tab2'+temp).className = "dj2_"+temp;
           }
       }
    }
    $('ddlorder').value = order;
    Sort = SortImgInfo();
    if(order == 0)
    {
        $('imgtime').src = Sort.timeDown;
        $('imgpub').src=Sort.down;
    }
    else if(order == 1)
    {
        $('imgprice').src =  Sort.priceUp;
        $('imgtime').src=$('imgtime').src.replace(".gif",'b.gif').replace('bb','b'); 
        $('imgsellprice').src= Sort.up; 
    }
    else if(order == 2)
    {
        $('imgprice').src =Sort.priceDown;
        $('imgtime').src=$('imgtime').src.replace(".gif",'b.gif').replace('bb','b'); 
        $('imgsellprice').src=Sort.down;
    }
    else if(order == 3)
    {
        $('imgtime').src =Sort.timeUp;
        $('imgprice').src=$('imgprice').src.replace(".gif",'b.gif').replace('bb','b');  
        $('imgpub').src= Sort.up;
    }
    else if(order == 4)
    {
        $('imgtime').src =Sort.timeDown;
        $('imgprice').src=$('imgprice').src.replace(".gif",'b.gif').replace('bb','b');  
        $('imgpub').src=Sort.down;
    }
    else if(order == 5)
    {
        $('imgbuycar').src=Sort.up;
    }
    else if(order == 6)
    {
         $('imgbuycar').src= Sort.down;
    }
    else if(order == 7)
    {
        $('imgdrive').src= Sort.up;
    }
    else if(order == 8)
    {
        $('imgdrive').src=Sort.down;
    }
    if(pagecount == 30)
    {
         $('hf30').className = "mclb_ytcz";
         $('hf15').className = "";
    }
    else
    {
         $('hf15').className = "mclb_ytcz";
         $('hf30').className = "";
    }
}
function priceImgClick(id)
{
    if($(id).src ==Sort.priceDownb)
    {
        SearcheCarList('order','2');
    }
    else if($(id).src == Sort.priceUpb)
    {
        SearcheCarList('order','1');
    }
    else if($(id).src == Sort.priceUp)
    {
        SearcheCarList('order','2');
    }
    else if($(id).src == Sort.priceDown)
    {
        SearcheCarList('order','1');
    }
}
function timeImgClick(id)
{
    if($(id).src ==Sort.timeDownb)
    {
        SearcheCarList('order','4');
    }
    else if($(id).src == Sort.timeUpb)
    {
        SearcheCarList('order','3');
    }
    else if($(id).src ==Sort.timeUp)
    {
        SearcheCarList('order','4');
    }
    else if($(id).src == Sort.timeDown)
    {
        SearcheCarList('order','3');
    }
}
function ListtopImgClick(id,value1,value2)
{
    var ordervalue = GetIntValue(DecodeUrlParameter('order'))
    if(ordervalue == value1)
    {
        SearcheCarList('order',value2);
    }
    else
    {
        SearcheCarList('order',value1)
    }
}
function HistorySearchView()
{
    var strDiv ="";
    var cookievalue = eval('['+GetCookie('LastSearchView')+']');

    if(cookievalue == null)
    {
        $('divRecently').style.display='none';
        return;
    }
    for(var i=0;i<cookievalue.length;i++)
    {
        if(cookievalue[i])
        {
           strDiv +="<li>";
           strDiv +="<a href=\"" +cookievalue[i].href + "\" title='" +unescape(cookievalue[i].title) +"' target=\"_blank\">";
           strDiv += unescape(cookievalue[i].title);
           strDiv +="</a>"
           strDiv+="</li>";
       }
    }
    $('divHistory').update(strDiv);
}

function WriteSearchHistory()
{
   var title= escape($('sptitle').getElementsByTagName('a')[0].innerHTML);
   var link= window.location.href;
   if(title == null || title == '' || title == '全部车源')
   {
        return;
   }

   var cookieList = GetCookie('LastSearchView');
   var cookievalue = '{href:\''+window.location.href+'\',title:\''+title+'\'}';

   if(cookieList == null)
   {
        SetCookie('LastSearchView',cookievalue);
   }
   else
   {
        var temp=null;
        temp=cookievalue;
        var oldcookievalue = eval('['+GetCookie('LastSearchView')+']');
        var count=0;
        for(var i=0;i<oldcookievalue.length;i++)
        {
            if((eval('['+cookievalue+']')[0].title != oldcookievalue[i].title) && count < 4)
            {
                temp+=","+'{title:\''+oldcookievalue[i].title+'\',href:\''+oldcookievalue[i].href+'\'}';
                count++;
            }
        }
       
        DelCookie('LastSearchView');
        SetCookie('LastSearchView',temp);
   }
}
function GetIsHigh(id)
{
    if($(id).parentNode.className == 'bg2')
    {
        return 'mclb_lb2';
    }
    else
    {
        return 'bg1 mclb_lb3 ';
    }
}
var _Ucar_SaleCarList = 
{
   attachEvent:function(o,name,fun){
		return document.all ? o.attachEvent(name,fun) : o.addEventListener(name.substr(2),fun,false);
	},
	
    AppendHTML: function() 
    {
        WriteSearchHistory();
        HistorySearchView();
        //this.attachEvent(window,"onload",function(){HistorySearchView()});
        //this.attachEvent(window,"onload",function(){WriteSearchHistory()});
    }
}

function saet(o)
{
	var x=y=0;
	do{
      x+=o.offsetLeft;
	  y+=o.offsetTop;
	}
	while (o=o.offsetParent);
	return {"x":x,"y":y};
}

function opendiv(thisObj,openAId,numx,numy)
{	

    var x=saet(thisObj).x;
	var y=saet(thisObj).y;
	
	var newx = x + numx;
	var newy = y + numy; 
    $(openAId).style.display="block";
    $(openAId).style.top=newy+"px";
	$(openAId).style.left=newx+"px";
}

function loadcarmiddleImg(id)
{
    opendiv($(id),'fucengimg',88,0);
    if ($(id).src.toString().indexOf("CarImage") >= 0)
    {
        $('imgmiddle').src = "/buycar/images/nopicmiddle.jpg";
        $('imgmiddle').style.width='250px';
        $('imgmiddle').style.height='187px';
        return;
    }
    $('imgmiddle').src= $(id).src.replace("_smaller","_middle");
    $('imgmiddle').style.width='250px';
    $('imgmiddle').style.height='187px';
}
var iTimeoutID;
function BookReadMail(id)
{
    var mail = $(id);
    var divBookRead = $('divBookRead');
    divBookRead.style.display="block";
    var _EmailNumFilter=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if(mail.value == null || mail.value == '')
    {
        $('divBookRead').update("请填写Email!");
        iTimeoutID = window.setTimeout("know(iTimeoutID)", 3000);
    }
    else if(!_EmailNumFilter.test(mail.value))
    {
        $('divBookRead').update("Email格式不正确!");
        iTimeoutID = window.setTimeout("know(iTimeoutID)", 3000);
    }
    else
    {
         $('divBookRead').update("正在处理请稍候...");
         var search = document.location.search == ''?'?bt=1':document.location.search;
        var url="/ajaxPage/bookReadCarSource.ashx"+search + "&bt=1&type=add&ism=1&mail=" +mail.value+"&url="+window.location.href.replace(/\&/g,'$') + "&suiji=" + Math.round(Math.random()*10000);
        new Ajax.Request(url, {method:"get",onComplete:updatedivBookRead,evalScripts:true,asynchronous:true} ); 
    }
}

function updatedivBookRead(request)
{
    var text = '';
    if(request.responseText=="1")//成功
    {
        text='感谢您使用优卡网车源订阅服务!';
    }
    else if(request.responseText=="0")//重复
    {
        text='您已订阅,不能重复订阅!';
    }
    else if(request.responseText=="-1")//失败
    {
         text='抱歉，您的订阅失败,请重试!';
    }
    $("divBookRead").update(text);
    $('txtMail').value='';
    iTimeoutID = window.setTimeout("know(iTimeoutID)", 3000);
}
function know()
{
     $("divBookRead").style.display="none";
     window.clearTimeout(iTimeoutID)  
}
function CreateRSS()
{
    var search=$F('ucCarlist_hdurlsearch')==''?'':'?'+$F('ucCarlist_hdurlsearch');
    window.open('/buycar/CreateRSS.ashx' + search);
}
function perAttention()
{
  if($('spAttened').innerHTML == '[ 设为关注 ]')
  {
    bit.popUp.coping.load('showIdasdaaa','',250,30,'bgIedasdaa','#333',9999,1,'',onloadHTML(),function(){});
    var url="/ajaxPage/personAttention.ashx?t=checkLog&sj="+Math.round(Math.random()*10000);
    new Ajax.Request(url, {method:"get",onComplete:CheckUserLogIn,evalScripts:true,asynchronous:true} ); 
  }
  else 
  {
    $('spAttened').innerHTML = '[ 您已关注成功 ]';
  }
}
function onloadHTML()
{
    var html='';
    html +="<div>";
    html +="<img id=\"imgmiddle1\" src=\"http://img2.ucar.cn/ucar/image/ucar/ucar2009/buycar/onload.gif\" alt=\"正在加载\" />";
    html += "系统正在加载请稍后...";
    html += '</div>';
    return html;
}
function CheckUserLogIn(request)
{
    var result = request.responseText;
    bit.popUp.coping.clear('bgIedasdaa','showIdasdaaa')
    if(result=='true')//已登录用户验证收藏数目
    {
        var url="/ajaxPage/personAttention.ashx?t=checkCount&sj="+Math.round(Math.random()*10000);
        new Ajax.Request(url, {method:"get",onComplete:CheckUserCount,evalScripts:true,asynchronous:true} ); 
    }
    else//未登录用户
    {
        bit.popUp.coping.load('showIdasdaa','',350,1100,'bgIedasda','#333',1000,30,'',showDiogue(),function(){});
        
    }
}
function CheckUserCount(request)
{
    var result = request.responseText;
    if(result == 'true')
    {
        var search = document.location.search == ''?'?bt=1':document.location.search+"&bt=1";
        var url="/ajaxPage/bookReadCarSource.ashx"+search + "&type=add&title=" +escape($('sptitle').innerHTML) + "&url="+window.location.href.replace(/&/g,"$","$&");;
        new Ajax.Request(url, {method:"get",onComplete:bookResult,evalScripts:true,asynchronous:true} ); 
    }
    else//收藏列表
    {
        bit.popUp.coping.load('showIdasdaa','',350,0,'bgIedasda','#333',1000,30,'',showDiogue2(result),function(){});
      
    }
}
function bookResult(request)
{
    var result = request.responseText;
    if(result == "1")
    {
        $('spAttened').update('[ 关注设置成功 ]');
        $('spAttened').title='当前搜索条件已成功设为关注';
         $('spAttened').disabled=true;
        $('spAttened').onclick=function (){};
    }
    else
    {
        alert('您已关注过此条件的车源');
    }
}
function showDiogue2(result)
{
    var html =''; 
    var list = eval('['+result+']');
    html+="<div id='divattend' class=\"tsxx\" style=\"position: absolute;height:auto;\">";
    html+="<div class=\"tsxxa\">";
    html+="<div class=\"tsxxb\">";
    html+="<h2><span style=\"cursor: pointer;\" onclick=\"bit.popUp.coping.clear('bgIedasda','showIdasdaa')\">关闭</span>设为关注提示信息</h2>";
    html+="<P class=\"tsxx_ts\">Hi <span>" + list[0].userName + "</span>，你关注已达5条，如需新增关注请删除至少一条已有关注。</P>";
    for(var i=0;i<list.length;i++)
    {
        html+="<div class=\"tsxx_wz\" id='div" +i+ "' value='" +list[i].id+ "'>";
        html+=" <label>条件" + (i+1) + "：</label>";
        html+="<span><a href=\"" +list[i].url + "\" class=\"mc_cola\" target=\"_blank\">" +list[i].text + "</a><br />";
        html+="  &nbsp; &nbsp;共" +list[i].count+ "条信息"; 
	    html+=" </span>";
	    html+="<em  style=\"cursor: pointer;\" onclick=\"delAttend('div" +i+ "')" + "\">删除</em>";
	    html+="</div>";
    }
    html+="</div>";
    html+="</div>";
    html+="</div>";
    return html;
}
function delAttend(id)
{
    var item= $(id);
    var url="/ajaxPage/bookReadCarSource.ashx?type=canel&mscid="+item.value;
    new Ajax.Request(url, {method:"get",onComplete:function(response){bookcanel(response,id)},evalScripts:true,asynchronous:true} ); 
}
function bookcanel(response,id)
{
    if(response.responseText=='邮件订阅已取消'){
     var item= $(id);
     item.removeNode(true);
    }
    else{
    alert('系统忙，请重试!');
    }
    
}
function showDiogue()
{
     var html =''; 
     html+="<div class=\"hydl\" style=\"position: absolute;height:600px;\" id=\"divUserLogin\">"
     html+="<div class=\"hydla\">";
     html+="<div class=\"hydlb\">";
     html+="<h2>";
     html+=" <span style=\"cursor: pointer;\" onclick=\"bit.popUp.coping.clear('bgIedasda','showIdasdaa')\">关闭</span>会员登录</h2>";
     html+=" <p class=\"hydl_ts\">";
     html+="<strong>提示：</strong>只有登录后才能报存你设置的关注。没有注册的用户请先<strong><a href=\"/User/reg.aspx?back=true\" class=\"mc_cola\">注册</a></strong></p>";
     html+="<div class=\"hydl_wz\">";
     html+="<samp>";
     html+= "用户名：</samp>";
     html+= "<input type=\"text\" id='txtuserName' class=\"hydl_input1\"/>";
     html+= "</div>";
     html+= "<div class=\"hydl_wz\">";
     html+= "<samp>";
     html+= "密码：</samp>";
     html+= "<input id='txtpwd' type=\"password\" class=\"hydl_input1\"/>";
     html+= "</div>";
     html+="<div class=\"hydl_wz2\">";
     html+=" <input type=\"button\" class=\"hydl_but1\" value=\"登录\" onclick='userLogIn();' /> ";
     html+="<a href=\"/User/Findpwd.aspx\" class=\"mc_cola\">忘记密码？</a>";
     html+="</div>";
     html+= "</div>";
     html+= "</div>";
     html+= "</div>";
     return html;
}
function userLogIn()
{
    var name = $F('txtuserName');
    var pwd = $F('txtpwd');
    if(name=='')
    {
        alert('用户名必填');return;
    }
    if(pwd == '')
    {
     alert('密码必填');return;
    }
    var url="/ajaxPage/personAttention.ashx?t=login&username=" + escape(name) + "&pwd=" + pwd;
    new Ajax.Request(url, {method:"get",onComplete:UserLogIn,evalScripts:true,asynchronous:true} ); 
}
function UserLogIn(request)
{
    var result = request.responseText;
    if(result == 'true')
    {
        window.location.href = this.location.href;
    }
    else
    {
        alert('登录失败');
    }
}
// JScript 文件
function GetUrlLink(UcarID,carSource1L,UcarSerialNumber,UserID)
{
   if (carSource1L==1)
   {
        return "CarInfo.aspx?UcarID=" + UcarID;
   }
   else if (carSource1L==2)
   {
        return "UcarTransDetailPage.aspx?secb_id=" + UcarSerialNumber + "&tvg_id=" + UserID;
   }
   else if (carSource1L==3)
   {
        return "t_CarInfo.aspx?UcarID=" + UcarID;
   }
   return "#";
}



function CreateCompare(liId,BrandName,UcarType,UcarSerialNumber,UserID)
{

    var Url=GetUrlLink(liId,UcarType,UcarSerialNumber,UserID);
    var ul= $("ulCompare");
    var li= document.createElement("li");
    li.setAttribute("id",liId);
    ul.appendChild(li);
    var listr="<span" + " onclick='RemoveCompare("+"\""+liId+"\""+",\""+BrandName+"\""+",\""+UcarType+"\""+",\""+UcarSerialNumber+"\""+",\""+UserID+"\""+");' style=\"cursor: pointer;\"/>&nbsp;&nbsp;</span>";
        listr+="<a href='"+Url+"' title='"+BrandName+"' target=\"_blank\" class=\"mc_cola\">"+BrandName+"</a>";
    $(liId).update(listr);
    
    var cookieCompare=GetCompare();   
    cookieCompare+=("%"+liId+"@"+BrandName+"@"+UcarType+"@"+UcarSerialNumber+"@"+UserID);
    SetCompare(cookieCompare);
    if($("li"+liId)){
        $("li"+liId).className='mclb_lbcx';
    }
}

function RemoveCompare(LiId,name,UcarType,UcarSerialNumber,UserID)
{
   var strtemp="%"+LiId+"@"+name+"@"+UcarType+"@"+UcarSerialNumber+"@"+UserID
   
    var cookieCompare=GetCompare();   
    SetCompare(cookieCompare.replace(strtemp,""));
   
   var objLi= $(LiId);
   if(objLi!=null)
   {
       $(LiId).remove();
   }
   if($("ckx"+LiId)!=null)
   {
        $("ckx"+LiId).checked=false;
        $("li"+LiId).className='mclb_lbc';
   }
}

function Display()
{
   var show=GetCompare().split("%");    
   if(show.length>0)
   {
       SetCompare("");
       for(i=1;i<show.length;i++)
       {
           var para=show[i].split("@");
           CreateCompare(para[0],para[1],para[2],para[3],para[4])
        
           if($("ckx"+para[0])!=null)
           {
               $("ckx"+para[0]).checked=true;
               $("li"+para[0]).className='mclb_lbcx';
           }
           Show('i1','i2');
       }
   }
}

function ValidateAndAddCompare(liId,BrandName,UcarType,UcarSerialNumber,UserID)
{
  
   var str=GetCompare();
   //需要检查是否已存在相同项 以及是否超出了个数
   var show=str.split("%");
   if(show.length>1)
   {
       for(i=1;i<show.length;i++)
       {
           var para=show[i].split("@");
           if(para[0]==liId)
           {
               alert("此车源已经添加到了对比窗口中！");
               return;
           }
       }
   }
   if(show.length<5)
   {
       CreateCompare(liId,BrandName,UcarType,UcarSerialNumber,UserID);
   }
   else
   {
       alert("最多只能选择四种车源进行对比！");
       objCkx=$("ckx"+liId);
       if(objCkx!=null)
       {
           objCkx.checked=false;
       }
       return;
   }
}
function ToCompare()
{
    var s="/buycar/carcompare.aspx?ucarid=";
    var str=GetCompare();
    var show=str.split("%");
    var url="";
    if(show.length>2)
    {   
       for(i=1;i<show.length;i++)
       {
           var para=show[i].split("@");
           url+=","+para[0];
       }
    }
    else
    {
        alert("最少选择两种车源进行对比！");
        return;
    
    }
   var i=url.indexOf(",");
   url=s+url.substring(i+1);
   window.open(url);
 }      
 
 
 function CompareChange(obj,liId,BrandName,UcarType,UcarSerialNumber,UserID)
 {
    if(obj.checked==true)
    {
       ValidateAndAddCompare(liId,BrandName,UcarType,UcarSerialNumber,UserID);
    }
    else
    {
       RemoveCompare(liId,BrandName,UcarType,UcarSerialNumber,UserID);
    }
 }
 
 
 function SetCompare(value)
 {
      SetCookie("Ucar_Compare",value,"","/",null,null);
 
 }
 function GetCompare()
 {
     var Compare=GetCookie("Ucar_Compare");
     if(Compare==null)
     {
        return "";
     }
     else
     {
       return Compare;
     }
 }
  function SetCookie(name, value, expires, path, domain, secure) {
	    document.cookie = name + "=" + escape (value) +
	        ((expires) ? "; expires=" + expires : "") +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        ((secure) ? "; secure" : "");
	    
	} 

    //--- 获取cookie
    function GetCookie(sName) {
      var aCookie = document.cookie.split("; ");
      for (var j=0; j < aCookie.length; j++){
        var aCrumb = aCookie[j].split("=");
        if (escape(sName) == aCrumb[0])
          return unescape(aCrumb[1]);
      }
      return null;
    }
    //--- 删除cookie
    function DelCookie(name)
    {
        var exp = new Date();
        exp.setTime (exp.getTime() - 1);
        var cval = GetCookie(name);
        document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
    }
    function getExpDate(days, hours, minutes) {
	    var expDate = new Date( );
	    if (typeof days == "number" && typeof hours == "number" && 
	        typeof hours == "number") {
	        expDate.setDate(expDate.getDate( ) + parseInt(days));
	        expDate.setHours(expDate.getHours( ) + parseInt(hours));
	        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
	        return expDate.toGMTString( );
	    }
	}
	
function $G(){
    var Url=window.location.href;//如果想获取框架顶部的url可以用 top.window.location.href
       var u,g,StrBack='';
      if(arguments[arguments.length-1]=="#")
        u=Url.split("#");
          else
        u=Url.split("?");
         if (u.length==1) g='';
        else g=u[1];

      if(g!=''){
         gg=g.split("&");
          var MaxI=gg.length;
          str = arguments[0]+"=";
          for(xm=0;xm<MaxI;xm++){
       if(gg[xm].indexOf(str)==0) {
         StrBack=gg[xm].replace(str,"");
         break;
       }
    }
}
return StrBack;
}

//*******************
function showMenu(id)
{ 
	document.getElementById(id).style.display = "block";
}

function hideMemu(id)
{
	document.getElementById(id).style.display = "none";
}

function doSearch()
{
	var province = vb("hidePvc").value;
	var serial = vb("hideSerial").value;
	var price = vb("hidePrice").value;
	window.location.href = "CarSourceListForCompany.aspx?pv=" + province + "&bid=" + serial + "&price=" + price;
}

function vb(id)
{
	return document.getElementById(id);
}

function nTabs(thisObj,Num){
	if(thisObj.className == "active") return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++) {
		if (i == Num){
			thisObj.className = "active"; 
			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}
		else {
			tabList[i].className = "normal"; 
			document.getElementById(tabObj+"_Content"+i).style.display = "none";
		}
	} 
}

///////////////////////////

function initProducerList()
{
    var id = "divProducerList";
    var url = "/buycar/ProducerList.shtml";
    new Ajax.Updater(id, url, {method:"get", onComplete:initProducerListAsync});
}

function initProducerListAsync()
{
    var pid = GetIntValue(DecodeUrlParameter('pid'));
    if(pid > 0)
    {
       $('divSerial').className = "select_style1";
       $('divSerial').disabled = false;
       $('spanProducer').innerHTML = $("pid" + pid).innerHTML;
       
       initBrandList(pid);
    }    
}

function initBrandList(pid)
{
    var id = "divBrandList";
    var url = "/ajaxpage/VirtualCarList.ashx?pid=" + pid;
    new Ajax.Updater(id, url, {method:"get", onComplete:initBrandListAsync});
}

function initBrandListAsync()
{
    var bid = GetIntValue(DecodeUrlParameter('bid'));
    if(bid > 0)
    {
        $('divCar').className = "select_style1";
        $('divCar').disabled = false;
        $('spanSerial').innerHTML = $("bid" + bid).innerHTML;
        
        initCarList(bid);
    }
}

function initCarList(bid)
{
    var id = "divCarList";
    var url = "/ajaxpage/VirtualCarList.ashx?bid=" + bid;
    new Ajax.Updater(id, url, {method:"get", onComplete:initCarListAsync});
}

function initCarListAsync()
{
    var cid = GetIntValue(DecodeUrlParameter('cid'));
    if(cid > 0)
    {
       $('spanCar').innerHTML = $("cid" + cid).innerHTML;
    }
}