$(document).ready(function()
{	
	$('#openPanel').bind('mouseenter mouseleave',function(e)
	{
		$('.bgpanel').show();
		$('.panel').show();
		$('.savepanel').show();
	});
	
	$('.panel').bind('mouseleave',function(e)
	{
		$('.bgpanel').hide();
		$('.panel').hide();
		$('.savepanel').hide();
	});

	$('#forgotPass').click(function()
	{ 
		$('#BoxL').hide();
		$('#BoxF').show();
	});

	$('#backLogin').click(function()
	{ 
		$('#BoxF').hide();
		$('#BoxL').show();
	});

	$('#forgotPassBack').click(function()
	{ 
		$('#forgotPassResult').hide();
		$('#forgotPassForm').show();
	});
	
	$("#forgotPassForm form").submit(function()
	{
		$('#forgotPassLoading').ajaxStart(function()
		{
			$(this).show();
			$('#forgotPassForm').hide();
		});
		
		$('#forgotPassLoading').ajaxStop(function()
		{
			$(this).hide();
		}); 

		$.ajax(
		{
			type: 'POST',
			url: url + 'web/forgotPassword',
			data: 'email=' + $('#forgotPassEmail').val(),
			success: function(html)
			         {
						 $('#forgotPassResultMsg').html(html);
						 $('#forgotPassResult').show();
				     }	
		});

		return false;
		
	});

	$("#searchForm form").submit(function()
	{

		if($('#searchField').val() != '')
		{
			window.location = url + 'busqueda/' + $('#searchField').val();
		}
		
		return false;
	});
	
	$("#calendarform form").submit(function()
	{

		$.ajax(
		{
			type: 'POST',
			url: url + 'web/getDays',
			data: 'desde=' + $('#CalendarDesdeYear').val() + '-' + $('#CalendarDesdeMonth').val() + '-' + $('#CalendarDesdeDay').val() + '&hasta=' + $('#CalendarHastaYear').val() + '-' + $('#CalendarHastaMonth').val() + '-' + $('#CalendarHastaDay').val(),
			success: function(html)
			         {
						 $('#calendarformresult').html(html);
				     }	
		});

		return false;
		
	});
	
	function vote(rate,id)
	{
		$.ajax(
		{
			url:     '/ratings/vote/' + rate + '/' + id,
			cache:   false,
			success: function(html)
					 {
						 $('#u_votes').html(html);
						 
						 $.ajax(
						{
							url:     '/ratings/result/' + id,
							cache:   false,
							success: function(html)
									 {
										 $('#g_votes').html(html);
									 }
						});
					 }
		});
	}

});

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

$(document).ready(function() {
	
	jQuery('#list1a').accordion({
		autoheight: false
	});
	
	
	
});


function videovote(rate,id){
	
	$.ajax({
		url:     "/videoratings/vote/" + rate + "/" + id,
		cache:   false,
		success: function(html){
			$("#u_votes").html(html);
			$.ajax({
				url:     "/videoratings/result/" + id,
				cache:   false,
				success: function(html){
					$("#g_votes").html(html);
				}
			});
		}
	});
}

