jQuery(document).ready(function(){

/*************************** List Styling ***************************/

jQuery(document).ready(function(){	
	jQuery("ul li:first-child").addClass("li-first");
	jQuery("ul li:last-child").addClass("li-last");		
});


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

jQuery(document).ready(function(){	

	//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:first").filter(':not(:animated)').slideDown();
			});

			//hide submenus on exit
			jQuery(this).mouseleave(function() {
				jQuery(this).find("ul:first").slideUp();
			});
			
		}
	});
	
});


/*************************** 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('H1').css("line-height", "0.8");
jQuery('P').css("line-height", "16px");

jQuery('.circle').hover(
	function() {
		jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0.95);
		jQuery(this).find('.circle-content-image').stop(true,true).fadeTo(800, 1);
		jQuery(this).addClass('circle-active');
		jQuery(this).css("border-width","0px");
	},
	function() {
		jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0);
		jQuery(this).find('.circle-content-image').stop(true,true).fadeTo(800, 0);
		jQuery(this).find('.circle-content-image').css("border-bottom", "0px solid transparent !important");
		jQuery(this).find('.circle-content-text').css("border-bottom", "0px solid transparent !important");
		jQuery(this).removeClass('circle-active');
		jQuery(this).css("border", "0px solid transparent !important");
		
		jQuery(this).children().css("border", "0px solid transparent");
	}
);

jQuery('.circleimg').hover(
	function() {
		jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0.95);
		jQuery(this).addClass('circle-active');
		jQuery(this).css("border-width","0px");
	},
	function() {
		jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0);
		jQuery(this).removeClass('circle-active');		
		jQuery(this).css("border", "0px solid transparent !important");
	}
);

jQuery('.circle-content-image').css({'opacity':'0'});

jQuery("#circle1").hover(
	function() {jQuery(this).stop(true,true).animate({width:"395px",height:"395px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"280px",height:"125px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle2").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"200px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle3").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"250px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle4").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"250px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle5").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"250px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle6").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"200px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle7").hover(
	function() {jQuery(this).stop(true,true).animate({width:"270px",height:"220px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);
jQuery("#circle8").hover(
	function() {jQuery(this).stop(true,true).animate({width:"250px",height:"200px"},500);},
	function() {jQuery(this).stop(true,true).animate({width:"100px",height:"100px"},300);jQuery('.circle-content-text').css("border-bottom", "0px solid transparent");}
);

jQuery('.circle-content-text').css("border", "0px solid transparent");

jQuery('.circle-content-text').mouseout(function() {
	jQuery('.circle-content-text').css("border", "0px solid transparent");
	jQuery('#container-wrapper').trigger('mouseleave');
	jQuery('#container-wrapper').trigger('hover');
});

jQuery('#container-wrapper').hover(function(){
	jQuery('.circle-content-text').css("border", "0px solid transparent");
});

jQuery('#container-wrapper').mouseleave(function() {
	jQuery('.circle-content-text').css("border", "0px solid transparent");
});


/*************************** 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(),
		phone: jQuery('#phone').val(),
		company: jQuery('#company').val(),
		city: jQuery('#city').val(),
		position: jQuery('#position').val(),
		country: jQuery('#country').val(),
		adminmail: jQuery('#adminmail').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
}
