// menu

/// PRECARGA IMG dreamweaver
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->


//over riga
function overRIGA ()
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className=='grid')
			{
				var trs=tables[i].getElementsByTagName('tr');
			
				
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						/*if(trs[j].className=='riga-a')
						{
							trs[j].onmouseover=function(){this.className='riga-o';return false}
							trs[j].onmouseout=function(){this.className='riga-a';return false}	
							trs[j].onclick=function(){this.className='riga-sel';return false}	
						}*/						
						/*if(trs[j].className=='riga-b')
						{
							trs[j].onmouseover=function(){this.className='riga-o';return false}
							trs[j].onmouseout=function(){this.className='riga-b';return false}
							trs[j].onclick=function(){this.className='riga-sel';return false}
						}*/	
						if(trs[j].className=='riga-a')
						{
							trs[j].onmouseover=function()
							{
								if (this.className!='riga-sel-a')
								{
									this.className='riga-o';
									return false
								}
							}
							trs[j].onmouseout=function()
							{
								if (this.className!='riga-sel-a')
								{								
									this.className='riga-a';
									return false
								}
							}
							/*
							trs[j].onclick=function()
							{
								if (this.className=='riga-sel-a')
								{								
									this.className='riga-a';
									return false
								}
								else 
								{
									this.className='riga-sel-a';
									return false
								}
							}
							*/
						}						
						if(trs[j].className=='riga-b')
						{
							trs[j].onmouseover=function()
							{
								if (this.className!='riga-sel-b')
								{
									this.className='riga-o';
									return false
								}
							}
							trs[j].onmouseout=function()
							{
								if (this.className!='riga-sel-b')
								{								
									this.className='riga-b';
									return false
								}
							}
							/*
							trs[j].onclick=function()
							{
								if (this.className=='riga-sel-b')
								{								
									this.className='riga-b';
									return false
								}
								else 
								{
									this.className='riga-sel-b';
									return false
								}
							}
							*/
						}	
					}
				}
			}
		}
	}
}
/*********************************/
//over CAMPO
function overINPUT()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('input');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
function overTEXTAREA()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('textarea');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
function overSELECT()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('select');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
/****************************/
/****************** ROLLOVER ****************/
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//over ITEM
function overITEM()
{
	if (document.getElementById && document.createTextNode)
	{
		var divs=document.getElementsByTagName('div');
		for (var i=0;i<divs.length;i++)
		{
			if(divs[i].className=='item')
			{
				divs[i].onmouseover=function(){
						this.className='item-o';
						return false
					}
				divs[i].onmouseout=function(){
						this.className='item';
						return false
					}		
			}
		}
	}
}

// CAMBIO IMAGE
function swapPhoto(imgID, photoSRC, alto, largo) {
	//document.getElementById(nombreImg).src = "foto/" + photoSRC02;
	document.getElementById(imgID).src = photoSRC;
	document.getElementById(imgID).height = alto;
	if (largo == null)
	{
		document.getElementById(imgID).width = '370';
	}
	else
	{
		document.getElementById(imgID).width = largo;
	}
}
/*******/

/**********************************/
/******* MENU **********/

function buttonOpen(id) {

	but = document.getElementById(id);
	cnt = document.getElementById(id+'-cnt');

	// check open function
	onop = but.getAttribute('kn_onopen');
	var op_exist = false;
	if (onop) eval('if (window.'+onop+') op_exist = true;');
	
	// open button
	//if (cnt) cnt.className = 'open';
	but.className = 'open';
}


function buttonClose(id) {

        but = document.getElementById(id);
        cnt = document.getElementById(id+'-cnt');

        // check close function
        oncl = but.getAttribute('kn_onclose');
        var cl_exist = false;
        if (oncl) eval('if (window.'+oncl+') cl_exist = true;');

        // close button
		//if (cnt) cnt.className = 'close';
        but.className = 'close';

}


function press_button(id) {

	but = document.getElementById(id);
	cnt = document.getElementById(id+'-cnt');

	if (but.className == 'open') {			// close
		
		buttonClose(id);

	} else if (but.className == 'close') {		// open
		
		// reload every time the button is opened?
		var rl = parseInt(but.getAttribute("kn_reload"));
		var lo = parseInt(but.getAttribute("kn_loaded"));

		if (rl == 0) {					// fixed content

			buttonOpen(id);

		} else if (rl == 1) {

			buttonOpen(id);

		} else if (rl == 2) {				// load at first button open

			buttonIsLoading(id);

			if (lo == 0) {
				but.setAttribute('kn_loaded',1);	
			}

			buttonOpen(id);

		} else if (rl == 3) {				// reload every time is opened
			
			buttonIsLoading(id);
			buttonOpen(id);
		}

	} else return;
}

//
/**********************************/
function swichINFO(id, button){
	if (window.getComputedStyle) { //read value, only Moz
  	if ( window.getComputedStyle(document.getElementById(id),null).display == 'none' ) {
	 		document.getElementById(id).style.display = 'table';
			bt = document.getElementById(button);
			bt.className = 'link-ico closeInfo';
		} else {
			document.getElementById(id).style.display = 'none';
			bt = document.getElementById(button);
			bt.className = 'link-ico openInfo';			
		}
	} else { //read value, only IE
 		if ( document.getElementById(id).currentStyle.display == 'none' ) {
			document.getElementById(id).style.display = 'block';
			bt = document.getElementById(button);
			bt.className = 'link-ico closeInfo';			
		} else {
			document.getElementById(id).style.display = 'none';
			bt = document.getElementById(button);
			bt.className = 'link-ico openInfo';	
		}

	}
	
}
/////
// POPUP
function openPOPUP(url,largo,alto){
	var nome_finestra="foto";
	var folder='';	
	ventana=window.open(folder+url,nome_finestra,'width='+largo+',height='+alto+',left=300,top=100,statusbar=yes,resizable=yes,scrollbars=yes');  
	//Asigna la ventana que se abre a la variable hola para poder manejarla en otros eventos
	ventana.focus()   //Hace que la ventana que se abre sea la activa (lleva el foco)
}

function overEvents ()
{
	//overITEM();
	initRollovers();
	overRIGA();
	overINPUT();
	overSELECT();
	overTEXTAREA();
	//overMENU();
}
// PARA LINKAR MAILS SIN QUE LOS RASTREEN ROBOTS
function mailnobot(nm,dm)
{
   mailurl = "mailto:" + nm + "@" + dm;
   window.location = mailurl;
}
/*******/
window.onload=function()
{
	overEvents();
} 


