var thePage = 'dunno';


$(document).ready(function(){
	/* The following code is executed once the DOM is loaded */
	
	$(".pnl-all").css('display','none');
	
	$(".btn-home").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-aboutus").click(function(){
			$(".pnl-all").slideUp();
			$("#nav li a").removeClass("active");
			$("#aboutuspanel").slideToggle("slow");
			$(this).toggleClass("active"); return false;
	});
	
	$(".btn-prices").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#pricespanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-firsttime").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#firsttimepanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-faq").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#faqpanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-gallery").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#gallerypanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-aftercare").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#aftercarepanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-findus").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#finduspanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	$(".btn-contact").click(function(){
		$(".pnl-all").slideUp();
		$("#nav li a").removeClass("active");
		$("#contactpanel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	 

	 
		 $('.homeimagebluff').each(
			 function( intIndex ){
				
		
		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
		
		var elem = $(this);
		
		// data('flipped') is a flag we set when we flip the element:
		
		if(elem.data('flipped'))
		{
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:
			
			elem.revertFlip();
			
			// Unsetting the flag:
			elem.data('flipped',false)
		}
		else if($("#thepage").val() != 'contact')
		{
			// Using the flip method defined by the plugin:
			setTimeout(function(){
				elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					
					elem.html(elem.siblings('.homeimgflip').html());
				}
			});
			},100*intIndex);
			
			// Setting the flag:
			elem.data('flipped',true);
		}else if($("#thepage").val() == 'contact'){
				elem.flip({
				direction:'lr',
				speed: 1,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					
					elem.html(elem.siblings('.homeimgflip').html());
				}
			});
			
			}
	});
	

	
	//--------------------------------------------------------------------------------------
	
	$('.homeimagebluff').bind("click",function(){
		
		// $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):
		
		var elem = $(this);
		
		// data('flipped') is a flag we set when we flip the element:
		
		if(elem.data('flipped'))
		{
			// If the element has already been flipped, use the revertFlip method
			// defined by the plug-in to revert to the default state automatically:
			
			elem.revertFlip();
			elem.css('height','217px');
			elem.css('width','217px');
			elem.css('color','#666');
			elem.css('border','1px solid #333');
			
			// Unsetting the flag:
			elem.data('flipped',false)
		}
		else
		{
			// Using the flip method defined by the plugin:
			
			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					// Insert the contents of the .sponsorData div (hidden from view with display:none)
					// into the clicked .sponsorFlip div before the flipping animation starts:
					
					elem.html(elem.siblings('.homeimgflip').html());
				}
			});
			
			elem.css('height','219px');
			elem.css('width','219px');
			elem.css('border','1px solid #111');
			
			// Setting the flag:
			elem.data('flipped',true);
		}
	});
	
	
	
	$("a.fancyboximg").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});


});
