/************** Proizvodstvo ******************/
	/*function proizvodstvoImages(active_img,next_img,speed,title,panel){
			panel.stop(true).animate({"height" : 0}, 200);
			title.stop(true,true).fadeOut(100);
			next_img.css({"display" : "block", "opacity" : "1"});
			active_img.stop(true).animate({ "opacity" : "0" }, speed, function(){
				active_img.removeClass('active');
				next_img.addClass('active');
				panel.stop(true).animate({"height" : "60px"}, 200);
				title.stop(true,true).fadeIn(300);
				title.text(next_img.attr('alt'));
			});
	}*/
/**************end Proizvodstvo ******************/

	function changeOnClick(elm){
		var active = $('#active');
		if(active){
			active.removeAttr('id');
		}	
		$(elm).attr("id","active");
	}
	
	function changeIndexOnClick(elm){
		var active = $('#active_Index');
		if(active){
			active.removeAttr('id');
		}	
		$(elm).attr("id","active_Index");
	}

$(function(){

/*****Panels*****/
/*	$("div.advice, div.promo, div.media").mouseenter(function(){
		$(this).removeClass("inactive_panel");
		$(this).addClass("active_panel");
	});
	$("div.advice, div.promo, div.media").mouseleave(function(){
		$(this).removeClass("active_panel");
		$(this).addClass("inactive_panel");
	});
*/
	$(".controler").click(function(){
		if ($(this).parent("div").position().top == 0){
			$(this).css("background-position","-18px 0").mouseover(function(){
				$(this).css("background-position","-18px -18px");
				}).mouseout(function(){
				$(this).css("background-position","-18px 0");
			});
			$(this).parent("div").animate({"top" : "87px"}, 400);
		}else{
			$(this).css("background-position","0 0").mouseover(function(){
				$(this).css("background-position","0 -18px");
				}).mouseout(function(){
				$(this).css("background-position","0 0");
			});
			$(this).parent("div").animate({"top" : "0px"}, 400);
			}
		}
	);
/*****end Panels*****/

/*****Pictures Change*****/
	function changeImages(active_img,active_button,next_img,next_button,speed){
			next_img.css({"display" : "block", "opacity" : "1"});
			active_img.animate({ "opacity" : "0" }, speed, function(){
				active_img.removeClass('active');
				active_button.removeClass('active');
				next_img.addClass('active');
				next_button.addClass('active');
			});
	}
	
	function slideShow() {
		changeImages(
		$('div.images .active'), 
		$('div.navigation-img .active'), 
		($('div.images .active').next().length > 0) ? $('div.images .active').next() : $('div.images img:first'), 
		($('div.navigation-img .active').next().length > 0) ? $('div.navigation-img .active').next() : $('div.navigation-img a:first'),
		2000
		);
	}
	
	interval = setInterval(function(){
		slideShow()
	}, 6000);
	
	
	$('div.navigation-img a').each(function(i,el){
		$(el).click(function(){ 
			if ( !$($('div.images img').get(i)).attr("class") ) {
				changeImages(
				$('div.images .active'), 
				$('div.navigation-img .active'), 
				$($('div.images img').get(i)), 
				$(el),
				100
				);
			}
			return false;
		});
	});
/*****end Pictures Change*****/

/*******Light Box******/
	function container(target, link){
		if(target == "video"){
			$('span#title').text(link.attr('title'));
			$('#lightboxContainer').html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="430" height="315"><param name="movie" value="'+link.attr('href')+'" /><param name="quality" value="high"/><embed src="'+link.attr('href')+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="430" height="315"></embed></object>');
			$("#outerContainer").css({"height" : "355px","width" : "440px"});
			$("#btnClose").animate({"width" : "19px"}, 400);
		}else if(target == "see_map"){
			$('#lightboxContainer').load(link.attr('href'));
			$("#outerContainer").css({"height" : "405px","width" : "440px"});
			$("#lightboxContainer").css({"height" : "350px","width" : "425px"});
			$("#btnClose").animate({"width" : "19px"}, 400);
		}else{
			$('span#title').text(link.attr('title'));
			$('#lightboxContainer').html('<img src="'+link.attr('href')+'" alt="'+link.attr('href')+'" width="430" height="315" />');
			$("#outerContainer").animate({"height" : "355px","width" : "440px"}, 600, function(){
				$("#btnClose").animate({"width" : "19px"}, 400);
			});
		}
	}
	
	$('a[rel="LightBox"]').click(function(){
		clearInterval(interval);
		$('<div id="overlay" style="height:'+($('#container').outerHeight()-$('#footer').outerHeight())+'px;"></div>'+
			'<div id="lightbox">'+
				'<div id="outerContainer">'+
					'<div id="DataContainer">'+
						'<span id="title"></span>'+
						'<a href="javascript:" id="btnClose" title="close"><img src="/data/images/close.png" alt="Close" /></a>'+
					'</div>'+
					'<div id="lightboxContainer">'+
					'</div>'+
				'</div>'+
			'</div>').appendTo($('div#container'));
		container($(this).attr('class'),$(this));
		
		$('#btnClose').click(function(){
			$('#lightbox').remove();
			$('#overlay').remove();
			interval = setInterval(function(){
				slideShow()
			}, 6000);
		});
		return false;
	});
	
	
/*******end Light Box******/

/*******NewsLetter*********/
	$('a.newsletter').click(function(){
		$('.bubble').slideDown();
	});
	$('.bubble a.close').click(function(){
		$('.bubble').fadeOut();
		$('.bubble input.edit').attr("value","");
	});
/*****end NewsLetter******/

});
