// JavaScript Document
function imggrande(objeto, imagen) {
	ppth=document.getElementById(objeto);
	thn=document.createElement('div');
	thn.className="thgrande";
	thn.style.top='10px';
	thn.style.left='14px';
	img=document.createElement('img');
	img.setAttribute('src', imagen);
	img.setAttribute('alt', 'imagen producto');
	mn = document.createElement('div');
	mn.className = 'thim';
	im = document.createElement('input');
	im.className='thim';
	im.setAttribute('type', 'image');
	im.setAttribute('src', 'img/minus.gif');
	im.onclick=function(){imgquitar()};
	thn.appendChild(im);
	thn.appendChild(img);
	ppth.appendChild(thn);
}

function imgquitar(objeto) {
	ppth.removeChild(thn);
}

// Abrir ventana
function Condiciones() {
	View = window.open("paginas/condiciones.htm", "Imagen", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=480,height=470");
}

function VerTipo() {
	obj = document.getElementById("busprod");
	if (obj.value == 0)
		return false;
		
	return true;
}

function AbrirCerrarOpcion(obj) {
	var objs, i, sel;
	sel = (obj.className == 'parentXSel')?true:false;
	if (obj.className == 'parentX' || obj.className == 'parentXSel') {
		objs = document.getElementsByName('menuIz');
		for (i=0; i<objs.length; i++) {
			if (objs[i].className == 'parentXSel') {
				CerrarOpcion( objs[i].id );
				objs[i].className = 'parentX';
			}
		}
	} if (!sel) {
	switch (obj.className) {
		case 'parentX':
			obj.className = 'parentXSel';
			AbrirOpcion( obj.id );
			break;
		case 'parentXSel':
			obj.className = 'parentX';
			CerrarOpcion( obj.id );
			break;
		case 'childC':
			obj.className = 'childCSel';
			AbrirOpcion( obj.id );
			break;
		case 'childCSel':
			obj.className = 'childC';
			CerrarOpcion( obj.id );
			break;
	}
	}
}

function AbrirOpcion( nombre ) {
	var i,objs;
	objs = document.getElementsByName( nombre );
	for (i=0; i<objs.length; i++) {
		objs[i].style.display = 'block';
	}
}

function CerrarOpcion( nombre ) {
	var i, objs;
	objs = document.getElementsByName( nombre );
	for (i=0; i<objs.length; i++) {
		CerrarOpcion( objs[i].id );
		objs[i].style.display = 'none';
		switch (objs[i].className) {
			case 'parentXSel':
				objs[i].className = 'parentX';
				break;
			case 'childCSel':
				objs[i].className = 'childC';
				break;
		}
	}
}

function MostrarOpciones( nombre ) {
	var obj, objpadre, objabuelo, padre, abuelo;
	if (!nombre=="") {
		obj = document.getElementById( nombre );
		// ahora vamos a ver si hay que buscar mas.
		padre = obj.getAttribute( "name" );
		objpadre = document.getElementById( padre );
		if (objpadre.className == "parentX") {
			AbrirCerrarOpcion( objpadre );
			Resalta( obj );
			AbrirCerrarOpcion( obj );
		} else {
			abuelo = objpadre.getAttribute( "name" );
			objabuelo = document.getElementById( abuelo );
			AbrirCerrarOpcion( objpadre );
			Resalta( objpadre );
			AbrirCerrarOpcion( objabuelo );
		}
	}
}

function Resalta( obj ) {
	switch (obj.className) {
		case 'childC':
			obj.className = 'childCSel';
			break;
	}
}