 var activeFrame = "homePageFrame";
 var aboutExpanded = false;
 var loadedSSImages = 0;
 var homeSSImages = Array("images/home_ss_1.jpg", "images/home_ss_2.jpg", "images/home_ss_3.jpg");
 Shadowbox.loadSkin('classic', 'shadowbox/src/skin');
 Shadowbox.loadLanguage('en', 'shadowbox/src/lang');
 $(function() {
 	// Home Page Link
	$("#homePageFrameLink").click(function(){
		if (aboutExpanded)
 		{
 			toggleAbout();
 		}
		openTo(200, 83, "homePageFrame");
		$("#homePageSS").cycle("resume");	
	});
	// Portfolio Link
	$("#portfolioFrameLink").click(function(){
		if (aboutExpanded)
 		{
 			toggleAbout();
 		}
		openTo(200, 84, "portfolioFrame");	
	});
	// About link
	$("#aboutFrameLink").click(function(){
		if (!aboutExpanded)
 		{
			openTo(200, 192, "aboutFrame");
			toggleAbout();
 		}
		aboutSelectSection(0);
	});
	// My Story Link
	$("#myStoryFrameLink").click(function(){
		aboutSelectSection(452);
	});
	// Your Story Link
	$("#yourStoryFrameLink").click(function(){
		aboutSelectSection(902);
	});
	// Prices Link
	$("#pricesFrameLink").click(function(){
		aboutSelectSection(1350);
	});
	// Contact Link
	$("#contactFrameLink").click(function(){
		if (aboutExpanded)
		{
			toggleAbout();
		}
		openTo(200, 174, "contactFrame");
	});
	// Contact Form Functionality
	$("#contact_name").focus(function(){
		if ($(this).val() == "" || $(this).val() == "name")
		{
			$(this).val("");
		}
	});
	$("#contact_name").blur(function(){
		if ($(this).val() == "" || $(this).val() == "name")
		{
			$(this).val("name");
		}
	});
	$("#contact_phone").focus(function(){
		if ($(this).val() == "" || $(this).val() == "phone number")
		{
			$(this).val("");
		}
	});
	$("#contact_phone").blur(function(){
		if ($(this).val() == "" || $(this).val() == "phone number")
		{
			$(this).val("phone number");
		}
	});
	$("#contact_email").focus(function(){
		if ($(this).val() == "" || $(this).val() == "email address")
		{
			$(this).val("");
		}
	});
	$("#contact_email").blur(function(){
		if ($(this).val() == "" || $(this).val() == "email address")
		{
			$(this).val("email address");
		}
	});
	$("#contact_message").focus(function(){
		if ($(this).val() == "" || $(this).val() == "message")
		{
			$(this).val("");
		}
	});
	$("#contact_message").blur(function(){
		if ($(this).val() == "" || $(this).val() == "message")
		{
			$(this).val("message");
		}
	});
	// adjust bottom piece to screen hight if needed
	if ($(window).height() > 700)
	{
		var coverHeight = $(window).height() - 700;
		$("#bottomCover").css({
			"height": coverHeight
		});
	}
	 $("#contact_button").click(function(){
	 	if (($("#contact_email").val() == "" || $("#contact_email").val() == "email address")
		&& ($("#contact_phone").val() == "" || $("#contact_phone").val() == "phone number"))
		{
			alert("Please provide either a phone number or email address");
			return false;
		}
		if ($("#contact_name").val() == "" || $("#contact_name").val() == "name")
		{
			alert("Please supply your name");
			return false;
		}
		var dataString = "name="+$("#contact_name").val()+"&email="+$("#contact_email").val()+"&phone="+$("#contact_phone").val()+"&message="+$("#contact_message").val();
		$.ajax({
			type: "POST",
			url: "process.php",
			data: dataString,
			success: function(){
				$("#contactFrame").html("Thank you for your interest. <br>Please call Heather at 702-588-1423<br> if you do not get a response within 2 business days.");
			}
		});
	 });
	 // preload home page ss images
	 for (var i = 0; i < homeSSImages.length; i++)
	 {
	 	var img = new Image();
	 	$(img).load(function(){
	 		loadedSSImages++;
	 		finishImageLoad();
	 	}).attr("src", homeSSImages[i])
	 }
	 //Shadowbox.init();

	 Shadowbox.init({
	 	assetURL: '',
	 	loadingImage: 'images/ajax-loader.gif',
	 	flvPlayer: 'swf/autoviewer.swf',
	 	animate: true,
	 	animateSequence: 'wh',
	 	overlayColor: '#000',
	 	overlayOpacity: 0.45,
	 	overlayBgImage: 'images/overlay.png',
	 	listenOverlay: true,
	 	autoplayMovies: true,
	 	showMovieControls: true,
	 	resizeDuration: 0.35,
	 	fadeDuration: 0.35,
	 	displayNav: true,
	 	continuous: false,
	 	displayCounter: true,
	 	counterType: 'default',
	 	viewportPadding: 20,
	 	handleLgImages: 'resize',
	 	initialHeight: 160,
	 	initialWidth: 320,
	 	enableKeys: true,
	 	keysClose: ['c', 'q', 27],
	 	keysPrev: ['p', 37],
	 	keysNext: ['n', 39],
	 	handleUnsupported: '',
	 	text: {
	 		cancel: 'Cancel',
	 		loading: 'loading',
	 		close: '<span class="shortcut">C</span>lose',
	 		next: '<span class="shortcut">N</span>ext',
	 		prev: '<span class="shortcut">P</span>revious',
	 		errors: {
	 			single: 'You must install the <a href="{0}">{1}</a> browser plugin to view this content.',
	 			shared: 'You must install both the <a href="{0}">{1}</a> and <a href="{2}">{3}</a> browser plugins to view this content.',
	 			either: 'You must install either the <a href="{0}">{1}</a> or the <a href="{2}">{3}</a> browser plugin to view this content.'
	 		}
	 	}
	 });
 });
function finishImageLoad()
{
	if (loadedSSImages == homeSSImages.length)
	{
		for (var i = 0; i < homeSSImages.length; i++)
		{
			$("#homePageSS").append("<img src='"+homeSSImages[i]+"' />");
		}
		$("#loading").fadeOut(500);
		$("#homePageSS").fadeIn(500);
		$("#homePageSS").cycle("scrollLeft");
	}
}
function toggleAbout()
{
	if (aboutExpanded)
	{
		$("#about").animate({
			width: "80px"
		}, 300, "linear" );
		aboutExpanded = false;
	}
	else
	{
		$("#about").animate({
			width: "290px"
		}, 300, "linear" );
		aboutExpanded = true;
	}
}
function openTo(top, bottom, newFrame)
{
	// fade out frame
	$("#"+activeFrame).fadeOut(500);
	// close animation
	$("#pageHeader").animate({
		height: "370px"
	}, 500, "linear" );
	$("#pageFooter").animate({
		height: "370px"
	}, 500, "linear", 
		function(){
			$("#"+newFrame).fadeIn(750);
			$("#pageHeader").animate({
				height: top + "px"
			}, 500, "linear" );
			$("#pageFooter").animate({
				height: bottom + "px"
			}, 500, "linear" );
		}
	 );
	// frame close tasks
	if (activeFrame == "homePageFrame")
	{
		$("#homePageSS").cycle("pause");
	}
	activeFrame = newFrame;
}
function aboutSelectSection(scrollTo) 
{
	$("#aboutContentDivs").animate({scrollTop: scrollTo}, 700);
}
// add images to slideshow 
function onBefore(curr, next, opts) { 
	if (opts.addSlide) // <-- important! 
		while(stack.length) 
			opts.addSlide(stack.pop());  
}; 
