function popitup(url, name, width, height, scrolling)
{
	newwindow=window.open(url,name,'width='+width+',height='+height+',toolbar=0,scrollbars='+scrolling+',location=0,statusbar=1,menubar=0,resizable=0,top=300,left=300');
	if (window.focus) {newwindow.focus()}
	return false;
}

function ICJ_browserWindowSize() {
		var r = new Array();
		r['width'] = 0;
		r['height'] = 0;
		if(typeof(window.innerWidth) == 'number' ) {
		//Non-IE
		r['width'] = window.innerWidth;
		r['height'] = window.innerHeight;
		}
		else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		r['width'] = document.documentElement.clientWidth;
		r['height'] = document.documentElement.clientHeight;
		}
		else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		r['width'] = document.body.clientWidth;
		r['height'] = document.body.clientHeight;
		}
		return r;
}

function FitPic() {
	var x,y;
	var ancho = document.getElementById('imagen').width;
	var alto = document.getElementById('imagen').height;
	window.resizeTo(ancho, alto);
	if (self.innerHeight)
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) 
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	while(ancho > x){
	
		if (self.innerHeight) 
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		window.resizeBy(+(ancho-x),+(alto-y));
		
	}
	posY=(Math.round(screen.height-(alto))/2);
	posX=(Math.round(screen.width-(ancho))/2);
		moveTo(posX,posY);
		focus();
}


function newwindow(url, name, width, height)
{
	newwindow=window.open(url,name,'width='+width+',height='+height+',toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,top=300,left=300');
	if (window.focus) {newwindow.focus()}
	return false;
}

function exists(v)
{
	return ( typeof(v) != "undefined" );
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function hideFlash()
{
	if (document.getElementById('flashMessage'))
		document.getElementById('flashMessage').style.display='none';
}

function num_imagenes(numero) {
	if (isNaN(numero))
		num = 0;

	for(x = 1; x <= 30; x++)
	{
		if ((obj = document.getElementById('adj_image_' + x)) != null)
			if(parseInt(numero) >= x)
				obj.style.display = '';
			else
				obj.style.display = 'none';
	}			
}

function num_ficheros(numero) {
	if (isNaN(numero))
		num = 0;

	for(x = 1; x <= 5; x++)
	{
		if ((obj = document.getElementById('adj_fichero_' + x)) != null)
			if(parseInt(numero) >= x)
				obj.style.display = '';
			else
				obj.style.display = 'none';
	}			
}

function num_preguntas(numero) {
	if (isNaN(numero))
		num = 0;

	for(x = 1; x <= 200; x++)
	{
		if ((obj = document.getElementById('adj_pregunta_' + x)) != null)
			if(parseInt(numero) >= x)
				obj.style.display = '';
			else
				obj.style.display = 'none';
	}			
}

function IsPopupBlocker() {	var oWin = window.open("","testpopupblocker","width=100,height=50,top=5000,left=5000");	if (oWin==null || typeof(oWin)=="undefined") {		return true;	} else {		oWin.close();		return false;	}}


var ventanaCalendario=false

function muestraCalendario(formulario_destino,campo_destino,mes_destino,ano_destino){
	//funcion para abrir una ventana con un calendario.
	//Se deben indicar los datos del formulario y campos que se desean editar con el calendario, es decir, los campos donde va la fecha.
	if (typeof ventanaCalendario.document == "object") {
		ventanaCalendario.close()
	}
	ventanaCalendario = window.open("/index.php/pages/calendario/?formulario=" + formulario_destino + "&nomcampo=" + campo_destino,"calendario","width=300,height=300,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO")
}

