function addEvent(elm, evType, fn, useCapture)
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("No se puede acceder al evento");
  }
} 
addEvent(window, "load", informacion_ini);
addEvent(window, "load", botones_ini);
addEvent(window, "load", tarjeta_ini);



function tarjeta_ini()
{
	validarBrowser();
	
	losdivs = f_getElementsByClassName (document , "img" , "ver_tarjeta") 
	for(i=0; i<losdivs.length; i++) { losdivs[i].onclick = function () { ver_tarjeta(this); }  }

	losdivs = f_getElementsByClassName (document , "img" , "imagen_tarjeta_oculta") 
	for(iii=0; iii<losdivs.length; iii++) { losdivs[iii].onclick = function () { cerrar_tarjeta(this); }  }

}


function ver_tarjeta(este)
{ 
	if (document.getElementById){}else{ return true };
//	alert(estacapa.id);
	lacapa = f_getElementsByClassName (document , "img" , "imagen_tarjeta_oculta") 
	estacapa = lacapa ;
	if( lacapa.length>0 ) 
	{

		var subobj = lacapa[0] ; 

		subobj.style.display=(subobj.style.display!="block")? "block" : "none"		
		var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)
		var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 
		xpos = xpos-200; 
		ypos = ypos-150;
		subobj.style.left=xpos+"px";
		subobj.style.top=ypos+"px" ;
		return false
	}
	else	{ return true;	}	
}


function cerrar_tarjeta()
{
	losdivs = f_getElementsByClassName (document , "img" , "imagen_tarjeta_oculta") 
	for(i=0; i<losdivs.length; i++){losdivs[i].style.display="none";}	
}




function botones_ini()
{
	loschecks = f_getElementsByClassName (document , "div" , "boton_azul") ;
	if(loschecks.length>0)
	{
		for(ii=0; ii<loschecks.length; ii++) 
		{
			tbls = loschecks[ii].getElementsByTagName("button");
	 		for(hj=0; hj<tbls.length; hj++) 
				{
					 tbls[hj].onmouseover = function () { boton_over(this); }  
					 tbls[hj].onmouseout = function () { boton_out(this); }  
				}
		}
	}
	
	loschecks2 = f_getElementsByClassName (document , "div" , "boton_gris") ;
	if(loschecks2.length>0)
	{
		for(hh=0; hh<loschecks2.length; hh++) 
		{
			tbls = loschecks2[hh].getElementsByTagName("button");
	 		for(fhj=0; fhj<tbls.length; fhj++) 
				{
					 tbls[fhj].onmouseover = function () { boton_gris_over(this); }  
					 tbls[fhj].onmouseout = function () { boton_gris_out(this); }  
				}
		}
	}
	
	loschecks3 = f_getElementsByClassName (document , "input" , "boton_modificar") ;
	if(loschecks3.length>0)
	{
		for(hhh=0; hhh<loschecks3.length; hhh++) 
		{
			 loschecks3[hhh].onmouseover = function () { boton_modificar_over(this); }  
			 loschecks3[hhh].onmouseout = function () { boton_modificar_out(this); }  
		}
	}
}

//
function boton_gris_over(este){este.style.backgroundColor= "#2c6bbb" ;este.style.color= "#FFFFFF" ; }
function boton_gris_out(este){este.style.backgroundColor= "#e7e7e7" ;este.style.color= "#2c6bbb" ;}


function boton_modificar_over(este){este.style.textDecoration= "underline" ;}
function boton_modificar_out(este){este.style.textDecoration= "none" ;}


function boton_over(este){este.style.backgroundPosition= "bottom left" ;}
function boton_out(este){	este.style.backgroundPosition= "top left" ;}


function informacion_ini()
{
	validarBrowser();
	loschecks = f_getElementsByClassName (document , "a" , "a_detalle_producto") ;
	if(loschecks.length>0)
	{
		for(ii=0; ii<loschecks.length; ii++) 
		{

			loschecks[ii].onclick = function () { verdetalle(this); }  
			loschecks[ii].href="javascript:void(null)" ;
		}
	}
}


function verdetalle(este)
{
	
	//ver_detalle_off();
	contenedor = e_getParent( este , "tr" ) ;
	contenedort = e_getParent( este , "table" ) ;
	
	

	for (i=0;i<contenedort.rows.length;i++)	
	{
		if(contenedort.rows[i] == contenedor )
		{

			nnn = i+1;
			if(contenedort.rows[nnn])
			{
			if(contenedort.rows[nnn].className=="detalle_producto_oculto")
			{
				if(este.className == "a_detalle_producto")
				{
	 				
					if(brw=="NN"){contenedort.rows[nnn].style.display = "table-row" ;}
					else{contenedort.rows[nnn].style.display = "block" ;}
					este.className = "a_detalle_producto_on" ;
				}
				else 
				{
					contenedort.rows[nnn].style.display = "none" ;
					este.className = "a_detalle_producto";
				}
			}
			}
		}
	}
}//


function ver_detalle_off()
{
	losdivs = f_getElementsByClassName (document , "a" , "a_detalle_producto") ;
	for(i=0; i<losdivs.length; i++) 
	{
		losdivs[i].style.display="none";
	}
}


function f_getElementsByClassName(ele, eltag, strClassName)
{
	var arrElements = (eltag == "*" && ele.all)? ele.all : ele.getElementsByTagName(eltag);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for ( var i=0; i<arrElements.length; i++ ) { oElement = arrElements[i];if(oRegExp.test(oElement.className)){arrReturnElements.push(oElement);}}
	return (arrReturnElements)
}


function e_getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	
		return el;
	else
		return e_getParent(el.parentNode, pTagName);
}


var brw="";
function validarBrowser(){
  if(document.getElementById)
  {
	if(navigator.appName == "Netscape")		brw='NN';
	else if(navigator.appName == "Microsoft Internet Explorer")
		{
		if(navigator.appVersion.indexOf("MSIE 5.0"))
			brw='IE5.0';
		else
			brw='IE';
		}
	return true;
  }
  else	
	return false;
}



function getposOffset(overlay, offsettype)
{
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null)
	{
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
return totaloffset;
}



function ver_popup_condiciones(cual)
{
	ventana1 = window.open(cual , 'popup_condiciones' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=yes , resizable=no , '+centerPositionString(701,400) ) ;
	ventana1.focus();
}



function ver_popup_visualizar(cual)
{
	ventana2 = window.open(cual , 'popup_visualizar' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no ,'+centerPositionString(800,590)) ;
	ventana2.focus();
}



function ver_popup_proyectar(cual)
{
	ventana3 = window.open(cual , 'popup_proyectar' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no , '+centerPositionString(1016,690)) ;
	ventana3.focus();
}


function ver_popup_foto(cual)
{
	ventana4 = window.open(cual , 'popup_foto' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no , '+centerPositionString(745,625)) ;
	ventana4.focus();
}




function ver_popup_video(cual)
{
	ventana5 = window.open(cual , 'popup_video' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no , '+centerPositionString(685,376)) ;
	ventana5.focus();
}


function ver_popup_audio(cual)
{
	ventana6 = window.open(cual , 'popup_audio' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no , '+centerPositionString(683,277)) ;
	ventana6.focus();
}


function recordar_contrasena(cual)
{
	ventana7 = window.open(cual , 'recordar_contrasena' , ' toolbar=no , location=no , statusbar=no ,  menubar=no , scrollbars=no , resizable=no , '+centerPositionString(683,220)) ;
	ventana7.focus();
}

function centerPositionString(width,height){
	return 'left='+((screen.width-width)/2)+' ,top='+((screen.height-height)/2)+' , width='+width+'  , height='+height;
}








