
prevPag=new Object();
var duration=4000;
var nextInt=1;
pageVar="";


function swapMain(imageInt){
	duration=4000;
	pageVar=document.body.id;
	document.getElementById('mainImage').src=mainImageArray[imageInt-1];
	document.getElementById('moreinfoLink').href=document.getElementById('hidden_' + imageInt).getAttribute("rel");
	if(document.getElementById('hidden_' + imageInt).getAttribute("rel")=="")document.getElementById('infoLinkOuter').style.display="none"; else document.getElementById('infoLinkOuter').style.display="block";
	if(document.getElementById('hidden_' + imageInt).getAttribute("title")=="")document.getElementById('buyLinkOuter').style.display="none"; else document.getElementById('buyLinkOuter').style.display="block";
	if(!prevPag.parentNode){
		prevPag=document.getElementById("pag_1");
		}
	prevPag.parentNode.className="";	
	tmp=document.getElementById("pag_" + imageInt);
	tmp.parentNode.className="pagOn";
	prevPag=tmp;
	//alert(mainImageArray.length);
	if(nextInt>mainImageArray.length){
		nextInt=1;
	}
	clearInterval(rotateInterval);	
	rotateInterval=setInterval("swapMain("+ nextInt +")", duration);
	nextInt++;
}


function Random(X) {return Math.floor(X*(Math.random()%1))}

function rotateAd(){
	var ad="";
	tmpInt=Random(11);
	
	if(parent.globalEd)tmpInt=10;
	//ad="<a href='javascript:openWindow(\"http://www.soyouthinkyouknowhorseracing.com/?partner_id=00&amp;link_id=493&amp;ref=cheltenhamrc\",\"adwindow\",\"900,500\");' class='contentLink'><img src=/images/general/betsarein.jpg width='200' height='200' alt='Bets are in, Play the ultimate horse racing game' /></a>";
	ad="<a href='http://www.ladbrokes.com/ast?action=go_asset&aff_id=31426&asset_id=267'target='_blank'><img src='http://www.ladbrokes.com/ast?action=asset_req&imgonly=1&aff_id=3142 6&asset_id=267'width='200' height='200' border='0' alt=''/></a>";
	if(tmpInt==0)ad="<a href='javascript:openWindow(\"http://www.soyouthinkyouknowhorseracing.com/?partner_id=00&amp;link_id=493&amp;ref=cheltenhamrc\",\"adwindow\",\"900,500\");' class='contentLink'><img src=/images/general/betsarein.jpg width='200' height='200' alt='Bets are in, Play the ultimate horse racing game' /></a>";
	if(tmpInt==1)ad="<a href='javascript:openWindow(\"http://www.raceodds.com\",\"quiz\",\"900,500\");' class='contentLink'><img src='/images/general/Raceodds_Ad.gif' width='200' height='200' alt='Every race, every day, Runners riders, results and news. RACEODDS' /></a>";
	if(tmpInt==2)ad="<a href='http://www.racinguk.com/page/ruby?WT.mc_id=Che07rubymar10&affiliateCode=Che07rubymar10' target='_blank'><img src='http://static.adfactory88.com/gfx/pics/3000285/Racing_UK/Cheltenham_Race_Site/200x200_cheltenham.gif' /></a>";
	if(tmpInt==3 && !conferences_event)ad="<iframe allowtransparency='true' src='http://www.ladbrokes.com/ast?action=asset_req&new=0&aff_id=31426&asset_id=5379' width='200' height='200' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' style='border-width:0'></iframe>";
	if(tmpInt==4)ad="<a href='javascript:openWindow(\"http://www.cheltenhamcollection.co.uk/\",\"adwindow\",\"1000,600\");' class='contentLink'><img src='/images/general/Cover_Compilation.jpg' width='200' height='200' alt='The Cheltenham collection' /></a>";
	if(tmpInt==5)ad="<a href='http://www.ladbrokes.com/ast?action=go_asset&aff_id=31426&asset_id=267'target='_blank'><img src='http://www.ladbrokes.com/ast?action=asset_req&imgonly=1&aff_id=3142 6&asset_id=267'width='200' height='200' border='0' alt=''/></a>";
	if(tmpInt==6)ad="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='200' height='200' id='Cross_Country_Trains' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='/images/general/cheltenham200x200.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='/images/general/cheltenham200x200.swf' quality='high' bgcolor='#ffffff' width='200' height='200' name='Cross_Country_Trains' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /></object>";
	if(tmpInt==7)ad="<a href='http://www.freebetshere.com' target='_blank'><img src='/images/general/freebets_feb10.gif' /></a>";
	if(tmpInt==8)ad="<a href='http://www.cheltenhamcollection.co.uk/Products/220-festival-preview-magazine.aspx' target='_blank'><img src='/images/general/fest_prev_mag_2010.jpg' /></a>";
	if(tmpInt==9)ad="<a href='http://donnmcclean.com/' target='_blank'><img src='/images/general/donn_mcclean.gif' /></a>";
	if(tmpInt==10)ad="<a href='/racing/festival_in_vision.html'><img src='/images/general/cheltenham080310.gif' /></a>";

	document.getElementById('sideAd').innerHTML=ad;
}

//if(tmpInt==1)ad="<a href='javascript:openWindow(\"http://www.booking.com/\",\"adwindow\",\"900,500\");' class='contentLink'><img src=/images/general/booking-com.jpg width='200' height='200' alt='Looking For Racing Accommodation?' /></a>";
//if(tmpInt==5)ad="<a href='javascript:openWindow(\"http://www.freebetshere.com\",\"freebetshere\",\"1000,500\");' class='contentLink'><img src='/images/general/freebets.gif' width='200' height='200' alt='Free Cheltenham bets' /></a>";



var rotateInterval;
var imageCount=1;
var mainImageArray=new Array();
window.onload = function() {
	if(document.getElementById('mainImage')){
		for(var i=1; i< 5; i++){
			if(document.getElementById('hidden_' + i).value!=""){
				mainImageArray[i-1]=document.getElementById('hidden_' + i).value;
				tmpLi=document.getElementById('pag_' + i);
				tmpLi.parentNode.style.display="block";
				imageCount++;
				}
				if(mainImageArray.length>1)document.getElementById("pag_1").parentNode.style.display="block"; else document.getElementById("pag_1").parentNode.style.display="none"; 
				document.getElementById("pag_1").parentNode.className="pagOn";
				document.getElementById('moreinfoLink').href=document.getElementById('hidden_1').getAttribute("rel");
				if(document.getElementById('hidden_1').getAttribute("rel")=="")document.getElementById('infoLinkOuter').style.display="none";
				if(document.getElementById('hidden_1').getAttribute("title")=="")document.getElementById('buyLinkOuter').style.display="none"
		}
	
		rotateInterval=setInterval("swapMain(1)", duration);			
	}
	if(parent.frameLoaded)parent.frameLoaded();
}


function bookingLink(){
		//var urlSTR="https://secure-booking.rht.net/servlet/com.isa.balmoral.admin.portal.PortalFrameworkServlet?subAction=portal2&customerpk=544&login=no&browser=" +( navigator.userAgent.toLowerCase().indexOf('msie') < 0 ? 'MOZILLA' : 'IE' ) + "&sw=" + screen.width + "&sh=" + screen.height + "&useragent=" + navigator.userAgent;
		var urlSTR="https://salesportal.jockeyclubracecourses.com/jcr_ws/jcr.aspx?venue=CHE";
		var FURN="directories=no,width=800,height=600,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no;";
		//http://slx.www.ticketswitch.com/tickets/tsw_queue_slx/jcr
		//https://salesportal.jockeyclubracecourses.com/jcr_ws/jcr.aspx?venue=CHE
		var popwin;
		popwin=window.open(urlSTR,"RelatisLogin",FURN);
		popwin.focus();		
}


function openWindow(page,windowName,w)
{
if(parent.wysiwygEditing) return false;
 if ((window.windowHandle) && (!window.windowHandle.closed) && (popuploaded==page))
  {
   window.windowHandle.focus();
   }
   else
   {
  if(window.windowHandle) window.windowHandle.close();
   windowHandle = window.open(page,windowName,"scrollbars=yes,width=" + w.split(",")[0] +",height=" + w.split(",")[1] + ",toolbar=no,resizable=yes");
   }
    window.windowHandle.focus();
    popuploaded=page;
 }

 
 function searchClick(){
 	document.getElementById('searchinput').value="";
 }
 
 
 var bannerInt=1;
 function swapBanner(){
	 if(bannerInt==0){
		if(!conferences_event){
		document.getElementById('adHolder').innerHTML="<iframe allowtransparency='true' src='http://www.ladbrokes.com/ast?action=asset_req&new=0&aff_id=31425&asset_id=3590' width='728' height='90' marginwidth='0' marginheight='0'scrolling='no' frameborder='0' style='border-width:0'></iframe>";
		}
		else
		{
		document.getElementById('adHolder').innerHTML="<a href='http://www.cheltenhamcollection.co.uk/' target='_blank'> <img src='/images/general/cheltenhambannerad.jpg' alt='' height='90' width='728' /></a>";
		return;
		}
		bannerInt=1;
	 }
	 if(bannerInt==1){
		document.getElementById('adHolder').innerHTML="<a href='http://www.cheltenhamcollection.co.uk/' target='_blank'> <img src='/images/general/cheltenhambannerad.jpg' alt='' height='90' width='728' /></a>";
		bannerInt=0;
	 } 
 
 
 }
setInterval( "swapBanner()", 10000);

var conferences_event=false;
var str="conferences_event";

if(location.href.search(str)!=-1){
	conferences_event=true;
}
























