function RA_setCookie(name,value, days)
{
	var exp = new Date();
	exp.setTime(exp.getTime() + days*24*60*60*1000);
	document.cookie = name + "="+ escape(value) +";path=/;expires="+ exp.toGMTString();
}

function RA_getCookie(name)
{
	var arr = document.cookie.match(new RegExp("[\s\S]*"+ name +"=([^;]*)(;|$)"));
	if(arr != null)
		return unescape(arr[1]);
	return null;
}
function RA_addAd(type,width,height,res,url,sitename)
{
	var temp = ""
	if (type==1){
		temp = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		temp += '      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width +'" height="'+ height +'" vspace="0">';
		temp += '         <param name="movie" value="'+ res +'" />';
		temp += '         <param name="quality" value="high" />';
		temp += '         <param name="wmode" value="opaque" />';
		temp += '         <embed src="'+ res +'" width="'+ width +'" height="'+ height +'" vspace="0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque"></embed>';
		temp += '</object>';
	}
	if (type==2)
	{
		temp = '<a href="'+ url +'" target="_blank"><img src="'+ res +'" width="'+ width +'" height="'+ height +'" border="0"></a>'
	}
	adtemp = new Array()
	adtemp.code = temp;
	adtemp.sitename = sitename;
	RA_ad.push(adtemp);
}
function RA_show(divid,mode,time){
	var noadid = -1;
	var visa = "";
	if(RA_ad.length==0)return false;
	noadid = RA_getCookie("RandomAd"+divid);
	if (noadid == "")noadid= -1;
	if (noadid < RA_ad.length-1){
		noadid++;
	}else{
		noadid = 0;
	}
	//alert(noadid);
	RA_setCookie("RandomAd"+divid,noadid,30)
	var adcode = RA_ad[noadid].code;
	var adcity = RA_ad[noadid].sitename;
	document.getElementById(divid).innerHTML=adcode;
	if (mode==1)
	{
		setTimeout("RA_show('"+ divid +"',"+ mode +","+ time +")",time*1000);
	}
}
