function submitSearch(formObj)
{
	var word = formObj.keyword.value;	
	var uri = formObj.action;
	if(uri.length > 0 && word.length > 0)
	{
		window.location.href = uri+"buscar/"+encodeURIComponent(word);		
	}
	return false;
}


//JQUERY CODE
$(function() { 

/***JQ FONTEND**********************************************/	 
	
	//[INDEX]//
	
	//preload scrollable images
	$(".fiHomeScrollableItems img").each(function(index,el){
		var preimg = new Image();		
		$(preimg).load(function () {		
		
		}).error(function () {
		
		}).attr('src', $(this).attr('alt'));
	});
	
	$.easing.custom = function (x, t, b, c, d) {
		//http://gsgd.co.uk/sandbox/jquery/easing/
		/*
		var s = 1.70158; 
		if ((t/=d/2) < 1) 
		return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
		*/		
		//return c*(t/=d)*t + b;
		/*
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
		*/		
	}
	
	/*
	var rootscroll = $(".fiHomeScrollable").scrollable({easing: 'swing', speed: 700,circular: true}).fiautoscroll(5000);
	window.apiscroll = rootscroll.data("scrollable");
	*/
	
	$(".fiHomeScrollable").scrollable({easing: 'swing', speed: 700,circular: true}).fiautoscroll({
		interval: 5000		
	});
	
	$(".fiHomeScrollableItems img").click(function() {	
		if ($(this).hasClass("active")) { 
			return; 
		}
		
		var url = $(this).attr("alt");//large image		
		var pid = $(this).attr("pid");//place id
		
		$("#fiHomeTopTitle").fadeOut("slow", function() {
			$("#fiHomeTopTitle").empty();			
		});	
		$("#fiHomeTopDetail").fadeOut("slow", function() {
			$("#fiHomeTopDetail").empty();			
		});			
		
		$("#fiHomeImageWrap")
		.fadeOut("slow", function() {
			
			$("#fiHomeLoading").css("display","block");	
			
			var img = new Image(); //large image		
			$(img).load(function () {
				$("#fiHomeImageWrap").find("img").attr("src", url);	
				
				$.getJSON('_core/interactive/place.action.php?action=getdata&pid='+pid, function(data, textStatus){
					if(data.errorMsg)
					{
						alert(data.errorMsg);
					}
					else
					{				
						var thisBrief = ''+data.brief+''+
							'<br />' +
							'<br /><a href="'+data.seo_link+'">Ver Mas</a>...';
						
						$("#fiHomeTopTitle").html(data.name).fadeIn(1000);	
						$("#fiHomeTopDetail").html(thisBrief).fadeIn(1000);

						$("#fiHomeLoading").css("display","none");	
						
						$("#fiHomeImageWrap").fadeIn(1000, function() {
					
						});	
					}
				});
				
			}).attr('src', url);			
		});		
			
		// activate item
		$(".fiHomeScrollableItems img").removeClass("active");
		$(this).addClass("active");			
	
	// when page loads simulate a "click" on the first image
	});//.filter(":first").click();
	
	
	//[STATE]//
	
	//[PLACE]//
	
	//[SITEMAP]//	
	
	$("img.fiTownToggle").click(function() {
		var objId = $(this).attr('target');
		var isOpen = $(this).attr('open');
		var uri = $(this).attr('uri');
		if(isOpen==1)
		{
			$('#'+objId).toggle("slow");
			$(this).attr('open','0');				
			$(this).load(function () {					
			}).attr('src', uri+'themes/default/plus_icon.jpg');			
		}
		else
		{
			$('#'+objId).toggle("slow");
			$(this).attr('open','1');
			$(this).load(function () {				
			}).attr('src', uri+'themes/default/minus_icon.jpg');	
		}
	});	
  
 });

