<!--
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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function seleccionar_marcas_buscador(id_cats,id_marcas) {
	mostrar_cartel_cargando();
	var cad='funcAjax.php?modo=SMB&cats='+document.getElementById(id_cats).options[document.getElementById(id_cats).selectedIndex].value+'&marcas='+document.getElementById(id_marcas).options[document.getElementById(id_marcas).selectedIndex].value+'&id_marcas='+id_marcas;
	parse_xmlhttp(cad);
}

function seleccionar_categorias_buscador(id_cats,id_marcas) {
	mostrar_cartel_cargando();
	var cad='funcAjax.php?modo=SCB&cats='+document.getElementById(id_cats).options[document.getElementById(id_cats).selectedIndex].value+'&marcas='+document.getElementById(id_marcas).options[document.getElementById(id_marcas).selectedIndex].value+'&id_cats='+id_cats;
	parse_xmlhttp(cad);
}

function cargar_pantalla(script,metodo,param) {
	mostrar_cartel_cargando();
	var provis=document.getElementById('columnaMedio').innerHTML;
	var salida='';
	objAjax=get_xmlhttp();
	objAjax.open(metodo,script,true);
	objAjax.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
	objAjax.onreadystatechange=function() {
		if (objAjax.readyState==4) {
			if(objAjax.status==200) {
				result=objAjax.responseText;
				salida=result;
			} else {
				alert('Hubo un problema con la lectura de los datos. Por favor vuelva a intentarlo.');
				salida=provis;
			}
			borrar_cartel_cargando('columnaMedio');
			if(script.indexOf('carrito_',script)==-1) {
				mostrar_bloque_carrito();
			} else {
				borrar_bloque_carrito();
			}
		}
		document.getElementById('columnaMedio').innerHTML=salida;
	}
	objAjax.send(param);
	if(script=='carrito_paso_1.php') {
		setTimeout("cargar_div('carrito_costos_envio.php','bloque_costos_envio')", 1000);
	}
}

function getForm(obj) {
	var getstr = "?";
	for (i=0; i<obj.length; i++) {
		if (obj.elements[i].tagName == "INPUT") {
			if (obj.elements[i].type == "text" || obj.elements[i].type == "password" || obj.elements[i].type == "hidden") {
				getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
			}
			if (obj.elements[i].type == "checkbox") {
				if (obj.elements[i].checked) {
	  				getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
				} else {
					getstr += obj.elements[i].name + "=&";
				}
			}
			if (obj.elements[i].type == "radio") {
				if (obj.elements[i].checked) {
					getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
				}
			}
		}
		if (obj.elements[i].tagName == "TEXTAREA") {
			getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
		}   
		if (obj.elements[i].tagName == "SELECT") {
			var sel = obj.elements[i];
			getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
		}
	}
	return getstr;
}

function form_contacto() {
	var params=getForm(document.getElementById('frmContacto'));
	cargar_pantalla('parse_webform_ajax.php'+params,'GET',null);
}

function form_lista_de_precios() {
	var params=getForm(document.getElementById('frmLista'));
	cargar_pantalla('lista_de_precios_resultado.php'+params,'GET',null);
}

function form_lista_de_precios_ordenada() {
	var params=getForm(document.getElementById('ordenProductos'));
	cargar_pantalla('lista_de_precios_resultado.php'+params,'GET',null);
}

function form_vidriera_productos() {
	var params=getForm(document.getElementById('ordenProductos'));
	cargar_pantalla('productos.php'+params,'GET',null);
}

function form_vidriera_ofertas() {
	var params=getForm(document.getElementById('ordenProductos'));
	cargar_pantalla('ofertas.php'+params,'GET',null);
}

function form_actualizar_cliente() {
	var params=getForm(document.getElementById('formCliente'));
	cargar_pantalla('parse_actualizar_cliente.php'+params,'GET',null);
}

function form_cambiar_password() {
	var params=getForm(document.getElementById('formPassword'));
	cargar_pantalla('parse_cambiar_password.php'+params,'GET',null);
}

function form_leer_compras() {
	var params=getForm(document.getElementById('formFechas'));
	cargar_pantalla('parse_mis_compras.php'+params,'GET',null);
}

function form_buscador() {
	var params=getForm(document.getElementById('frmBuscSup'));
	cargar_pantalla('buscador_resultado.php'+params,'GET',null);
}

function form_buscador_ordenado() {
	var params=getForm(document.getElementById('ordenProductos'));
	cargar_pantalla('buscador_resultado.php'+params,'GET',null);
}

function carrito_paso_1() {
	cargar_pantalla('carrito_paso_1.php','GET',null);
}

function carrito_paso_2() {
	var params=getForm(document.getElementById('frmCarrito'));
	cargar_pantalla('carrito_paso_2.php'+params,'GET',null);
}

function carrito_paso_2_5() {
	document.getElementById('confirmar').style.display='none';
	cargar_pantalla('carrito_paso_2.5.php','GET',null);
	setTimeout("cargar_pantalla('carrito_paso_3.php','GET',null)", 1000);
}

function abrir_pedido(id_pedido) {
	window.open('pedido_detalle.php?id='+id_pedido,'pedido','width=600,height=400,scrollbars=yes,directories=no,location=no,menubar=no,status=no,toolbar=no');
}

function obtener_valor_select(id_select) {
	return document.getElementById(id_select).options[document.getElementById(id_select).selectedIndex].value;
}

function habilitar_objetos(id_check,id_objs) {
	var ch=document.getElementById(id_check);
	for(var x=0;x<id_objs.length;x++) {
		var tx=document.getElementById(id_objs[x]);
		if(!ch.checked) {
			tx.disabled=true;
		} else {
			tx.disabled=false;
		}
	}
}

function verif_habilitacion($id_check,id_obj) {
	var ch=document.getElementById(id_check);
	if(!ch.checked) {
		document.getElementById(id_obj).disabled=true;
	} else {
		document.getElementById(id_obj).disabled=false;
	}
}

function busqueda_avanzada() {
	document.getElementById('busquedaAvanzada').style.display='block';
	document.getElementById('btBusquedaAvanzada').style.display='none';
	document.getElementById('btBusquedaSimple').style.display='block';
	document.getElementById('btBuscarSimple').style.display='none';
	document.getElementById('btBuscarAvanzada').style.display='block';
	document.getElementById('palabrasClave').style.width='300px';
	document.getElementById('modoBusqueda').value='a';
}

function busqueda_simple() {
	document.getElementById('busquedaAvanzada').style.display='none';
	document.getElementById('btBusquedaAvanzada').style.display='block';
	document.getElementById('btBusquedaSimple').style.display='none';
	document.getElementById('btBuscarSimple').style.display='block';
	document.getElementById('btBuscarAvanzada').style.display='none';
	document.getElementById('palabrasClave').style.width='235px';
	document.getElementById('modoBusqueda').value='s';
}

function verif_busqueda() {
	/* Opcional
	if(document.getElementById('palabrasClave').value=='') {
		alert('Debe ingresar alguna palabra clave para la búsqueda');
		return false;
	}
	*/
	var cat=obtener_valor_select('cats');
	var mar=obtener_valor_select('marcas');
	var pal=document.getElementById('palabrasClave').value;
	if(cat=='00' && mar=='00' && pal=='') {
		alert('Para no obtener un resultado demasiado largo, debe elegir al menos una categoría o una marca');
		return false;
	}
	document.getElementById('frmBuscSup').submit();
}

function borrar_bloque_carrito() {
	var car=document.getElementById('divCarrito');
	car.style.display='none';
}

function mostrar_bloque_carrito() {
	var car=document.getElementById('divCarrito');
	car.style.display='block';
	car.style.visibility='hidden';	
	cargar_div('refrescar_carrito.php','divCarrito');
	car.style.visibility='visible';
}

function mostrar_mi_cuenta() {
	document.getElementById('mi_cuenta').style.display='block';
	document.getElementById('mis_datos').style.display='none';
	document.getElementById('mis_compras').style.display='none';
	document.getElementById('mi_password').style.display='none';
}

function mostrar_mis_datos() {
	document.getElementById('mi_cuenta').style.display='none';
	document.getElementById('mis_datos').style.display='block';
	document.getElementById('mis_compras').style.display='none';
	document.getElementById('mi_password').style.display='none';
}

function mostrar_mis_compras() {
	document.getElementById('mi_cuenta').style.display='none';
	document.getElementById('mis_datos').style.display='none';
	document.getElementById('mis_compras').style.display='block';
	document.getElementById('mi_password').style.display='none';
}

function mostrar_mi_password() {
	document.getElementById('mi_cuenta').style.display='none';
	document.getElementById('mis_datos').style.display='none';
	document.getElementById('mis_compras').style.display='none';
	document.getElementById('mi_password').style.display='block';
}

function mostrar_productos_complementarios(id_prod) {
	cargar_div('productos_complementarios.php?id='+id_prod,'complementarios');
	document.getElementById('bt_productos_complementarios').style.display='none';
}

function mostrar_productos_similares(id_prod) {
	cargar_div('productos_similares.php?id='+id_prod,'similares');
	document.getElementById('bt_productos_similares').style.display='none';
}

function verificar_form_contacto() {
	var datos_oblig = new Array('Nombre','Consulta','Email');
	var label_oblig = new Array('Nombre','Consulta','E-Mail');
	for(i=0; i<datos_oblig.length; i++) {
		if(document.getElementById(datos_oblig[i]).value=='') {
			alert('Es obligatorio ingresar el campo '+label_oblig[i]);
			return false;
		}
	}
	document.getElementById('frmContacto').submit();
	return true;
}

function verificar_form_registro() {
	var datos_oblig = new Array('Nombre','Puesto','Razon_Social','CUIT','Ingresos_Brutos','Direccion_Real','Direccion_Legal','Localidad','Codigo_Postal','Telefono','Direccion_Entrega','Email','Nombre_Fantasia');
	var label_oblig = new Array('Nombre y Apellido','Puesto','Razón Social','C.U.I.T.','Número de Ingresos Brutos','Dirección Real','Dirección Legal','Localidad','Código Postal','Teléfono/s','Dirección de Entrega','E-Mail','Nombre de Fantasía');
	for(i=0; i<datos_oblig.length; i++) {
		if(document.getElementById(datos_oblig[i]).value=='') {
			alert('Es obligatorio ingresar el campo '+label_oblig[i]);
			return false;
		}
	}
	return true;
}

function verificar_form_cliente() {
	var datos_oblig = new Array('Telefono','Email');
	var label_oblig = new Array('Teléfono','E-Mail');
	for(i=0; i<datos_oblig.length; i++) {
		if(document.getElementById(datos_oblig[i]).value=='') {
			alert('Es obligatorio ingresar el campo '+label_oblig[i]);
			return false;
		}
	}
	document.getElementById('formCliente').submit();
	return true;
}

function verificar_form_password() {
	if(document.getElementById('PasswordActual').value=="") {
		alert('Es obligatorio ingresar la contraseña actual');
		return false;
	}
	if(document.getElementById('PasswordNueva1').value!=document.getElementById('PasswordNueva2').value) {
		alert('La nueva contraseña no se ingres&oacute; correctamente');
		return false;
	}
	if(document.getElementById('PasswordNueva1').value.length<6) {
		alert('La nueva contraseña no puede tener menos de 6 caracteres');
		return false;
	}
	return true;
}
//-->
