/*
--------------------------------------------------------------------------- 
Default Javascript File
(c) 2011 Select Performers

Version:	3.00
Date:		15/03/2011
Author:		Ian Anderson Gray
Website:	http://selectperformers.com/
---------------------------------------------------------------------------
Notes:	
		
---------------------------------------------------------------------------
To Do

---------------------------------------------------------------------------
Change Log

---------------------------------------------------------------------------
*/



$(document).ready(function()	{
						   
		
		// Background Fade on 404 error page
		// $("#error404").vkfade("ff0000");	
		
		// If linking to an external link then open in a new window
		$(function() {$('a[href^="http://"]').filter(function(){return this.hostname && this.hostname !== location.hostname; }).addClass("newWindow").click(function(){window.open(this.href);return false;});});
		
		// If there is a rel=external then open in a new window
		$(function() {$('a[rel*=external]').addClass("newWindow").click( function(){window.open(this.href);return false;});});
		
		// If we are opening in a new window then add this to the title tag
		$("a.newWindow").attr("title", $("a.newWindow").attr("title")+" - (This link will open in a new window)");
		
		// Error Sound
		// swfobject.embedSWF("/media/swf/audioPlayer/playerNew.swf", "errorSound", "1", "1", "9.0.0","/media/swf/swfObject/expressInstall.swf", {soundFile:"/media/audio/error.mp3&autostart=yes"}, {menu:"false", quality:"high",wmode:"transparent"}, {id:"myDynamicContent",name:"myDynamicContent"});
		
		// Add email blocking script
		geo();
		
		// Clear any inputs when you click on them
		clearInputs();
		
		// Get me out of this frame script
		if (top.location != location){top.location.href = document.location.href;}
  	 
		// Footer script
		$("#footerTools").html('<li><a href="#container" title="Go to the top of this page" class="top">Top of Page</a></li><li><a href="#nav" title="Skip to navigation" class="navIcon">Skip to navigation</a></li><li><a href="#main" title="Skip to content" accesskey="S" class="main">Skip to main content</a></li><li><a href="#footer" title="Skip to the bottom of the page" accesskey="F" class="bottom">Skip to bottom of the page</a></li><li id="printPage"><a href="javascript:window.print()" title="Print this Page" class="print">Print this Page</a></li><li id="favorites">'+"<a href=\"javascript:bookmarksite('"+document.title+"', '"+location.href+"')\" title=\"Add this page to your favourites\" class=\"favorites\">Add to Favourites</a></li>"+'<li><a href="/" class="home" title="Visit Select Performers Home Page" accesskey="1">Home</a></li>');

		
		// $.localScroll({hash: true,easing:'easeOutSine'});
		
		
		$('*').tooltip({
			track: true,
			delay: 250,
			showURL: true,
			showBody: " - ",
			fade: 150
		});
		
		// $.easing.easeOutSine = function (x, t, b, c, d) {return c * Math.sin(t/d * (Math.PI/2)) + b;};

		
		// swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn) 
		
		
		
		// Image does not exist...
		/*$("img").error(function ()
			{
				$(this).unbind("error").attr(
					{
						src: '/images/elements/page.png',
						alt: 'Sorry!  This image is not available!',
						style:'width:16px;height:16px;'
					})
			});
		*/
		
		var myDate = new Date();
		var hr = myDate.getHours();

		if (hr > 18) 		{greeting = "Good evening and welcome to Select Performers, ";}
		else if (hr > 12)  	{greeting = "Good afternoon and welcome to Select Performers, ";}		
		else 				{greeting = "Good morning and welcome to Select Performers, ";}
		$('#greeting').prepend(greeting);
		
		
		
		$.localScroll({hash: true,easing:'easeOutSine'});
		
		$.easing.easeOutSine = function (x, t, b, c, d) {return c * Math.sin(t/d * (Math.PI/2)) + b;};

		// Hide grid feature
		$('.fullGrid').hide();
		$('.contentGrid').hide();
		
		//top of page script
		/*$('#top-link').topLink({
			min: 400,
			fadeSpeed: 500
		});*/
		
		// listens for any navigation keypress activity
		$(document).keypress(function(e)
			{
				// cancel if in an input field
				if( $(e.target).is(":input") ) return;
				switch(e.which)
					{
						// user presses the "g" key to show grid
						case 103:	$('.fullGrid').toggle('slow');
						break;
						// user presses the "m" key to show grid for main content
						case 109:	$('.contentGrid').toggle('slow');
						break;
						// user presses the "h" key to show help box
						case 104:	$("#toolBox").fadeTo('1','0.95').animate({top:"0px"}).css("cursor","default");
						break;
						// user presses the "s" key to toggle styles
						case 115:	
						var myloc = window.location.href;
						var locarray = myloc.split("/");
						delete locarray[(locarray.length-1)];
						var currentLoc = locarray.join("/");
						window.location = "/sty.le?style=simple&loc="+currentLoc;						break;
						// user presses the "SHIFT+n" key to toggle styles
						case 78:	
						var myloc = window.location.href;
						var locarray = myloc.split("/");
						delete locarray[(locarray.length-1)];
						var currentLoc = locarray.join("/");
						window.location = "/sty.le?style=none&loc="+currentLoc;						break;
					}
				});
	});

















