
function init() {
	images = $$('img');
	productmenu = $('productmenu').value;
	productmenu = "productmenu" + ((productmenu == '') ? "1" : productmenu);

	for(cont = 0; cont < images.length; cont++) {
		if (images[cont].getAttribute('over')) {
			if ( images[cont].id == productmenu ) {
				over(images[cont]);
			}
			else {
				if (images[cont].id == $('active').value) {
					over(images[cont]);
				}
				else {
					setRollover(images[cont]);
				}
			}
		}

	}

	celdas = $$('td')
	for(cont = 0; cont < celdas.length; cont++) {
		if (celdas[cont].getAttribute('over')) {
			celdas[cont].onmouseover = function() {
				overBg(this);
			}
			celdas[cont].onmouseout = function() {
				outBg(this);
			}
		}
	}
}

function setRollover(anImg) {
	anImg.onmouseover = function() {
		over(this);
	}
	anImg.onmouseout = function() {
		out(this);
	}
}

function noRollover(anImg) {
	anImg.onmouseover = function() {
	}
	anImg.onmouseout = function() {
	}
}

function validarMail(email) {
	if (email=="") return false;
	if (email.length < 5) return false;
	posArroba = email.indexOf("@", 0)
	if (posArroba <= 0) return false;
	posArroba2 = email.indexOf("@", posArroba+1)
	if (posArroba2 != -1) return false;
	posPunto = email.lastIndexOf(".");
	if (posPunto < 4) return false;
	if (posPunto == posArroba*1 + 1*1) return false;
	return true;
}

function splitName ( aFile ) {
	p = new Array("", "");
	a = aFile.split(".");
	for (i = 0; i < a.length - 2; i++)
		p[0] += a[i] + ".";
	p[0] += a[a.length - 2];
	p[1] = a[a.length - 1];
	return p;
}

function over(imagen){
	switchImg(imagen);
}

function switchImg(anImg) {
	q = splitName ( anImg.getAttribute("src") );
	c = q[0].substr(q[0].length - 3);

	if ( c == "_on") {
		anImg.setAttribute("src", q[0].substr(0, q[0].length - 3) + "." + q[1] );
	}
	else {
		anImg.setAttribute("src", q[0] + "_on." + q[1]);
	}
}

function out(imagen){
	switchImg(imagen);
}

function overBg(celda){
	celda.setAttribute("fichero", celda.getAttribute("background"));
	celda.setAttribute("background", celda.getAttribute("over"));
}

function outBg(celda){
	celda.setAttribute("background", celda.getAttribute("fichero"));
}

function dosDecimales(valor){
	var forma = new Array;
	valor = valor + "";
	forma = valor.split(".");
	return forma[0] + "." + padRight(forma[1], "0", 2);
}

function padRight(cadena, caracter, longitud){
	if (!cadena) cadena = "";
	while(cadena.length < longitud){
		cadena += caracter;
	}
	return cadena;
}

function padLeft(cadena, caracter, longitud){
	if (!cadena) cadena = "";
	while(cadena.length < longitud){
		cadena = caracter + caden;
	}
	return cadena;
}

var anterior = "";

function activalink(destino)
{
	nombre = destino;
	obj = eval("document.getElementById('"+nombre+"')");
	if (obj!=null)
	{
		obj.className=obj.className+"_on";
		if (anterior!="")
		{
			obj = eval("document.getElementById('"+anterior+"')");
			s = obj.className;
			s = s.replace(/_on/g,"");
			obj.className=s;
		}
		anterior = nombre;
	}
}

function activalinkImg(destino)
{
	if (destino != "")
		$('active').value = destino;
}

function actualizarMenuSeccion(destino,pos)
{
	if ((destino!=null) && (destino) && (destino!=""))
	{
		if (destino.indexOf("http://")<0)
		{
			parent.frames["contenidoframe"].location.href="print_contenido.aspx?contenido="+destino;
		}
		else
		{
			window.open(destino)
		}
	}
	activalink(destino)
}	

function actualizarMenuSeccionMas(destino,pos, args)
{
	if ((destino!=null) && (destino) && (destino!=""))
	{
		if (destino.indexOf("http://")<0)
		{
			parent.frames["contenidoframe"].location.href="print_contenido.aspx?contenido="+destino;
		}
		else
		{
			window.open(destino)
		}
	}
	activalink(destino)
}	

function actualizarMenuSeccionImg(destino)
{
	if ((destino!=null) && (destino) && (destino!="") && (destino != $('active').value))
	{
		if (destino.indexOf("http://")<0)
		{
			setRollover($($('active').value));
			out($($('active').value));
			$('active').value = destino;
			noRollover($(destino));
			parent.frames["contenidoframe"].location.href = "print_contenido.aspx?contenido="+destino;
		}
		else
		{
			window.open(destino);
		}
	}
	
}	