var xmlhttp = null;
if (window.ActiveXObject){
	try{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
}else if (window.XMLHttpRequest){
	xmlhttp=new XMLHttpRequest();
}
function getxml(x){
	if (xmlhttp!=null){  
		xmlhttp.open("GET",x,false);
		xmlhttp.send(null);
	}else{
		alert("Your browser does not support XMLHTTP.11");
		return false;
	}
	return xmlhttp;
}
function loadxmldoc(x){	
	if (window.ActiveXObject){
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(x);
		return xmlDoc;
	}else if (window.XMLHttpRequest){
		xmlDoc = getxml(x).responseXML;
		return xmlDoc;
	}else{
		alert("11Your browser does not support XMLHTTP.");
		return false;
	}
}

function Ad_New_XmlDoc() {
  var xmlDoc = false;
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  try {
	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  } catch (e) {
    try {
      xmlDoc = new ActiveXObject("Msxml2.XMLDOM");
    } catch (e2) {
      xmlDoc = false;
    }
  }
  @end @*/

  if (!xmlDoc) {
    xmlDoc = document.implementation.createDocument('','',null);
  }
  return xmlDoc;
}

isie = String(navigator.appVersion).indexOf("MSIE") > -1;

function IsOverTime(endtime){
	if(endtime == '1900-01-02'){
		return false;
	}
	var nowtime,etime;
	nowtime = new Date()
	etime=new Date(endtime.replace(/-/g,'\/'));
	return nowtime > etime;
}

function adshow(aid){
	if(isie){
		adshow_byIE(aid);
	}
	else{
		adshow_byFF(aid);
	}
}

function adshow_byIE(aid){
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async = false;
	if(!xmlDoc.load('/xml/ad/'+aid+'.xml')){
		return;
	}
	
	var codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0';
	var src = 'http://www.yescar.cn/images/picxg';
	var src2 = 'http://www.yescar.cn/images/picxg.swf';
	var wmode = 'opaque';
	var quality = 'high';
	var pluginspage = 'http://www.macromedia.com/go/getflashplayer';
	var movie = 'http://www.yescar.cn/images/picxg';
	
	var id = '';
	var width = '';
	var height = '';
	var url = '';
	var endtime = '';
	
	var pic = '';
	var links = '';
	var bname = '';
	var time = '';
	var FlashVars = '';
	
	var html = '';
	var str = '';
	
	var root = xmlDoc.documentElement;
	var node = root.getElementsByTagName('Table');
	
	for(i=0;i<node.length;i++){
		endtime = node[i].selectSingleNode('endtime').text;
		if(IsOverTime(endtime)){
			root.removeChild(node[i]);
		} 
	}
	node = root.getElementsByTagName('Table');
	
	if(node.length > 1){
		width = node[0].selectSingleNode('width').text;
		height = node[0].selectSingleNode('height').text;
		for(i=0;i<node.length;i++){
			pic = pic + '|' + node[i].selectSingleNode('pic').text;
			links = links + '|' + node[i].selectSingleNode('url').text;
			bname = bname + '|' + node[i].selectSingleNode('name').text;
			time = time + '|' + node[i].selectSingleNode('time').text;
		}
		pic = pic.replace('|','');
		links = pic.replace('|','');
		bname = pic.replace('|','');
		time = pic.replace('|','');
		FlashVars = 'pics='+pic+'&links='+links+'&bname='+bname+'&timesAd='+time+'&pWidth='+width+'&pHeight='+height;
		
		str =  AC_FL_RunContent( 'codebase',codebase,'width',width,'height',height,'src',src,'wmode',wmode,'quality',quality,'FlashVars',FlashVars,'pluginspage',pluginspage,'movie',movie );			
			
		document.write(html+str);
		
	}
	else if(node.length == 1){
		movie = node[0].selectSingleNode('pic').text;
		src = node[0].selectSingleNode('pic').text;
		width = node[0].selectSingleNode('width').text;
		height = node[0].selectSingleNode('height').text;
		id = node[0].selectSingleNode('id').text;
		url = node[0].selectSingleNode('url').text;
		bname = node[0].selectSingleNode('name').text;
		if(src.indexOf('.swf') > -1){
			str = AC_FL_RunContent( 'codebase',codebase,'width',width,'height',height,'src',src.replace('.swf',''),'quality',quality,'wmode',wmode,'pluginspage',pluginspage,'movie',movie.replace('.swf','') );
			
			
			//统计代码
			if(url && url != 'http://')
			{
				
				html = '<div id="flashDiv" style="position:absolute; width:'+width+'; height:'+height+'; z-index:1;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="http://images.yescar.cn/ad/flash.gif" width='+width+' height='+height+' border="0" /></a></div>';
			}
			
			document.write(html+str);
			
		}
		else{
			var imghtml = '<a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="'+src+'" width="'+width+'" height="'+height+'" border="0" style="background-color:#FFFFFF" /></a>';
			document.write(imghtml);
		}
	}
}

function adStat(name)
{	
	if(name.length>=7)
	{
		
	if(name.substring(0,6)=='defaul')
	{
		
		//window.open('http://ad-apac.doubleclick.net/clk;224269545;48027450;i?http://www.lexus.com.cn/forms/shenzhen.asp');	
	}
	return;
	}
	var  strurl="http://www.yescar.cn/WebService/Ad/AdService.asmx/Ad_Click?bname="  +  name;
	if (window.ActiveXObject)
	{
		try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	 if (xmlhttp!=null)
	 {  
		 	xmlhttp.open("GET",strurl,  false);
		   xmlhttp.send(null);
	}
	else
	{
			alert("Your browser does not support XMLHTTP.11");
			return false;
	}
	
}

function adshow_byFF(aid){
	var xmlDoc = loadxmldoc('/xml/ad/'+aid+'.xml');
	if(!xmlDoc){
		return;
	}
	
	var codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0';
	var src = 'http://www.yescar.cn/images/picxg';
	var src2 = 'http://www.yescar.cn/images/picxg.swf';
	var wmode = 'opaque';
	var quality = 'high';
	var pluginspage = 'http://www.macromedia.com/go/getflashplayer';
	var movie = 'http://www.yescar.cn/images/picxg';
	
	var id = '';
	var width = '';
	var height = '';
	var url = '';
	var endtime;

	var html='';
	
	var pic = '';
	var links = '';
	var bname = '';
	var time = '';
	var FlashVars = '';
	
	var root = xmlDoc.documentElement;
	var node = root.getElementsByTagName('Table');
	
	for(i=0;i<node.length;i++){
		endtime = node[i].getElementsByTagName('endtime')[0].textContent;
		if(IsOverTime(endtime)){
			root.removeChild(node[i]);
		}
	}
	node = root.getElementsByTagName('Table');
	
	
	if(node.length > 1){
		width = node[0].getElementsByTagName('width')[0].textContent;
		height = node[0].getElementsByTagName('height')[0].textContent;
		for(i=0;i<node.length;i++){
			pic = pic + '|' + node[i].getElementsByTagName('pic')[0].textContent;
			links = links + '|' + node[i].getElementsByTagName('url')[0].textContent;
			bname = bname + '|' + node[i].getElementsByTagName('name')[0].textContent;
			time = time + '|' + node[i].getElementsByTagName('time')[0].textContent;
		}
		
		pic = pic.replace('|','');
		links = pic.replace('|','');
		bname = pic.replace('|','');
		time = pic.replace('|','');
		FlashVars = 'pics='+pic+'&links='+links+'&bname='+bname+'&timesAd='+time+'&pWidth='+width+'&pHeight='+height;
		
		var adhtml=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width+ +'" height="'+ height +'">');           
		adhtml +=('<param name="movie" value="'+src2+'">');
		adhtml +=('<param name="quality" value="high">');  
		adhtml +=('<param name="menu" value="false">');
		adhtml +=('<param name="wmode" value="opaque">');
		adhtml +=('<param name="allowScriptAccess" value="sameDomain">');
		adhtml +=('<param name="type" value="application/x-shockwave-flash">');
		adhtml +=('<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer">');
		adhtml +=('<param name="FlashVars" value="'+FlashVars+'">');
		adhtml +=('<embed src="'+src2+'" FlashVars="'+FlashVars+'" width="'+ width +'" height="'+ height +'" wmode="opaque" menu="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');       
		adhtml +=('</object>');
		document.write(adhtml);
	}
	else if(node.length == 1){
		movie = node[0].getElementsByTagName('pic')[0].textContent;
		src = node[0].getElementsByTagName('pic')[0].textContent;
		width = node[0].getElementsByTagName('width')[0].textContent;
		height = node[0].getElementsByTagName('height')[0].textContent;
		id = node[0].getElementsByTagName('id')[0].textContent;
		url = node[0].getElementsByTagName('url')[0].textContent;
		bname=node[0].getElementsByTagName('name')[0].textContent;
		if(src.indexOf('.swf') > -1){
			var adhtml=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width+ +'" height="'+ height +'">');           
			adhtml +=('<param name="movie" value="'+src+'">');
			adhtml +=('<param name="quality" value="high">');
			adhtml +=('<param name="menu" value="false">');
			adhtml +=('<param name="wmode" value="opaque">');
			adhtml +=('<param name="allowScriptAccess" value="sameDomain">');
			adhtml +=('<param name="type" value="application/x-shockwave-flash">');
			adhtml +=('<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer">');
			adhtml +=('<embed src="'+src+'" width="'+ width +'" height="'+ height +'" wmode="opaque" bgcolor="#ffffff" menu="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			adhtml +=('</object>');

			//统计代码
			if(url && url != 'http://')
			{
				html = '<div id="flashDiv" style="position:absolute; width:'+width+'; height:'+height+'; z-index:1;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="http://images.yescar.cn/ad/flash.gif" width='+width+' height='+height+' border="0" /></a></div>';
			}
			document.write(html+adhtml);
		}
		else{
			var imghtml = '<a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="'+src+'" width="'+width+'" height="'+height+'" border="0" style="background-color:#FFFFFF" /></a>';
			document.write(imghtml);
		}
	}
}


//*********************下拉广告******************************************]
function adshowdown(aid){
	if(isie){
		adshowdown_byIE(aid);
	}
	else{
		adshowdown_byFF(aid);
	}
}



var intervalId = null;    
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){    
  this.stayTime=nStayTime*1000 || 3000;    
  this.maxHeigth=nMaxHth || 340;    
  this.minHeigth=nMinHth || 2.5;    
  this.state=sState || "down" ;    
  var obj = document.getElementById(id);    
  if(intervalId != null)window.clearInterval(intervalId);
      
  function openBox(){    
   var h = obj.offsetHeight;    
   obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";    
    if(obj.offsetHeight>this.maxHeigth){    
    window.clearInterval(intervalId);    
    intervalId=window.setInterval(closeBox,this.stayTime);    
    }    
    if (obj.offsetHeight<this.minHeigth){    
    window.clearInterval(intervalId);    
    obj.style.display="none";    
	//obj.style.height = "72px";
    }
  }    
  
  function closeBox(){    
   slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);    
  }    
  intervalId = window.setInterval(openBox,30); 
}   


function adshowdown_byIE(aid){
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async = false;
	if(!xmlDoc.load('/xml/ad/'+aid+'.xml')){
		return;
	}
	
	var codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0';
	var src = 'http://www.yescar.cn/images/picxg';
	var src2 = 'http://www.yescar.cn/images/picxg.swf';
	var wmode = 'opaque';
	var quality = 'high';
	var pluginspage = 'http://www.macromedia.com/go/getflashplayer';
	var movie = 'http://www.yescar.cn/images/picxg';
	
	var id = '';
	var width = '';
	var height = '';
	var url = '';
	var endtime = '';
	
	var pic = '';
	var links = '';
	var bname = '';
	var time = '';
	var FlashVars = '';
	
	var html = '';
	var str = '';
	
	var root = xmlDoc.documentElement;
	var node = root.getElementsByTagName('Table');
	
	for(i=0;i<node.length;i++){
		endtime = node[i].selectSingleNode('endtime').text;
		if(IsOverTime(endtime)){
			root.removeChild(node[i]);
		} 
	}
	node = root.getElementsByTagName('Table');
	
	if(node.length > 1){
		width = node[0].selectSingleNode('width').text;
		height = node[0].selectSingleNode('height').text;
		for(i=0;i<node.length;i++){
			pic = pic + '|' + node[i].selectSingleNode('pic').text;
			links = links + '|' + node[i].selectSingleNode('url').text;
			bname = bname + '|' + node[i].selectSingleNode('name').text;
			time = time + '|' + node[i].selectSingleNode('time').text;
		}
		pic = pic.replace('|','');
		links = pic.replace('|','');
		bname = pic.replace('|','');
		time = pic.replace('|','');
		FlashVars = 'pics='+pic+'&links='+links+'&bname='+bname+'&timesAd='+time+'&pWidth='+width+'&pHeight='+height;
		
		str =  AC_FL_RunContent( 'codebase',codebase,'width',width,'height',height,'src',src,'wmode',wmode,'quality',quality,'FlashVars',FlashVars,'pluginspage',pluginspage,'movie',movie );			
			
		document.write(html+str);
	}
	else if(node.length == 1){
		movie = node[0].selectSingleNode('pic').text;
		src = node[0].selectSingleNode('pic').text;
		width = node[0].selectSingleNode('width').text;
		height = node[0].selectSingleNode('height').text;
		id = node[0].selectSingleNode('id').text;
		url = node[0].selectSingleNode('url').text;
		bname = node[0].selectSingleNode('name').text;
		if(src.indexOf('.swf') > -1){
			str = AC_FL_RunContent( 'codebase',codebase,'width',width,'height',height,'src',src.replace('.swf',''),'quality',quality,'wmode',wmode,'pluginspage',pluginspage,'movie',movie.replace('.swf','') );
			
			
			//统计代码
			if(url && url != 'http://')
			{
				html = '<div id="flashDiv" style="position:absolute; width:'+width+'; height:'+height+'; z-index:1;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="http://images.yescar.cn/ad/flash.gif" width='+width+' height='+height+' border="0" /></a></div>';
			}
			
			document.write(html+str);
			
		}
		else{
			var imghtml = '<div id="MyMoveAd" class="dbad" style="background:#ffffff;height:12px;overflow:hidden;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="'+src+'" width="'+width+'" height="'+height+'" border="0" style="background-color:#FFFFFF" /></a></div><script type="text/javascript">slideAd("MyMoveAd",5);</script>';
			document.write(imghtml);
		}
	}
}



function adshowdown_byFF(aid){
	var xmlDoc = loadxmldoc('/xml/ad/'+aid+'.xml');
	if(!xmlDoc){
		return;
	}
	
	var codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0';
	var src = 'http://www.yescar.cn/images/picxg';
	var src2 = 'http://www.yescar.cn/images/picxg.swf';
	var wmode = 'opaque';
	var quality = 'high';
	var pluginspage = 'http://www.macromedia.com/go/getflashplayer';
	var movie = 'http://www.yescar.cn/images/picxg';
	
	var id = '';
	var width = '';
	var height = '';
	var url = '';
	var endtime;

	var html='';
	
	var pic = '';
	var links = '';
	var bname = '';
	var time = '';
	var FlashVars = '';
	
	var root = xmlDoc.documentElement;
	var node = root.getElementsByTagName('Table');
	
	for(i=0;i<node.length;i++){
		endtime = node[i].getElementsByTagName('endtime')[0].textContent;
		if(IsOverTime(endtime)){
			root.removeChild(node[i]);
		}
	}
	node = root.getElementsByTagName('Table');
	
	
	if(node.length > 1){
		width = node[0].getElementsByTagName('width')[0].textContent;
		height = node[0].getElementsByTagName('height')[0].textContent;
		for(i=0;i<node.length;i++){
			pic = pic + '|' + node[i].getElementsByTagName('pic')[0].textContent;
			links = links + '|' + node[i].getElementsByTagName('url')[0].textContent;
			bname = bname + '|' + node[i].getElementsByTagName('name')[0].textContent;
			time = time + '|' + node[i].getElementsByTagName('time')[0].textContent;
		}
		
		pic = pic.replace('|','');
		links = pic.replace('|','');
		bname = pic.replace('|','');
		time = pic.replace('|','');
		FlashVars = 'pics='+pic+'&links='+links+'&bname='+bname+'&timesAd='+time+'&pWidth='+width+'&pHeight='+height;
		
		var adhtml=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width+ +'" height="'+ height +'">');           
		adhtml +=('<param name="movie" value="'+src2+'">');
		adhtml +=('<param name="quality" value="high">');  
		adhtml +=('<param name="menu" value="false">');
		adhtml +=('<param name="wmode" value="opaque">');
		adhtml +=('<param name="allowScriptAccess" value="sameDomain">');
		adhtml +=('<param name="type" value="application/x-shockwave-flash">');
		adhtml +=('<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer">');
		adhtml +=('<param name="FlashVars" value="'+FlashVars+'">');
		adhtml +=('<embed src="'+src2+'" FlashVars="'+FlashVars+'" width="'+ width +'" height="'+ height +'" wmode="opaque" menu="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');       
		adhtml +=('</object>');
		document.write(adhtml);
	}
	else if(node.length == 1){
		movie = node[0].getElementsByTagName('pic')[0].textContent;
		src = node[0].getElementsByTagName('pic')[0].textContent;
		width = node[0].getElementsByTagName('width')[0].textContent;
		height = node[0].getElementsByTagName('height')[0].textContent;
		id = node[0].getElementsByTagName('id')[0].textContent;
		url = node[0].getElementsByTagName('url')[0].textContent;
		bname=node[0].getElementsByTagName('name')[0].textContent;
		if(src.indexOf('.swf') > -1){
			var adhtml=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width+ +'" height="'+ height +'">');           
			adhtml +=('<param name="movie" value="'+src+'">');
			adhtml +=('<param name="quality" value="high">');
			adhtml +=('<param name="menu" value="false">');
			adhtml +=('<param name="wmode" value="opaque">');
			adhtml +=('<param name="allowScriptAccess" value="sameDomain">');
			adhtml +=('<param name="type" value="application/x-shockwave-flash">');
			adhtml +=('<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer">');
			adhtml +=('<embed src="'+src+'" width="'+ width +'" height="'+ height +'" wmode="opaque" bgcolor="#ffffff" menu="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			adhtml +=('</object>');

			//统计代码
			if(url && url != 'http://')
			{
				html = '<div id="flashDiv" style="position:absolute; width:'+width+'; height:'+height+'; z-index:1;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="http://images.yescar.cn/ad/flash.gif" width='+width+' height='+height+' border="0" /></a></div>';
			}
			document.write(html+adhtml);
		}
		else{
			var imghtml = '<div id="MyMoveAd" class="dbad" style="background:#ffffff;height:12px;overflow:hidden;"><a href="'+url+'" target="_blank" onclick=\'adStat("'+bname+'");\'><img src="'+src+'" width="'+width+'" height="'+height+'" border="0" style="background-color:#FFFFFF" /></a></div><script type="text/javascript">slideAd("MyMoveAd",5);</script>';
			document.write(imghtml);
		}
		
	}
}

/*   function  getdata()
    {
		var  strurl="../WebService/Users.asmx/Login?UserName="  +  strUser  +  "&Password="  +  strPass;

                        var  xmlHttp;
                        try
                          {
                                xmlHttp  =  new  XMLHttpRequest();
                          }
                        catch  (e)
                          {
                                  xmlHttp=new  ActiveXObject('Microsoft.XMLHTTP');
                            }
                        xmlHttp.open("GET",strurl,  false);
                        xmlHttp.send(null);

		
		
        var  index=0;      
        docSubmit  =new  ActiveXObject("Microsoft.XMLDOM");
        docSubmit.async  =  false;      
        docSubmit.load("http://localhost/WebApplication1/Service1.asmx/GetData?maxval=5");      
        docSubmit.loadXML(docSubmit.xml.replace(/&lt;/g,"<").replace(/&gt;/g,">"));
              
        var  s="";    
        nodeList=docSubmit.documentElement.getElementsByTagName("ds");
        for  (i=0;i<nodeList.length;i++)
        {
          s=s+nodeList(i).selectSingleNode("KeShimch").text+'<br>';
        }
        div1.innerHtml  ="";
        div1.innerHTML=s;
        div1.style.visibility="visible";              
    }        

  
//如果返回是个字符串：
 
      function  chang()
      {                  
        docSubmit  =new  ActiveXObject("Microsoft.XMLDOM");
        docSubmit.async  =  false;      
        docSubmit.load("http://localhost/Advertisement/ADService.asmx/GetADCode?ADID=1");      
                
        var  s=docSubmit.documentElement.text;    
        
        window.alert(s);        
        td_AD.innerHTML=s;                
      }      
      //setInterval(chang,2000);//间隔执行        
	  */



