function formatText(index, panel) {
	return index + "";
}

$(document).ready( function() { 

// anythingSlider =================================================================================== /
	$('#slideshow').show();
	$('#slideshowAlternate').hide();
	
	$('#slideshow').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		delay: 6500,                    // How long between slide transitions in AutoPlay mode
		animationTime: 500,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Start",             // Start text
		stopText: "Stop",               // Stop text
		navigationFormatter: null       // Details at the top of the file on this use (advanced use)
	});
	
	$("#slide-jump").click(function(){
    	$('.anythingSlider').anythingSlider(5);
    });

// primary nav - animate =================================================================================== /

// blend - hovers
	if ($.browser.msie && !($.browser.version.substr(0,1) < 8) || !($.browser.msie)){ 
		$('#header h1 a.logo, ul.primaryNav li a.home, ul.primaryNav li a.work, ul.primaryNav li a.contact').blend();
	};
	
// go to home		
		$("a.home").click(function(){
			$("html, body").animate({scrollTop:0}, "slow"); 
			return( false );
		}); 
		
// go to portfolio		
		$("a.work").click(function(){
			$("html, body").animate({scrollTop:810}, "slow"); 
			return( false );
		}); 
		
// go to contact form
		$("a.contact").click(function(){
			$("html, body").animate({scrollTop:250}, "slow"); 
			$("#content .arrow, #sidebar img").fadeIn().delay(2000).fadeOut(700);
			$("form#contactForm label").css({color: "#FFFFFF"});
			return( false );
		}); 
// open in new window
		$("a.newWindow").attr("target", "_blank"); 

// clickable links - portfolio =================================================================================== /

	/*$("ul.portfolio li").find("p").wrapInner(
		"<a href=" + $(this).find("a.zoom").attr("href") + " alt=" + $(this).find("a.zoom").attr("alt") + " class= \"zoomText\"></a>"
	);*/
	
	//var altText = $("ul.portfolio li").each(function() {$(this).find("p").text()});
	//alert (altText);return false;
	
	$("ul.portfolio li p").each(function() {
		$(this).wrapInner(
			"<a href=" + $(this).parent().find("a.zoom").attr("href") + " class= \"zoomText\"></a>"
		) 
	});

// portfolio listing hovers
	$('ul.portfolio li a.zoom').append('<span><img class=\"overlay\" src=\"image/overlay.png\" alt=\"\" /></span>');
					  
	$('ul.portfolio li').hover(
		function() {
			$(this).addClass('hover').find('span').fadeOut('fast');
			
		},
		function() {
			$(this).removeClass('hover').find('span').fadeIn('slow');
		}
	);

// fancybox popups
	$("a.zoom, a.zoomText").fancybox({
				'speedIn'			:	500,
				'zoomSpeedOut'		:	200,
				'overlayOpacity'	:	0.7,
				'overlayColor'		:	'#000',
				'transitionIn'		:	'elastic',
				'transitionOut'		:	'elastic',
				'easingIn'			:	'swing',
				'easingOut'			:	'swing',
				'padding'			:	0,
	});	
	
// contact form - styling =================================================================================== /
	$('form#contactForm input#name, form#contactForm input#email, form#contactForm input#phone').focus(function() {
		$(this).css({background: '#FFFFFF', border: '2px solid #00C6FF', width: '256px', height: '18px'});
		}
	);
	$('form#contactForm input#name, form#contactForm input#email, form#contactForm input#phone').blur(function() {
		$(this).css({background: '#E6E6E6', border: '1px solid #999999', width: '258px', height: '20px'});
		}
	); 
	
	$('form#contactForm textarea').focus(function() {
		$(this).css({background: '#FFFFFF', border: '2px solid #00C6FF', width: '256px', height: '78px'});
		}
	);
	$('form#contactForm textarea').blur(function() {
		$(this).css({background: '#E6E6E6', border: '1px solid #999999', width: '258px', height: '80px'});
		}
	); 
	 
// contact form - behaviour and validation
	$('.error').hide();
		$(".button").click(function() {
		  // validate and process form here
		  $('.error').hide();
		  var name = $("input#name").val();
			if (name == "") {
			$("label#name_error").show();
			$("input#name").focus();
			return false;
		  }
			var email = $("input#email").val();
			if (email == "") {
			$("label#email_error").show();
			$("input#email").focus();
			return false;
		  }
			var phone = $("input#phone").val();
			if (phone == "") {
			$("label#phone_error").show();
			$("input#phone").focus();
			return false;
		  }
		  
		  	var comments = $("textarea#comments").val();
		  
		    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&comments=' + comments;
  			//alert (dataString);return false;
  			$.ajax({
				type: "POST",
				url: "FormToEmail.php",
				data: dataString,
				success: function() {
					$('form#contactForm').fadeOut();
					$('.sidebarWidget').html("<div id='message'></div>");
					$('#message').html("<h3>Contact Form Submitted!</h3>")
					.append("<p>I'll be in touch soon.</p><p>Thank you!</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message')
					});
    			}
			});
			return false;
		  
		});
		
}); // end DOC ready

Cufon.set("selector", jQuery);
Cufon.replace("#slideshow h2, #sidebar h2", {textShadow: "1px 1px 2px #000", separate: "none", hover: true });
Cufon.replace("#content h2, h2.work, #sidebar #message h3, #portfolioHeader h1", { fontFamily :"Museo 300", separate: "none", hover: true });
