function getVars() {
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++){
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars;
}
$(function() {
	/* Slider */
	if($('#nivoSlider').length != 0){
		$('#nivoSlider').nivoSlider({
			effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
			slices:15, // For slice animations
			boxCols:8, // For box animations
			boxRows:4, // For box animations
			animSpeed:500, // Slide transition speed
			pauseTime:3000, // How long each slide will show
			startSlide:0, // Set starting Slide (0 index)
			directionNav:false, // Next & Prev navigation
			directionNavHide:true, // Only show on hover
			controlNav:true, // 1,2,3... navigation
			controlNavThumbs:false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav:true, // Use left & right arrows
			pauseOnHover:true, // Stop animation while hovering
			manualAdvance:false, // Force manual transitions
			captionOpacity:1, // Universal caption opacity
			prevText: '&larr;', // Prev directionNav text
			nextText: '&rarr;', // Next directionNav text
			beforeChange: function(){}, // Triggers before a slide transition
			afterChange: function(){}, // Triggers after a slide transition
			slideshowEnd: function(){}, // Triggers after all slides have been shown
			lastSlide: function(){}, // Triggers when last slide is shown
			afterLoad: function(){} // Triggers when slider has loaded
		});
	}
	
	$('#nav').droppy();
	
	/* NT Functions */
	$('#txt_nt_short').click(function(){
		$('#content_nt').removeClass("txt_nt_large txt_nt_medium");
		$('#content_nt').addClass("txt_nt_short");
		return false;
	});
	$('#txt_nt_medium').click(function(){
		$('#content_nt').removeClass("txt_nt_short txt_nt_large");
		$('#content_nt').addClass("txt_nt_medium");
		return false;
	});
	$('#txt_nt_large').click(function(){
		$('#content_nt').removeClass("txt_nt_short txt_nt_medium");
		$('#content_nt').addClass("txt_nt_large");
		return false;
	});
	$('#txt_nt_less').click(function(){
		if($('#content_nt').hasClass('txt_nt_large')){
			$('#content_nt').removeClass("txt_nt_large");
			$('#content_nt').addClass("txt_nt_medium");
		}else if($('#content_nt').hasClass('txt_nt_medium')){
			$('#content_nt').removeClass("txt_nt_medium");
			$('#content_nt').addClass("txt_nt_short");
		}else if($('#content_nt').hasClass('txt_nt_short')){
		}else{
			$('#content_nt').addClass("txt_nt_short");
		}
		return false;
	});
	$('#txt_nt_more').click(function(){
		if($('#content_nt').hasClass('txt_nt_short')){
			$('#content_nt').removeClass("txt_nt_short");
			$('#content_nt').addClass("txt_nt_medium");
		}else if($('#content_nt').hasClass('txt_nt_medium')){
			$('#content_nt').removeClass("txt_nt_medium");
			$('#content_nt').addClass("txt_nt_large");
		}else if($('#content_nt').hasClass('txt_nt_large')){
		}else{
			$('#content_nt').addClass("txt_nt_large");
		}
		return false;
	});
	$('.print_this').click(function(){
		//window.print();
		$('.sections-left').jqprint();
		return false;
	});
	
	/* NT Receta Functions */
	var i=0;
	$(".tbl_ingredientes table tr, .tbl_nutricion table tr").each(function(){
		if(i==1){
			$(this).addClass('tr_otherbg');
			i=0;
		}else{
			i=1;
		}
	});
	
	var hash = getVars();
	var f = 0;
	if($("#iframe-search-src").length) {
		if(hash['q']) {
			var actualSRC = $("#iframe-search-src").attr("src");
			$("#iframe-search-src").attr("src",actualSRC+"&q="+unescape(hash['q']));
		}else{
			window.location="/";
		}			
	}
	
	$(".box-tit-recetasdeldia, .box-tit-videos, .box-tit-consejos, .box-tit-hazlofacil, .box-tit-chefsinvitados, #newsandevents").css("cursor","pointer");
	$(".box-tit-recetasdeldia").click(function(){	window.location=url_recetas;		});
	$(".box-tit-videos").click(function(){			window.location=url_videos;			});
	$(".box-tit-consejos").click(function(){		window.location=url_consejos;		});
	$(".box-tit-hazlofacil").click(function(){		window.location=url_hazlofacil;		});
	$(".box-tit-chefsinvitados").click(function(){	window.location=url_chefsinvitados;	});
	$("#newsandevents").click(function(){			window.location=url_noticiaseventos;});
	
});
