jQuery(document).ready(function(){

/*************************** Menu ***************************/


(function(jQuery){

	//cache nav
	var nav = jQuery("#nav");

	//add indicators and hovers to submenu parents
	nav.find("li").each(function() {
		Cufon.replace('#nav', {hover: true});
		if (jQuery(this).find("ul").length > 0) {

			jQuery("<span>").html("<img src='"+rootFolder+"/images/nav_arrow.png' alt=''/>").appendTo(jQuery(this).children(":first"));

			//show subnav on hover
			jQuery(this).mouseenter(function() {
				jQuery(this).find("ul").stop(true, true).slideDown();
			});

			//hide submenus on exit
			jQuery(this).mouseleave(function() {
				jQuery(this).find("ul").stop(true, true).slideUp();
			});
			
		}
	});
})(jQuery);


/*************************** Tool Tips ***************************/


jQuery(document).ready(function() { 
    jQuery("#social-icons img[title]").tooltip({
        tip: '.social-tooltip', 
        effect: 'slide', 
        position: "bottom center",         
        offset: [25, 20] 
    });
    jQuery("#similar-posts img[title]").tooltip({
        tip: '.similar-tooltip', 
        effect: 'slide', 
        position: "bottom left",         
        offset: [20, 340] 
    });
});


/*************************** Image Hover Effects ***************************/


jQuery('.circle-content-text').css({'opacity':'0'});
jQuery('.circle').hover(
	function() {
		jQuery(this).find('.circle-content-text').stop().fadeTo(500, 0.95);
		jQuery(this).addClass('circle-active');
		jQuery(this).css("border-width","0");
	},
	function() {
		jQuery(this).find('.circle-content-text').stop().fadeTo(500, 0);
		jQuery(this).removeClass('circle-active');		
		jQuery(this).css("border-width","2px");		
	}
);

jQuery('.circle-content-image').css({'opacity':'0'});
jQuery('.circle').hover(
	function() {
		jQuery(this).find('.circle-content-image').stop().fadeTo(800, 1);
		jQuery(this).addClass('circle-active');
		jQuery(this).css("border-width","0");
	},
	function() {
		jQuery(this).find('.circle-content-image').stop().fadeTo(800, 0);
		jQuery(this).removeClass('circle-active');		
		jQuery(this).css("border-width","2px");		
	}
);


jQuery("#circle1").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},300);}	
);
jQuery("#circle2,#circle17").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"126px",height:"126px"},300);}	
);
jQuery("#circle3,#circle16").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"62px",height:"62px"},300);}	
);
jQuery("#circle4,#circle15").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"79px",height:"79px"},300);}	
);
jQuery("#circle5,#circle14").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"88px",height:"88px"},300);}	
);
jQuery("#circle6,#circle13").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"70px",height:"70px"},300);}	
);
jQuery("#circle7,#circle12").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"56px",height:"56px"},300);}	
);
jQuery("#circle8,#circle11").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"84px",height:"84px"},300);}	
);
jQuery("#circle9,#circle10").hover(
	function() {jQuery(this).stop().animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop().animate({width:"42px",height:"42px"},300);}	
);


/*************************** Lightbox ***************************/


jQuery("a[rel^='prettyPhoto']").prettyPhoto({
	theme: 'light_square',
	animationSpeed: 'fast'
});


/*************************** Toggle Content ***************************/


jQuery(".toggle-box").hide(); 

jQuery(".toggle").toggle(function(){
	jQuery(this).addClass("toggle-active");
	}, function () {
	jQuery(this).removeClass("toggle-active");
});

jQuery(".toggle").click(function(){
	jQuery(this).next(".toggle-box").slideToggle();
});


/*************************** Contact Form ***************************/


jQuery('#contactform').submit(function(){

	var action = jQuery(this).attr('action');
	
	jQuery("#message").slideUp(750,function() {
	jQuery('#message').hide();
	
	jQuery('#submit')
		.after('<div class="loader"> </div>')
		.attr('disabled','disabled');
	
	jQuery.post(action, { 
		name: jQuery('#name').val(),
		email: jQuery('#email').val(),
		subject: jQuery('#subject').val(),
		comment_box: jQuery('#comment_box').val(),
		verify: jQuery('#verify').val()
	},
		function(data){
			document.getElementById('message').innerHTML = data;
			jQuery('#message').slideDown('slow');
			jQuery('#contactform div.loader').fadeOut('slow',function(){jQuery(this).remove()});
			jQuery('#contactform #submit').attr('disabled',''); 
			if(data.match('success') != null) jQuery('#contactform').slideUp('slow');
			
		}
	);
	
	});
	
	return false; 

});

});

/*************************** Image Preloader ***************************/

jQuery(function () {
	jQuery('.preload').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
jQuery(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("doThis(i)",10);//500 is the fade in speed in milliseconds
});

function doThis() {
	var images = jQuery('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(int);//When it reaches the last image the loop ends
	}
	jQuery('.preload:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
	i++;//add 1 to the count
}
