

/* Script para los elementos desplegables. Thanks Orangeside!! http://www.orangeside.org */

function menuDOWN(prefijo,total,idNo){
	id=prefijo+idNo;
	//switchObj=document.getElementById(id).previousSibling.firstChild;
	switchObj=document.getElementById(id).previousSibling.childNodes[0];
	//alert(switchObj.nodeName);
//	switchObj=document.getElementById(id).parentNode.firstChild;
//	alert('switchObj.nodeValue='+switchObj.firstChild.nodeValue);
//	alert('switchObj.className = '+switchObj.className);
//	alert(document.getElementById(id).previousSibling.nodeName);

	if (window.getComputedStyle) { //leemos valor, solo Moz
  		if ( window.getComputedStyle(document.getElementById(id),null).display == 'none' ) {
	 		document.getElementById(id).style.display = 'block';//despliego
			switchOn(switchObj);
			allUP(prefijo,total,idNo);
		} else {
			document.getElementById(id).style.display = 'none';//pliego
			switchOff(switchObj);
		}
	} else if (document.getElementById(id).currentStyle.display) { //leemos valor, solo IE
 		if ( document.getElementById(id).currentStyle.display == 'none' ) {
			 document.getElementById(id).style.display = 'block';
			 switchOn(switchObj);
			 allUP(prefijo,total,idNo);
		} else {
			 document.getElementById(id).style.display = 'none';
			 switchOff(switchObj);
			 
		}

	} else {
 		if ( document.getElementById(id).style.display == 'none' ) {
			 document.getElementById(id).style.display = 'block';
			 switchOn(switchObj);
			 allUP(prefijo,total,idNo);
		} else {
			 document.getElementById(id).style.display = 'none';
			switchOff(switchObj);
		}	
	}
}

function allUP(prefijo,total,idNo) {
	for (var i=1; i <= total; i++){
		//alert(count+'-'+i+'-'+total);
		id=prefijo+i+'';
		//alert(idNo+'-'+i+'-'+total);
		if (i != idNo) {
			if (document.getElementById(id)){
			//pliego todos
				switchObj=document.getElementById(id).previousSibling.firstChild;
				document.getElementById(id).style.display = 'none';
				switchOff(switchObj);
			}
		}
	}
}

function allDOWN(prefijo) {
	var sufijo=1;
	while (sufijo<100){
		id=prefijo+sufijo;
		sufijo++;
		//alert(id);
		if (document.getElementById(id)){
			/*desplego todos*/
			if (window.getComputedStyle) { //leemos valor, solo Moz
				document.getElementById(id).style.display = 'block';
			} 
			else {
				document.getElementById(id).style.display = 'block';
			}
		}
		else{
			break;
		}
	}
}

function switchOff(switchObj) {
	switchObj.className='switchcontent_off';
	//switchObj.onmouseover=new Function("e", "switchObj.className='seccion_on'");
	//switchObj.onmouseout=new Function("switchObj.className='seccion_off'");
}

function switchOn(switchObj) {
	switchObj.className='switchcontent_on';
	//switchObj.onmouseover=new Function();
	//switchObj.onmouseout=new Function();
}

function blockOn(blockObj) {
	blockObj.className='blockcontent_on';
}

function blockOff(blockObj) {
	blockObj.className='blockcontent_off';
}

/* Scripts necesarios para el centrado de los menús desplegables al variar el tamaño de la ventana */

function repositionMenu() {
	var newLeft = getWindowWidth() / 2 + myOffset;
	myMenu.container.style ? myMenu.container.style.left = newLeft + "px" : myMenu.container.left = newLeft;
	}
		
function repositionMenu2() {
	var newLeft = getWindowWidth() / 2 + myOffset2;
	myMenu2.container.style ? myMenu2.container.style.left = newLeft + "px" : myMenu2.container.left = newLeft;
	}
		
function repositionMenu3() {
	var newLeft = getWindowWidth() / 2 + myOffset3;
	myMenu3.container.style ? myMenu3.container.style.left = newLeft + "px" : myMenu3.container.left = newLeft;
	}

function getWindowWidth() {return window.innerWidth ? window.innerWidth : document.body.offsetWidth;}