$(document).ready(function(){
	
	$('INPUT[title]').focus(
		function() {
			var obj = $(this).get(0);
			if(obj.value == $(this).attr('title')) { obj.value = ''; }
		}
	)

	$('INPUT[title]').blur(
		function() {
			var obj = $(this).get(0);
			if(obj.value == '') { obj.value = $(this).attr('title'); }
		}
	)
	
	$(".GaleryContainer .ArticleFoto A[rel=galeria]").colorbox({photo:true});
	$(".LinkRecomendar").colorbox({iframe:true, innerWidth:300, innerHeight:250});
	$(".LinkNewsletter").colorbox({iframe:true, innerWidth:250, innerHeight:150});
	$(".Movie").colorbox({iframe:true, innerWidth:550, innerHeight:350});
	
	
	$('.artDetailExtraImages').click(function(){
		$("a[rel=galeria]").colorbox({open:true, photo:true});									  
	});
	
});

function fixDottedLinksOutline(domChunk) { $(domChunk).focus(function(){$(this).blur();});}

//----------------------
// FAQ
//----------------------
function SwitchFAQ(iQuestion) {
	$('.Question a').removeClass('selected');
	$('.Answer').each(function(){
		if(this!=$('#A' + iQuestion).get(0)) { $(this).hide('fast'); }					   
	});
	$('#Q' + iQuestion + ' a').addClass('selected');
	$('#A' + iQuestion).show('fast');
}


function onChangeFilterAgendaYear(iCategoryId) {
	
	var filter_year = $('#filter_year option:selected').attr('value');
	$('#filter_month').attr('disabled', 'disabled');
	$('#filter_day').attr('disabled', 'disabled');


	$.get("ajx.get_months.php", { filter_year:filter_year, iCatId:iCategoryId },
		function(data){
			$('#filter_month').html(data);
			$('#filter_month').removeAttr('disabled');
			onChangeFilterAgendaMonth(iCategoryId);
		}
	);
}

function onChangeFilterAgendaMonth(iCategoryId) {
	
	var filter_month = $('#filter_month option:selected').attr('value');
	$('#filter_day').attr('disabled', 'disabled');

	$.get("/ajx.get_days.php", { filter_month:filter_month, iCatId:iCategoryId },
		function(data){
			$('#filter_day').html(data);
			$('#filter_day').removeAttr('disabled');
		}
	);
}

function galleryShowMore(zID, maxPages, iLimit){
		
	var iNextOffset = iCurPage * iLimit;

	if(iCurPage < maxPages){
		$.get('/ajx.get_photos.php', { zID:zID, offset : iNextOffset}, function(data){ 
			var newContent = '<div id="new_page_content_' + iCurPage + '" style="display:none">' + data + '</div>';
		
			$('#GaleryContainer').append(newContent);
			$('#GaleryContainer').scrollTo('#new_page_content_' + iCurPage, 100, { onAfter:function() {
					$('#new_page_content_' + iCurPage).slideDown('slow');
			} });
			
			
			$(".GaleryContainer A[rel=galeria]").colorbox({photo:true});
			$gallery = $("a[rel='galeria']");
			$gallery.colorbox({onComplete: function(){
					previous = this;
				}, onOpen: function(){
					previous = this;
			}});
		
		});
	} 
	
	iCurPage++;
	if(iCurPage >= maxPages) $('#btn_show_more').hide();
	
	
	
	return; 
}
