function Logout()
{
	location.assign("Logout.aspx");
}
function Trim(Value)
{
	var m = Value.match(/^\s*(\S+(\s+\S+)*)\s*$/);
	return (m==null) ? "" : m[1];
}
function ExpIsValid(Value, Expr)
{
	if(Trim(Value).length==0)
		return true;
		
	var rx = new RegExp(Expr);
	var matches = rx.exec(Value);
	return (matches!=null && Value==matches[0]);		
}
function checkFraming()
{
	if(top.location.href==window.location.href)
	{
		window.location.assign('Racing.aspx'); 
		return;
	}
}
function setEvents(disableCopyAndPaste)
{
	if(document.layers)
		document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

	document.onmouseover=hideStatus;
	document.onmouseout=hideStatus;

	if(disableCopyAndPaste)
	{
		if(document.all) 
			document.onselectstart = disableSelectIE;
		else
		{
			document.onmousedown = disableSelectFF;
			document.onmouseup = enableFF;
		}			
	}
	
	if(document.all) 
		document.onmousedown = click;

	document.onclick = click;	
	document.ondblclick = click;
}
function hideStatus()
{
	window.status='';
	return true;
}
function unsetEvents()
{
	if(document.all) 
		document.onselectstart = enableSelectIE;
}
function disableSelectIE()
{
	return false;
}
function disableSelectFF(e)
{
	var omitformtags = "input,textarea,select";
	if(omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
		return false;
}
function enableFF()
{
	return true;
}
function enableSelectIE()
{
	return true;
}
function click(e) 
{
	var currentDate = new Date();	
	
	var message = 'Use of this website inculsive of RISAForm is subject to the express terms of use  & privacy policy of Racing Information Services Australia(RISA). As a RISAForm subscriber You are only permitted to use the racing materials supplied to you via your RISAForm account for your own personal use only.\n\n';
	message += 'No part of the material available to you via your RISAForm account either free or paid may be reproduced, adapted or disseminated without the prior written consent of RISA.\n\n';
	message += 'Copyright \u00a9 ' + currentDate.getFullYear() + ' Racing Information Services Australia Pty Ltd (RISA).  All Rights Reserved.';  

	if(document.all) 
	{
		if(event.button==2) 
		{
			alert(message);  
			return false;
		}
	}
	else 
	{
		if(e.which==2 || e.which==3)
		{
			e.preventDefault();
			alert(message);
		}
	}
}
function getCurrentDate()
{
	var datToday = new Date();			
	var weekDay = datToday.getDay();			
	var day = datToday.getDate(); 
	var month = datToday.getMonth();
	var year = datToday.getFullYear();	
	var hour = datToday.getHours();
	var ampm = '';
	
	if(hour<12)
		ampm = 'AM';
	else
		ampm = 'PM';
	
	if(hour>=13)
		hour = hour-12;
			
	var minute = datToday.getMinutes();
	if(minute<10)
		minute = '0' + minute;
		
	if(weekDay==0)
		weekDay = 'Sunday';
	else if(weekDay==1)
		weekDay = 'Monday';
	else if(weekDay==2)
		weekDay = 'Tuesday';
	else if(weekDay==3)
		weekDay = 'Wednesday';
	else if(weekDay==4)
		weekDay = 'Thursday';
	else if(weekDay==5)
		weekDay = 'Friday';
	else if(weekDay==6)
		weekDay = 'Saturday';
	
	if(month==0)
		month = 'January';
	else if(month==1)
		month = 'February';
	else if(month==2)
		month = 'March';
	else if(month==3)
		month = 'April';
	else if(month==4)
		month = 'May';
	else if(month==5)
		month = 'June';
	else if(month==6)
		month = 'July';
	else if(month==7)
		month = 'August';
	else if(month==8)
		month = 'September';
	else if(month==9)
		month = 'October';
	else if(month==10)
		month = 'November';
	else if(month==11)
		month = 'December';		
	
	return weekDay + ', ' + day + ' ' + month + ' ' + year + '&nbsp;&nbsp;&nbsp;' + hour + ':' + minute + ' ' + ampm;
}

function WorldClockV()
{
	ampm='';
	now=new Date();
	secs=now.getUTCSeconds();
	hours=now.getUTCHours();
	mins=now.getUTCMinutes();
	
	hours+=10;
	
	if (hours < 0) hours+=24;
	if (hours > 23) hours-=24;
	ampm = (hours > 11)?"PM":"AM";
	statusampm = ampm.toLowerCase();

	hr2 = hours;
	if (hr2 == 0) hr2=12;
	(hr2 < 13)?hr2:hr2 %= 12;
	if (hr2<10) hr2="0"+hr2

	var finalTime=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;
	
	if (document.all)
	worldclock.innerHTML=finalTime
	else if (document.getElementById)
	document.getElementById("CurrentDate").innerHTML=finalTime
	else if (document.layers)
	{
		document.worldclockns.document.worldclockns2.document.write(finalTime)
		document.worldclockns.document.worldclockns2.document.close()
	}


	setTimeout('WorldClockV()',1000);

}

function getNow()
{
	var datToday = new Date();
	var day = datToday.getDate(); 
	var month = datToday.getMonth();
	var year = datToday.getFullYear();
	var hours = datToday.getHours();
	var minutes = datToday.getMinutes();
	var seconds = datToday.getSeconds();
  
	if(month==0)
		month = 'January';
	else if(month==1)
		month = 'February';
	else if(month==2)
		month = 'March';
	else if(month==3)
		month = 'April';
	else if(month==4)
		month = 'May';
	else if(month==5)
		month = 'June';
	else if(month==6)
		month = 'July';
	else if(month==7)
		month = 'August';
	else if(month==8)
		month = 'September';
	else if(month==9)
		month = 'October';
	else if(month==10)
		month = 'November';
	else if(month==11)
		month = 'December';		
	
	return day + ' ' + month + ' ' + year + ' ' + hours + ':' + minutes + ':' + seconds;
}
function ToCurrency(value)
{
	value = value.toString();
	
	var len = value.length;
	
	if(Number(value)>=1000)
	{
		var thousands = value.substr(0,len-3);
		var hundreds = value.substr(len-3);
		return "$" + thousands + "," + hundreds + ".00";
	}	
	else
		return "$" + value + ".00";
}
