//写入 cookie
//不区分 cookieName 的大小写
//不考虑子键
function initCookies(cookieName, cookieValue, expires){
	if (expires){
		document.cookie = GetCookieName(cookieName) + "=" + escape(cookieValue) + "; expires=" + expires.toGMTString();
	}
	else{
		document.cookie = GetCookieName(cookieName) + "=" + escape(cookieValue);
	}
}

//获取并返回与 cookieName 同名的 cookie 名称，允许大小写不同
//如果不存在这样的 cookie，就返回 cookieName
function GetCookieName(cookieName){
	var lowerCookieName = cookieName.toLowerCase();
	var cookieStr = document.cookie;
	if (cookieStr == ""){
		return cookieName;
	}
	var cookieArr = cookieStr.split("; ");
	var pos = -1;
	for (var i=0; i<cookieArr.length; i++){
		pos = cookieArr[i].indexOf("=");
		if (pos > 0){
			if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName){
				return cookieArr[i].substring(0, pos);
			}
		}
	}
	return cookieName;
}

//获取并返回 cookie 值
//不区分 cookieName 的大小写
//defaultValue 为默认返回值
//不考虑子键
function getCookies(cookieName, defaultValue){
	var lowerCookieName = cookieName.toLowerCase();
	var cookieStr = document.cookie;
	if (cookieStr == ""){
		return defaultValue;
	}
	var cookieArr = cookieStr.split("; ");
	var pos = -1;
	for (var i=0; i<cookieArr.length; i++){
		pos = cookieArr[i].indexOf("=");
		if (pos > 0){
			if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName){
				return unescape(cookieArr[i].substring(pos+1, cookieArr[i].length));
			}
		}
	}
	return defaultValue;
}

function initAdRotation(){
	var AdStr1 = "<embed src='http://img3.fj007.com/money/2008/5/apple.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='794' height='70' wmode='transparent'></embed>";
	var AdStr2 = "<embed src='http://img3.fj007.com/money/2008/5/apple.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='794' height='70' wmode='transparent'></embed>";
	var curAd = getCookies("curAd","1");
	if (curAd=="1"){
		curAd = "2";
		document.getElementById("AdRotation").innerHTML =AdStr1;
	}
	else{
		curAd = "1";
		document.getElementById("AdRotation").innerHTML =AdStr2;
	}

	var expires = new Date("December 31, 2045");
	initCookies("curAd", curAd, expires);
}

function initAd1()
{
	/*************************************************/
	var curAd1 = getCookies("curAd1","1");
//	if (curAd1=="1"){
//		curAd1 = "2";
		//TopAD
		//document.getElementById("TopAD").innerHTML ='<a href="http://zt.fj007.com/0951lj" target="_blank"><img src="http://img3.fj007.com/money/2009/4/0951lj.gif" width="958" height="80" border="0" /></a>';
//	}
//	else{
//		curAd1 = "1";
//		document.getElementById("topad2").innerHTML ='<a href="http://zt.fj007.com/1dmx" target="_blank"><img src="http://img3.fj007.com/money/2009/3/mxzt.gif" width="477" height="70" border="0" /></a>';
//		}

	var expires = new Date("December 31, 2045");
	initCookies("curAd1", curAd1, expires);
	/*************************************************/
	document.getElementById("Ad1").innerHTML = '<a href="http://www.jinmax.com" target="_blank"><img src="http://img3.fj007.com/money/2008/1/jm1.gif" width="150" height="145" border="0" /></a>';
	/*************************************************/
}

function initAd2()
{
	//document.getElementById("Ad2").innerHTML = '<a href="http://www.2so.com.cn/" target="_blank"><img src="img3.fj007.com/money/2008/2/2s.gif" width="794" height="70" border="0" /></a>';

	var curAd2 = getCookies("curAd2","1");
	if (curAd2=="1"){
		curAd2 = "2";
		document.getElementById("Ad2").innerHTML ='<a href="http://www.fzks.com.cn" target="_blank"><img src="http://img3.fj007.com/money/2008/3/08JS1.gif" width="794" height="70" border="0" /></a>';
	}
	else{
		curAd2 = "1";
		document.getElementById("Ad2").innerHTML ='<a href="http://www.fzks.com.cn" target="_blank"><img src="http://img3.fj007.com/money/2008/3/08JS1.gif" width="794" height="70" border="0" /></a>';
	}

	var expires = new Date("December 31, 2045");
	initCookies("curAd2", curAd2, expires);
}

function initAd3()
{
	//document.getElementById("Ad3").innerHTML = '<a href="http://www.007xm.com/buynow/" target="_blank"><img src="http://img3.fj007.com/money/2009/2/bnh.gif" width="477" height="70" border="0" /></a>'
}

function initAd4()
{
	//document.getElementById("Ad4").innerHTML = '<embed src="http://img3.fj007.com/money/2009/2/maya.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="477" height="70" wmode="Opaque"></embed><!--<a href="http://www.igooglejob.com/" target="_blank"><img src="http://img3.fj007.com/money/2008/10/hdhd.gif" width="477" height="70" border="0" /></a>-->'
}

function initAd5()
{
	document.getElementById("Ad5").innerHTML = '<table width=958 border=0 align="center" cellpadding=0 cellspacing=0><tr height=64><td width=315 valign=bottom><EMBED pluginspage=http://www.macromedia.com/go/getflashplayer src=http://img3.fj007.com/money/2009/2/31560.swf width=315 height=60 type=application/x-shockwave-flash quality="high"></EMBED></td><td width=321 align=right valign=bottom><a href="http://www.2so.com.cn" target=_blank><img src="http://img3.fj007.com/money/2009/3/2so315.gif" border=0></a></td><td width=321 align=right valign=bottom><a href="http://fj007.com/news/news_html/20084/200842371818_0.html" target=_blank><img src="http://img3.fj007.com/money/2009/2/mwmw1.gif" border=0></a></td></tr></table>';
}

function initAd6()
{
	document.getElementById("Ad6").innerHTML ='<TABLE cellSpacing=0 cellPadding=0 width=958 align=center border=0><tr><td height=4></td></tr><TR><TD vAlign=top><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TR><TD height=74 valign="top"><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="794" height="70"><param name="movie" value="http://img3.fj007.com/money/2009/5/950-60-modify.swf" /><param name="quality" value="high" /><embed src="http://img3.fj007.com/money/2009/5/950-60-modify.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="794" height="70"></embed></object></TD></TR><TR><TD height=74 valign="top"><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="794" height="70"><param name="movie" value="http://img3.fj007.com/money/2009/2/3lj.swf" /><param name="quality" value="high" /><embed src="http://img3.fj007.com/money/2009/2/3lj.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="794" height="70"></embed></object></TD></TR><TR><TD height=74><A href="http://www.ufida.com.cn/" target=_blank><IMG height=70 src="http://img3.fj007.com/money/2009/4/yysoft.gif" width=794 border=0></A></TD></TR></TABLE></TD><TD vAlign=top><EMBED pluginspage=http://www.macromedia.com/go/getflashplayer src=http://img3.fj007.com/money/2009/1/lak.swf width=150 height=145 type=application/x-shockwave-flash quality="high"></EMBED></TD></TR></TBODY></TABLE>';

	/*************************************************
	var curAd6 = getCookies("curAd6","1");
	if (curAd6=="1"){
		curAd6 = "2";
		document.getElementById("Ad6").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="201" valign="top"><a href="http://www.fj007.com/tuijian.htm" target="_blank"><img src="img3.fj007.com/money/2008/8/jj.gif" width="150" height="200" border="0" /></a></td></tr><tr><td height="123" valign="bottom"><a href="http://www.wayje.com" target="_blank"><img src="img3.fj007.com/money/2008/4/www.gif" width="150" height="120" border="0" /></a></td></tr></table>';
	}
	else{
		curAd6 = "1";
		document.getElementById("Ad6").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="201" valign="top"><a href="http://www.fj007.com/tuijian.htm" target="_blank"><img src="img3.fj007.com/money/2008/8/jj.gif" width="150" height="200" border="0" /></a></td></tr><tr><td height="123" valign="bottom"><a href="http://www.wayje.com" target="_blank"><img src="img3.fj007.com/money/2008/4/www.gif" width="150" height="120" border="0" /></a></td></tr></table>';
	}

	var expires = new Date("December 31, 2045");
	initCookies("curAd6", curAd6, expires);
	*************************************************/
	//document.getElementById("Ad6").innerHTML ="<!--<div style='margin-top:1px;'><a href='http://www.wayje.com' target='_blank'><img src='img3.fj007.com/money/2008/4/www.gif' width='150' height='120' border='0' /></a><\/div>-->";
}

function initAd7()
{
	document.getElementById("Ad7").innerHTML = '';

	//document.getElementById("Ad7_1").innerHTML = "<!--<div><a href=\"#\" onclick=\"javascript:goUrl(0); return false;\" ><img onmouseover=\"javascript:changeto(0);clearTimeout(theTimer);\" onmouseout=\"nextAd();\" id=\"a1\" name=\"a1\" src=\""+imgUrl[0].src+"\"  border=\"0\" \/><\/a><\/div>" + "<div><a href=\"#\" onclick=\"javascript:goUrl(1);  return false;\" ><img onmouseover=\"javascript:changeto(1);clearTimeout(theTimer);\" onmouseout=\"nextAd();\" id=\"a2\" name=\"a2\"  src=\""+imgUrl[1].src+"\" border=\"0\" \/><\/a><\/div>" + "<div><a href=\"#;\" onclick=\"javascript:goUrl(2);  return false;\" ><img onmouseover=\"javascript:changeto(2);clearTimeout(theTimer);\" onmouseout=\"nextAd();\" id=\"a3\" name=\"a3\"  src=\""+imgUrl[2].src+"\" border=\"0\" \/><\/a><\/div>--><embed src=\"http://img3.fj007.com/money/2009/1/lak.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"150\" height=\"145\"></embed>";
	//preloadPic();
}

function initAd8()
{
	document.getElementById("Ad8").innerHTML = '<table width="794" border="0" cellpadding="0" cellspacing="0"><tr><td height="75" align=left valign=bottom><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="958" height="70"><param name="movie" value="http://img3.fj007.com/money/2008/5/banner960X70.swf" /><param name="quality" value="high" /><embed src="http://img3.fj007.com/money/2008/5/banner960X70.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="794" height="70"></embed></object></td></tr><tr align="left" height=74><td valign=bottom><a href="http://www.fjpc007.com" target="_blank"><img src="http://img3.fj007.com/money/2008/7/xx1.gif" width="958" height="70" border="0" /></a></td></tr></table>';
}

function initAd9()
{
	document.getElementById("Ad9").innerHTML ='<table width="794" border="0" cellpadding="0" cellspacing="0"><tr><td height="75" align=left valign=bottom><a href="http://topic.ffw.com.cn/zt/news/2009/20090224xfhg/" target="_blank"><img src="http://img3.fj007.com/money/2009/2/954170.gif" width="958" height="70" border="0" /></a></td></tr></table>';
}

function initAd10()
{
	document.getElementById("Ad10").innerHTML ='<table width="794" border="0" cellpadding="0" cellspacing="0"><tr><td height="75" align=left valign=bottom><a href="http://fz.51qc.com/SeeCar/?from=007" target="_blank"><img src="http://img3.fj007.com/money/2009/3/51qc_95870.gif" width="958" height="70" border="0" /></a></td></tr></table>';
}

function initAd11()
{
	document.getElementById("Ad11").innerHTML ='';
}

function initAd12()
{
	//document.getElementById("Ad12").innerHTML ='';
}

function initAd13()
{
	//document.getElementById("Ad13").innerHTML ='<table width="156" border="0" cellspacing="0" cellpadding="0" style="border: solid 1px #A9CFE6;padding-top:2px;padding-bottom:2px;" align=right><tr><td height="120" align="center"><a href="http://fj007.com/news/news_html/20084/200842371818_0.html" target="_blank"><img src="http://img3.fj007.com/money/2007/1/mmll.gif" width="150" height="120" border="0" /></a></td></tr><tr><td height="120" align="center"><a href="http://shop.fj007.com/104273/" target="_blank"><img src="http://img3.fj007.com/money/2008/12/zhsm2.gif" width="150" height="70" border="0" /></a></td></tr></table>';
}

function initAd14()
{
	//document.getElementById("Ad14").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: solid 1px #A9CFE6;padding-top:2px;padding-bottom:2px;"><tr><td height="255" align="center"><a href="http://zt.fj007.com/3g" target="_blank"><img src="img3.fj007.com/money/2008/2/150250.jpg" width="150" height="250" border="0" /></a></td></tr></table>';
}


/**************************************/
var imgLink = new Array();

var imgUrl = new Array();
imgUrl[0] = new Image();
imgUrl[1] = new Image();
imgUrl[2] = new Image();

var imgUrl2 = new Array();
imgUrl2[0] = new Image();
imgUrl2[1] = new Image();
imgUrl2[2] = new Image();

imgUrl[0].src = 'images/ss1.gif'
imgLink[0] = 'http://www.fj007.com/tuijian.htm';
imgUrl2[0].src ='images/ss11.gif';

imgUrl[1].src = 'images/ss2.gif'
imgLink[1] =  'http://price.fj007.com/';
imgUrl2[1].src = 'images/ss21.gif';

imgUrl[2].src = 'images/ss3.gif'
imgLink[2] = 'http://www.iptime.cn/';
imgUrl2[2].src = 'images/ss31.gif';

var count = imgUrl.length;

var adNum = 0;

var imgPre = new Array();

function nextAd() {

	if (adNum < (count - 1)) {
		adNum++;
	} else {
		adNum = 0;
	}

	if(adNum==0) {
		document.a1.src = imgUrl[0].src;
		document.a2.src = imgUrl2[1].src;
		document.a3.src = imgUrl2[2].src;
	}
	if(adNum==1) {
		document.a1.src = imgUrl2[0].src;
		document.a2.src = imgUrl[1].src;
		document.a3.src = imgUrl2[2].src;
	}
	if(adNum==2) {
		document.a1.src = imgUrl2[0].src;
		document.a2.src = imgUrl2[1].src;
		document.a3.src = imgUrl[2].src;
	}
   theTimer = setTimeout("nextAd()", 3000);
}

function changeto(i) {
	if(i==0) {
		document.a1.src = imgUrl[0].src;
		document.a2.src = imgUrl2[1].src;
		document.a3.src = imgUrl2[2].src;
	}
	if(i==1) {
		document.a1.src = imgUrl2[0].src;
		document.a2.src = imgUrl[1].src;
		document.a3.src = imgUrl2[2].src;
	}
	if(i==2) {
		document.a1.src = imgUrl2[0].src;
		document.a2.src = imgUrl2[1].src;
		document.a3.src = imgUrl[2].src;
	}
}


function goUrl(num) {
	jumpUrl = imgLink[num];
	jumpTarget = '_blank';
	window.open(jumpUrl);
}
function preloadPic() {
	document.a1.src = imgUrl[0].src;
	document.a2.src = imgUrl2[1].src;
	document.a3.src = imgUrl2[2].src;
	nextAd();
}/**************************************/
