jQuery(document).ready(function()
{
	
	jQuery('.photos #picsRental').innerfade({ 
		speed: 2000, 
		timeout: 3000, 
		type: 'sequence', 
		containerheight: '300px' 
	});
	
	jQuery("#stage").animate({height:"415px"},100,function()
	{
		jQuery(".bodyTabContent").eq(0).fadeIn('slow',function()
		{
	// 		startGallery(0);
		});
	});
	jQuery(".navDivs").eq(0).addClass('tabHighlight');	
	jQuery(".navDivs").click(function()
	{
		
		thisIndex = jQuery(".navDivs").index(this);
		
		showTabAndContent(thisIndex);
	}); 
// 	jQuery('#contact-form input.contact, #contact-form a.contact').click(function (e) {
	jQuery('#contactUs').click(function (e) {
		e.preventDefault();
		// load the contact form using ajax
		jQuery.get("wp-content/contact.php", function(data){
			// create a modal dialog with the data
			jQuery(data).modal({
				closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
				position: ["15%",],
				overlayId: 'contact-overlay',
				containerId: 'contact-container',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
				
			});
		});
	});

	// preload images
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
	jQuery(img).each(function () {
		var i = new Image();
		i.src = 'wp-content/simpleModal/images/' + this;
	});

});

function returnStageElemHeight(id)
{
	arrStageElems = new Array
	(
		["rentals",415],
		["sound",415],
		["lighting",350],
		["video",300],
		["staging",440],
		["links",650]
	);
	// alert("offending loop");
	jQuery(arrStageElems).each(function(i)
	{
		if(arrStageElems[i][0]==id)
		{
			thisReturn = arrStageElems[i][1];
		}
	});
	return thisReturn;
	
}


function showTabAndContent(indx)
{
	
	jQuery(".navDivs").each(function(i)
	{
		if(indx==i)
		{
			jQuery(".navDivs").eq(i).addClass('tabHighlight');
			indexToFadeIn=i;
			switch(i)
			{
				case 0: ctnr = "picsRental"; break;
				case 1: ctnr = "picsSound"; break;
				case 2: ctnr = "picsLighting"; break;
				case 3: ctnr = "picsVideo"; break;
				case 4: ctnr = "picsStaging"; break;
				case 5: ctnr = "picsLinks"; break;
			}
			
			jQuery('#'+ctnr).innerfade({ 
				speed: 2000, 
				timeout: 3000, 
				type: 'sequence', 
				containerheight: '300px' 
			});
			
		} else {
			jQuery(".navDivs").eq(i).removeClass('tabHighlight');
		}
	});
	jQuery(".bodyTabContent").each(function(i)
	{
		thisCSS=jQuery(this).css('display');
		if(thisCSS=='block')
		{
		 	indexToFadeOut = i;
		} 
	});

	if(!indexToFadeOut)
	{
	}

	jQuery(".bodyTabContent").eq(indexToFadeOut).fadeOut('fast',function()
	{
		thisID = jQuery(".bodyTabContent").eq(indexToFadeIn).attr('id');
		// alert("thisID = "+thisID);
		thisHeight = returnStageElemHeight(thisID);
		
		jQuery("#stage").animate({ height:thisHeight+"px"},300,function()
		{
			jQuery(".bodyTabContent").eq(indexToFadeIn).fadeIn(900,function(){});
		});
	});
}