//pretty photo

		$(document).ready(function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({
				animation_speed: 'normal', /* fast/slow/normal */
				slideshow: 5000, /* false OR interval time in ms */
				autoplay_slideshow: false, /* true/false */
				opacity: 0.80, /* Value between 0 and 1 */
				show_title: true, /* true/false */
				allow_resize: true, /* Resize the photos bigger than viewport. true/false */
				default_width: 500,
				default_height: 344,
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
				horizontal_padding: 20, /* The padding on each side of the picture */
				hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
				wmode: 'opaque', /* Set the flash wmode attribute */				modal: false, /* If set to true, only the close button will close the window */
				social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' /* html or false to disable */
			});
		});
	

//image effects 
	$(document).ready(function(){
			var image_e= $("img.opaco");
			image_e.mouseover(function(){$(this).stop().animate({ opacity:1
					}, 400);
			}).mouseout(function(){
				image_e.stop().animate({ 
					opacity:0.5
					}, 400 );
			});
	});

	
//img preload
$(function () {
			$('.loadpie').hide();//hide all the images on the page
		});
		
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
		});

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




//preloading 
$(function () {
	//$('.preload').hide();//hide all the images on the page
	$('.play,.magnifier').css({opacity:0});
	$('.preload').css({opacity:0});
	$('.preload').addClass("animated");
	$('.play,.magnifier').addClass("animated_icon");
});


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

});

function doThis() {
	var images = $('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(cint);//When it reaches the last image the loop ends
	}
	$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
	$('.animated_icon').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).removeClass("animated");
	$('.animated_icon').eq(0).removeClass("animated_icon");
	i++;//add 1 to the count
}



//SHOW THE LOADER AND HIDE BACKGROUND IMAGE UNTIL IT IS LOADED
$('#bg img').css('display', 'none');
$('body').append('<span id="body_loader"></span>');	
$('#body_loader').fadeIn();


//100% MAIN DIV HEIGHT HACK
var winHeight = $(window).height();
var mainHeight = $('#main').height();

if(winHeight > mainHeight){
$('#main').addClass('fullheight');	
}
else
{$('#main').addClass('expandheight');}

	//100% main div height hack - apply on window resize
	$(window).resize(function() {	
		if(winHeight > mainHeight){
			$('#main').addClass('fullheight');
		}
		else
		{$('#main').addClass('expandheight');}	
	});
	


//RANDOM IMAGE ON PAGE LOAD 	
$.randomImage = {
	defaults: {
		
		//you can change these defaults to your own preferences.
		path: 'images/', //change this to the path of your images
		myImages: ['background1.jpg', 'background2.jpg', 'background3.jpg', 'background4.jpg', 'background5.jpg' ] //put image names in this bracket. 
		
	}			
}

$.fn.extend({
		randomImage:function(config) {	
			var config = $.extend({}, $.randomImage.defaults, config); 
			 return this.each(function() {		
					var imageNames = config.myImages;	
					//get size of array, randomize a number from this
					// use this number as the array index
					var imageNamesSize = imageNames.length;
					var lotteryNumber = Math.floor(Math.random()*imageNamesSize);
					var winnerImage = imageNames[lotteryNumber];
					var fullPath = config.path + winnerImage;
					//put this image into DOM at class of randomImage
					// alt tag will be image filename.
					$(this).attr( {
									src: fullPath,
									alt: winnerImage
								});	
			});	
		}
});

	
//run the random script
$('.random').randomImage();

//random image script ends here


//WAIT UNTIL CONTENT IS LOADED
$(window).load(function() {
	 
	//hide loader
	$('#body_loader').hide().remove();
	
	//append grid if not on the home page
	if (!$('body').hasClass('body_home')) {	
	$('.grid_overlay, #bg').fadeTo('fast', .8).append('<div class="grid"></div>');
	}
	
	//fade in the image
	$('#bg img').fadeIn('normal');
	   	
});

//Effetcs
$(document).ready(function(){
	//$('.page-content').hide()
	
 $("#nav li a").hover(function() {
               $(this).stop().animate({ marginLeft: "15px"}, 200);
               },function() {
               $(this).stop().animate({ marginLeft: "0" }, 200);
               });
 });

$(window).bind("load", function() {

$('#slogan').delay(2000).fadeIn(1000);

$('.page-content').delay(1500).fadeIn(1000);

});


