//make HTML5 placeholders work in non supportive browsers
$(document).ready(function(){
  $("input[placeholder]").each(function(){
    if($(this).val()==""){
     // $(this).addClass('hasplaceholder');
      $(this).val($(this).attr("placeholder"));
      $(this).focus(function(){
        if($(this).val()==$(this).attr("placeholder")) $(this).val("");
       // $(this).removeClass('hasplaceholder');
      });
      $(this).blur(function(){
        if($(this).val()==""){
	  // $(this).addClass('hasplaceholder');
           $(this).val($(this).attr("placeholder"));
        }
       });
    }
  });

	$('form').submit(function(evt){
		$('input[placeholder]').each(function(){
			if($(this).attr("placeholder") == $(this).val()) {$(this).val('');}
		});
	});
});
//make HTML5 placeholders work in non supportive browsers

$(document).ready(function() {
    $('.slider').cycle({
		fx: 'scrollHorz',
	    next:   	'#next, .next', 
	    prev:   	'#prev, .prev',
	    timeout: 0
	});
	
	$('.slider2').cycle({
		fx: 'scrollHorz',
	    next:   	'#next, .next', 
	    prev:   	'#prev, .prev',
	    timeout: 5000,
	    pause: 		1,
	    after:		onAfter
	});
	
	
	
	$('.arrows').css("opacity", 0.5);
	
	$(".arrows").hover(function(){
	      $(this).stop().animate({"opacity": "1"}, 100);
	  }, function () {      
	      $(this).stop().animate({"opacity": "0.5"}, 100);
	  });
	  
	  $(".imgwrapper").hover(function(){
	      $(this).stop().animate({"height": "133px"}, 350);
	  }, function () {      
	      $(this).stop().animate({"height": "85px"}, 350);
	  });
	  
	  $(".menushow").hover(function(){
	      $('#workallproj').slideDown(350);
	      $('#currentprojecttitle').fadeOut('fast');
	  }, function () {      
	      $('#workallproj').slideUp(350);
	      $('#currentprojecttitle').fadeIn('fast');
	  });
	  
	$("#openworkdiv").click(function(){  
		jQuery.history.load('work'); 
		  $("header").addClass("inv");
	      $(".floatycontent").hide();
	      $("#workdiv").fadeIn();
	      $("#tadiv").hide();
	      $("#prev").fadeOut();
	      $("#next").fadeOut();
	}); 
	
	$("#openlovediv").click(function(){  
		jQuery.history.load('love'); 
		  $("header").addClass("inv"); 
		  $(".floatycontent").hide();
	      $("#lovediv").fadeIn();
	      $("#tadiv").hide();
	      $("#prev").fadeOut();
	      $("#next").fadeOut();
	}); 
	
	$("#opencontactdiv").click(function(){  
	jQuery.history.load('contact'); 
		  $("header").addClass("inv"); 
		  $(".floatycontent").hide();
	      $("#contactdiv").fadeIn();
	      $("#tadiv").hide();
	      $("#prev").fadeOut();
	      $("#next").fadeOut();
	}); 
	
	$("#openmoneydiv").click(function(){ 
	jQuery.history.load('money');  
		  $("header").addClass("inv"); 
		  $(".floatycontent").hide();
	      $("#moneydiv").fadeIn();
	      $("#tadiv").hide();
	      $("#prev").fadeOut();
	      $("#next").fadeOut();
	});  
	
	$(".close").click(function(){   
		  $("header").removeClass("inv"); 
	      $(".floatycontent").fadeOut();
	      $("#prev").fadeIn();
	      $("#next").fadeIn();
	      $("header").animate({"opacity": "1"}, 1000);
	});  
	
	$("header").hover(function(){
         $("header").stop().animate({"opacity": "1"}, 400);
     }, function () {      
         $('div.floatycontent:visible').length == 0 || $("header").stop().animate({"opacity": "0.4"}, 1000);
     });
     
     
     $.history.init(function(hash){
	       if(hash != "") {
	       // Pretend we're clicking on the link to the modal box in the hash.
	       $('#open'+hash+'div').click();
	       }
	   },
	   { unescape: ",/" });
	 
	
});

function onAfter(curr,next,opts) {
	var caption = (opts.currSlide + 1) + '/' + opts.slideCount;
	$('#caption').html(caption);
}

$(document).ready(function() {
	$(".validateform").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			email2: {
				required: true,
				equalTo: "#email"
			}
		},
		messages: {
			name: "Please enter your name",
			email: "Please enter a valid email address",
			email2: {
				required: "Please enter a valid email address",
				equalTo: "Email addresses do not match"
			}
		}
	});
});



