var activateHomeSlides = false;

$(window).load(function () {
	//FIRST PAGE SLIDES
	if (activateHomeSlides)
	{	
		$('#slider').css("display","block");
		$('#sliderpreloader').css("display","none");
		$('#slider #slidetitle1').css("display","block");
		$('#slider #slidetitle1').css("opacity","0.0");
		$('#slider #slidetitle1').animate({opacity: '1.0'},300);
					
		$('#slider').nivoSlider({
			pauseTime:homeSlidesTime,
			directionNav:false,
			captionOpacity:0.7,
			beforeChange: function(){ $(".slidetitle").animate({opacity: '0', top: '-17px'},400); },
			afterChange: function(){ $(".slidetitle").css("display","block"); $(".slidetitle").animate({opacity: '1.0', top: '0px'},300); }
		});
	}
});

// jQuery Document Ready
$(function(){
	//preload images from css
	$.preloadCssImages();
	
	//main menu display
	//$('.mainmenu').css("display","block");
			
	$('form textarea').css("resize","none");
	
	//MAIN MENU FIX FOR PORTFOLIO PAGES
	var menuElement = $(".mainmenu .current-menu-item").parent().parent();
	while (menuElement.attr("class") == "menu-item")
	{
		var newClass = menuElement.attr("class")+" current-menu-parent" ;
		menuElement.attr("class",newClass);
		menuElement = menuElement.parent().parent();
	}
	
	//MENU EFFECTS
	$(".mainmenu ul li").hover(
		
		function(){ 
			//adjust submenus width
			var  menuWidth = $(this).children("ul").width();
			$(this).children("ul").css("width",menuWidth);
			$(this).children("ul").find("ul").css('left', menuWidth );	
			
			//slide down button
			if (!($(this).attr("class").indexOf('current') != -1) && (!($(this).parent().attr("class")=='children') && !($(this).parent().attr("class")=='sub-menu')) )
			{
				$(this).children("a").animate({marginTop: '7px'},80,function() {
																	$(this).find("span.leftcorner").attr('class','leftcornerH'); 
																	$(this).find("span.middle").attr('class','middleH'); 
																	$(this).find("span.rightcorner").attr('class','rightcornerH'); 
																}
				);//animate
			}
			//open submenu if any
			$(this).children("ul").css("display","block");
			$(this).children("ul").css("opacity","0.0");
			$(this).children("ul").animate({
				opacity: 1.0,
    			top: '+=10'
			},200); 			
		},
		function(){
			//slide up button
			if (!($(this).attr("class").indexOf('current') != -1) && (!($(this).parent().attr("class")=='children') && !($(this).parent().attr("class")=='sub-menu')) )
			{
				$(this).find("a span.leftcornerH").attr('class','leftcorner');
				$(this).find("a span.middleH").attr('class','middle');
				$(this).find("a span.rightcornerH").attr('class','rightcorner');
				$(this).children("a").animate({marginTop: '0px'},50,function() {
																	$(this).find("span.leftcornerH").attr('class','leftcorner'); 
																	$(this).find("span.middleH").attr('class','middle'); 
																	$(this).find("span.rightcornerH").attr('class','rightcorner'); 
																});
			}
			//close submenu if any
			$(this).children("ul").animate({
				opacity: 0.0,
    			top: '-=10'
			},100,function() { $(this).css("display","none");} ); 			
		}
	);
	
	//POST THUMBNAIL EFFECT
	$(".post-thumbnail img").css("opacity","1.0");
	$(".post-thumbnail img").hover(
		function(){ 
			$(this).animate({opacity: '0.8'},250);
		},
		function(){
			$(this).animate({opacity: '1.0'},150);
		}
	);
	
	
	//PRETTY PHOTO ENABLING AND CUSTOM EFFECT
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$("a[rel^='prettyPhoto']").attr('class','prettyPhotoBox'); 
	$("a[rel^='prettyPhoto']").append('<div class="prettyPhotoOverlay"></div>');
	$(".prettyPhotoBox").css('width',function(index) { var elem = $(".prettyPhotoBox:eq("+index+")"); return elem.children().width(); });
	$(".prettyPhotoBox img.aligncenter").parent().css('margin','0 auto 0');
	$(".prettyPhotoBox img.alignleft").parent().css('float','left');
	$(".prettyPhotoBox img.alignleft").parent().css('marginRight','25px');
	$(".prettyPhotoBox img.alignright").parent().css('float','right');
	$(".prettyPhotoBox img.alignright").parent().css('marginLeft','15px');
	
	$("a[rel^='prettyPhoto']").hover(
		function(){ 
			$(this).find("div.prettyPhotoOverlay").css("opacity","0.0");
			$(this).find("div.prettyPhotoOverlay").css("display","block");
			$(this).find("div.prettyPhotoOverlay").animate({opacity: '0.8'},250);
		},
		function(){
			$(this).find("div.prettyPhotoOverlay").animate({opacity: '0.0'},150,function(){$(this).find("div.prettyPhotoOverlay").css("display","none");});
		}
	);
	
});


function openSocialBookmarks(){
	if ($("#socialicons").css('display')=='none')
	{
		$("#socialicons").css('display','block');
		$("#socialicons").css('left','120px');
		$("#socialicons").css('opacity','0');
		$("#socialicons").animate({left: '150', opacity: 1.0},300);
	
	}
	else
	{
		$("#socialicons").animate({left: '120', opacity: 0.0},200,function() {
																	$("#socialicons").css('display','none');														
																});
	}

}


function changeRelatedToRecent(){
	$("#relatedtitle").html('<a href="javascript:popularandrelatedSwap(0)">Recent Posts</a>');
}


// end jquery

