// JavaScript Document

$(document).ready(function(){
    
	//    if ( $('ul.gallery li').length > 0 ) {	$('ul.gallery').jcarousel({scroll: 4}); }
    if ( $('.clb, .html').length > 0 ) {	$('.clb, .html').colorbox(); }
    if ( $('.video').length > 0 ) {	$('.video').colorbox(    {iframe:true, innerWidth:455, innerHeight:345}); }
    if ( $("a[rel='lightbox']").length > 0 ) {	$("a[rel='lightbox']").colorbox(); }
     
// Main navy begin
	$('ul.main_navy > li').hover(function(){
		$(this).children('a').css({'color':'#ffffff', 'background':'url(/netcat_files/images/bg-main-navy-arrow-hover.gif) no-repeat 12px 50%'});
		$(this).css({'background':'url(/netcat_files/images/bg-main-navy-hover.gif) repeat-x'});
		$(this).find('ul').show();
	}, function (){
		$(this).children('a').removeAttr('style');
		$(this).removeAttr('style');
		$(this).find('ul').hide();
		}
	);
	
	$('ul.main_navy > li:has("ul.sub_navy")').hover(function(){
		$(this).append('<div class="hover_arrow"></div>');
	}, function (){
		$('div.hover_arrow').remove();
		}
	);
// Main navy end


// News block begin
	$('.news_block_wrapper:last').css({'border':'none'});
// News block end

// Toggle Links begin
	if ( $('.toggle').length > 0) {
		$('.toggle').click(function() {
			var id = $(this).attr('id').substr(5);
			var trg_id = '#div_' + id;
	
			if (trg_id) $(trg_id).toggle();
		});
	}

// Toggle Links end

// Slider and carousel begin
	if ($('#slider').length > 0) {
	   $('#slider').loopedSlider();
	       loadImgs([
			$("#slider img"),
            $("<img src=\"/netcat_files/images/bg-slideshow.png\" />"),          
			], function() {
			 $(".ld_slides").fadeOut("slow", function () {
             $(".ld_slides").css({visibility: "hidden"});
             $('.slides, .slider_navy_wrapper').hide().css({visibility : "visible"});
             $('.slides, .slider_navy_wrapper').fadeIn("medium");
             });
		});    
       }
	if ($('#bottom_carousel').length > 0) {
			   $('#bottom_carousel').jcarousel({scroll: 2});
       }
// Slider and carousel end

// Teasers begin
	$('.teaser_block').hover(function(){
		$(this).css({'background':'url(/netcat_files/images/bg-teaser-sprite.png) no-repeat -314px 0'});
		$(this).children('div.teaser_img').hide();
		$(this).children('div.teaser_desc').show();
		$(this).children('div.teaser_title').addClass('teaser_title_h');
	}, function (){
		$(this).css({'background':'url(/netcat_files/images/bg-teaser-sprite.png) no-repeat 0 0'});
		$(this).children('div.teaser_title').removeClass('teaser_title_h');
		$(this).children('div.teaser_desc').hide();
		$(this).children('div.teaser_img').show();
	});
	
	$('.teaser_block').click(function(){
		window.location = $(this).find("a").attr("href");
		return false;
	})
// Teasers end

});

// Load IMGs BEGIN
function loadImgs(images, callback) {
	var loaded = {};
	$(images).each(function() {
		if ($(this).length > 0) {
			$(this).each(function() {
				loaded[$(this).attr("src")] = false;
			});
		}
	});
	$(images).each(function() {
		if ($(this).length > 0) {
			$(this).each(function() {
				$(new Image()).load(function() {
					loaded[$(this).attr("src")] = true;
					var l = true;
					$.each(loaded, function(i, n) {
						if (this != true) l = false;
					});
					if (l) callback.call();
				}).attr("src", $(this).attr("src"));
			});
		} else {
			callback.call();
		}
	});
}
// Load IMGs END

function unused_drop(name)
{ if(document.getElementById(name).style.display=='none')
	{document.getElementById(name).style.display='block';}
else
	{document.getElementById(name).style.display='none';}
}
