var mydate = new Date();
var YY = mydate.getFullYear();
var MM = mydate.getMonth()+1;
var DD = mydate.getDate();
var timer=100 ;
var isHomePage2="false";
var isChannelOn="false";
function RunAgain() {
}
   if(window.location.host.toLowerCase().indexOf("tech.chinatimes.com")>-1)
   {
    	if(String(window.location).toLowerCase().indexOf("2007cti-news-tech-inc")<0)
		 {
			var reUrl=new RegExp("tech.chinatimes.com","i");
			var sRedirUrl=String(window.location);
			sRedirUrl=sRedirUrl.replace(reUrl, "news.chinatimes.com");
			window.location.href=sRedirUrl;
		 }
   }

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_jumpMenuopen(targ,selObj,restore){ //v3.0
 var temp = selObj.options[selObj.selectedIndex].value
 window.open(temp,"_blank");
 if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Cti2007getCookie(name)
{
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length>0)
	{
		var begin = dc.indexOf(cname);
		if (begin != -1)
		{
			begin += cname.length;
			var end = dc.indexOf(";" , begin);
			if (end == -1)
			{
				end = dc.length;
			}
			return unescape(dc.substring(begin,end));
		}
	}
	return null;
}

function Cti2007setCookie(name, value, expires)
{
	document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? " " : "; expires=" + expires.toGMTString());
	//document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? " " : "; expires=" + expires.toGMTString())+";domain="+domain+";";
}

function Cti2007delCookie(name)
{
	document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";
}

function CreatScript(Src) 
{

var oDIVResults=document.createElement('script'); 
oDIVResults.src=Src; 
document.getElementsByTagName("head").item(0).appendChild(oDIVResults);
}

function CreatDiv(whitchdiv,divTop,divLeft) 
{
 var oDIVResults=document.createElement('div');
	    oDIVResults.id=whitchdiv;
	    document.getElementsByTagName("body").item(0).appendChild(oDIVResults);
	    oDIVResults=document.getElementById(whitchdiv);
	    oDIVResults.style.position="absolute";
		oDIVResults.style.display="none"
		//oDIVResults.style.VISIBILITY="hidden";
	    oDIVResults.style.left=divTop;
	    oDIVResults.style.top=divTop;
}

function makeContent(url,whichDiv) {

var http_request = false;
var content;
var timer = 0;

function makeRequest(url) {
    
    timer++;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        /*		try {
             http_request= new ActiveXObject("Msxml2.XMLHTTP");
			
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
		*/
		var sCHValue="MSXML2.XMLHttp.5.0,MSXML2.XMLHttp.4.0,MSXML2.XMLHttp.3.0,MSXML2.XMLHttp,Microsoft.XMLHttp";
        var aVersions = sCHValue.split(",");
		for (var i = 0; i < aVersions.length; i++) {
	        try {
	            http_request = new ActiveXObject(aVersions[i]);
	           
	        } catch (oError) {
	            //Do nothing
	        }
	    }

    }

    if (!http_request) {
        //alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }

    http_request.onreadystatechange = insertContents;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function insertContents() {
	try {
    if (http_request.readyState == 4) {
        if (http_request.status == 200 && document.getElementById(whichDiv)) {
         
          document.getElementById(whichDiv).innerHTML=http_request.responseText;
		  
		  
        } else {
		   
			var str='setTimeout("makeContent(';
			    str=str+"'"+url+"','"+whichDiv+"');";
				str=str+'",100);';
			eval(str);
			
        }
    } else {//alert(http_request.readyState)
	}
    } catch(e) { //alert(e.message)
    
	}
}   

makeRequest(url);

}

function makeContent2(url,whichDiv,func) {

var http_request = false;
var content;
var timer = 0;

function makeRequest(url) {
    
    timer++;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        /*		try {
             http_request= new ActiveXObject("Msxml2.XMLHTTP");
			
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
		*/
		var sCHValue="MSXML2.XMLHttp.5.0,MSXML2.XMLHttp.4.0,MSXML2.XMLHttp.3.0,MSXML2.XMLHttp,Microsoft.XMLHttp";
        var aVersions = sCHValue.split(",");
		for (var i = 0; i < aVersions.length; i++) {
	        try {
	            http_request = new ActiveXObject(aVersions[i]);
	           
	        } catch (oError) {
	            //Do nothing
	        }
	    }

    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = insertContents;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function insertContents() {
	try {
    if (http_request.readyState == 4) {
        if (http_request.status == 200 && document.getElementById(whichDiv)) {
         
          document.getElementById(whichDiv).innerHTML=http_request.responseText;
		  
		  
        } else {
		   var str='setTimeout("makeContent(';
			    str=str+"'"+url+"','"+whichDiv+"');";
				str=str+'",100);';
			eval(str);
        }
    }
    } catch(e) {
	
	}
}   

makeRequest(url);
eval(func);

}

function calculateSumOffset(objItem, offsetName) 
{
//if( g_IsSupport == false )
//return 0;
var totalOffset = 0;
var item = objItem;
do
{
totalOffset += eval('item.'+offsetName);
item = eval('item.offsetParent');
} while (item != null);
return totalOffset;
}

function customSetupon() 
{	
	
	var SetupCHannelArray = new Array(
	"/2007Cti/2007Cti-Common/Inc/2007-TotalHeader/1,4554,THpJd01EZERkR2t2TWpBd04wTjBhUzFKYm1SbGVDMXBibU12U1c1akx6SXdNRGN0TURNdFEyaHZhV05sUTJndFUyVjBkWEFnWTI5dWRHVnVkQT09,00.jhtml",
	"/2007Cti/2007Cti-Common/Inc/2007-TotalHeader/1,4554,THpJd01EZERkR2t2TWpBd04wTjBhUzFKYm1SbGVDMXBibU12U1c1akx6SXdNRGN0TURNdFEyaHZhV05sUTJndFUyVjBkWEFnYVc1bWIzSnRZWFJwYjI0PQ==,00.jhtml",
	"/2007Cti/2007Cti-Common/Inc/2007-TotalHeader/1,4554,THpJd01EZERkR2t2TWpBd04wTjBhUzFKYm1SbGVDMXBibU12U1c1akx6SXdNRGN0TURNdFEyaHZhV05sUTJndFUyVjBkWEFnWW5WemFXNWxjM009,00.jhtml"
	);
	//try {
	
	if (!g_IsExpressDownload)
	{
	    var i=Math.floor(Math.random()*2)
		//alert(i)
		void(CreatDiv("customSetuponDiv",100,100) );
		//void(makeContent(SetupCHannelArray[i],"customSetuponDiv"));
		g_IsExpressDownload=true;
	}
	
	document.getElementById('customSetuponDiv').style.top=parseInt(parent.document.body.scrollTop)+10;
	document.getElementById('customSetuponDiv').style.left=10;
	document.getElementById('customSetuponDiv').style.display="block";
//} catch(e) {}
}

function changePage(URL) {
if(document.getElementById("Choiceiframe"))
document.getElementById("Choiceiframe").src=URL;
}

function displayWeather() {
if(document.getElementById("setweather"))
document.getElementById("setweather").style.visibility="visible";
}

function rtnMorePage() {
if(document.getElementById("rtnews10").innerHTML||(document.getElementById("rtnews10").innerHTML).length==0){
makeContent("/2007Cti/2007Cti-Common/Inc/2007-TotalHeader/1,4554,THpJd01EZERkR2t2TWpBd04wTjBhUzFKYm1SbGVDMXBibU12U1c1akx6SXdNRGN0TURFdFZHOXdMVkowYmpBeQ==,00.jhtml","rtnews10");
document.getElementById("rtnews10").style.top=calculateSumOffset( document.getElementById("rtnews20"), 'offsetTop')
document.getElementById("rtnews10").style.left=calculateSumOffset( document.getElementById("rtnews20"), 'offsetLeft')
//alert(calculateSumOffset( document.getElementById("rtnews20"), 'offsetLeft'))
}
MM_showHideLayers('setweather','','hide','rtnews10','','show')

}

function MakeFwdContent()
{
	
	if(document.getElementById("CtiFwd") ==null)
	{ 
		CreatDiv("CtiFwd",100,100);
		
		makeContent("/2007Cti/2007Cti-Common/Inc/2007-TotalHeader/1,4554,THpJd01EZERkR2t2TWpBd04wTjBhUzFEYjIxdGIyNHZTVzVqTHpJd01EZERkR2t0Um05eWQyRnlaQT09,00.jhtml","CtiFwd");
	
	}
	
	document.getElementById('CtiFwd').style.top=parseInt(parent.document.body.scrollTop)+100;
	document.getElementById("CtiFwd").style.display="block";
}
function MakeFwdContentClose()
{
if(document.getElementById("CtiFwd"))
	{ 
		document.getElementById("ctiforwarddiframe").src="/2007Cti/2007Cti-Common/Inc/2007Cti-Forward-iFrame/0,4684,,00.html";
		document.getElementById("CtiFwd").style.display="none";
	}
}

function MakeCTIweb20 ()
{
var CTIweb20Str;
if(document.getElementById("CTIweb20"))
	{ 
		CTIweb20Str='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		CTIweb20Str=CTIweb20Str+'<a href="http://funp.com/push/submit/add.php?url='+ encodeURIComponent(String(window.location))+'&s='+encodeURI(define_content_1)+"&via=tool";
		CTIweb20Str=CTIweb20Str+'" target=_blank><img src="http://www.chinatimes.com/2007Cti/2007Cti-index/images/961002funp.gif" alt="funp" width="80" height="15" hspace="2" vspace="2" border="0" align="middle"></a>&nbsp;&nbsp;/ &nbsp;&nbsp;';
		
		CTIweb20Str=CTIweb20Str+'<a href="http://www.hemidemi.com/user_bookmark/new?url='+encodeURIComponent(String(window.location))+'&title='+encodeURI(define_content_1);
		CTIweb20Str=CTIweb20Str+'" target=_blank><img src="http://www.chinatimes.com/2007Cti/2007Cti-index/images/ico-hemidemi.png" width="80" height="15" hspace="3" vspace="3" border="0" align="middle"></a>&nbsp;&nbsp;/ &nbsp;&nbsp;';
		
		var desc='';var via='';if(document.referrer)via=document.referrer;if(typeof(_ref)!='undefined')via=_ref;
		CTIweb20Str=CTIweb20Str+'<a href="http://bookmark.udn.com/add?f_TITLE='+encodeURIComponent(define_content_1)+'&f_URL='+encodeURIComponent(location.href)+'&f_DIGEST='+encodeURIComponent(desc)+'&via='+encodeURIComponent(via);
		CTIweb20Str=CTIweb20Str+'" target=_blank><img src="http://www.chinatimes.com/2007Cti/2007Cti-index/images/961002udn.gif" border="0" alt="udn" width="80" height="15" hspace="2" vspace="2" align="middle" /></a>&nbsp;&nbsp;/ &nbsp;&nbsp;';
		
		CTIweb20Str=CTIweb20Str+'<a href="http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url='+encodeURIComponent(String(window.location))+'&desc='+encodeURI(define_content_1);
		CTIweb20Str=CTIweb20Str+'" target=_blank><img src="http://www.chinatimes.com/2007Cti/2007Cti-index/images/add2myshare_80x15-1.gif" alt="收進你的MyShare個人書籤" title="收進你的MyShare個人書籤" hspace="2" vspace="2" border="0" align="middle"></a>';
		document.getElementById("CTIweb20").innerHTML=CTIweb20Str;
		
	}
}

if(document.getElementById("todayDate"))
document.getElementById("todayDate").innerHTML=YY+"."+MM+"."+DD+" ";

MakeCTIweb20();


