// JavaScript Document


function getSize( getWhat ) {

	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	if (getWhat == 'width') {
		return parseFloat(myWidth);
	} else {
		return parseFloat(myHeight);
	}

}


function toggle ( id, themeid, hideWords ) {

	var theSpanElement = document.getElementById('hideShow'+id).style.display;
	var linkContent = '';
	//alert(theSpanElement);

	if (theSpanElement == 'none' || !theSpanElement) {
		style = 'inline';
		if (hideWords == false) {
			linkContent = 'Hide';
			arrow = 'downArrow';
		} else {
			arrow = 'upArrow';
		}
		linkContent = linkContent+'<img src="/images/theme/'+arrow+'_'+themeid+'.png" width="10" height="10" alt="Hide" />';
	} else {
		style = 'none';
		if (hideWords == false) linkContent = 'More';
		linkContent = linkContent+'<img src="/images/theme/rightArrow_'+themeid+'.png" width="10" height="10" alt="More" />';
	}

	document.getElementById('hideShow'+id).style.display = style;
	document.getElementById('moreHideLink'+id).innerHTML = linkContent;
	
}

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(51.505457, -0.114455), 15);
	}
}

function clearEmail () {
	var theField = document.getElementById("signUpEmail");
	if (theField.value.substring(0,5).toLowerCase()=="enter" || theField.value.substring(0,6).toLowerCase()=="please") theField.value = '';	
}



function regLinks ( $loadedData ) {
	
	$(".prevNext a",$loadedData).unbind("click").click(function() {
		
		var $path = $(this).attr("href");
	
		$path = $path.split("&");
		var $pid = $path[0].split("=");
		var $month = $path[1].split("=");
		var $themeid = $path[2].split("=");
		
		var $attractionid = $path[3].split("=");
		var $interestid = $path[4].split("=");		
		
		$.get("/calendar.php",

      	{pid: $pid[1], month: $month[1], themeid: $themeid[1], attractionid: $attractionid[1], interestid: $interestid[1]},

      	function(data) {
			var $regCol = $("#calendar");
			$regCol.html(data);
			regLinks( $regCol );
      	});

		return false;

	});
	
}



$(document).ready(function(){
	
	/*------------------- CALENDAR ------------------------------*/
	$(".prevNext a").unbind("click").click(function() {
		
		var $path = $(this).attr("href");
		
		$path = $path.split("&");
		var $pid = $path[0].split("=");
		var $month = $path[1].split("="); 
		var $themeid = $path[2].split("=");
		
		var $attractionid = $path[3].split("=");
		var $interestid = $path[4].split("=");			
		
		$.get("/calendar.php",
		
      	{pid: $pid[1], month: $month[1], themeid: $themeid[1], attractionid: $attractionid[1], interestid: $interestid[1]},

      	function(data) {
			var $regCol = $("#calendar");
			$regCol.html(data);
			regLinks( $regCol );
			
      	});

		return false;
	});
	
});


function updateCalendarOnHomePage ( thePid, theThemeId ) {
	
	//alert('need to update the page!  ' + thePid );
	
	var $pid = thePid;
	var $month = 1; 
	var $themeid = theThemeId;
	
	var $attractionid = parseFloat(document.getElementById('attractionid').value);
	var $interestid = parseFloat(document.getElementById('interestid').value);		
	
	$.get("/calendar.php",
	
	{pid: $pid[1], month: $month[1], themeid: $themeid, attractionid: $attractionid, interestid: $interestid},

	function(data) {
		var $regCol = $("#calendar");
		$regCol.html(data);
		regLinks( $regCol );
		
	});
	
}



function updateDrop () {
	
	var $attractionid = parseFloat(document.getElementById('attractionid').value);
	var $interestid = parseFloat(document.getElementById('interestid').value);
	var $week = document.getElementById('week').value;
	var $q = document.getElementById('q').value;
	var $themeid = document.getElementById('themeid').value;
	
	var $date = 0;
	//alert(document.getElementById('date'));
	if (document.getElementById('date') != null) $date = document.getElementById('date').value;
	
	//alert($themeid);
	
	$.get("/dropOptions.php",
	
	{attractionid: $attractionid, interestid: $interestid, week: $week, q: $q, themeid: $themeid, date: $date},
	
	function(data) {
		var $regCol = $("#browseEvents");
		$regCol.html(data);
		
	});	

}

function reloadThumb ( table, id, element, themeid, thumbinfo ) {
	
	var $id = parseFloat(id);
	var $table = table;
	var $themeid = parseFloat(themeid);
	var $thumbinfo = parseFloat(thumbinfo);
	
	$.get("/getThumb.php",
	
	{id: $id, table: $table, themeid: $themeid, thumbinfo: $thumbinfo},
	
	function(data) {
		var $regCol = $(element);
		$regCol.html(data);
		
	});		
	
}



