//<![CDATA[	

/************************************************************************/
/*       					WEB CINUR		  							*/
/*						Fichero: funciones.js 				            */
/* 				Ultima actualización: 12 de julio de 2006 			    */
/************************************************************************/


var bConfirmacion = true;
var popUpWin=0;
var popUpWinEdicion = 0;

function popUpWindow(URLStr, left, top, width, height)
{
	if(popUpWin)
	{
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpWindowEdicion(URLStr)
{
	var left = (screen.width - 720)/2;
	var top = (screen.height - 620)/2;
	var width = 720;
	var height = 620;
	if(popUpWinEdicion)
	{
		if(!popUpWinEdicion.closed) popUpWinEdicion.close();
	}
	popUpWinEdicion = open(URLStr, 'popUpWinEdicion', 'toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function nothing() {}


/* Carga de página */

function parentGoto(page)
{
	window.parent.location.href = page;
}

function Goto(page)
{
	window.location.href = page;
}





function confirmar(sTexto)
{
	bConfirmacion = confirm(sTexto);
}


/* AMPLIACION Cambio de Class */
function updateClassName(Elemento, class1, class2)
{
	if(Element.hasClassName(Elemento, class1))
		Element.classNames(Elemento).set(class2);
	else
		Element.classNames(Elemento).set(class1);
}

function changeAllClassName(classname, oldclass)
{
	var allNodes = document.getElementsByClassName(classname);
	for(i = 0; i < allNodes.length; i++)
	{
		Element.classNames(allNodes[i]).set(oldclass);
	}
}

function changeClassName(oLink, newclass, oldclass)
{
	changeAllClassName(newclass, oldclass)
	oLink.className = newclass;
}

function cambiaEstilo(enlace, op)
{
	for ( var count = 0 ; count < document.links.length; count++ ) 
	{
		if (document.links[count].className == "enlace3activo")
			document.links[count].className = "enlace3";
		if (document.links[count].className == "enlace4activo")
			document.links[count].className = "enlace4";
	} 
	
	switch (op)
	{
		case 4:	enlace.className = "enlace3activo";
			break;
		case 3:	default: enlace.className = "enlace3activo";
			break;
	}
}



/* CALCULO HIPOTECA */
function calc(hipoteca, plazo, interes, anual){
	var hipo=parseInt(hipoteca);
	var plaz=parseInt(plazo);
	var inte=parseFloat(interes);
	var y;
	var cuot;
	var mensualidad;

	if (anual)
	{
		plaz = plaz * 12;
	}
	if (hipoteca.length!=0 && plazo.length!=0 && interes.length!=0)
	{
		inte=inte/1200.0;
		y=1.0 + inte;
		cuot=hipo*inte*Math.pow(y,plaz)/(Math.pow(y,plaz)-1.0);
		cuot = cuot*100;
		cuot = Math.round(cuot);
		cuot = cuot / 100;
		mensualidad = cuot;
	}
	else
	{
		mensualidad = 0;
	}
	if(mensualidad == 0)
		mensualidad = "";
		
	return mensualidad;
}

function puntua()
{
	if (event.keyCode == 44)
	{
		event.returnValue = event.keyCode = 46;
	}
}




/* FUNCIONES AJAX */
/* Usando Prototype */

function getHTML(url, pars, placeholder)
{
	var myAjax = new Ajax.Updater(placeholder, url, { method: 'get', parameters: pars });
	//alert($(placeholder).innerHTML);
}


	//]]>

