
ajax=new Ajax();
pag_orden=0;

function abrirVideoPortada(tipo)
{
	ajax.showModalURL('components/com_cortometrajes/ver_video.php?ruta='+tipo,600,400);
}

	this.showModalURL = function(url,ancho,alto){
		this.showModal('<iframe name="frame_ajax" width="'+ancho+'" height="'+alto+'" scrolling="no" src="'+url+'" frameborder="no"></iframe>');
	}

	function getScrollY(){
		var scrollY = 0;
		
		if ( document.documentElement && document.documentElement.scrollTop )		{
			scrollY = document.documentElement.scrollTop;
		}else if ( document.body && document.body.scrollTop ){
			scrollY = document.body.scrollTop;
		}else if ( window.pageYOffset ){
			scrollY = window.pageYOffset;
		}else if ( window.scrollY ){
			scrollY = window.scrollY;
		}
		
		return scrollY;
	}


function Ajax(){

// FUNCIONAMIENTO GENERAL (XML) /////////////////////////////////////////////

	// VARIABLES LOCALES /////////////////////

	var intentos=0;
	var self;
	var indicemodal=0;
	var indicetooltip=0;



	// VARIABLES LOCALES /////////////////////

	var label;
	var modal2Html = '';
	var tooltipTimeout;
	

	// PROPIEDADES ///////////////////////////
	
	this.hideTimeout = 2;
	this.errorTimeout = 5;


		// Ventana modal centrada
	this.showModal = function(html,estilo){
		indicemodal++;
		bgTrans();
		var idventana = '_ajax_modalcontent_'+this.id+'_'+indicemodal;
		
		if(!$(idventana))
		{
			
			var modalcontent = document.createElement('DIV');
			modalcontent.style.cssText = 'position:absolute; left: 0px; top: 0; width: 100%; height: 100%; z-index:'+((1000*indicemodal)+1)+';';
			modalcontent.id = idventana;
			document.body.appendChild(modalcontent);
//			visionCombos('hidden');
		}
		
		$(idventana).innerHTML = '<table border="0" width="100%" height="100%" align="center"><tr><td align="center"><div class="modalstyle'+(estilo?' '+estilo:'')+'">'+html+'</div></td></tr></table>';
		document.body.style.height = '100%'
		$(idventana).style.top = getScrollY() + 'px'

		/*if(document.all)
			document.body.style.overflow = 'hidden';
		else
			window.onscroll = function(){
				if($(idventana)){
					$(idventana).style.top = getScrollY();
				}
			}*/
	}
	
	
	// Ventana modal centrada que carga un iframe con el contenido url con ancho y alto
	this.showModalURL = function(url,ancho,alto){
		this.showModal('<iframe name="frame_ajax" width="'+ancho+'" height="'+alto+'" scrolling="no" src="'+url+'" frameborder="no"></iframe>');
	}	
	


	function bgTrans(){
		if(!$('_ajax_trans_'+self.id+'_'+indicemodal))
		{
			var modal = document.createElement('DIV');
			if(document.all)
				modal.style.filter = 'Alpha(Opacity=95)';
			else
				modal.style.MozOpacity='0.95';
			
				/*
				modal.style.backgroundColor = 'transparent'; 
				modal.style.backgroundImage = 'url(/images/px.gif)';
				modal.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader (src="/images/px.png", sizingMethod="scale")';
				*/

				/* modal.style.backgroundImage = 'url(/images/px.png)'; */
			
			//modal.style.backgroundColor = self.transBgColor;
			modal.style.position = 'absolute';
			//modal.style.height = (document.body.scrollHeight?document.body.scrollHeight:document.documentElement.scrollHeight)+'px';
			modal.style.height = '100%';
			modal.style.top = '0px';
			modal.style.left = '0px';
			modal.style.zIndex = 1000*indicemodal;
			modal.style.width = '100%';
			modal.className = 'ajax_trans';
			modal.id = '_ajax_trans_'+self.id+'_'+indicemodal;


			document.body.appendChild(modal);
			visionCombos('hidden');
		}
	}

	function visionCombos(opcion){
		if(document.all){
			if(indicemodal<=1)
				var arr = document.getElementsByTagName('select');
			else
				if($('_ajax_modal2_'+self.id+'_'+(indicemodal-1)))
					var arr = $('_ajax_modal2_'+self.id+'_'+(indicemodal-1)).getElementsByTagName('select');
				else
					if($('_ajax_modalcontent_'+self.id+'_'+(indicemodal-1)))
						var arr = $('_ajax_modalcontent_'+self.id+'_'+(indicemodal-1)).getElementsByTagName('select');

			for(i = 0; i < arr.length; i++)
				arr[i].style.visibility = opcion;
				
		}

		// También para flash
		if(document.all)
			var arr = document.getElementsByTagName('object');
		else
			var arr = document.getElementsByTagName('embed');
		
		for(i = 0; i < arr.length; i++)
			arr[i].style.visibility = opcion;
	}

	

	function $(id){return document.getElementById(id);}


	self = this;
}


function abrirventana(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}