
	$.fn.pause = function(duration) {
		$(this).animate({ dummy: 1 }, duration);
		return this;
	};
	
	
	function zpc_switch_to( which_one ){
	
		panel_width = 520;
		
		// which news ?
		new_left = panel_width * (which_one-1);	

		$("#zp_slideshow_inner_slide").animate({ 
			
			left: "-" + new_left + "px" 
		}, 
		{ duration: 1000, easing: 'easeOutBack' } );
		
		$("#tools_nav UL A").removeClass('active');
		$("#tools_nav UL A").eq(which_one-1).addClass('active');
		
		if(zpc_news_timer) zpc_news_timer = setTimeout ( "zpc_switch_to(zpc_news_find_next_num())", zpc_news_speed_default );
		
	}
	
	
	function zpc_news_find_next_num(){
		
		return_value	= 0;
		
		num_of_news 	= $("#tools_nav A").length;
		current_news	= $("#tools_nav A").index( $("#tools_nav A.active") );
		
		// current_news starts from 0
		current_news++;
		
		if( current_news < num_of_news ){ return_value = (current_news+1); }
		else return_value = 1;
		
		return return_value;
		
	}
	

	zpc_news_timer = 0;
	zpc_news_speed_default = 5000;
	function zpc_switcher(){
		
		// generate nav
		inner_li = '';
		for(i=1; i<=$(".slideshow_content").length; i++){ inner_li += '<li><a href="#">'+i+'</a></li>'; }
		if( inner_li != "" ){ $("#tools_nav UL").html(inner_li); }
		
		$("#tools_nav UL A:first").addClass('active');
		$("#tools_nav UL A").bind('click', function(){
			//$("#tools_nav UL A").removeClass('active');
			//$(this).addClass('active');
			zpc_switch_to( $(this).text() );
			clearTimeout(zpc_news_timer);
			zpc_news_timer = 0;
			return false;	
		});
		
		zpc_news_timer = setTimeout ( "zpc_switch_to(zpc_news_find_next_num())", zpc_news_speed_default );
		
		
	}


	function recepti_news_switcher_next( which_one ){
		
		if( $("#scr_panel_cont").length ){
			
			// scr_panel width
			scp_panel_width = $(".scr_panel").width();
			
			// which news ?
			new_left = scp_panel_width * (which_one-1);
			
			$("#scr_panel_cont").animate({ 
				
				left: "-" + new_left + "px" 
			}, 
			{ duration: 1000, easing: 'easeOutBack' } );

			
			// mark active
			recepti_new_mark_active(which_one);
			
			// next..
			r_news_timer = setTimeout ( "recepti_news_switcher_next(recepti_news_find_next_num())", r_news_speed );
			
			
		}
		
	}
	
	
	function recepti_new_mark_active(which_one){
		
		// reset active links
		$("#tools_nav A").removeClass('active');

		// first - active
		$("#tools_nav A").eq(which_one-1).addClass('active');
		
	}
	
	function recepti_news_find_prev_num(){
		
		return_value	= 0;
		
		num_of_news 	= $("#tools_nav A").length;
		current_news	= $("#tools_nav A").index( $("#tools_nav A.active") );	
		
		// current_news starts from 0
		current_news++;
		
		if( current_news == 1 ){ return_value = num_of_news; }
		else return_value = (current_news-1);
		
		return return_value;
		
	}
	
	
	function recepti_news_find_next_num(){
		
		return_value	= 0;
		
		num_of_news 	= $("#tools_nav A").length;
		current_news	= $("#tools_nav A").index( $("#tools_nav A.active") );
		
		// current_news starts from 0
		current_news++;
		
		if( current_news < num_of_news ){ return_value = (current_news+1); }
		else return_value = 1;
		
		return return_value;
		
	}

	r_news_timer = 0;
	r_news_speed_default = 5000;
	r_news_speed = r_news_speed_default;
	r_news_speed_block = 600000;
	function recepti_news_switcher(){
		
		// reset active links
		$("#tools_nav A").removeClass('active');

		// first - active
		$("#tools_nav A:first").addClass('active');

		// start slideshow
		r_news_timer = setTimeout ( "recepti_news_switcher_next(2)", r_news_speed );
		
		// assign clicks on arrows
		$("#tools_prev A").bind('click', function(){ r_news_speed = r_news_speed_default; clearTimeout(r_news_timer); recepti_news_switcher_next( recepti_news_find_prev_num() ); return false; });
		$("#tools_next A").bind('click', function(){ r_news_speed = r_news_speed_default; clearTimeout(r_news_timer); recepti_news_switcher_next( recepti_news_find_next_num() ); return false; });

		
		// assign click on nav
		$("#tools_nav A").bind('click', function(){ clearTimeout(r_news_timer); r_news_speed = r_news_speed_block; recepti_news_switcher_next( $(this).text() );  return false; });
		
		/*if( $("#scr_panel_cont").length ){
			
			// assign click events
			
			// scr_panel width
			scp_panel_width = $(".scr_panel").width();
			
			$("#scr_panel_cont").animate({ 
				
				left: "-" + scp_panel_width + "px" 
			}, 
			{ duration: 1000, easing: 'easeOutBack' });
			
			
		}*/
		
	}
	
	zpc_height = 0;
	function zpc_hide_other(){
		
		zpc_height = $("UL.boxname_moji_clanci").height();
		
		$("UL.boxname_moji_clanci LI").each(function(index){
			
			if( !$(this).hasClass('box_header') && !$(this).hasClass('zpc') ){
				if( index > 5 ){
					$(this).addClass('perm_hidden');	
				}	
			}
			
			
			
		});
		
		zpc_height_new = $("UL.boxname_moji_clanci").height();
		$("UL.boxname_moji_clanci").height(zpc_height_new);
		$("UL.boxname_moji_clanci LI.perm_hidden").css('opacity', 0);	
		
	}
	
	moji_recepti_height = 0;
	function moji_recepti_hide_other(){
		
		moji_recepti_height = $("UL.boxname_moji_recepti").height();
		
		$("UL.boxname_moji_recepti LI").each(function(index){
			
			if( !$(this).hasClass('box_header') && !$(this).hasClass('all_link') ){
				if( index > 5 ){
					$(this).addClass('perm_hidden');	
				}	
			}
			
			
			
		});
		
		moji_recepti_height_new = $("UL.boxname_moji_recepti").height();
		$("UL.boxname_moji_recepti").height(moji_recepti_height_new);
		$("UL.boxname_moji_recepti LI.perm_hidden").css('opacity', 0);	

		
	}
	
	my_r_animate_speed = 1000;
	function moji_recepti_pokazi_sve(){
		
		$("UL.boxname_moji_recepti LI.perm_hidden").animate({
			opacity: 1
		}, my_r_animate_speed * 3);	
		$("UL.boxname_moji_recepti LI").removeClass('perm_hidden');	

		$("UL.boxname_moji_recepti").animate({
			height: moji_recepti_height + "px"
		}, my_r_animate_speed);
		
	}
	
	zpc_animate_speed = 1000;
	function zpc_pokazi_sve(){
		
		$("UL.boxname_moji_clanci LI.perm_hidden").animate({
			opacity: 1
		}, zpc_animate_speed * 3);	
		$("UL.boxname_moji_clanci LI").removeClass('perm_hidden');	

		$("UL.boxname_moji_clanci").animate({
			height: zpc_height + "px"
		}, zpc_animate_speed);
		
	}
	

	function submitBolestiFilterForm(){
		
		if( document.forms['form_bolesti_search'].bolesti_dio_tijela.value != 'Odaberite dio tijela' ){ 
			
			/*checked_button = $("input:radio[@name=show_what]:checked").val()
			
			switch( checked_button ){
				
				case "simptomi": break;
				case "bolesti": break;
				default: break;
				
			}*/

			document.forms['form_bolesti_search'].submit(); 
		}  
		
		return false;
		
	}
	
	fade_in_speed = 800;
	function naslovnica_zanimljivosti_clanci_switch( switch_what ){

		div_zanimljivosti	= $("#najnovije_zanimljivosti");
		div_clanci			= $("#najnoviji_clanci");
		tab_zanimljivosti	= $("#swith_z");
		tab_clanci			= $("#swith_c");
		
		switch( switch_what ){
			
			case "zanimljivosti":
			
				div_clanci.css('display', 'none');
				div_zanimljivosti.css('opacity', 0);	
				div_zanimljivosti.css('display', 'block');	
				div_zanimljivosti.fadeTo(fade_in_speed, 1, function(){ /*$(this).style.removeAttribute("filter");*/ });
				
				tab_clanci.removeClass('active');
				tab_zanimljivosti.addClass('active');
				break;
				
			case "clanci":
				
				div_zanimljivosti.css('display', 'none');
				div_clanci.css('opacity', 0);	
				div_clanci.css('display', 'block');	
				div_clanci.fadeTo(fade_in_speed, 1, function(){ /*$(this).style.removeAttribute("filter");*/ });
				
				tab_zanimljivosti.removeClass('active');
				tab_clanci.addClass('active');
				break;
			
		}
		
	}
	
	
	function naslovnica_zanimljivosti_clanci(){
		
		$("#swith_z").click(function () { 
		    naslovnica_zanimljivosti_clanci_switch( 'zanimljivosti' );
		    return false;
		});	
		
		$("#swith_c").click(function () { 
		    naslovnica_zanimljivosti_clanci_switch( 'clanci' );
		    return false;
		});	
		
	}

	
	function naslovnica_izdvajamo_switcher_switch_to( switch_to , clear_timeout ){


		// find active
		active_element 			= $(".box_izd");
		active_element_index 	= $("UL#home_izdvajamo_pages LI A.active").text();

		/*for( i=0; i<active_element.length; i++ ){
			if( active_element[i].offsetWidth ){ active_element_index = i+1 }
			
		}*/

		// active_element_index = $("UL#home_izdvajamo_pages LI A").index($("UL#home_izdvajamo_pages LI A.active"));

		if( active_element_index ){
			
			// hide active
			//$("#box_izd_" + active_element_index).css('display', 'none');
			
			// fade in active			
			open_element = $("#box_izd_" + switch_to);
			$("#box_izd_" + switch_to + " , #box_izd_" + switch_to + " DIV.banner_izdvajamo").css('opacity', 0);
			open_element.css('display', 'block');
			
			// fadeout current

			$("#box_izd_" + active_element_index).fadeTo(fade_in_speed/2, 0, function(){

				// none for active element
				$(this).css('display', 'none');

				/// switch next element
				//$("#box_izd_" + switch_to + " , #box_izd_" + switch_to + " DIV.banner_izdvajamo").fadeTo(fade_in_speed, 1, function(){
				$("#box_izd_" + switch_to + " , #box_izd_" + switch_to + " DIV.banner_izdvajamo").fadeTo(fade_in_speed, 1);
					
					// display block for next element
					//open_element.css('display', 'block');
	
					// remove active
					$("UL#home_izdvajamo_pages LI A").removeClass('active');
					
					// mark active
					$("UL#home_izdvajamo_pages LI A").eq(switch_to-1).addClass('active');
					
						// news fader
						if( clear_timeout ){ if( switch_speed ) clearTimeout ( news_timeout_internal ); }
						else { fade_next(); }						
					
				//});	
							
			
				
			});
			

			
		}
		
	}
	
	switch_speed = 5000;
	function fade_next(){
		
		
		// news fader
		if( switch_speed ){
			
			// find current
			var active_index = $("UL#home_izdvajamo_pages LI A").index($("UL#home_izdvajamo_pages LI A.active"));
			
			// fade next	
			switch_to = active_index+2;
			if( switch_to > ($("UL#home_izdvajamo_pages LI A").length) ){ switch_to = 1; }
			if( switch_speed )	news_timeout_internal = setTimeout("naslovnica_izdvajamo_switcher_switch_to("+switch_to+", 0);", switch_speed); 

			
		}
		
	}
	
	
	function naslovnica_izdvajamo_switcher(){
		
		// hide all
		$(".box_izd").css('display', 'none');
		
		// show first
		$(".box_izd:first").css('display', 'block');
		
		// nav links
		nav_links = $("UL#home_izdvajamo_pages LI A");
		
		$("UL#home_izdvajamo_pages LI A").removeClass('active');
		$("UL#home_izdvajamo_pages LI A").eq(0).addClass('active');
		
		nav_links.click(function () { 
		  	naslovnica_izdvajamo_switcher_switch_to(this.innerHTML,1);
		    return false;
		});	

		// news fader
		fade_next();
		
	}
	
	
	function naslovnica_izracun_kalorija_namirnica_kcal(){
		
		namirnica_kcal = $("SELECT#izracun_namirnica option:selected").val();

		if( namirnica_kcal ){
			
			return namirnica_kcal;
			
		}
		
		return 0;
	}
	
	
	function naslovnica_izracun_kalorija_input_val(){
		
		if( isNaN( parseInt($("DIV#input_values INPUT").val()) ) ) $("DIV#input_values INPUT").val(0);
		else { $("DIV#input_values INPUT").val( parseInt($("DIV#input_values INPUT").val()) ); }
		
		return  $("DIV#input_values INPUT").val();
		
	}
	
	
	function naslovnica_izracun_kalorija_izracun(){
		
		namirnica_kcal 	= naslovnica_izracun_kalorija_namirnica_kcal();
		input_val		= naslovnica_izracun_kalorija_input_val();
	
		$("DIV#output_result").text( parseInt(( namirnica_kcal / 100 ) * input_val));		
		
	}
	
	
	
	function naslovnica_izracun_kalorija(){
		
		$("SELECT#izracun_namirnica").change(function () { 
			
			namirnica_kcal = naslovnica_izracun_kalorija_namirnica_kcal();
			
			if( namirnica_kcal ){
				
				naslovnica_izracun_kalorija_izracun();
				
			}
			
			
		});
		
		$("DIV#input_values INPUT").keyup(function () { 
		
			naslovnica_izracun_kalorija_izracun();
			
		});
		
	}
	
	function bmi_kalk_do_calculate(){
		
		visina = $("#bmi_kalk_form input[name='visina']").val();
		if( isNaN( parseInt($("#bmi_kalk_form input[name='visina']").val()) ) ) $("#bmi_kalk_form input[name='visina']").val(0);
		visina = $("#bmi_kalk_form input[name='visina']").val();
		
		tezina = $("#bmi_kalk_form input[name='tezina']").val();
		if( isNaN( parseInt($("#bmi_kalk_form input[name='tezina']").val()) ) ) $("#bmi_kalk_form input[name='tezina']").val(0);
		tezina = $("#bmi_kalk_form input[name='tezina']").val();
		
		if( visina && tezina ){
			
			visina    = visina / 100;
			// bmi_index = Math.round( tezina / ( visina * visina ) );
			// bmi_index = Math.round( tezina / ( visina * visina ) * 100 ) / 100;
			bmi_index = Math.round( tezina / ( visina * visina ) * 10 ) / 10;

			if( bmi_index ){

				$("LI.li_hidden").css('display' , 'block');
				$("DIV#vas_bmi").html('<b>' + bmi_index + '</b>');				
				
				
			}
			
		}
		
	}