// Tennis Australia - Ajax Calendar Component calendar.js v1.0.0, Thur Dec 07 12:55:00
// Copyright (c) 2006 Atomic Media (http://www.atomicmedia.com.au)

var rootURL = 'http://www.tennis.com.au/';

function initAjaxComponents(siteid, pageid){
	// VIDEO
	//if (document.getElementById('divFlashVideo'))
	//	setvideo('clips/emma.flv', '230', 'pause()');
	
	// NEWS
	if (document.getElementById('tnews'))
		initNews(0,0);
		
	// PHOTOS
	if (document.getElementById('contphotos'))
		initPhotos();
	
	// OUR PARTNERS
	if (document.getElementById('partner'))
		initPartners();
		
	// LATEST NEWS (SMALL NEWS IMAGE SCROLLER)
	if (document.getElementById('latestnews'))
		getLatestNewsXML();
		
	// LATEST PHOTO GALLERIES (SMALL PHOTO GALLERY SCROLLER)
	if (document.getElementById('latestphotos'))
		getLatestPhotoGalleryXML();		
		
	// MORE NEWS (NEWS IMAGE SCROLLER WITH NEWS LINKS UNDERNEATH IMAGE)
	if (document.getElementById('morenewsimg'))
		getMoreNewsXML();
		
	// CALENDAR
	if (document.getElementById('divtour'))
		getCalendarXML(1,1);
		
	// PHOTO GALLERY
	if ($('gallery1'))
		initPhotoGallery();
		
	// AUDIO GALLERY
	if ($('firstAudio'))
		initAudioGallery();
		
	if ($('firstVideo'))
		initVideoGallery();
}


function getAjaxMessagingComponent(){

	// MESSAGES
	if (document.getElementById('spInboxMsg'))
		getInboxMessage();
}


function submitOnEnterGlobalSearch(e)
{
	var k = (e.which) ? e.which : e.keyCode; 
	
	if (k == 13)
	{
		if (e && e.preventDefault)
			e.preventDefault();
		//e.cancelable = true;
		//e.bubbles = false;
		//e.cancelBubble = true;
		e.returnValue = false; 
		e.cancel = true;
		searchBloxGo(document.frmSearch.cname.value, document.frmSearch.query.value);
	}
}

function searchField()
{
	if (document.frmSearch.query.value == '')
	{
		document.frmSearch.query.value = 'Search';
	}
}

function locationField()
{
	if (document.frmHaveAHit.SearchValue.value == '')
	{
		document.frmHaveAHit.SearchValue.value = 'Location';
	}
}

function FirstnameField()
{
	if (document.frmSignup.txtname_nav.value == '')
	{
		document.frmSignup.txtname_nav.value = 'First';
	}
	
}

function SurnameField()
{
	if (document.frmSignup.txtsurname_nav.value == '')
	{
		document.frmSignup.txtsurname_nav.value = 'Last';
	}
	
}

function EmailField()
{
	if (document.frmSignup.txtemail_nav.value == '')
	{
		document.frmSignup.txtemail_nav.value = 'Email';
	}
	
}

function submitOnEnterGlobalSearchRHS(e)
{
	var k = (e.which) ? e.which : e.keyCode; 
	
	if (k == 13)
	{
		if (e && e.preventDefault)
			e.preventDefault();
		//e.cancelable = true;
		//e.bubbles = false;
		//e.cancelBubble = true;
		e.returnValue = false; 
		e.cancel = true;	
		searchBloxGoWithType(document.frmSearchNews.cname.value, document.frmSearchNews.query.value, document.frmSearchNews.SearchType.value);
	}
}


function searchBloxGo(strName, strQuery)
{
	var strURL = "http://search.atomicmedia.com:8080/searchblox/servlet/SearchServlet?sort=relevance&cname=" + strName + "&query=" + strQuery;
	//var strURL = "http://www.tennis.com.au:8080/searchblox/servlet/SearchServlet?sort=relevance&cname=" + strName + "&query=" + strQuery;
	//var strURL = "http://www.google.com.au/";
	/*if (rootURL.indexOf('www.tennis.com.au') != -1 && strURL.indexOf('www.tennis.com.au/pages/') == -1 && strURL.indexOf('http://') != -1 && strURL.indexOf('www.tennis.com.au:8080/searchblox/') == -1)
		var strHTML = '<iframe id="myiframe" style="border:none;width:100%;" name="myiframe" width="100%" height="0px" onload="DYNIFS.resize(\'myiframe\');" valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" src="' + strURL + '"></iframe>';
	else*/
		var strHTML = '<iframe valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="1360px" src="' + strURL + '"></iframe>';
	if ($('maindiv'))
	{
		$('maindiv').style.height = "1222";		
		$('maindiv').innerHTML = '';
		$('maindiv').innerHTML = strHTML;
	}
}

function searchBloxGoWithType(strName, strQuery, strType)
{
	var strURL = "http://search.atomicmedia.com:8080/searchblox/servlet/SearchServlet?sort=relevance&cname=" + strName + "&query=" + strQuery + "&SearchType=" + strType;
	//var strURL = "http://www.google.com.au/";
	/*if (rootURL.indexOf('www.tennis.com.au') != -1 && strURL.indexOf('www.tennis.com.au/pages/') == -1 && strURL.indexOf('http://') != -1 && strURL.indexOf('www.tennis.com.au:8080/searchblox/') == -1)
		var strHTML = '<iframe id="myiframe" style="border:none;width:100%;" name="myiframe" width="100%" height="0px" onload="DYNIFS.resize(\'myiframe\');" valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" src="' + strURL + '"></iframe>';
	else*/
		var strHTML = '<iframe valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="1360px" src="' + strURL + '"></iframe>';
	if ($('maindiv'))
	{
		$('maindiv').style.height = "1360px";
		$('maindiv').innerHTML = '';
		$('maindiv').innerHTML = strHTML;
	}
}

function genericLoadPageInIframe(strURL)
{
	/*if (rootURL.indexOf('www.tennis.com.au') != -1 && strURL.indexOf('www.tennis.com.au/pages/') == -1 && strURL.indexOf('http://') != -1 && strURL.indexOf('www.tennis.com.au:8080/searchblox/') == -1)
		var strHTML = '<iframe id="myiframe" style="border:none;width:100%;" name="myiframe" width="100%" height="0px" onload="DYNIFS.resize(\'myiframe\');" valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" src="' + strURL + '"></iframe>';
	else*/
		var strHTML = '<iframe valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" width="643" height="1800" src="' + strURL + '"></iframe>';
	if ($('maindiv'))
	{
		$('maindiv').innerHTML = '';
		$('maindiv').innerHTML = strHTML;
	}
}

function viewTournamentLink(strURL)
{
	/*if (rootURL.indexOf('www.tennis.com.au') != -1 && strURL.indexOf('www.tennis.com.au/pages/') == -1 && strURL.indexOf('http://') != -1 && strURL.indexOf('www.tennis.com.au:8080/searchblox/') == -1)
		var strHTML = '<iframe id="myiframe" style="border:none;width:100%;" name="myiframe" width="100%" height="0px" onload="DYNIFS.resize(\'myiframe\');" valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" src="' + strURL + '"></iframe>';
	else*/
		var strHTML = '<iframe valign="left" align="left" frameborder="0" marginheight="0" marginwidth="0" width="643" height="800" src="' + strURL + '"></iframe>';
	if ($('maindiv'))
	{
		$('maindiv').innerHTML = '';
		$('maindiv').innerHTML = strHTML;
	}
}

// DEPRECATED
function submitOnEnter(e, strSubmitButtonID)
{
	if (e.keyCode == 13)
	{
		e.returnValue = false; 
		e.cancel = true;
		window.top.eval(strSubmitButtonID).click();
	}	
}
// END

function gTracker(arg)
{
	try
	{
		urchinTracker(arg);
	}
	catch(err)
	{
		//alert(err);
	}
}