//<![CDATA[
RECORD = {};
RECORD.minNews = 1;
RECORD.maxNews = 15;
$(document).ready(function(){
	var currentTheme = $("#costumeBar ul.colourList li.selected").attr('rel');
	var currentThemeElement;
	var topicChange = false;
	$(".arrow").click(function() {
		var scope = $(this);
		if(scope.parent().parent().attr('class').indexOf('related') > -1){
			scope.parent().parent().next('ul').toggle("blind", {direction: "vertical" }, 200);
			scope.parent().parent().next().next().toggle("blind", {direction: "vertical" }, 200, function(){
				changeArrow(scope);
			});
			return;
		}
		$(this).parent().parent().next("div").toggle("blind", {direction: "vertical" }, 200, function(){
			var visible = changeArrow(scope);
			$.post("save.php", 'visible='+visible+'&id='+$(this).parent().attr('id'));
		});
	});
	
	$("#costumeColourBtn").click(function(){
		$("#costumeBar").toggle("blind", {direction: "vertical" }, 200);
		currentThemeElement = $("#costumeBar ul.colourList li.selected");
		return false;
	});
	
	$("#restorePageBtn").click(function(){
		if(confirm("Al restablecer la pagina, todos los elementos volverán a su estado original, ¿desea continuar?")){
			window.location = 'backends/restorePage.php';
		}
		return false;
	});
	$("#costumeBar ul.topic li label").click(function(){
		var selected = $(this).parent().attr('class').indexOf('selected') > -1;
		if(selected){
			$(this).parent().removeClass('selected');
			$(this).next().removeAttr('checked');
			$(this).next().attr('checked','');
			$(this).next().attr('selected','');
			
		}else{
			$(this).parent().addClass('selected');
			$(this).next().attr('selected', 'selected');
			$(this).next().attr('checked', 'checked');
			//$(this).next().addAttr('checked');
			
		}
		hdnCheckValue($(this).next().next().attr('id'), $(this).next().attr('id'));
	});
	$("#submitCostume").click(function(){
		$("#formTheme").submit();
	});
	
	$("#cancelCostume").click(function(){
		$("#costumeBar").hide("blind", {direction: "vertical" }, 200);
		return false;
	});
	$("li.costumeColour").click(function(){
		var noCache = Math.random();
		$("#costumeBar ul.colourList li.selected").removeClass('selected');
		$(this).addClass('selected');
		var currentTheme = $(this).attr('rel');
		$('#theme').attr('href', 'css/'+currentTheme+'.css');
		$("#costumeBar ul.colourList li.selected input").attr('checked', true);
		$.post("backends/savecostumeColour.php?noCache="+noCache, 'theme='+currentTheme);
	});
	
	
	
	/***********************************************
	 Added
	***********************************************/
	$("#cst_1st_List li.costumeColour").click(function(){
		$("#cst_1st_List li.selected").removeClass('selected');
		$(this).addClass('selected');
		currentTheme = $("#cst_1st_List li.selected").attr('rel');
		$('#theme').attr('href', 'css/'+currentTheme+'.css');
		$("#cst_1st_List li.selected input").attr('checked', true);
		//$(this).submit();
	});
	
	
	
	
	$(".addremove a").click(addRemoveNews);
	$(".box .header a.edit").click(function()
	{
		var scope = $(this).parent().parent().children(".content").children('.edition');
		if(!scope[0]){
			var target = $(this).parent().parent().children('.content');
			toggleCommentForm(target[0]);
		}
		var visible = Boolean($(this).parent().parent().children(".content").children('.edition:visible').length);
		var moduleID = $(this).attr('rel');
		if(!visible){
			scope.text("Cargando...");
			$.post("edit.php", { moduleID: moduleID },
			  function($data){
				//$(".box .header a.edit").click(onEdit);y
				scope.html($data);
			});
			$(this).parent().parent().children(".content").children('.more').hide();
		}else{
			scope.html('');
			if($(this).parent().parent().children(".content").children('.more').children().length){
				$(this).parent().parent().children(".content").children('.more').show();
			}
		}
		$(this).parent().parent().children(".content").children('ol').toggle();
		$(this).parent().parent().children(".content").children('ul').toggle();
		$(this).parent().parent().children(".content").children('p').toggle();
		$(this).parent().parent().children(".content").children('.footer').toggle();
		$(this).parent().parent().children(".content").children('.carousel').toggle();
		$(this).parent().parent().children(".content").children('.tabs').toggle();
		$(this).parent().parent().children(".content").children('.body').toggle();
		scope.toggle();
		return false;
	});
	/*
		@Author:Cep
		@Date:15/01/09 12:27 am
		@Comment: Agregue la linea de abajo para cuando se usen los tabs.
					Si se quiere pasar un texto de cargando ponerlo en la propiedad spinner,
					si no dejar en blanco. Es preferible dejar en blanco.
					
		+++++++++++++++++++++ No quitar el try catch!!. ++++++++++++++++++++
	*/
	try{
		$('.box div.tabsList').tabs({remote:true,  spinner: '' });
	}catch(e){}
	$(".box .content ol li a").hover(function(){
			var src = $(this).children('img').attr('src');
			var titleSRC = $(this).children('img').attr('title');
			var altSRC = $(this).children('img').attr('alt');			
			$(this).parent().parent().parent().parent().children('img').attr('src', src);
			$(this).parent().parent().parent().parent().children('img').attr('title', titleSRC);
			$(this).parent().parent().parent().parent().children('img').attr('alt', altSRC);
		},
		function(){return;}
	);
	
	$(".box .content ol li a").hover(function(){
			var src = $(this).children('img').attr('src');
			var titleSRC = $(this).children('img').attr('title');
			var altSRC = $(this).children('img').attr('alt');
			$(this).parent().parent().parent().parent().children('img').attr('src', src);
			$(this).parent().parent().parent().parent().children('img').attr('title', titleSRC);
			$(this).parent().parent().parent().parent().children('img').attr('alt', altSRC);
		},
		function(){return;}
	);
	
	$('.pages a.page').click(function(){
		var page = $(this).attr('rel');
		var target = $(this).parent().parent().parent();
		//alert('sera? '+target.html());
		$.post("modules/sectionComments.php", {next:page}, function($data){
			target.html($data);
		});
		return false;
	});
	//-- Empiezan las funciones para los paginadores ------------------------------------------------------------------		
	$('.pages a.pageComments').click(onPageComments);
	$('.pages a.pageJournal').click(onPageJournal);
	$('#gal_controls a.searchGallery').click(onSearchGallery);
	$('#gal_controls a.searchVideo').click(onSearchVideo);
	$('#gal_controls a.searchVideoRelated').click(onSearchVideoRelated);
	$('.pages a.pageFriendSearch').click(onPageFriendSearch);
	$('.pages a.pageMyFriends').click(onPageMyFriends);
	$('.pages a.pageList').click(onPageList);
	$('.pages a.pageRelatedList').click(onPageRelatedList);
	$('.pages a.pageTodayRelatedList').click(onPageTodayRelatedList);
	$('.pages a.pageHistoryComments').click(onPageHistoryComments);
	$('.pages a.pageUnpublishComments').click(onPageUnpublishComments);
	$('.pages a.pageJournalComments').click(onPageJournalComments);
	$('.pages a.pagesSectionComments').click(onPageSectionComments);
	$('.pages a.pageSearchList').click(onPageSearchList);
	$('.pages a.pagePollsList').click(onPagePollsList);
	//-----------------------------------------------------------------------------------------------------------------
	$('#commentFormReset').click(function(){
		var target = $(this).parent().parent().parent().children('.content');
		toggleCommentForm(target[0]);
	});
	//-- Funciones para el backend de login ---------------------------------------------------------------------------------
	//-----------------------------------------------------------------------------------------------------------------
	$('#muroFormReset').click(function(){
		document.forms["commentForm"].reset();
		$(this).parent().parent().parent().toggle();
		$("#main_wall").toggle();
		$("#paginador_comments").toggle();
	});
	//-- Funciones para el backend de login ---------------------------------------------------------------------------------
	$("#forgotPassword").click(initBtnForgotPassword);
	$("#registerMember").click(initBtnRegisterMember);
	//-- END ----------------------------------------------------------------------------------------------------------------
	
	//-- Gallerias 
	$("#gal_controls a.image_gallery").click(onSelectImage);
	//-- END
	
	//-- Función para el paginador de la galeria ----------------------------------------------------------------------------
	$('#gallery_navigation a.next_pic').click(nextPrevGalleryImage);
	
	function nextPrevGalleryImage(){
		var galleryData = $(this).attr('rel').split("|");
		var target = $(this).parent().parent().children('#image_holder');
		//alert(target.html());
		var imageCounter = 0;
		
		alert(imageCounter++);
		/*$.post("modules/getGalleryImage.php", {next:page}, function($data){
			target.html($data);
		});*/
		return false;
	}
	//-- END ----------------------------------------------------------------------------------------------------------------
	
	//-- Función para cambiarle el tamaño de la fuente a una nota -----------------------------------------------------------
	$('#LetterMap area').click(function(){
		var classType = $(this).attr('class').split("_");
		var divContent = $('.content').children();
		var currentClass = divContent.attr('class');
		divContent.removeClass(currentClass);
		if(classType[1] == "big"){
			//alert(divContent.attr('class'));			
			divContent.addClass('letter_'+classType[1]);
		}else if(classType[1] == "default"){
			divContent.addClass('letter_'+classType[1]);
		}else if(classType[1] == "small"){
			divContent.addClass('letter_'+classType[1]);
		}
		return false;
	});
	//-- END ----------------------------------------------------------------------------------------------------------------
		
 });



function onSelectImage()
{
	var vIdPhoto = $(this).attr('rel');
	var target = $("#container_photo");
	$.post("backends/refreshPhotoGallery.php", {vIdPhoto:vIdPhoto}, function($data)
	{
		target.html($data);
	});
	var vIdGaleria     = $(this).attr('rel2');
	var vContadorPhoto = $(this).attr('rel3');
	var target2 = $("#container_paginator");
	$.post("backends/refreshPaginatorPhotoGallery.php",{vIdGaleria:vIdGaleria,vContadorPhoto:vContadorPhoto},function($data)
	{
		target2.html($data);
		$("#gal_controls a.image_gallery").click(onSelectImage);
	});
}
function stopEdition($target){
$($target).parent().parent().children('ol').toggle();
$($target).parent().parent().children('.footer').toggle();
$($target).parent().parent().children('.carousel').toggle();
$($target).parent().parent().children('.edition').toggle();
$($target).parent().parent().children('.more').toggle();
}


function submitForm($target){
stopEdition($target);
var options = {
	target: $($target).parent().parent().children('.more'),
	success:updateAddRemoveLinks
};
$($target).submit(function() {
	$($target).ajaxSubmit(options);
	return false;
});
}
function updateAddRemoveLinks(){
$(".addremove a").click(addRemoveNews);
}
function addRemoveNews(){
	var type = $(this).attr('class');
	var newsAddData = $(this).attr('rel').split("|");
	var ul = $(this).parent().next().children();			
	var total = ul.length;
	if(!ul[0]) return false;
	if(type == "add"){
		if(total < RECORD.maxNews && total != newsAddData[1]){
			ul.parent().append('<li>Cargando...</li>');
			ul = $(this).parent().next().children();
			var item = $(ul[total]);
			total++;
			if(total % 2 == 0){
				item.addClass("pair");
			}else{
				item.addClass("non");
			}
			$.post("backends/saveNews.php", { parentID: newsAddData[0], currentNewNumber: total-1, addType: newsAddData[2] },
			  function($data){
				item.html($data);
			});
			
		}
	}else{
		if(total > RECORD.minNews){					
			$.post("backends/removeNews.php", { parentID: newsAddData[0], currentNewNumber: total-1, categoryID: newsAddData[2] });					
			$(ul[total-1]).remove();
		}
	}
	return false;
}
function updateList(){
	var id = $(this).attr('id');
	var list = $(this).sortable('serialize', { key:id+"[]"})+"&column="+id;
	$.post("backends/saveCookieModules.php", list.toString(), function($data){
		$("#ajaxDebuger").append($data);
	});
	//alert(list.toString());
}
function changeArrow($target){//:Boolean
	if($target.attr('src') != 'images/arrow_left.gif'){
		$target.attr('src', 'images/arrow_left.gif');
		$target.attr('align', 'absmiddle');
		return false;
	}else{
		$target.attr('src', 'images/arrow.gif');
		return true;
	}
}

function toggleCommentForm($target){//:Void
	$($target).children().toggle();
	$($target).next().toggle();
	$($target).next().next().toggle();
	$($target).next().next().next().toggle();
}
//-- Submit para el formulario de ingreso ------------------------------------------------------------------------------
function submitFormIngreso ($target){
	stopEdition($target);
	var options = 
	{
		target: $($target).parent().parent().children('.login')
	};
	$($target).submit(function() 
	{
		$($target).ajaxSubmit(options);
		return false;
	});
}
//-- END
//-- Submit para el formulario de comentarios ------------------------------------------------------------------------------
function submitCommentForm ($target)
{	
	/*$.ajax(
	{
		url: "backends/paginadorComments.php",
		cache: false,
		success: function(html)
		{					
			$('#paginador_comments').append(html);
		}
	});*/
	
	var scope = $('#paginador_comments');
	$.post("backends/paginadorComments.php",{ var1: "foo" },
		function($data){
			scope.html($data);
	});
	
	
	stopEdition($target);
	var options = {target: $($target).parent().parent().children('.content')};
	$($target).submit(function() 
	{
		$($target).ajaxSubmit(options);			
		return false;
	});
}
//-- END
//-- Submit para el formulario para hacer reset de Box Login  ------------------------------------------------------------------------------
function submitFormResetLoginBox($target){
	stopEdition($target);
	var options = {target: $($target).parent().parent().parent().children('.right_registro')};
	$($target).submit(function() 
	{
		$($target).ajaxSubmit(options);
		return false;
	});
}
//-- Submit para el formulario de registro ------------------------------------------------------------------------------
function submitRegisterForm($target)
{
	stopEdition($target);
	var options = {target: $($target).parent().parent().children('.login')};
	$($target).submit(function() 
	{
		$($target).ajaxSubmit(options);
		return false;
	});	
	return true;
 }
//-- END
//-- Funcion para los comnetarios ------------------------------------------------------------------------------

function onSearchGallery()
{
	var page = $(this).attr('rel');
	var target = $('#gallerySearchHolder');
	$.post("modules/getGallerysBySearch.php", {next:page}, function($data)
	{
		target.html($data);
		$('#gal_controls a.searchGallery').click(onSearchGallery);
	});
	return false;
}
//-- END
//-- Funcion para los videos ------------------------------------------------------------------------------
function onSearchVideo()
{
	var page = $(this).attr('rel');
	var target = $('#videoSearchHolder');
	$.post("modules/getVideoBySearch.php", {next:page}, function($data)
	{
		target.html($data);
		$('#gal_controls a.searchVideo').click(onSearchVideo);
	});
	return false;
}
//-- END
//-- Funcion para los comnetarios ------------------------------------------------------------------------------
function onPageComments()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children('.content');
	$.post("modules/getCommentsByUser.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#paginador_comments");
	$.post("modules/getPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageComments').click(onPageComments);
		$('a.removeComment').click(onRemoveComment);
	});
	return false;
}
//-- END
//-- Funcion para los comentarios del Muro
function onCommentSubmit()
{
	var target = $(this).parent().parent().children('.content');
	toggleCommentForm(target[0]);
	var options = {target: target};
	$(this).ajaxSubmit(options);
	return false;
}
//-- END
//-- Funcion para el Journal ------------------------------------------------------------------------------
function onPageJournal()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children('.content');
	$.post("modules/getJournalByUser.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#paginador_journal");
	$.post("modules/getJournal.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageJournal').click(onPageJournal);
		$('a.blogActionLink').click(onBlogAction);
	});
	return false;
}
//-- END
//-- Funcion para el buscador de amigos -------------------------------------------------------------------
function onPageFriendSearch()
{
	var page = $(this).attr('rel');
	//var target = $(this).parent().parent().parent().children('.content');
	var target = $("#resultados_busqueda");
	$.post("modules/getFriendSearch.php", {next:page}, function($data){
		target.html($data);
		$('a.sendFriendComment').click(onSendFriendComment);
	});
	var targetPaginador = $("#paginador_comments");
	$.post("modules/getFriendSearchPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageFriendSearch').click(onPageFriendSearch);
		$('a.sendFriendComment').click(onSendFriendComment);
		$("a.friendList").click(onFriendList);
	});
	return false;
}
//-- END
//-- Funcion para el buscador de amigos -------------------------------------------------------------------
function onPageMyFriends()
{
	var page = $(this).attr('rel');
	//var target = $(this).parent().parent().parent().children('.content');
	var target = $("#resultados_busqueda");
	$.post("modules/getMyFriends.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#paginador_comments");
	$.post("modules/getMyFriendPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageMyFriends').click(onPageMyFriends);
		$('a.sendFriendComment').click(onSendFriendComment);
		$("a.removeFriend").click(onRemoveFriend);
	});
	return false;
}
//-- END
//-- Funcion para el buscador de amigos -------------------------------------------------------------------
function onPageList()
{
	var page = $(this).attr('rel');			
	var target = $(this).parent().parent().parent().children('.content');
	//alert(target.attr('class'))
	$.post("modules/getNewsList.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $(this).parent().parent();
	$.post("modules/getNewsListPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageList').click(onPageList);
	});
	return false;
}
//-- END
//-- Funcion para el paginador de noticias relacionadas ----------------------------------------------------
function onPageRelatedList()
{
	var page = $(this).attr('rel');			
	var target = $(this).parent().parent().parent().children('.content');
	var parentID = $(this).parent().attr('id');
	//alert(parentID)
	$.post("modules/getRelatedNewsList.php", {next:page, related:parentID}, function($data){
		target.html($data);
	});
	var targetPaginador = $(this).parent().parent();
	$.post("modules/getRelatedNewsListPaginator.php", {next:page, related:parentID}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageRelatedList').click(onPageRelatedList);
	});
	return false;
}
//-- END
//-- Funcion para el paginador de noticias relacionadas ----------------------------------------------------
function onPageTodayRelatedList()
{
	var page = $(this).attr('rel');			
	var target = $(this).parent().parent().parent().children('.content');
	var parentID = $(this).parent().attr('id');
	//alert(parentID)
	$.post("modules/getRelatedTodayNewsList.php", {next:page, related:parentID}, function($data){
		target.html($data);
	});
	var targetPaginador = $(this).parent().parent();
	$.post("modules/getRelatedTodayNewsListPaginator.php", {next:page, related:parentID}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageTodayRelatedList').click(onPageTodayRelatedList);
	});
	return false;
}
//-- END

//-- Funcion para el paginador de noticias relacionadas ----------------------------------------------------
function onPageSearchList()
{
	var page = $(this).attr('rel');			
	var target = $(this).parent().parent().parent().children('.content');
	var parentID = $(this).parent().attr('id');
	//alert(parentID)
	$.post("modules/getRelatedSearchList.php", {next:page, related:parentID}, function($data){
		target.html($data);
	});
	var targetPaginador = $(this).parent().parent();
	$.post("modules/getRelatedSearchListPaginator.php", {next:page, related:parentID}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageSearchList').click(onPageSearchList);
	});
	return false;
}
//-- END

//-- Funcion para el paginador de encuestas ----------------------------------------------------
function onPagePollsList()
{
	var page = $(this).attr('rel');			
	var target = $(this).parent().parent().parent().children('.content');
	var parentID = $(this).parent().attr('id');
	//alert(parentID)
	$.post("modules/getEncuestasList.php", {next:page, related:parentID}, function($data){
		target.html($data);
	});
	var targetPaginador = $(this).parent().parent();
	$.post("modules/getEncuestasListPaginator.php", {next:page, related:parentID}, function($data){
		targetPaginador.html($data);
		$('.pages a.pagePollsList').click(onPagePollsList);
	});
	return false;
}
//-- END

//-- Funcion para el historial de comentarios --------------------------------------------------------------
function onPageHistoryComments()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children('.content');
	$.post("modules/getCommentsHistory.php", {next:page}, function($data){
		target.html($data);
		//alert($data);
	});
	var targetPaginador = $("#paginador_comments");
	$.post("modules/getCommentsHistoryPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageHistoryComments').click(onPageHistoryComments);
	});
	return false;
}
//-- END

//-- Funcion para el historial de comentarios --------------------------------------------------------------
function onPageUnpublishComments()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children('.content');
	$.post("modules/getUnpublishComments.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#paginador_comments");
	$.post("modules/getUnpublishCommentsPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageUnpublishComments').click(onPageUnpublishComments);
	});
	return false;
}
//-- END

//-- Funcion para el paginador de comentarios de blog ------------------------------------------------------
function onPageJournalComments()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children().children('#comment_holder');
	$.post("modules/getJournalComments.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#paginador_journal");
	$.post("modules/getJournalCommentsPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pageJournalComments').click(onPageJournalComments);
	});
	return false;
}
//-- END

//-- Funcion para el paginador de comentarios de una seccion ------------------------------------------------------
function onPageSectionComments()
{
	var page = $(this).attr('rel');
	var target = $(this).parent().parent().parent().children('.content');
	$.post("modules/getSectionComments.php", {next:page}, function($data){
		target.html($data);
	});
	var targetPaginador = $("#sectionCommentsPager");
	$.post("modules/getSectionCommentsPaginator.php", {next:page}, function($data){
		targetPaginador.html($data);
		$('.pages a.pagesSectionComments').click(onPageSectionComments);
	});
	return false;
}
//-- END

//-- Funcion para los comnetarios ------------------------------------------------------------------------------
function reloadLoginBox()
{			
	var target = $("#right_registro");
	$.post("modules/divsLogin.php", 
		function($data)
		{
			target.html($data);
			$("#forgotPassword").click(initBtnForgotPassword);
			$("#registerMember").click(initBtnRegisterMember);
		}
	);
	return false;
}
function initBtnForgotPassword()
{
	var scope = $(this).parent().parent().parent().children(".content");
	$.post("backends/forgotPassword.php",{ var1: "foo" },
		function($data){
			scope.html($data);
	});
	return false;
}
function initBtnRegisterMember()
{
	var scope = $(this).parent().parent().parent().children(".content");
	$.post("backends/registerMember.php",{ var1:"foo"},
		function($data){
			scope.html($data);
		});
	return false;
}
//
// Esto es para las galerias
//
function refreshGaleriasUp()
{
	var target = $("#divGaleriaFotos");
	$.post("modules/fullGallerysAjax.php?order=up", 
		function($data)
		{
			target.html($data);
		}
	);
	return false;
}
function refreshGaleriasDown()
{
	var target = $("#divGaleriaFotos");
	$.post("modules/fullGallerysAjax.php?order=down", 
		function($data)
		{
			target.html($data);
		}
	);
	return false;
}
//
// Esto es para las imagenes de las galerias
//
function refreshGaleriaUp()
{
	var target = $("#divGaleriaFotos");
	$.post("modules/fullGalleryAjax.php?order=up",
		function($data)
		{
			target.html($data);
		}
	);
	return false;
}
function refreshGaleriaDown()
{
	var target = $("#divGaleriaFotos");
	$.post("modules/fullGalleryAjax.php?order=down",
		function($data)
		{
			target.html($data);
		}
	);
	return false;
}		

//]]>
 
/***************************************************
 - Funcion para los rollovers de las imagenes
 - Autor: Chowchow
***************************************************/
$(document).ready(function() {

	$(function() {
		$(".roll_overs a img").hover(function() {
		var defaultPath = $(this).attr("src");
			$(this).attr("src", defaultPath.substr(0,(defaultPath.length-6))+"_b.gif");
		}, function() {
		var defaultPath = $(this).attr("src");
			$(this).attr("src", defaultPath.substr(0,(defaultPath.length-6))+"_a.gif");
		});
	});

});
/***************************************************
 - Funcion para hacer refresh automatico en el widget de minuto a minuto
 - Autor: Fernando Torres
***************************************************/
$(document).ready(function() {

	if ( $("#widget_mam").length > 0 ) {
		var widgetScope = $("#widget_mam").children("#fondo").children().children();
		var refreshId = setInterval(function(){
     		widgetScope.fadeOut("slow").load('widgets/minuto_a_minuto_ajax_content.php').fadeIn("slow");
		}, 120000);
	}

	if ( $("#cronicle").length > 0 ) {
		var refreshId = setInterval(function(){
     		window.location.reload();
		}, 120000);
	}

	
});

/***************************************************
 - Funcion para videos relacionados
 - Autor: Chiban :D
***************************************************/
function submitVerMasVideos(pIdCategoria)
{
	var scope = $("#divGaleriaVideos");
	$.post("modules/searchVideoRelated.php", 'id_categoria='+pIdCategoria,
	function($data){
		scope.html($data);
		$('#gal_controls a.searchVideoRelated').click(onSearchVideoRelated);
	});
}
// -- Fin de la funcion para videos relacionados
//-- Funcion para los videos ------------------------------------------------------------------------------
function onSearchVideoRelated()
{
	var page = $(this).attr('rel');
	var target = $('#videoSearchHolder');
	$.post("modules/getVideoByRelated.php", {next:page}, function($data)
	{
		target.html($data);
		$('#gal_controls a.searchVideoRelated').click(onSearchVideo);
	});
	return false;
}
//-- END
