// Innitiate Main Menu
j=jQuery.noConflict();
j(document).ready(function() { 
	j('ul#menu').superfish(); 
}); 

//Homepage boxes
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = j(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
j(document).ready(function() {
	equalHeight(j(".equalize"));
	equalHeight(j(".equalize2"));
});


//News Scroller (Widget)
j(document).ready(function() {
 
 	j('.news-scroller').cycle({ 
	    fx: 'scrollVert',
		speed: 1000,
		rev: true,
		timeout: 4000,
		next: '.news-next', 
	    prev: '.news-previous'
	 });      
 
});


// Social Drop Down Panel 
j(document).ready(function() {
	j(".btn-slide").click( function() {
		if (j("#openCloseIdentifier").is(":hidden")) {
			j("#social").animate( {top: "0"} , 650 );
			j(this).addClass("active");
			j("#openCloseIdentifier").show();
		} else {
			j("#social").animate( {top: "-46px"} , 650 );
			j(this).removeClass("active");
			j("#openCloseIdentifier").hide();
		}
	});  
});


//Innititate Pretty Photo
j(document).ready(function(){
	j("a[rel^='lightbox']").prettyPhoto({theme:'light_rounded'});
});


//Contact Form
j(document).ready(function() {

	//Define URL to PHP mail file
	url = j("meta[name=template_url]").attr('content') + "/sendmail.php";
	
	//Activate jQuery form validation
	j("#jaybich-contact").validate({
	
		submitHandler: function() {
		
			//Define data string
			var datastring = j("#jaybich-contact").serialize();
			
			//Submit form
			j.ajax({
				type: "POST",
				url: url,
				data: datastring,
				success: function(){
					j('#jaybich-contact').slideUp();
					j('#sent').fadeIn();
				}
			});
		}
	
	});
			
});

//Comments Form
j(document).ready(function() {
	
	//Activate jQuery form validation
	j(".comments-form").validate();
			
});

//Portfolio thumbnail
j(document).ready(function(){

	j('.portfolio-box a').hover(function() {
		
		//Show darkenned hover over thumbnail image
		j(this).find('img').stop(true, true).animate({opacity:0.5},400);

	}, function() {
		
		//Hide darkenned hover over thumbnail image
		j(this).find('img').stop(true, true).animate({opacity:1},400);
			
	});

});

//Portfolio thumbnail
j(document).ready(function(){

	j('.portfolio-image a').hover(function() {
		
		//Show darkenned hover over thumbnail image
		j(this).find('img').stop(true, true).animate({opacity:0.5},400);

	}, function() {
		
		//Hide darkenned hover over thumbnail image
		j(this).find('img').stop(true, true).animate({opacity:1},400);
			
	});

});



//Cufon text
Cufon.replace('h2, h3');




