/*
 * IAS specific libraries needed on all pages
 * Keep this to a minimum - load on the page in a page specific JS rather than in here!!
 *
 * Copyright (c) 2007-2008 IASeminars Ltd
 */

// Clears search box when clicked on
function clearDefault(el) { if (el.defaultValue==el.value) el.value=""; }

function displayInput(el,inputValue) { 
	if (el.value=='') el.value=inputValue
	//if (el.defaultValue=='') el.value=inputValue; 
}

// Creates a pop-up window for the terms & conditions
function popitup(url) {
	newwindow=window.open(url,'name','height=400,width=600,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

// Check whether a course is scheduled one year in advance
function checkCourse(eventID,startDate,eventTopic,subTopic) 
{
	
	var taxPointDateArray = startDate.split("-");
							          			
		var first = taxPointDateArray[2];
		var day = first.substring(0, 2);
		var month = taxPointDateArray[1];
		var year = taxPointDateArray[0];
	
		var todaysdate= new Date(); // today's date
		var date = new Date ( year,month-1,day); // Create date object for the course startdate 
		
		var afterOneYearms = todaysdate.getTime()+365*24*60*60*1000; // Find milliseconds for time after one year
		var startdatems = date.getTime(); // Course Start date in milliseconds
		
		if(eventTopic = 'undefined')
		{	
			eventTopic = '';
		}
	
		if(subTopic = 'undefined')
		{
			subTopic = '';
		}


	if(startdatems > afterOneYearms)
	{	
		var answer = confirm('This Event is more than 12 months in the future. Please confirm you wish to continue to book a place on this event.')
		if(answer)
		{
			window.location.href='/en/basket/?Add=1&EventID='+eventID+'&EventTopicID='+eventTopic+'&EventSubTopicID='+subTopic;
		}
		else
		{
			return false;
		}
	}
	else
	{
		window.location.href='/en/basket/?Add=1&EventID='+eventID+'&EventTopicID='+eventTopic+'&EventSubTopicID='+subTopic;
	}

}