
/* --------------------------------------------------------
 * MMG-CRM - developed for Fullhouse Group
 * Copyright (C) 2004-2006 MMG interactive
 * 
 * MMG interactive versioning:
 * ---------------
 * $Revision: 857 $
 * $Author: Mark $
 * $Date: 2010-02-17 09:40:51 +1100 (Wed, 17 Feb 2010) $ 
 * 
 * --------------------------------------------------------
 */

function doRegion(nRegionID) {
	doAwayEvents(nRegionID);
}

function doSeason(nSeasonID, nType) {
	window.location= 'Index.asp?SID=' + nSeasonID + '&TID=' + nType;
}

function submitPoll(){
	document.forms.frmPoll.submit();;
}

function doAwayEvents(nRegionID){

	if(nRegionID == 0 || nRegionID == '' || typeof(nRegionID) == 'undefined'){
		document.getElementById('regionLink').style.display = 'none';
		document.forms.frmRegion.RegionID.selectedIndex = 0;
	}else {
		document.getElementById('regionLink').style.display = '';
	}
	ajax('Index.asp?Action=Away&RID=' + nRegionID + '&t=' + Math.random(), '', parseJSON);

}

function doHomeEvents(){
	ajax('Index.asp?Action=Home&t=' + Math.random(), '', parseJSON);
}

function doDreamteam(){
	ajax('Index.asp?Action=Dreamteam&t=' + Math.random(), '', parseJSON);
}

function parseJSON (s) {
	
	var obj = eval("(" + s + ")");
	if (obj) {
	
		if(obj.TID == 2){
			document.getElementById('AwayEventsListing').innerHTML = obj.Listing;	
		} else if(obj.TID == 1) {
			document.getElementById('HomeEventsListing').innerHTML = obj.Listing;			
		} else if(obj.TID == 3) {
			document.getElementById('DreamteamListing').innerHTML = obj.Listing;								
		}			
	}
}	

function venueParseJSON (s) {
	
	var obj = eval("(" + s + ")");
	if (obj) {
	
		if(obj.TID == 1) {
			document.getElementById('LocationListing').innerHTML = obj.Listing;			
		} else if(obj.TID == 2) {
			document.getElementById('AtoZListing').innerHTML = obj.Listing;	
		} else if(obj.TID == 3) {
			document.getElementById('NameKeywordListing').innerHTML = obj.Listing;							
		}			
	}
}	

function doRegionLink() {
	window.location='Events.asp?TID=2&amp;RegionID=' + document.forms.frmRegion.RegionID.value;
}


function doLocationSearch(){

	var sSuburb = document.forms.frmMain.Suburb.value;
	var sPostcode = document.forms.frmMain.Postcode.value;
	var sState = document.forms.frmMain.State.value;
	
	GLoadSearch('VenueLocator', sSuburb, sPostcode, sState);
	
	ajax('VenueLocator.asp?Action=LocationSearch&Suburb=' + sSuburb + '&Postcode=' + sPostcode + '&State=' + sState + '&t=' + Math.random(), '', venueParseJSON);
}

function doAtoZSearch(sSearchChar){
	ajax('VenueLocator.asp?Action=AtoZSearch&SearchChar=' + sSearchChar + '&t=' + Math.random(), '', venueParseJSON);
}

function doVenueSearch(){

	var sNameKeyword = document.forms.frmMainVenue.NameKeyword.value;
	ajax('VenueLocator.asp?Action=VenueSearch&NameKeyword=' + sNameKeyword + '&Suburb=&Postcode=&State=&t=' + Math.random(), '', venueParseJSON);
}

function doPagingVenueSearch(sNameKeyword, sSearchChar, sSuburb, sPostcode, sState, nPage, nStart, nTypeID){
	
	if(nTypeID == 1) {
		if(nPage == 1 || nPage == '') {
			GLoadSearch('VenueLocator', sSuburb, sPostcode, sState);
		}
		ajax('VenueLocator.asp?Action=LocationSearch&Suburb=' + sSuburb + '&Postcode=' + sPostcode + '&State=' + sState + '&pg=' + nPage + '&start=' + nStart + '&t=' + Math.random(), '', venueParseJSON);
		
	} else if(nTypeID == 2) {
		ajax('VenueLocator.asp?Action=AtoZSearch&SearchChar=' + sSearchChar + '&pg=' + nPage + '&start=' + nStart + '&t=' + Math.random(), '', venueParseJSON);
		
	} else if(nTypeID == 3) {
		ajax('VenueLocator.asp?Action=VenueSearch&NameKeyword=' + sNameKeyword + '&pg=' + nPage + '&start=' + nStart + '&t=' + Math.random(), '', venueParseJSON);
		
	}
	
	
}


function loadResults(nEventID, nGameID, nTypeID){
	if(nTypeID == 1) {
		ajax('EventDetails.asp?Action=Home&ID=' + nEventID + '&GID=' + nGameID + '&TID=' + nTypeID + '&t=' + Math.random(), '', parseJSON);
	} else {
		ajax('EventDetails.asp?Action=Away&ID=' + nEventID + '&GID=' + nGameID + '&TID=' + nTypeID + '&t=' + Math.random(), '', parseJSON);
	}
}


