// JavaScript Document
<!--
function setPointer(theRow, thePointerColor)
{
	thePointerColor = "url("+thePointerColor+")";
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundImage = thePointerColor;
    }

    return true;
}
// ---------------------------- 
function cambiarImagen(){
	img = arguments[0];
	var imagen = img.src.substr(img.src.lastIndexOf("/"));
	if(imagen.indexOf("menos") != -1){
		img.src = img.src.substr(0,img.src.lastIndexOf("/"))+"/mas.gif";
	}else{
		img.src = img.src.substr(0,img.src.lastIndexOf("/"))+"/menos.gif";
	}
}
function setBrowser()
{
	if (document.all)
	{
		isIE4 = true;isNav6 = true;
	}
	else if (document.layers)
	{
		isNav4 = true
	}
	else if (document.getElementById)
	{
		isNav6 = true
	}
}

function getElementById( strId )
{
setBrowser();
    if (isNav6)
    {
        return document.getElementById( strId );
    }
    else if (isIE4)
    {
        return document.all[strId]
    }
    else
	{
		return null
	}
}
function getElementObject( element )
{
setBrowser();
	var oElement = null;
	
	// get the element
	if (typeof element == "object")
	{
		oElement = element;
	}
	else if (typeof element == "string")
	{
		oElement = getElementById( element );
	}
	return oElement;	
}
function getStyleBySelector( selector )
{
setBrowser();
    if (!isNav6)
    {
        return null;
    }
    var sheetList = document.styleSheets;
    var ruleList;
    var i, j;

    /* look through stylesheets in reverse order that
       they appear in the document */
    for (i=sheetList.length-1; i >= 0; i--)
    {
        ruleList = sheetList[i].cssRules;
        for (j=0; j<ruleList.length; j++)
        {
            if (ruleList[j].type == CSSRule.STYLE_RULE && ruleList[j].selectorText == selector)
            {
                return ruleList[j].style;
            }   
        }
    }
    return null;
}
function getStylePropertyById( strId, strProperty )
{
setBrowser();
    if (isNav6)
    {
        var styleObject = document.getElementById( strId );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            if (styleObject[strProperty])
            {
                return styleObject[ strProperty ];
            }
        }
        styleObject = getStyleBySelector( "#" + strId );
        return (styleObject != null) ?
            styleObject[strProperty] :
            null;
    }
    else if (isIE4)
    {
        return document.all[strId].style[strProperty];
    }
    else
	{
		return ""
	}
}
function setStylePropertyById( strId, strProperty, strValue )
{
setBrowser();
    if (isNav6)
    {
        var styleObject = document.getElementById( strId );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ strProperty ] = strValue;
        }
    }
    else if (isIE4)
    {
		if (document.all[strId] != null)
			document.all[strId].style[strProperty] = strValue;
    }
    else
	{}	//so Nav4 won't return error
}
function setStylePropertyByElement( oElement, strProperty, strValue )
{
setBrowser();
    if (isNav6)
    {
        var styleObject = oElement;
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ strProperty ] = strValue;
        }
    }
    else if (isIE4)
    {
		if (oElement != null)
			oElement.style[strProperty] = strValue;
    }
    else
	{}	//so Nav4 won't return error
}
function toggleElementDisplay( element, strStyle )
{
setBrowser();
	// strStyle = (none,block,inline)
	var strID
	
	//get the element id
	if (typeof element == "object")
	{
		strID = element.id	
	}
	else if (typeof element == "string")
	{
		strID = element
	}
	if ((strID != "") && (strID != null)){
		if ( getStylePropertyById( strID,'display')=='none' ){
			setStylePropertyById( strID, 'display', strStyle ) //show the element
				
		}else{
			setStylePropertyById( strID, 'display', 'none' ) //hide the element
		}
	}
}


/********************************************************************************/


//Esta funcion trabaja con retardo de tiempo
function toggleLayer( element, strStyle )
{
	setBrowser();
	// strStyle = (none,block,inline)
	var strID
	
	//get the element id
	if (typeof element == "object")
	{
		strID = element.id	
	}
	else if (typeof element == "string")
	{
		strID = element
	}
	if ((strID != "") && (strID != null)){
		if ( getStylePropertyById( strID,'display')=='none' ){
			//document.write("valor de empezar:" + empezar);
			if (empezar){
				
				clearTimeout(retardo)
				setStylePropertyById( strID, 'display', strStyle ) //show the element
			} 	
		}else{
			//document.write("valor de empezar:" + empezar);
			if (empezar){
				clearTimeout(retardo)
				//retardo = setTimeout("xHide('" + ocultar + "')",1000)
				retardo = setTimeout("setStylePropertyById( " + strID + ", 'display', 'none' )",1000) //hide the element
			}
		}
		
	}
}
/********************************************************************************/

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];}}
}
//-->

function obtenerAction(formulario, funcion, pagina){	
	var var_post;
	
	if(pagina.indexOf('?') == -1){
		var_post="?";
		agregar_asper=false;
	}else{
		var_post="";
		agregar_asper=true;
	}

	for (var i = 0; i < formulario.elements.length; i++){
		if (formulario.elements[i].value != "" && formulario.elements[i].type!="submit" && formulario.elements[i].type!='reset' && formulario.elements[i].type!='button') {  
			elemento=formulario.elements[i];
			if(agregar_asper){
				var_post= var_post + "&"+ elemento.name+"="+elemento.value;	
			}else{
				var_post= var_post + elemento.name+"="+elemento.value;	
				agregar_asper=true;
			}
			
		}
	}
	
	
	//alert("javascript:"+funcion+"('"+pagina+var_post+"')");
	formulario.action="javascript:"+funcion+"('"+pagina+var_post+"')";//('seccion.php"+var_post+"')";
	
	//alert(formulario.action);
	return true;

}


function enviarPost(formulario, funcion, pagina){	
	var var_post="";
	var e;

	for (var i = 0; i < formulario.elements.length; i++){
		if (formulario.elements[i].value != "" && formulario.elements[i].type!="submit" && formulario.elements[i].type!='reset' && formulario.elements[i].type!='button') {  
			elemento=formulario.elements[i];

			e = elemento.name+"="+elemento.value;	

			if(var_post!=""){
				var_post= var_post + "&"+ e;
			}else{
				var_post= var_post + e;
			}
			
		}
	}
	
	//alert("javascript:"+funcion+"('"+pagina+"',"+"'"+var_post+"')");
	formulario.action="javascript:"+funcion+"('"+pagina+"','"+var_post+"')";
	
	return true;

}
function validarDatosRegistro(formulario){
	if(formulario.nombre.value==""){
	  alert("Por favor ingrese su nombre"); 
	  formulario.nombre.focus();
	  return false;
	}else if(formulario.apellido.value==""){
	  alert("Por favor ingrese su apellido"); 
	  formulario.apellido.focus();
	  return false;
	}else if(formulario.login.value==""){
	  alert("Por favor ingrese su usuario"); 
	  formulario.login.focus();
	  return false;
	}else if(formulario.password.value==""){
	  alert("Por favor ingrese su password"); 
	  formulario.password.focus();
	  return false;
	}else if(formulario.rpassword.value==""){
	  alert("Por favor reingrese su password"); 
	  formulario.rpassword.focus();
	  return false;
	}else if(formulario.email.value==""){
	  alert("Por favor ingrese su email"); 
	  formulario.email.focus();
	  return false;
	}else if(formulario.remail.value==""){
	  alert("Por favor reingrese su email"); 
	  formulario.remail.focus();
	  return false;
	}else if(formulario.nro_casa.value==""){
	  alert("Por favor ingrese el numero de su casa"); 
	  formulario.nro_casa.focus();
	  return false;
	}else if(formulario.calle.value==""){
	  alert("Por favor ingrese su calle"); 
	  formulario.calle.focus();
	  return false;
	
	}else if(formulario.ciudad.value==""){
	  alert("Por favor ingrese su ciudad"); 
	  formulario.ciudad.focus();
	  return false;
	}else if(formulario.provincia.value==""){
	  alert("Por favor ingrese su provincia"); 
	  formulario.provincia.focus();
	  return false;
	}else if(formulario.pais.value==""){
	  alert("Por favor ingrese su pais"); 
	  formulario.pais.focus();
	  return false;
	}else if(formulario.cp.value==""){
	  alert("Por favor ingrese su codigo postal"); 
	  formulario.cp.focus();
	  return false;	
	}else if(formulario.telefono.value==""){
	  alert("Por favor ingrese su telefono"); 
	  formulario.telefono.focus();
	  return false;
   	}else if(formulario.acepto.checked==false){
	  alert("Debe aceptar los terminos y condiciones "); 
	  formulario.acepto.focus();
	  return false;
   	}
	
}

/*********************************************************************/
/*
function cargar_datos(targ,selObj,restaurar){ 
  
  eval(selObj.options[selObj.selectedIndex].value);
  if (restaurar) selObj.selectedIndex=0;
}
*/
function cargar_datos(selObj,form,funcion,restaurar){ 
  
  pagina=selObj.options[selObj.selectedIndex].value;
  if(pagina.indexOf('?') == -1){
	 pagina+="?";
  }else{
  	pagina+="&";
  }
  
  request_url=obtenerDatosFormRegistro(form);
  
  func_ejecutar=funcion+"('"+pagina+request_url+"')";
  
  eval(func_ejecutar); 
  
  if (restaurar) selObj.selectedIndex=0;
}

function obtenerDatosFormRegistro(formulario){	
	var var_post;
	var elemento;
	var request_url="";
	var agregar_asper=false;
	
	for (var i = 0; i < formulario.elements.length; i++){
		
		if (formulario.elements[i].value != "" && formulario.elements[i].value !="NULL"  && formulario.elements[i].type!="submit" && formulario.elements[i].type!='reset' && formulario.elements[i].type!='button' && formulario.elements[i].type!='hidden' &&  formulario.elements[i].name != "paises" && formulario.elements[i].name != "estados") {  
			elemento=formulario.elements[i];
			if(agregar_asper){
				request_url= request_url + "&"+ elemento.name+"="+elemento.value;	
			}else{
				request_url= request_url + elemento.name+"="+elemento.value;	
				agregar_asper=true;
			}
			
		}
	}
	
	return request_url;

}

/*************************************************************************/
function colocarCosto(texto,total){
	
	var valor=String(texto);
	var valores;
	var inicio=valor.indexOf('_');
	var fin=valor.length-1;
	//alert(valor+"  "+fin);
	valores = valor.split('_');
	costo=valores[1];	
	//alert(costo);
	
	parseFloat(total);
	parseFloat(costo);
	
	document.getElementById('costo_envio').innerHTML=costo;
	document.getElementById('costo_total').innerHTML=eval(total+ "+" + costo);
		
		
		
	

}