﻿o.lastScrollY=0;
o.adId="advertizer";
o.adW=0;
o.adH=0;
header();
o.couplet=o["o"]("CoupletL","CoupletR");
if(o.couplet){setInterval("scrollCouplet_onload()",10);}
function pf(s){document.write(s);}
function header(){
	toToolsBar();
	try{
		var pathname=document.location.pathname.replace(/\//,"");
		if (!pathname) {
			pf(getAd(1,true,false));// waterfall
		}
		pf(getAd(8,false,true));// top banner
		// top menus
		var symbol='<span>|</span>';
		pf('<table align="center" cellpadding="0" cellspacing="0" class="standard">');
    	pf('<tr>');
    		pf('<td id="m2CellC">'); 
    		if (typeof o.tles!="undefined") { 
    			flashURL=o.tles.length;
    			for (var i=0;i<flashURL;i++) {
    				if (i==flashURL-1) {
    					symbol='';
    				}
    				pf('<a href="'+ o.urls[i] +'">'+ o.tles[i] +'</a>'+symbol);
    			}
    		}
	    	pf('</td>');
    	pf('</tr>');
		pf('</table>');
		topFixedCouplet();
		scrollCouplet();
	}catch(e){alert(e.message+"\n\n"+ header);}
} 
function toToolsBar(){
	pf('<table align="center" cellpadding="2" cellspacing="0" class="standard" style="background:url(/ig/bg/1x28.gif) repeat-x;height:28px;">');
	pf('<tr>');
	pf('<td><a href="/attachment/calendar" id="clock"></a></td>');
	pf('<td align="right"><a href="" onclick="return setHomePage(this);">设为主页</a> <a href="" onclick="return addFavorite();">收藏本页</a></td>');
	pf('</tr>');
	pf('</table>');timerContainer('clock');
}
/********************************************
* get ad from id
********************************************/
function getAd(id,closebar,isBackground){
	if (typeof o.adsId!="undefined") {
		for (var i=0;i<o.adsId.length;i++){
			if (o.adsId[i]==id){
				o.adW=o.adsWidth[i];
				o.adH=o.adsHeight[i];
				return getAdBox(id,o.adsImgUrl[i],o.adsWebUrl[i],o.adsWidth[i],o.adsHeight[i],closebar,isBackground);
			}
		}
	}
	return null;
}
/********************************************
* getAdBox
********************************************/
function getAdBox(id,imgurl,weburl,w,h,closebar,isBackground){
	if (imgurl) {
		id=o.adId+id;
		var background="";
		var flashURL="";
		if (isImage(imgurl)) {
			if (isBackground) {
				background=' background="'+ imgurl +'"';
				flashURL='/flash/'+(parseInt(Math.random()*16))+'.swf';
				flashURL=f(w,h,flashURL,true);
			} else {
				flashURL="<img src='"+ imgurl +"' width='"+ w +"' height='"+ h +"' border='0' />";
				if (weburl) {
					flashURL="<a href='"+ weburl +"' target='_blank'>"+ flashURL +"</a>";
				}
			}
		} else if (isFlash(imgurl)) {
			flashURL=f(w,h,imgurl,true);;
		}
		if (closebar) {
			closebar='<tr><td class="closebar"><img title="关闭" src="/images/skin/close.gif" onclick="hideAndShow(\''+id+'\');" /></td></tr>';
		} else {
			closebar="";
		}
		
		var ad_click="";
		if (/(\d+)/g.test(id)) {
			ad_click='onclick="ad_click(this,'+RegExp["$1"]+');"';
		}
		return'<table id="'+id+'" '+ad_click+' width="'+w+'" height="'+h+'" align="center" cellpadding="0" cellspacing="0"'+background+'><tr><td>'+flashURL+'</td></tr>'+closebar+'</table>';
	}   return '';
}
/********************************************
* couplet
********************************************/
function topFixedCouplet(){
	var couplet;
	couplet=getAd(4,true,false);
	if (couplet) {
		pf('<div id="topFixedCoupletL" style="top:5px;left:2px;">'+couplet+'</div>');
	}
	couplet=getAd(5,true,false);
	if (couplet) {
		pf('<div id="topFixedCoupletR" style="top:5px;right:2px;">'+couplet+'</div>');
	}
}
function scrollCouplet(){
	var couplet;
	couplet=getAd(6,true,false);
	if (couplet) {
		pf('<div id="CoupletL" style="top:230px;left:2px;">'+couplet+'</div>');
	}
	couplet=getAd(7,true,false);
	if (couplet) {
		pf('<div id="CoupletR" style="top:230px;right:2px;">'+couplet+'</div>');
	}
}
function scrollCouplet_onload(){
	var y;
	if (document.documentElement&&document.documentElement.scrollTop) {
		y=document.documentElement.scrollTop;
	} else if (document.body) {
		y=document.body.scrollTop;
	} else {
		// Netscape stuff in here
	}
	percent=.1*(y-o.lastScrollY);
	if (percent>0)
		percent=Math.ceil(percent);
	else 
		percent=Math.floor(percent);
	
	var lCouplet=o.couplet[0];
	if (!lCouplet) {
		lCouplet=document.getElementById("CoupletL");
	}
	if (lCouplet) {
		lCouplet.style.top=parseInt(lCouplet.style.top) + percent +"px";
	}
	var rCouplet=o.couplet[1];
	if (!rCouplet) {
		rCouplet=document.getElementById("CoupletR");
	}
	if (rCouplet) {
		rCouplet.style.top=parseInt(rCouplet.style.top) + percent +"px";
	}
	o.lastScrollY=o.lastScrollY + percent;
}