/*
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$.preloadImages('http://www.case.dev/wp-content/gallery/gradina-de-vara-capitol/thumbs/thumbs_ec001.jpg', 'http://www.case.dev/wp-content/gallery/gradina-de-vara-capitol/thumbs/thumbs_ec002.jpg', 'http://www.case.dev/wp-content/gallery/gradina-de-vara-capitol/thumbs/thumbs_ec003.jpg');
*/

$(document).ready(function(){
	mih();
	/* MENU */
	$('li.category').hover(function(){
		$('ul.subcategories').removeClass('curent');
		$(this).addClass('curent');
	},function(){
		$(this).removeClass('curent');
	});
	/* // MENU */


	$('#searchform #s').attr('value','cauta');
	$('#searchform #s').focus(function(){
		if ($(this).attr('value') == 'cauta')
		{
			$(this).attr('value','');
		} else {
		
		}
	});
	$('#searchform #s').blur(function(){
		if ($(this).attr('value') == '')
		{
			$(this).attr('value','cauta');
		} else {
			
		}
	});

	/* GALLERY */
	$('#gallery div.ngg-galleryoverview div.ngg-gallery-thumbnail-box').each(function(i){
		if (i == 0)
		{
			$link = $(this).children('div.ngg-gallery-thumbnail').children('a').attr('href');
			$('p.visual').html('<img src="'+$link+'" alt="" />');
			$('p.visual').fadeIn(1000);
		}
	});



	$('#gallery div.ngg-gallery-thumbnail a').click(function(){
		/*
		$pic = new Image();
		$pic.src = $(this).attr('href');
		$pic_height = $pic.height;
		$pic.onload = function(){
//			$link = $(this).attr('href');
			$('p.visual').fadeOut(500, function(){
					$('p.visual').html($pic);
			});
			$('p.visual').fadeIn(1000).css({'height': $pic_height, 'display': 'block'});
			$pic.onload = function(){}
//			alert($pic_height);
		};
		return false;
		*/
		$link = $(this).attr('href');
		$('p.visual').fadeOut(500, function(){
				$('p.visual').html('<img src="'+$link+'" alt="" />');
		});
		$('p.visual').fadeIn(1000);
		return false;
	});

	$('#gallery').scrollable({ 
		items: '.ngg-galleryoverview',
		next: '#gallery div.next', 
		prev: '#gallery div.prev' 
	});
	/* // GALLERY */

	$('div.content_news div.ngg-gallery-thumbnail a').lightBox();

	$('div.content_news p:contains(pdf)').addClass('pdf');
	$('#entry div.body p:contains(pdf)').addClass('pdf');
});

function mih(){
	$poze = new Array();
	$poza = new Image();
	$poza_height = new Array();
	var $counter = $('div.ngg-galleryoverview div.ngg-gallery-thumbnail-box').length;
	$('div.ngg-galleryoverview div.ngg-gallery-thumbnail-box a').each(function(i){
		$poze[i] = $(this).attr('href');
	});
	for (i=0;i<=6 ;i++ )
	{
		$poza.src = $poze[i];
	}
}