﻿//偵測瀏覽器的類型
	if (navigator.appVersion.indexOf("MSIE 6.0")!=-1)
	{
		document.getElementById('dyn_news').innerHTML = '<div id="ad_news" style="width: 300px; position: absolute; height: 50px; left: 50px; top: 250px;"></div>';
		document.getElementById('dyn_ad').innerHTML = '<div id="ad_img" style="width: 125px; position: absolute; height: 150px; left: 185px; top: 450px;"></div>';
	}
	else
	{
		document.getElementById('dyn_news').innerHTML = '<div id="ad_news" style="width: 300px; position: absolute; height: 50px; left: 50px; top: 250px;"></div>';
		document.getElementById('dyn_ad').innerHTML = '<div id="ad_img" style="width: 125px; position: absolute; height: 150px; left: 185px; top: 450px;"></div>';
	}
//偵測瀏覽器以取決使用XML物件的代碼
function jb() 
{
 var A=null;
 try 
 {
    A=new ActiveXObject("Msxml2.XMLHTTP");
    //alert (ActiveXObject('Msxml2.XMLHTTP'));
 }
 catch(e) 
 {
    try 
    {
        A=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(oc) 
    {
        A=null;
    }
 }
 if ( !A && typeof XMLHttpRequest != "undefined" ) 
 {
    A=new XMLHttpRequest();
        if (A.overrideMimeType) 
        {
            A.overrideMimeType('text/xml');
        }
 }
 return A;
}
//AJAX部分
//var XmlHttp = jb();
function get_news()
{
	var XmlHttp = jb();
	XmlHttp.open("GET", "ad_play/receive_news.aspx", true);
	XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XmlHttp.setRequestHeader("If-Modified-Since","0");
	XmlHttp.send(null);
	XmlHttp.onreadystatechange=function(){ServerProcess_2(XmlHttp);};
}
function ServerProcess_2(XmlHttp)
{
	//alert (XmlHttp.readyState);
	if (XmlHttp.readyState==4 || XmlHttp.readyState=='complete')
	{
	  if (XmlHttp.status == 200) 
	  {
		  document.getElementById('ad_news').innerHTML = XmlHttp.responseText;
		}
	}
}
function get_img_n()
{
	var XmlHttp = jb();
	XmlHttp.open("GET", "ad_play/receive_img.aspx", true);
	XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	XmlHttp.setRequestHeader("If-Modified-Since","0");
	XmlHttp.send(null);
	XmlHttp.onreadystatechange=function(){ServerProcess(XmlHttp);};
}
function ServerProcess(XmlHttp)
{
	if (XmlHttp.readyState==4 || XmlHttp.readyState=='complete')
	{
	  if (XmlHttp.status == 200) 
	  {
		  document.getElementById('ad_img').innerHTML = XmlHttp.responseText;
		}
	}
}
get_news();
get_img_n();
setInterval('get_img_n()',6000);