function randomize( l, t ){
 t -= 1;
 return Math.floor( Math.random() * ( t - l + 1 ) ) + l;
}

// detect whether just a normal domain pointing
function detectDomainPoint(){
 var ret = 0;
 var url = document.location.toString();
 if( url.substr(url.length-1) != '/' ){
  url += '/';
 }
 if( url.split('/').length == 4 ){
  ret = 1;
 }
 return ret;
}
var HOMEPAGE_TEXT = detectDomainPoint();

function getFlashRandom(){
 var bg_holder = document.getElementById( 'background' );

 if( HOMEPAGE_TEXT == 1 && HOMEPAGE_CLICK == 1 ){
  bg_holder.style.backgroundImage = "none";
 }else{



 var arg = ( arguments && arguments[0] == 1 ) ? true : false;
 var cookie_check = readCookie( 'css-switch' );
 if( cookie_check != 'text-only' && bg_holder ){
	 var res = ['biketrain_01','girlbus_01','girllaugh_01','laptop_01'];
	 var img_path = '/arriva/images/';
	 var flash_path = 'http://www.investis.com/arriva/flash/';
	 var index = randomize( 0, res.length );
	bg_holder.style.backgroundImage = "url('"+ img_path + res[ index ] + ".jpg')";
         if( ! arg ){
		document.write( getFlashCode( flash_path, res[ index ] ) );    
         }
 }else if( cookie_check == 'text-only' && bg_holder ){
	 bg_holder.style.backgroundImage = "none";
 }

 }

}

function getFlashCode( file_path, file_name ){
 var flash_code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="972" height="136" id="home_07" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+ file_path + file_name + '.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+ file_path + file_name + '.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="972" height="136" name="home_07" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
 return flash_code;
}
