

function hoverimage() {
		$("a[class^='lightbox']").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[class^='lightbox']").contents("img").hover(function() {
			$(this).stop().animate({"opacity": "0.2"}, 200);
			},function() {
			$(this).stop().animate({"opacity": "1"},200);
	});
}


function sys_toggle() {
	jQuery(".toggle_content").append("<div class='arrow'></div>").hide();

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

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

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", marginTop:15}).slideDown(400, function()
			{
				jQuery(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function()
		{	
			$sublist.stop().slideUp(400, function()
			{	
				jQuery(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});

	//  Menu mouse hovered background
}



jQuery(function(){
	hoverimage();
	k_menu();
	sys_toggle();

	jQuery('.nav li ul li span').css({display:'none'});
	jQuery('.sitemap li span').css({display:'none'});
    jQuery(".portimg, .gallery-item, .postimg, .post-thumb, .imagethumb, .sortable").preloadify({ imagedelay:"500"});
	jQuery("ul.tabs").tabs("> .tab_content", {tabs:'li',effect: 'fade', fadeOutSpeed: -400});
});
