// ---------------------------------------
// ------------   Variables   ------------
var baseURL = "http://www.shishavac.com/";
var commentsMin = 350;						// Minimum characters allowed in comments
var contentBlinds = 0;						// Keeps the menu working as expected
var currentGlow = "";						// Track the page with the glow
var footerLangTracker = 0;					// Used to make sure the footer language rollover stays open long enough
var hash = window.location.hash.substr(1);	// Get the content after the hashmark if available
var headerLoginTracker = 0;					// Used to make sure the header login rollover stays open long enough
var href = location.href;					// Get the current href
var logoLoadedTracker = false;				// Tracker to see if the logo is loaded
var navOffTracker = 0;						// Makes sure the navOff sound doesn't happen twice when clicking on a nav item
var scrollSettings = {						// Custom scrollbar settings
	showArrows: true,
	verticalDragMinHeight: 7,
	verticalDragMaxHeight: 7,
	horizontalDragMinWidth: 7,
	horizontalDragMaxWidth: 7
};
// ---------------------------------------

function queryLoaderLoaded ()
{	
	// Show the site first then load the rest of the functions
	$('#contentBlinds:visible').stop(true, true).fadeOut('slow', function()
	{	$('#sidebar:hidden').stop(true, true).fadeIn('fast');
		$(QueryLoader.loadBar).remove();
		$(QueryLoader.preloader).remove();
		$(QueryLoader.overlay).fadeOut(80);
		
		// -- Load the hashed page on page load --
		if ( hash.length > 0 )
		{	hashURL = baseURL + hash;
			var toLoad = hashURL+' #main';
			$('#content').load(toLoad, function () {
				pageSpecificFunctionLoader ( hashURL );
			});
		}
		// - Initialize highlight and scrollbars -
		else
		{	timeout = window.setTimeout(function()
			{	pageSpecificFunctionLoader ( href );	}, 100);
		}
	});
	
	// - Add notEqual method to the validation plugin -
	jQuery.validator.addMethod("notEqual", function(value, element, params) {
		thisInputID = $(element).attr("id");
		if ( value == document.getElementById(thisInputID).defaultValue )
		{	return false;	}
		else
		{	return true;	}
	}, "Please enter a value");
	// --------------------------------------------------------
	
	
	// --------------- Main Navigation rollovers --------------
	$('#nav a')
		.live("mouseover", function()
		{	if ( contentBlinds < 1 )
			{	// This triggers the mouseover clip in flash
				//logoInteraction ( "mouseover" );
				// Remove focus to the header form fields and fade in the nav BG
				$('#headerUsername, #headerPassword').blur();
				$("#navBG").stop(true, true).fadeIn("normal");
			}
			var currentID = $(this).attr("class");
			/*$('#nav div').each (function()
			{	// Cycle through all the nav fields
				if ( $(this).attr('id') != currentID )
				{	$("div.up",this).stop(true, true).fadeOut("normal");
					$("div.over",this).stop(true, true).fadeOut("normal");
					$("div.fade",this).stop(true, true).fadeIn("normal");
				}
				else 
				{	$("div.up",this).stop(true, true).fadeOut("normal");
					$("div.over",this).stop(true, true).fadeIn("normal");
					$("div.fade",this).stop(true, true).fadeOut("normal");
				}
			}); */
			timeout = window.setTimeout(function()
			{	// Set a small delay on the mouseover sound so it doesn't happen before the mouseout sound of the last item
				logoInteraction ( "introSoundPause" );
				logoInteraction ( "mouseoverSound" );
				//$('#contentBlinds:hidden').stop(true, true).fadeIn('slow');
				// Hide the login box if it's showing
				$('#headerLoginContainer').attr("display", "none");
				$('#headerLoginSlide').stop().animate({top:'-170px'},{queue:false,duration:300});
				$('#headerLoginButton').stop().animate({opacity:1},{queue:false,duration:300});
			}, 60);
			contentBlinds = contentBlinds + 1;
		})
		.live("mouseout", function()
		{	var currentID = $(this).attr("class");
			// Get the hash from the URL
			if ( window.location.hash.substr(1) != "" )
			{	var hash = window.location.hash.substr(1);	}
			else
			{	var currentPage = String(window.location);
				var hash = currentPage.replace(baseURL, "");
			}
			var hashSplit = hash.split("/");
			var hashSplitLength = hashSplit.length;
			
			if ( navOffTracker == 0 )
			{	logoInteraction ( "mouseoutSound" );	}
					
			timeout = window.setTimeout(function()
			{	if ( contentBlinds <= 1 )
				{	if ( navOffTracker == 0 )
					{	//logoInteraction ( "mouseout" );
						logoInteraction ( "introSoundPlay" );
						$("#navBG").stop(true, true).fadeOut("normal");
					}
					else if ( navOffTracker == 1 )
					{	navOffTracker = 0;	}
					$('#contentBlinds:visible').stop(true, true).fadeOut('slow');
					/*$('#nav > div').each (function() {
						var navClass = $(this).attr("id");
						thisLink = $('#nav a.'+navClass).attr('href');
						var thisHref = thisLink.substr(0,thisLink.length-1).replace(baseURL, "");
						//alert ( hash.substr(0,thisHref.length) +" || "+ thisHref);
						if( ( thisHref.length > 0 ) && ( hash.substr(0,thisHref.length) != thisHref ) )
						{	$("div.up",this).fadeIn("normal");
							$("div.fade",this).fadeOut("normal");
							$("div.over",this).fadeOut("normal");	}
					});
					highlightCurrent();*/
				}
				contentBlinds = contentBlinds - 1;
			}, 30);
		})
		.live("click", function()
		{	var thisHref = $(this).attr('href');
			var currentID = $(this).attr("class");
			
			// Give the main link the current class
			//$('#nav div').each (function() {	$(this).removeClass('current');	});
			//$('#nav #'+currentID).addClass('current');
			$(this).blur();
			// Load the clicked page
			loadNewPage ( thisHref, true );
			return false;
		});
		// Security to make sure the menu hide goes away
		$('#contentBlinds:visible').live("mouseover", function()
		{	timeout = window.setTimeout(function()
			{	if ( contentBlinds == 1 )
				{	$('#nav a').mouseout();
					contentBlinds = contentBlinds - 1;	}
			}, 300);
		});
	
	
	// ------------------- Header login form ------------------
	$('#headerLoginButton').mouseover(function(){
		headerLoginTracker++;
		timeout = window.setTimeout(function()
		{	if ( headerLoginTracker > 0 )
			{	$('#headerLoginContainer').show("fast", function() {
					$('#headerLoginSlide').stop().animate({top:'0px'},{duration:300});
				});
			}
		}, 300);
	}).click(function() {	return false;	});
	$('#headerLoginSlide').mouseover(function(){	headerLoginTracker++;	});
	$('#headerLoginButton, #headerLoginSlide').mouseout(function(){
		headerLoginTracker--;
		timeout = window.setTimeout(function()
		{	if ( headerLoginTracker == 0 )
			{	$('#headerLoginSlide').stop().animate({top:'-170px'},300, function() {
					$('#headerLoginContainer').hide("fast");
				});
			}
		}, 1000);
	});
	
	// --------------- Footer Toolbar rollovers ---------------
	$('#footerToolbar div a')
		.css( {backgroundPosition: "0 0"} )
		.live("mouseover", function(){
			$(this).stop().animate( {backgroundPosition:"(0 -190px)"}, 250);
		})
		.live("mouseout", function(){
			$(this).stop().animate( {backgroundPosition:"(0 0)"}, 250);
			highlightCurrent ();
		});
	
	$('#footerToolbar > div.language > a').live("mouseover", function(){
		footerLangTracker++;
		timeout = window.setTimeout(function()
		{	if ( footerLangTracker > 0 )
			{	$('#footerToolbar div.langSelectContainer').fadeIn("fast", function() {
					$('#footerToolbar div.langSelect').stop().animate({bottom:'0px'}, {queue:false,duration:160});
				});
			}
		}, 200);
	}).click(function() {	return false;	});
	$('#footerToolbar div.langSelect span').live("mouseover", function(){	footerLangTracker++;	});
	$('#footerToolbar > div.language > a, #footerToolbar div.langSelect span').live("mouseout", function(){
		footerLangTracker--;
		timeout = window.setTimeout(function()
		{	if ( footerLangTracker == 0 )
			{	$('#footerToolbar div.langSelect').stop().animate({bottom:'-136px'}, {queue:false,duration:160}, function() {
					$('#footerToolbar div.langSelectContainer').fadeOut("fast");
				});
			}
		}, 600);
	});
	
	$('#footerToolbar .productReg a, #footerToolbar .terms a, #footerToolbar .privacy a')
		.live("click", function(){
			var thisHref = $(this).attr('href');
			// Load the clicked page
			loadNewPage ( thisHref );
			return false;
		});
	
	// ----------- Functions/Subnav pages rollovers -----------
	$('#functionSubnav a, #subnav a, .functionNext')
		.live("mouseover", function(){
			$("span.up", this).stop().animate({opacity:"0"}, 400);
		})
		.live("mouseout", function(){
			$("span.up", this).stop().animate({opacity:"1"}, 400);
			highlightCurrent ();
		});
	$('#functionSubnav a, .functionNext').live("click", function(){
			var thisHref = $(this).attr('href');
			$("#functionSubnav a span.up, a.functionNext span.up").stop().animate({opacity:"1"}, 100, function(){
				// Load the clicked page
				loadNewPage ( thisHref );
			});
			return false;
		});
	$('#subnav a').live("click", function(){
			var thisHref = $(this).attr('href');
			// Load the clicked page
			loadNewPage ( thisHref );
			return false;
		});
	
	// ------------ Shishavac page rotating images ------------
	
	/*if ( href == baseURL+"shishavac" || href == baseURL+"shishavac/" )
	{	$('#mainHomeFlash .homeCountries').crossSlide({
			  speed: 20,
			  fade: 1
			}, [
			{	src:  baseURL+'images/home/countries.png', dir:'up'	},
			{	src:  baseURL+'images/home/countries.png', dir:'up'	}
		]);
		$('#mainHomeFlash .homeShop').crossSlide({
			  speed: 20,
			  fade: 1
			}, [
			{	src:  baseURL+'images/home/shop-shishavac1.jpg', dir:'left'	},
			{	src:  baseURL+'images/home/shop-shishavac2.jpg', dir:'up'	}
		]);
	} */

	if ( href == baseURL+"shishavac" || href == baseURL+"shishavac/" || href == baseURL+"shishavac/#shishavac" || href == baseURL+"shishavac#shishavac" )
	{
	  //clearInterval(itvl);
	}

	
	// ------------------ FAQ page rollovers ------------------
	$('#faqQuestions a')
		.live("mouseover", function(){
			thisclass = $(this).attr("class");
			$('div.answer').stop(true, true).hide();
			$('div#'+thisclass).stop(true, true).fadeIn("normal");
		})
		.live("mouseout", function(){
			thisclass = $(this).attr("class");
			$('div#'+thisclass).stop(true, true).hide();
		})
		.live("click", function(){
			return false;
		});
	
	// ---------------- Mission pages rollovers ---------------
	$('#mediaClose a, #missionClose a')
		.live("mouseover", function(){
			/* Currently not working, revisit
			logoInteraction ( "mouseover" );
			logoInteraction ( "mouseoverSound" );
			$('#contentBlinds:hidden').stop(true, true).fadeIn('slow');
			*/
			$("img", this).stop(true, true).animate({opacity:"0"}, 400);
		})
		.live("mouseout", function(){
			/* Currently not working, revisit
			logoInteraction ( "mouseout" );	
			logoInteraction ( "mouseoutSound" );
			$('#contentBlinds:visible').stop(true, true).fadeOut('slow');
			*/
			$("img", this).stop(true, true).animate({opacity:"1"}, 400);
		});
		
	// ------------- Purchase page link new window ------------
	$("#allDealerResults a").live("click", function(){
		if ( $(this).attr('href').substring(0,6) != "mailto" )
		{	window.open( $(this).attr('href'), '_blank');
			return false;	}
	});
	
	// ------- Contact and generic links, load with AJAX ------
	$('#contactSubnav a, #mediaClose a, #missionClose a, a.ajaxLoad')
		.live("click", function(){
			var thisHref = $(this).attr('href');
			// Load the clicked page
			loadNewPage ( thisHref );
			return false;
		});
	
	// Close overlay on click of the "Proceed to query form" button
	$("a#FAQOverlayClose").live("click", function(){
			$("#FAQOverlay").stop().fadeOut('fast');
			return false;
		});
	
	// -- Contact pages form field text/checkbox replacement --
	$('#frmSellit input, #frmSellit textarea, #frmPurchased input, #frmPurchased textarea, #frmGeneral input, #frmGeneral textarea, #frmMedia input, #frmMedia textarea, #frmNewsletter input, #frmNewsletter textarea, #frmProductReg input, #frmProductReg textarea')
	.live("focus",function() {
		thisInput = $(this);
		thisInputID = thisInput.attr("id");
		//alert ( trimInput(thisInput.val()) +"=="+ document.getElementById(thisInputID).defaultValue );
		if ( trimInput(thisInput.val()) == document.getElementById(thisInputID).defaultValue )
		{	thisInput.val("");	}
	})
	.live("blur",function() {
		api.reinitialise();
		thisInput = $(this);
		thisInputID = thisInput.attr("id");
		if (trimInput(thisInput.val()) == '')
		{	thisInput.val( document.getElementById(thisInputID).defaultValue );	}
		else
		{	thisInput.val( trimInput(thisInput.val()) );	}
	});
	// ---------------------------------------	
	
}


// ---------------------------------------
// ------ Sound pause on video load ------
function allSoundPause(e)
{	logoInteraction ( "allSoundPause" );	}

// ------ Product Registration Check -----
function businessCheck()
{	if ( $("#selShishavacApplication").val() == 'restaurant' || $("#selShishavacApplication").val() == 'cafe' )
	{	return true;	}
	else {	return false;	}
}
	
// ------- Close the features flash ------
function closeFeatures ()
{	// Load the main shishavac page
	loadNewPage ( baseURL+"shishavac/" );
}

// --- Highlight Current Main Nav item ---
function highlightCurrent ()
{	// Get the current page either from the hash or the window location
	if ( window.location.hash.substr(1) != "" )
	{	var hash = window.location.hash.substr(1);	}
	else
	{	var currentPage = String(window.location);
		var hash = currentPage.replace(baseURL, "");
	}
	var hashSplit = hash.split("/");
	var hashSplitLength = hashSplit.length;
	
	$("#footerToolbar .terms, #footerToolbar .privacy").css("background-color","#000000");
	// If we're on the Terms page
	if ( hashSplit[0] == "terms" )
	{	$("#footerToolbar .terms").css("background-color","#FFFFFF");	}
	// If we're on the Privacy Policy page
	if ( hashSplit[0] == "policy" )
	{	$("#footerToolbar .privacy").css("background-color","#FFFFFF");	}
	
	// Cycle through the main nav links
	var mainNav = $('#nav a').each(function(){
		thisHref = $(this).attr('href').substr(0,$(this).attr('href').length-1).replace(baseURL, "");
		thisClass = $(this).attr('class');
		//alert ( hash + " -|- " + thisHref );
		if( ( thisHref.length > 0 ) && ( hash.substr(0,thisHref.length) == thisHref ) ){
			if ( $('#nav #'+thisClass).hasClass('current') === false )
			{	// Give the current main link the .current class
				$('#nav #'+thisClass).addClass('current');
			}
			$('#nav #'+thisClass+' div.over').stop(true, true).fadeIn("normal");
			$('#nav #'+thisClass+' div.up').stop(true, true).fadeOut("normal");
			$('#nav #'+thisClass+' div.fade').stop(true, true).fadeOut("normal");
		}
		else
		{	$('#nav #'+thisClass).removeClass('current');
			$('#nav #'+thisClass+' div.over').stop(true, true).fadeOut("normal");
			$('#nav #'+thisClass+' div.up').stop(true, true).fadeIn("normal");
			$('#nav #'+thisClass+' div.fade').stop(true, true).fadeOut("normal");
		}
		
	});
	
	// If this page has more than 1 level go through the subnav as well
	if ( hashSplitLength > 1 )
	{	$('#subnav a').each(function(){
			thisLink = $(this);
			thisHref = $(this).attr('href').substr(0,$(this).attr('href').length-1).replace(baseURL, "");
			thisHrefSplit = thisHref.split("/");
			//alert ( hashSplit[1] + " -|- " + thisHrefSplit[1] );
			if ( hashSplit[1] == thisHrefSplit[1] )
			{	// Give the current subnav link the .current class
				$(thisLink).addClass('current');
			}	
			else
			{	$(thisLink).removeClass('current');	}
		});
	}
	
	// If this page has more than 2 levels it has to be the functions subnav so go through that as well
	if ( hashSplitLength > 2 )
	{	$('#functionSubnav a').each(function(){
			thisLink = $(this);
			thisHref = $(this).attr('href').substr(0,$(this).attr('href').length-1).replace(baseURL, "");
			thisHrefSplit = thisHref.split("/");
			//alert ( hashSplit[1] + " -|- " + thisHref );
			if ( hashSplit[2] == thisHrefSplit[2] )
			{	// Give the current subnav link the .current class
				$(thisLink).addClass('current');
			}	
			else
			{	$(thisLink).removeClass('current');	}
		});
	}
		
	$('#subnav a.current span.up').stop().animate({opacity:"0"}, 400);
	$('#functionSubnav a.current span.up').stop().animate({opacity:"0"}, 400);
	return false;
}

// --- Homepage flash is loaded, start the audio ---
function homeFlashLoaded ()
{	logoInteraction ( "introSoundPlay" );	}

// ---- Load the Dealer Locator script ---
function loadDealerLocator()
{	$('#frmDealers select').change( function(){
		loadNewPage ( $('#frmDealers').attr('action') + $('#frmDealers select').attr('value') + "/" );
		return false;
	});
}

// ----- Load Functions Clean images -----
function loadFunctionsClean ()
{	// CrossSlide images
	$('#functionsImages').crossSlide({
		fade: 1,
		sleep: 5,
		variant: true
	}, [
		{
		src:  baseURL+'images/functions/Clean_2.jpg'/*,
		from: '40% 60% 1x',
		to:   'bottom right .5x',
		time: 25
		*/}, {
		src:  baseURL+'images/functions/Clean_1.jpg'/*,
		from: '10% 40% 1x',
		to:   'bottom right .5x',
		time: 25
		*/}
	]);
}

// ----- Load Functions Clean images -----
function loadFunctionsIgnite ()
{	// CrossSlide images
	$('#functionsImages').crossSlide({
		fade: 1,
		sleep: 5,
		variant: true
	}, [
		{
		src:  baseURL+'images/functions/Ignite_1.jpg'/*,
		from: '30% 10% 1x',
		to:   'bottom right .5x',
		time: 25
		*/}, {
		src:  baseURL+'images/functions/Ignite_2.jpg'/*,
		from: '50% 80% 1x',
		to:   'bottom right .5x',
		time: 25
		*/}
	]);
}

// ----- Load Functions Clean images -----
function loadFunctionsStoke ()
{	// CrossSlide images
	/*$('#functionsImages').crossSlide({
		fade: 1,
		sleep: 5,
		variant: true
	}, [
		{
		src:  baseURL+'images/functions/Stoke_1.jpg',
		from: '60% 80% 1x',
		to:   'bottom right .5x',
		time: 25
		}, {
		src:  baseURL+'images/functions/Stoke_1.jpg',
		from: 'bottom right .5x',
		to:   'bottom right .5x',
		time: 2500
		}
	]);*/
}

// ----- Load Functions Clean images -----
function loadFunctionsDry ()
{	// CrossSlide images
	/*$('#functionsImages').crossSlide({
		fade: 1,
		sleep: 5,
		variant: true
	}, [
		{
		src:  baseURL+'images/functions/Dry_1.jpg',
		from: '10% 50% 1x',
		to:   'bottom right .5x',
		time: 25
		}, {
		src:  baseURL+'images/functions/Dry_1.jpg',
		from: 'bottom right .5x',
		to:   'bottom right .5x',
		time: 2500
		}
	]);*/
}

// ---- Load the Homepage lang select ----
function loadLangSelect ()
{	$('#homeLangSelect a')
		.css( {backgroundPosition: "0 0"} )
		.live("mouseover", function(){
			$(this).stop().animate( {backgroundPosition:"(0 -190px)"}, 250);
		})
		.live("mouseout", function(){
			$(this).stop().animate( {backgroundPosition:"(0 0)"}, 250);
		})
		.live("click", function()
		{	var languageLink = $(this).attr("href");
			var languageSelected = $(this).attr("id");
			$('#videoClipClose a').attr("href", languageLink);
			$('body').css('background-color','#000').css('background-image','none');
			$('#horizon_bg').fadeOut("fast");
			$('#videoClipFlash, #videoClipClose').fadeIn("fast");
			
			if ( languageSelected == 'arabic') { videoLocation = "http://www.youtube.com/watch?v=Wa5kWy_PSLM"; }
			else if ( languageSelected == 'english') { videoLocation = "http://www.youtube.com/watch?v=-dBUP8vX-Fw"; }
			else if ( languageSelected == 'french') { videoLocation = "http://www.youtube.com/watch?v=kWhs7keM6"; }
			else if ( languageSelected == 'german') { videoLocation = "http://www.youtube.com/watch?v=z7HqmyV1wpA"; }
			else if ( languageSelected == 'russian') { videoLocation = "http://www.youtube.com/watch?v=2vksWwkTsto"; }
			
			var flashvarsVideoClip = { type:'youtube', file:''+videoLocation+'', image:'none', stretching: 'none', skin:baseURL+'multimedia/glow.zip', plugins: 'sharing', 'sharing.link': ''+videoLocation+'', autostart:'true' };
			var paramsVideoClip = { allowfullscreen:'true', allowscriptaccess:'always', menu: "false", wmode: "transparent" };
			var attributesVideoClip = { id:'videoClipFlash1', name:'player1' };
			swfobject.embedSWF(baseURL+'multimedia/player.swf','videoClipFlash','915','515','9.0.115',baseURL+'images/expressInstall.swf',flashvarsVideoClip, paramsVideoClip, attributesVideoClip, loadLangSelectComplete);
			return false;
		});	
}
function loadLangSelectComplete (e)
{	logoInteraction ( "allSoundPause" );
	jwplayer(e.ref).onComplete(function() { window.location = baseURL+"shishavac/"; });	}

// -------- Load the mission flash -------
function loadMission ()
{	// Load the main shishavac page
	var flashvarsMission = { strLanguage: "english" };
	var paramsMission = {	allowScriptAccess:"always", menu: "false", wmode: "transparent"	};
	var attributesMission = false;
	swfobject.embedSWF(baseURL+"multimedia/logoMission.swf", "missionLogo", "85", "126", "8.0.0", baseURL+"images/expressInstall.swf", flashvarsMission, paramsMission, attributesMission);
	
	/* Removing this until we can figure out the jittery issue
	$('#missionImages').crossSlide({
		fade: 1,
		variant: true,
		easing: 'easeInOutQuad'
	}, [
		{
		src:  baseURL+'images/mission/shishavac1.jpg',
		from: '50% 70% 1x',
		to:   'top left .5x',
		time: 25
		}, {
		src:  baseURL+'images/mission/shishavac2.jpg',
		from: '10% 70% 1x',
		to:   'top left .5x',
		time: 25
		}
	]);
	*/
}

// ------------ Auto pageload ------------
function loadNewPage ( thisHref, mainNav )
{	var toLoad = thisHref+' #main';
	mainNav = typeof(mainNav) != 'undefined' ? mainNav : false;
	$('#content:visible').fadeOut('fast',loadContent);
	//$('#load').remove();
	//$('#container').append('<span id="load">LOADING&hellip;</span>');
	//$('#load').fadeIn('slow');
	window.location.hash = thisHref.substr(0,thisHref.length-1).replace(baseURL, "");
	function loadContent() {
		$('#content').load(toLoad, function () {
			showNewContent ();
			pageSpecificFunctionLoader ( thisHref );
		});
	}
	function showNewContent() {
		//$('#content').fadeIn('slow',hideLoader());
		
		$('#content').fadeIn('slow');
		$('#contentBlinds:visible').stop(true, true).fadeOut('normal');
		if ( navOffTracker == 0 && mainNav == true )
		{	navOffTracker = 1;
			logoInteraction ( "sheen" );
			logoInteraction ( "mouseout" );
			logoInteraction ( "introSoundPlay" );
			logoInteraction ( "mouseoutSound" );			
			$("#navBG").stop(true, true).fadeOut("normal");
		}
	}
	function hideLoader() {
		//$('#load').fadeOut('normal');
	}
}

// -------- Flash Logo Interaction -------
function logoInteraction ( doThis )
{	// Do a few checks to see if the flash is available to interact with
	if ( logoLoadedTracker === true ){
		if (navigator.appName.indexOf("Microsoft") != -1)
		{	if ( typeof(window.mainLogo) != 'undefined' )
			{	switch( doThis )
				{	case "allSoundPause":
						window.mainLogo.ambientSoundPause();
						window.mainLogo.introSoundPause();
						break;
					case "introSoundPause":
//						window.mainLogo.introSoundPause();
//						window.mainLogo.ambientSoundPlay();
						break;
					case "introSoundPlay":
//						window.mainLogo.ambientSoundPause();
//						window.mainLogo.introSoundPlay();
						break;
					case "introSoundRestart":
//						window.mainLogo.introSoundRestart();
						break;
					case "mouseout":
						window.mainLogo.mouseout();
						break;
					case "mouseoutSound":
//						window.mainLogo.mouseoutSound();
						break;
					case "mouseover":
						window.mainLogo.mouseover();
						break;
					case "mouseoverSound":
//						window.mainLogo.mouseoverSound();
						break;
					case "mouseoverSubnav":
						window.mainLogo.mouseoverSubnav();
						break;
					case "sheen":
						window.mainLogo.sheen();
						break;
					default:
						break;
				}
			}
		}
		else
		{	if ( typeof(document.mainLogo) != 'undefined' )
			{	switch( doThis )
				{	case "allSoundPause":
						document.mainLogo.ambientSoundPause();
						document.mainLogo.introSoundPause();
						break;
					case "introSoundPause":
//						document.mainLogo.introSoundPause();
//						document.mainLogo.ambientSoundPause();
						break;
					case "introSoundPlay":
//						document.mainLogo.introSoundPause();
//						document.mainLogo.ambientSoundPause();
						break;
					case "introSoundRestart":
//						document.mainLogo.introSoundRestart();
						break;
					case "mouseout":
						document.mainLogo.mouseout();
						break;
					case "mouseoutSound":
//						document.mainLogo.mouseoutSound();
						break;
					case "mouseover":
						document.mainLogo.mouseover();
						break;
					case "mouseoverSound":
//						document.mainLogo.mouseoverSound();
						break;
					case "mouseoverSubnav":
						document.mainLogo.mouseoverSubnav();
						break;
					case "sheen":
						document.mainLogo.sheen();
						break;
					default:
						break;
				}
			}
		}
	}
	else
	{	timeout = window.setTimeout(function()
		{	logoInteraction ( doThis )	}, 50);	}
}

// -- Funtions that trigger on pageload --
function logoLoaded ()
{	// This is triggered by the logo flash when it's ready
	if ( logoLoadedTracker == false )
	{	logoLoadedTracker = true;	}
}

// -- Funtions that trigger on pageload --
function pageSpecificFunctionLoader ( thisPage )
{	// Send the pageview to Google Analytics
	gaqURL = thisPage.replace(baseURL, "/");
	_gaq.push(['_trackPageview', gaqURL]);
	
	// Based on the page, we need to show and hide elements
	if ( thisPage == baseURL || thisPage.search("shishavac/features") != -1 || thisPage.search("shishavac/video/shishaAd2009") != -1 || thisPage.search("shishavac/video/shishaDemo2009") != -1 || thisPage.search("media") != -1 ||  thisPage.search("mission") != -1 || thisPage.search("mission/off") != -1 )
	{	$("div#footerLogo, div#footerToolbar, div#headerLogin").fadeOut(200);
		$("div#mainLogo, div#sidebar").css("display","none");	}
	else if ( thisPage.search("contact") != -1 )
	{	$("div#footerLogo").fadeOut("fast");
		$("div#footerToolbar, div#headerLogin").fadeIn(200);
		$("div#mainLogo, div#sidebar").css("display","block");	}
	else
	{	$("div#footerLogo, div#footerToolbar, div#headerLogin").fadeIn(200);
		$("div#mainLogo, div#sidebar").css("display","block");	}
		
	// Page specific calls based on thisPage
	if ( thisPage.search("contact/partner") != -1 )
	{	validateDistribution ();	}
	if ( thisPage.search("contact/customerservicequery") != -1 )
	{	validatePurchased ();	}
	if ( thisPage.search("contact/generalquery") != -1 )
	{	validateGeneral ();	}
	if ( thisPage.search("media") != -1 )
	{	validateMedia ();	}
	if ( thisPage.search("mission") != -1 || thisPage.search("mission/off") != -1 )
	{	loadMission ();	validateNewsletter ();	}
	if ( thisPage.search("productreg") != -1 )
	{	validateProductReg ();	}
	if ( thisPage.search("purchase") != -1 || thisPage.search("purchase/off") != -1 )
	{	validateNewsletter ();	}
	if ( thisPage.search("purchase/dealers") != -1 ||  thisPage.search("purchase/dealerdetails") != -1 )
	{	loadDealerLocator ();	}
	if ( thisPage == baseURL+"shishavac" || thisPage == baseURL+"shishavac/" )
	{	if ( logoLoadedTracker == true ) { loadHomepage ();	/*logoInteraction ( "introSoundRestart" );*/ }
		else { timeout = window.setTimeout(function() { pageSpecificFunctionLoader ( thisPage ); }, 400); }
	}
	if ( thisPage.search("shishavac/features") != -1 )
	{	loadFeatures ();	}
	if ( thisPage.search("shishavac/functions/clean") != -1 )
	{	loadFunctionsClean ();	}
	if ( thisPage.search("shishavac/functions/ignite") != -1 )
	{	loadFunctionsIgnite ();	}
	if ( thisPage.search("shishavac/functions/stoke") != -1 )
	{	loadFunctionsStoke ();	}
	if ( thisPage.search("shishavac/functions/dry") != -1 )
	{	loadFunctionsDry ();	}
	if ( thisPage == baseURL+"shishavac/videos" || thisPage == baseURL+"shishavac/videos/" )
	{	timeout = window.setTimeout(function()
		{	logoInteraction ( "introSoundPlay" );	}, 1600);	}
	if ( thisPage.search("shishavac/video/shishaAd2009") != -1 )
	{	loadVideoAd2009 ();	}
	if ( thisPage.search("shishavac/video/shishaDemo2009") != -1 )
	{	loadVideoDemo2009 ();	}
	if ( thisPage == baseURL )
	{	loadLangSelect ();	}
	
	// If the logo was loaded
	if ( logoLoadedTracker == true )
	{	if ( href == baseURL || href == baseURL+"shishavac" || href == baseURL+"shishavac/" || href.search("shishavac/video/shishaAd2009") != -1 || href.search("shishavac/video/shishaDemo2009") != -1 )
		{	/* don't autoplay introsound on these pages */	}
		else {	logoInteraction ( "introSoundPlay" );	}
	}
	
	// These load on all pages
	highlightCurrent ();
	scrollContent ();
	Cufon.replace('.trajan');
}

// --- Add scrollers to dynamic content --
function scrollContent ()
{	$('.scrollContent').each (function() {
		thisScroller = $(this).jScrollPane(scrollSettings);
		api = thisScroller.data('jsp');
	});
}

// --------- Trim provided string --------
function trimInput(str) 
{	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i > 0; i--) 
	{	if (/\S/.test(str.charAt(i))) 
		{	str = str.substring(0, i + 1);
			break;	}
	}
	return str;
};

// ------ Validate Distribution Form -----
function validateDistribution ()
{	// Distribution form validation - http://www.shishavac.com/contact/partner
	$("form#frmSellit").submit( function () {
		if ( !$('form#frmSellit').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmSellit").submit();	}
	});
	
	// Validate form
	$("#frmSellit").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtCompanyName: { 			required: true, notEqual:true, maxlength: 50 },
			txtContactName: { 			required: true, notEqual:true, maxlength: 25	},
			txtTitle: { 				required: true, notEqual:true, maxlength: 50	},
			txtEmail: { 				required: true, notEqual:true, maxlength: 50, email:true	},
			txtMobileNumber: { 			required: true, notEqual:true, maxlength: 15	},
			txtOfficeNumber: { 			required: true, notEqual:true, maxlength: 15	},
			txtFaxNumber: { 			required: true, notEqual:true, maxlength: 15	},
			txtCompanyAddress: { 		required: true, notEqual:true	},
			txtWebsite: { 				required: true, notEqual:true, maxlength: 50	},
			selCountry: { 				required: true, maxlength: 2	},
			selAnnualRevenue: { 		required: true	},
			chkProductType: { 			required: true	},
			chkClassification: { 		required: true	},
			selBestContact: { 			required: true	},
			selHearAboutShishavac: { 	required: true	},
			selMarket: { 				required: true	},
			txtComments: { 				required: true, notEqual:true, minlength:350	},
			chkTermsAgree: { 			required: true	},
			
			txtContactSurname: { 		required: true, notEqual:true, maxlength: 25	},
			txtEmailVerify: { 			required: true, notEqual:true, maxlength: 50, email:true, equalTo: "#txtEmail"	},
			txtYearEstablished: { 		required: true, notEqual:true, maxlength: 4, digits: true	},
			selInterest: { 				required: true	},
			selBestContactTime: { 		required: true	}
		},
		messages: {
			txtCompanyName: { 			required: "Please enter a Company Name",
										notEqual:"Please enter a Company Name",
										maxlength: "Your entered Company Name exceeds the maximum length"	},
			txtContactName: { 			required: "Please enter a Contact First Name",
										notEqual: "Please enter a Contact First Name",
										maxlength: "Your entered Contact First Name exceeds the maximum length"	},
			txtTitle: { 				required: "Please enter a Title",
										notEqual: "Please enter a Title",
										maxlength: "Your entered Title exceeds the maximum length"	},
			txtEmail: { 				required: "Please enter an Email Address",
										notEqual: "Please enter an Email Address",
										maxlength: "Your entered Email Address exceeds the maximum length",
										email: "Please enter a valid Email Address",
										equalTo: "Your entered email addresses do not match"	},
			txtMobileNumber: { 			required: "Please enter a Mobile Number",
										notEqual: "Please enter a Mobile Number",
										maxlength: "Your entered Mobile Number exceeds the maximum length"	},
			txtOfficeNumber: { 			required: "Please enter an Office Number",
										notEqual: "Please enter an Office Number",
										maxlength: "Your entered Office Number exceeds the maximum length"	},
			txtFaxNumber: { 			required: "Please enter a Fax Number",
										notEqual: "Please enter a Fax Number",
										maxlength: "Your entered Fax Number exceeds the maximum length"	},
			txtCompanyAddress: { 		required: "Please enter a Company Address",
										notEqual: "Please enter a Company Address"	},
			txtWebsite: { 				required: "Please enter a Website",
										notEqual: "Please enter a Website",
										maxlength: "Your entered Website exceeds the maximum length"	},
			selCountry: { 				required: "Please select a Country",
										maxlength: "Your entered Country exceeds the maximum length"	},
			selAnnualRevenue: { 		required: "Please select an Annual Revenue",
										notEqual: "Please select an Annual Revenue"	},
			chkProductType: { 			required: "Please select Product Types"	},
			chkClassification: { 		required: "Please select your Business Classification"	},
			selBestContact: { 			required: "Please select the best way to contact you"	},
			selHearAboutShishavac: { 	required: "Please select how you heard about Shishavac"	},
			selMarket: { 				required: "Please select a Geographic Market"	},
			txtComments: { 				required: "Please enter your Comments",
										notEqual: "Please enter your Comments",
										minlength: "Your comments are too brief, please elaborate" },
			chkTermsAgree: { 			required: "You must agree to this websites Terms &amp; Conditions"	},
			
			txtContactSurname: { 		required: "Please enter a Contact Last Name", 
										notEqual: "Please enter a Contact Last Name", 
										maxlength: "Your entered Contact Last Name exceeds the maximum length"	},
			txtEmailVerify: { 			required: "Please verify your email address",
										notEqual: "Please verify your email address", 
										maxlength: "Your entered email address verification exceeds the maximum length", 
										email: "Please enter a valid verification Email Address",
										equalTo: "Your entered email addresses do not match"	},
			txtYearEstablished: { 		required: "Please enter the year you were established", 
										notEqual: "Please enter the year you were established", 
										maxlength: "Your entered year established exceeds the maximum length", 
										digits: "Your year established must be a 4 digit number"	},
			selInterest: { 				required: "Please select your interest in the Shishavac"	},
			selBestContactTime: { 		required: "Please select the best time to contact you"	}
		}
	});
	// Custom checkboxes
	$('#frmSellit .chk').ezMark();
	// Comment Textbox limit tracker
	$('#txtComments').keyup(function(){
		var text = $('#txtComments').val();	
		var textlength = text.length;
		var minimum = commentsMin - textlength;
		if ( minimum < 0 ) { minimum = 0; }
		$('#txtCommentsCount').empty().append( minimum );
	});
	// Contact Sliding Box
	$('.contact #contactSlideBox').hover(function(){
		$(this).stop().animate({bottom:'0px'},{queue:false,duration:160});
	}, function() {
		$(this).stop().animate({bottom:'-125px'},{queue:false,duration:160});
	});
}

// -------- Validate General Form --------
function validateGeneral ()
{	// General form validation - http://www.shishavac.com/contact/generalquery
	$("form#frmGeneral").submit( function () {
		if ( !$('form#frmGeneral').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmGeneral").submit();	}
	});
	// Validate form
	$("#frmGeneral").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtName: { 				required: true, notEqual:true, maxlength: 50	},
			txtSurname: { 			required: true, notEqual:true, maxlength: 50	},
			txtMailingAddress: { 	required: true, notEqual:true	},
			selCountry: { 			required: true, notEqual:true, maxlength: 2	},
			txtComments: { 			required: true, notEqual:true	},
			txtEmail: { 			required: true, notEqual:true, maxlength: 50, email:true	},
			txtEmailVerify: { 		required: true, notEqual:true, maxlength: 50, email:true, equalTo: "#txtEmail"	},
			chkTermsAgree: { 		required: true	},
			txtPhone: { 			required: true, notEqual:true, maxlength: 15	},
			txtMobile: { 			required: true, notEqual:true, maxlength: 15	},
			selHowHear: {			required: true	}
		},
		messages: {
			txtName: { 				required: "Please enter a First Name",
									notEqual: "Please enter a First Name",
									maxlength: "Your entered First Name exceeds the maximum length"	},
			txtSurname: { 			required: "Please enter a Last Name", 
									notEqual: "Please enter a Last Name", 
									maxlength: "Your entered Last Name exceeds the maximum length"	},
			txtMailingAddress: { 	required: "Please enter a Mailing Address",
									notEqual: "Please enter a Mailing Address"	},
			selCountry: { 			required: "Please select a Country",
									notEqual: "Please select a Country",
									maxlength: "Your entered Country exceeds the maximum length"	},
			txtComments: { 			required: "Please enter your Comments", 
									notEqual: "Please enter your Comments"	},
			txtEmail: { 			required: "Please enter an Email Address",
									notEqual: "Please enter an Email Address",
									maxlength: "Your entered Email Address exceeds the maximum length",
									email: "Please enter a valid Email Address"	},
			txtEmailVerify: { 		required: "Please verify your email address",
									notEqual: "Please verify your email address", 
									maxlength: "Your entered email address verification exceeds the maximum length", 
									email: "Please enter a valid verification Email Address",
									equalTo: "Your entered email addresses do not match"	},
			chkTermsAgree: { 		required: "You must agree to this websites Terms &amp; Conditions"	},
			txtPhone: { 			required: "Please enter a Home Number",
									notEqual: "Please enter a Home Number",
									maxlength: "Your entered Home Number exceeds the maximum length"	},
			txtMobile: { 			required: "Please enter a Mobile Number",
									notEqual: "Please enter a Mobile Number",
									maxlength: "Your entered Mobile Number exceeds the maximum length"	},
			selHowHear: {			required: "Please select how you heard about Shishavac"	}
		}
	});
	// Custom checkboxes
	$('#frmGeneral .chk').ezMark();
	// Contact Sliding Box
	$('.contact #contactSlideBox').hover(function(){
		$(this).stop().animate({bottom:'0px'},{queue:false,duration:160});
	}, function() {
		$(this).stop().animate({bottom:'-125px'},{queue:false,duration:160});
	});
}

// --------- Validate Media Form ---------
function validateMedia ()
{	// Media form validation - http://www.shishavac.com/media
	$("form#frmMedia").submit( function () {
		if ( !$('form#frmMedia').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmMedia").submit();	}
	});
	// CrossSlide images
	$('#mediaImages').crossSlide({
		sleep: 5,
		fade: 1
	}, [
		{ src: baseURL+'images/media/GQRussia.jpg' },
		{ src: baseURL+'images/media/Stuff.jpg' },
		{ src: baseURL+'images/media/Bespoke.jpg' },
		{ src: baseURL+'images/media/T3.jpg' },
		{ src: baseURL+'images/media/jo.jpg' },
		{ src: baseURL+'images/media/cePro.jpg'   },
		{ src: baseURL+'images/media/exhibit.jpg'  }
	]);
	// Validate form
	$("#frmMedia").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtName: { 				required: true, notEqual:true, maxlength: 50	},
			txtCompany: { 			required: true, notEqual:true, maxlength: 50	},
			txtEmail: { 			required: true, notEqual:true, maxlength: 50, email:true	},
			txtEmailVerify: { 		required: true, notEqual:true, maxlength: 50, email:true, equalTo: "#txtEmail"	},
			txtPhone: { 			required: true, notEqual:true, maxlength: 15	},
			txtComments: { 			required: true, notEqual:true	}
		},
		messages: {
			txtName: { 				required: "Please enter a Contact Name",
									notEqual: "Please enter a Contact Name",
									maxlength: "Your entered Contact Name exceeds the maximum length"	},
			txtCompany: { 			required: "Please enter a Company Name", 
									notEqual: "Please enter a Company Name", 
									maxlength: "Your entered Company Name exceeds the maximum length"	},
			txtComments: { 			required: "Please enter your Comments", 
									notEqual: "Please enter your Comments"	},
			txtEmail: { 			required: "Please enter an Email Address",
									notEqual: "Please enter an Email Address",
									maxlength: "Your entered Email Address exceeds the maximum length",
									email: "Please enter a valid Email Address"	},
			txtEmailVerify: { 		required: "Please verify your email address",
									notEqual: "Please verify your email address", 
									maxlength: "Your entered email address verification exceeds the maximum length", 
									email: "Please enter a valid verification Email Address",
									equalTo: "Your entered email addresses do not match"	},
			txtPhone: { 			required: "Please enter a Phone Number",
									notEqual: "Please enter a Phone Number",
									maxlength: "Your entered Phone Number exceeds the maximum length"	}
		}
	});
}

// ------- Validate Newsletter Form ------
function validateNewsletter ()
{	// Newsletter form validation - http://www.shishavac.com/mission/
	$("form#frmNewsletter").submit( function () {
		if ( !$('form#frmNewsletter').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmNewsletter").submit();	}
	});
	// Validate form
	$("#frmNewsletter").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtName: { 				required: true, notEqual:true, maxlength: 50	},
			selCountry: { 			required: true, notEqual:true, maxlength: 2	},
			txtEmail: { 			required: true, notEqual:true, maxlength: 50, email:true	}
		},
		messages: {
			txtName: { 				required: "Please enter a Full Name",
									notEqual: "Please enter a Full Name",
									maxlength: "Your entered Full Name exceeds the maximum length"	},
			selCountry: { 			required: "Please select a Country",
									notEqual: "Please select a Country",
									maxlength: "Your entered Country exceeds the maximum length"	},
			txtEmail: { 			required: "Please enter an Email Address",
									notEqual: "Please enter an Email Address",
									maxlength: "Your entered Email Address exceeds the maximum length",
									email: "Please enter a valid Email Address"	}
		}
	});
}

// ------ Validate Product Reg Form ------
function validateProductReg ()
{	// Media form validation - http://www.shishavac.com/media
	$("form#frmProductReg").submit( function () {
		if ( !$('form#frmProductReg').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmProductReg").submit();	}
	});
	// Validate form
	$("form#frmProductReg").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtFirstName: { 		required: true, notEqual:true, maxlength: 50	},
			txtInitial: { 			required: true, notEqual:true, maxlength: 1	},
			txtLastName: { 			required: true, notEqual:true, maxlength: 50	},
			txtBusinessName: { 		required: function(element) {	return businessCheck(); }, notEqual:true, maxlength: 50	},
			txtWebsite: { 			required: true, notEqual:true, maxlength: 50	},
			txtBusinessAddress: {	required: function(element) {	return businessCheck(); }, notEqual:true },
			txtAddress: { 			required: true, notEqual:true },
			txtCity: { 				required: true, notEqual:true, maxlength: 50	},
			txtZipcode: { 			required: true, notEqual:true, maxlength: 10	},
			selCountry: { 			required: true, maxlength: 2	},
			txtHomePhone: { 		required: true, notEqual:true, maxlength: 15	},
			txtBusinessPhone: { 	required: function(element) {	return businessCheck(); }, notEqual:true, maxlength: 15	},
			txtMobilePhone: { 		required: true, notEqual:true, maxlength: 15	},
			txtFacsimile: { 		maxlength: 15	},
			txtEmailAddress: { 		required: true, notEqual:true, maxlength: 50, email:true	},
			txtPurchaseDate: { 		required: true, notEqual:true, maxlength: 10, date: true	},
			txtModelNumber: { 		required: true, maxlength: 15	},
			txtSerialNumber1: { 	required: true, notEqual:true, maxlength: 20	},
			txtSerialNumber2: { 	maxlength: 20	},
			txtSerialNumber3: { 	maxlength: 20	},
			txtSerialNumber4: { 	maxlength: 20	},
			txtStoreName: { 		required: true, notEqual:true, maxlength: 50},
			txtQuantityPurchased: { required: true, notEqual:true, maxlength: 4, number:true	},
			selShishavacApplication: { 	required: true	},
			selTotal: { 			required: function(element) {	return businessCheck(); },	number:true	},
			selTotalOther: { 		number:true	},
			selTotalServed: { 		required: function(element) {	return businessCheck(); }	},
			selCharcoalType: { 		required: function(element) {	return businessCheck(); }	},
			selEmployees: { 		required: function(element) {	return businessCheck(); }	},
			selPersonalNarghileUse: {	required: true	},
			selPersonalCharcoalType: {	required: true	},
			selNarghilePeople: { 	required: true	},
			selBirthdayMonth: { 	required: true	},
			selBirthdayDay: { 		required: true	},
			selBirthdayYear: { 		required: true	},
			selGender: { 			required: true	},
			selPurchaseReasons: { 	required: true, rangelength:[3,5]	},
			selFamilyIncome: { 		required: true	},
			txtComments: { 			notEqual:true	},
			selBestContact: { 		required: true	},
			chkTermsAgree: { 		required: true	}
		},
		messages: {
			txtFirstName: { 		required: "Please enter a First Name",
									notEqual: "Please enter a First Name",
									maxlength: "Your entered First Name exceeds the maximum length"	},
			txtInitial: { 			required: "Please enter a Middle Initial",
									notEqual: "Please enter a Middle Initial",
									maxlength: "Your entered  Middle Initial exceeds the maximum length"	},
			txtLastName: { 			required: "Please enter a Last Name",
									notEqual: "Please enter a Last Name",
									maxlength: "Your entered Last Name exceeds the maximum length"	},
			txtBusinessName: { 		required: "Please enter a Business Name",
									notEqual: "Please enter a Business Name",
									maxlength: "Your entered Business Name exceeds the maximum length"	},
			txtWebsite: { 			required: "Please enter a Website",
									notEqual: "Please enter a Website",
									maxlength: "Your entered Website exceeds the maximum length"	},
			txtBusinessAddress: {	required: "Please enter a Business Address",
									notEqual: "Please enter a Business Address"	},
			txtAddress: { 			required: "Please enter an Address",
									notEqual: "Please enter an Address"	},
			txtCity: { 				required: "Please enter a City/State",
									notEqual: "Please enter a City/State",
									maxlength: "Your entered City/State exceeds the maximum length"	},
			txtZipcode: { 			required: "Please enter a Zipcode",
									notEqual: "Please enter a Zipcode",
									maxlength: "Your entered Zipcode exceeds the maximum length"	},
			selCountry: { 			required: "Please enter a Country",
									maxlength: "Your selected Country exceeds the maximum length"	},
			txtHomePhone: { 		required: "Please enter a Home Phone",
									notEqual: "Please enter a Home Phone",
									maxlength: "Your entered Home Phone exceeds the maximum length"	},
			txtBusinessPhone: { 	required: "Please enter a Business Phone",
									notEqual: "Please enter a Business Phone",
									maxlength: "Your entered Business Phone exceeds the maximum length"	},
			txtMobilePhone: { 		required: "Please enter a Mobile Phone",
									notEqual: "Please enter a Mobile Phone",
									maxlength: "Your entered Mobile Phone exceeds the maximum length"	},
			txtFacsimile: { 		maxlength: "Your entered Facsimile Number exceeds the maximum length"	},
			txtEmailAddress: { 		required: "Please enter an Email Address",
									maxlength: "Your entered Email Address exceeds the maximum length",
									email: "Please enter a valid Email Address"	},
			txtPurchaseDate: { 		required: "Please enter a Purchase Date",
									maxlength: "Your entered Purchase Date exceeds the maximum length",
									date: "Please enter a valid Purchase Date (e.g. '12/10/2005')"	},
			txtModelNumber: { 		required: "Please enter a Model Number",
									notEqual: "Please enter a Model Number",
									maxlength: "Your entered Model Number exceeds the maximum length"	},
			txtSerialNumber1: { 	required: "Please enter a Serial Number",
									maxlength: "Your entered Serial Number #1 exceeds the maximum length"	},
			txtSerialNumber2: { 	maxlength: "Your entered Serial Number #2 exceeds the maximum length"	},
			txtSerialNumber3: { 	maxlength: "Your entered Serial Number #3 exceeds the maximum length"	},
			txtSerialNumber4: { 	maxlength: "Your entered Serial Number #4 exceeds the maximum length"	},
			txtStoreName: { 		required: "Please enter a Store Name",
									notEqual: "Please enter a Store Name",
									maxlength: "Your entered Store Name exceeds the maximum length"	},
			txtQuantityPurchased: { required: "Please enter an Quantity of Units Purchased",
									required: "Please enter an Quantity of Units Purchased",
									maxlength: "Your entered Quantity of Units Purchased exceeds the maximum length",
									number:"Quantity of Units Purchased must be a number"	},
			selShishavacApplication: { 	required: "Please select your application for the Shishavac",
									notEqual: "Please select your application for the Shishavac"	},
			selTotal: { 			number:"Your Total Shishavacs placed in your Establishment must be a number"	},
			selTotalOther: { 		number:"Your Total Shishavacs placed in your Establishment must be a number"	},
			selTotalServed: { 		},
			selCharcoalType: { 		required: "Please select the type of charcoal your establishment uses"	},
			selEmployees: { 		},
			selPersonalNarghileUse: {	required: "Please select How frequently you enjoy narghile"	},
			selPersonalCharcoalType: {	required: "Please select the type of charcoal you personally uses"	},
			selNarghilePeople: { 	required: "Please select How many people in your household enjoy a narghile"	},
			selBirthdayMonth: { 	required: "Please select your Date of Birth Month"	},
			selBirthdayDay: { 		required: "Please select your Date of Birth Day"	},
			selBirthdayYear: { 		required: "Please select your Date of Birth Year"	},
			selGender: { 			required: "Please select a Gender"	},
			selPurchaseReasons: { 	required: "Please select 3 to 5 reasons you chose the Shishavac",
									rangelength: "Please select only 3 to 5 reasons you chose the Shishavac"	},
			selFamilyIncome: { 		required: "Please enter your Family Income"	},
			txtComments: { 			},
			selBestContact: { 		required: "Please select the best way to contact you"	},
			chkTermsAgree: { 		required: "You must agree to this websites Terms &amp; Conditions"	}
		}
	});
}

// ------- Validate Purchased Form -------
function validatePurchased ()
{	// Purchased form validation - http://www.shishavac.com/contact/customerservicequery
	$("form#frmPurchased").submit( function () {
		if ( !$('form#frmPurchased').valid() ) {
			api.reinitialise();
			alert("Please correct the highlighted fields.");
			return false;
		}
		else {	$("form#frmPurchased").submit();	}
	});
	// Custom checkboxes
	$('#frmPurchased .chk').ezMark();
	// Validate form
	$("#frmPurchased").validate({
		errorLabelContainer: $("div#errorContainer"),
		onfocusout: false,
		rules: {
			txtContactName: { 			required: true, notEqual:true, maxlength: 25	},
			txtContactSurname: { 		required: true, notEqual:true, maxlength: 25	},
			txtQuestions: { 			required: true, notEqual:true	},
			txtMailingAddress: { 		required: true, notEqual:true	},
			txtStorePurchased: { 		required: true, notEqual:true, maxlength: 100	},
			txtSerial: { 				required: true, notEqual:true, maxlength: 10	},
			selCountry: { 				required: true, notEqual:true, maxlength: 2	},
			selModelNumber: { 			required: true	},
			txtPurchasedDay: { 			required: true, notEqual:true, maxlength: 2, digits: true	},
			txtPurchasedMonth: { 		required: true, notEqual:true, maxlength: 2, digits: true	},
			txtPurchasedYear: { 		required: true, notEqual:true, maxlength: 4, digits: true	},
			txtEmail: { 				required: true, notEqual:true, maxlength: 50, email:true	},
			txtEmailVerify: { 			required: true, notEqual:true, maxlength: 50, email:true, equalTo: "#txtEmail"	},
			chkTermsAgree: { 			required: true	},
			txtHomeNumber: { 			required: true, notEqual:true, maxlength: 15	},
			txtMobileNumber: { 			required: true, notEqual:true, maxlength: 15	}
		},
		messages: {
			txtContactName: { 			required: "Please enter a Contact First Name",
										notEqual: "Please enter a Contact First Name",
										maxlength: "Your entered Contact First Name exceeds the maximum length"	},
			txtContactSurname: { 		required: "Please enter a Contact Last Name", 
										notEqual: "Please enter a Contact Last Name", 
										maxlength: "Your entered Contact Last Name exceeds the maximum length"	},
			txtQuestions: { 			required: "Please enter your Questions about your purchased product", 
										notEqual: "Please enter your Questions about your purchased product"	},
			txtMailingAddress: { 		required: "Please enter a Mailing Address",
										notEqual: "Please enter a Mailing Address"	},
			txtStorePurchased: { 		required: "Please enter where you purchased your product",
										notEqual: "Please enter where you purchased your product",
										maxlength: "Your entered Store Purchased exceeds the maximum length"	},
			txtSerial: { 				required: "Please enter the serial number of your product",
										notEqual: "Please enter the serial number of your product",
										maxlength: "Your entered serial number exceeds the maximum length"	},
			selCountry: { 				required: "Please select a Country",
										notEqual: "Please select a Country",
										maxlength: "Your entered Country exceeds the maximum length"	},
			selModelNumber: { 			required: "Please select a Model Number"	},
			txtPurchasedDay: { 			required: "Please enter the day you purchased your product", 
										notEqual: "Please enter the day you purchased your product", 
										maxlength: "Your entered day you purchased your product exceeds the maximum length", 
										digits: "Your day you purchased your product must be a 2 digit number"	},
			txtPurchasedMonth: { 		required: "Please enter the month you purchased your product", 
										notEqual: "Please enter the month you purchased your product", 
										maxlength: "Your entered month you purchased your product exceeds the maximum length", 
										digits: "Your month you purchased your product must be a 2 digit number"	},
			txtPurchasedYear: { 		required: "Please enter the year you purchased your product", 
										notEqual: "Please enter the year you purchased your product", 
										maxlength: "Your entered year you purchased your product exceeds the maximum length", 
										digits: "Your year you purchased your product must be a 4 digit number"	},
			txtEmail: { 				required: "Please enter an Email Address",
										notEqual: "Please enter an Email Address",
										maxlength: "Your entered Email Address exceeds the maximum length",
										email: "Please enter a valid Email Address"	},
			txtEmailVerify: { 			required: "Please verify your email address",
										notEqual: "Please verify your email address", 
										maxlength: "Your entered email address verification exceeds the maximum length", 
										email: "Please enter a valid verification Email Address",
										equalTo: "Your entered email addresses do not match"	},
			chkTermsAgree: { 			required: "You must agree to this websites Terms &amp; Conditions"	},
			txtHomeNumber: { 			required: "Please enter a Home Number",
										notEqual: "Please enter a Home Number",
										maxlength: "Your entered Home Number exceeds the maximum length"	},
			txtMobileNumber: { 			required: "Please enter a Mobile Number",
										notEqual: "Please enter a Mobile Number",
										maxlength: "Your entered Mobile Number exceeds the maximum length"	}
		}
	});
	// Serial Number Explanation
	$("#txtSerialContainer a")
		.live("mouseover", function(){	$("#txtSerialDescription").fadeIn('fast');	})
		.live("mouseout", function(){	$("#txtSerialDescription").fadeOut('fast');	})
		.live("click", function(){	return false;	});
	// Contact Sliding Box
	$('.contact #contactSlideBox').hover(function(){
		$(this).stop().animate({bottom:'0px'},{queue:false,duration:160});
	}, function() {
		$(this).stop().animate({bottom:'-125px'},{queue:false,duration:160});
	});
}
// ---------------------------------------

