jQuery(function($){
    /*jQuery(".portfolio_item, .postimg, .post, #sidebar").preloadify({ imagedelay:500 });*/
    jQuery(".portfolio_item, .postimg, .post").preloadify({ imagedelay:500 });
});

$(document).ready(function(){
	jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
	jQuery("ul.tabs").tabs("> .tab_content");
});

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").each(function() {	
		var $image = $(this).contents("img");
			$hoverclass = 'hover_video';

	if($(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) 
	$hoverclass = 'hover_image';
		
	if ($image.length > 0)
	{	
		var $hoverbg = $("<span class='"+$hoverclass+"'></span>").appendTo($(this));
		
			$(this).bind('mouseenter', function(){
			$height = $image.height();
			$width = $image.width();
			$pos =  $image.position();		
			$hoverbg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
		});
	}

});	

$("a[rel^='prettyPhoto']").contents("img").hover(function() {
		$(this).stop().animate({"opacity": "0.3"}, 200);
		$("span[class^=hover]").stop().animate({"opacity": "1"});
		},function() {
		$(this).stop().animate({"opacity": "1"},200);
		$("span[class^=hover]").stop().animate({"opacity": "0"});
	});
});



function sys_toggle() {
	jQuery(".toggle_content").hide(); 

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

	jQuery("h4.toggle").click(function(){
		jQuery(this).next(".toggle_content").slideToggle();
	});
}

jQuery(function(){
	k_menu();
	sys_toggle();
	$('ul.sf-menu ul li span').css({display:'none'});
	$('.sub_nav li span, .footer-menu li span, .footer-menu ul li ul').css({display:'none'});
	$('.sitemap li span').css({display:'none'});
});

function k_menu()
{
	// k_menu controlls the dropdown menus and improves them with javascript
	
	jQuery(".nav a").removeAttr('title');
	jQuery(" .nav ul ").css({display: "none"}); // Opera Fix

	
	//smooth drop downs
	jQuery(".nav li").each(function()
	{	
		
		var $sublist = jQuery(this).find('ul:first');
		
		jQuery(this).hover(function()
		{	
			$sublist.stop().css({overflow:"hidden", height:"auto", display:"none", paddingTop:30}).slideDown(400, function()
			{
				jQuery(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function()
		{	
			$sublist.stop().slideUp(400, function()
			{	
				jQuery(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});
}

jQuery(document).ready(function() {

		jQuery('#slideshow').css("display", "block");		
		jQuery('.slideshow').cycle({
			fx: 'scrollLeft',
			timeout: 6000,
			pager: '#nav',
			speed: 500,
			pagerEvent: 'click',
   			pauseOnPagerHover: true,
			cleartypeNoBg: true,
			pause: 1 });
		jQuery('.slideshow').css("display", "block");
		jQuery('#nav').css("display", "block");
		// jQuery('.slideshow').cycle('pause'); //remove 2 slashes in beginning of line to remove auto rotate slides.

  });
