// JavaScript Document// JavaScript Document
var idInterval = new Array();
var imagesGallery = null;
var current = 0;
var currentSetting = null;

function _start(rel){
	imagesGallery = $('a[rel='+rel+']');
}

function _endRemove(elts, settings){
	for (int in idInterval )
		clearInterval(idInterval[int]);
		
}
function _endFillContent(elts, settings, callback){

}
function _endShowContent(elts, settings)
{
	currentSetting = settings;
	current = imagesGallery.index(settings.from);

	if( imagesGallery.length > 1 )
		idInterval.push( setInterval( next ,3000) );
	//$('#msg').html(imagesGallery.length);
}
function next(){
	if( current < imagesGallery.length -1 )
		$.nyroModalNext();
	else{
		imagesGallery.eq(0).nyroModalManual(currentSetting);
	}
	
	clearInterval(idInterval.pop());	
	currentSetting = null;
}
function startManual(id,mod){
	var	d = new Date();
    $.nyroModalManual({
      url: 'aspimagina/noticias/mod/galerias/winTopVideo.asp?id='+id+'&mod='+mod+'&date=' + d.getMilliseconds()
    });
    return false;
}
function startManualIndv(rel){
	$('a[rel='+rel+']').nyroModal({
				  debug:false,
				  endFillContent: _endFillContent,
				  endShowContent: _endShowContent,
				  endRemove: _endRemove,
				  bgColor: '#000000'
				  }
				 );
		_start(rel);
		return false;
}
//aspimagina/noticias/mod/galerias/winTopVideo.asp?id={379CD3BE-4976-4B6B-A46B-25E21CED7C48}&mod=galeriavideos
/*$( function() {
	$('a[rel=autoAmpliacion]').nyroModal({
				  debug:false,
				  endFillContent: _endFillContent,
				  endShowContent: _endShowContent,
				  endRemove: _endRemove,
				  bgColor: '#000000'
				  }
				 );
	_start('autoAmpliacion');		
});*/