function mostrar(capa){
	document.getElementById(capa).style.display = "block";
}

function ocultar(capa){
	document.getElementById(capa).style.display = "none";
}

function mostrarOcultar(capa){
	if (document.getElementById(capa).style.display == "none"){
	  document.getElementById(capa).style.display = "block";
	} else {
	  document.getElementById(capa).style.display = "none";
	}
}

function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function submitPedido(){
	var contenedorMensaje = document.getElementById('mensajeError'); 
	var objAjax = nuevoAjax();
	objAjax.open("POST","/ins_pedido.php",true);
	objAjax.onreadystatechange = function() {
		if (objAjax.readyState==4){
		 if (objAjax.status == 200){
			contenedorMensaje.innerHTML = objAjax.responseText;
		 return true;
			} else alert('Hubo un problema obteniendo los datos.');
		}
	}
	if (document.formped.seladministracion){
		var indicesel1 = document.formped.seladministracion.selectedIndex;
		var valorsel1 = document.formped.seladministracion.options[indicesel1].value;
	} else {
		var valorsel1 = 0;
	}
	if (document.formped.selfirewall){
		var indicesel2 = document.formped.selfirewall.selectedIndex;
		var valorsel2 = document.formped.selfirewall.options[indicesel2].value; 
	} else {
		var valorsel2 = 0;
	}
	if (document.formped.selantivirus){
		var indicesel3 = document.formped.selantivirus.selectedIndex;
		var valorsel3 = document.formped.selantivirus.options[indicesel3].value; 
	} else {
		var valorsel3 = 0;
	}
	if (document.formped.selbackup){
		var indicesel4 = document.formped.selbackup.selectedIndex;
		var valorsel4 = document.formped.selbackup.options[indicesel4].value; 
	} else {
		var valorsel4 = 0;
	}
	if (document.formped.selplesk){
		var indicesel5 = document.formped.selplesk.selectedIndex;
		var valorsel5 = document.formped.selplesk.options[indicesel5].value; 
	} else {
		var valorsel5 = 0;
	}
	
	if (document.formped.selhd){
		var indicesel6 = document.formped.selhd.selectedIndex;
		var valorsel6 = document.formped.selhd.options[indicesel6].value; 
	} else {
		var valorsel6 = 0;
	}
	if (document.formped.selram){
		var indicesel7 = document.formped.selram.selectedIndex;
		var valorsel7 = document.formped.selram.options[indicesel7].value;
	} else {
		var valorsel7 = 0;
	}
	if (document.formped.seltransferencia){
		var indicesel8 = document.formped.seltransferencia.selectedIndex;
		var valorsel8 = document.formped.seltransferencia.options[indicesel8].value;
	} else {
		var valorsel8 = 0;
	}
	if (document.formped.selso){
		var indicesel9 = document.formped.selso.selectedIndex;
		var valorsel9 = document.formped.selso.options[indicesel9].value;
	} else {
		var valorsel9 = 0;
	}
	if (document.formped.seltipopago){
		var indiceselectpago = document.formped.seltipopago.selectedIndex;
		var valorpago = document.formped.seltipopago.options[indiceselectpago].value; 	
	} else {
		var valorpago = 0;
	}
	var cadenapago ="";
	if (valorpago == 1){
		cadenapago="&numtarjeta="+document.getElementById('numtarjeta').value+"&mescaducidadtarjeta="+document.getElementById('mescaducidadtarjeta').value+"&anyocaducidadtarjeta="+document.getElementById('anyocaducidadtarjeta').value+"&cvvtarjeta="+document.getElementById('cvvtarjeta').value;
	}else{
		cadenapago="&entidadcuenta="+document.getElementById('entidadcuenta').value+"&sucursalcuenta="+document.getElementById('sucursalcuenta').value+"&digitocuenta="+document.getElementById('digitocuenta').value+"&numcuenta="+document.getElementById('numcuenta').value;
	}
	var indiceselprov = document.formped.selprovincia.selectedIndex;
    var valorselprov = document.formped.selprovincia.options[indiceselprov].value;
	if (document.formped.selperiodicidad){
		var indiceselperiod = document.formped.selperiodicidad.selectedIndex;
		var valorselperiod = document.formped.selperiodicidad.options[indiceselperiod].value;
	} else {
		var valorselperiod = 0;
	}
	objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	objAjax.send("idpedido="+document.getElementById('idpedido').value+"&sel1="+valorsel1+"&sel2="+valorsel2+"&sel3="+valorsel3+"&sel4="+valorsel4+"&sel5="+valorsel5+"&sel6="+valorsel6+"&sel7="+valorsel7+"&sel8="+valorsel8+"&nombre="+document.getElementById('nombre').value+"&nif="+document.getElementById('nif').value+"&email="+document.getElementById('email').value+"&direccion="+document.getElementById('direccion').value+"&poblacion="+document.getElementById('poblacion').value+"&selprovincia="+valorselprov+"&cp="+document.getElementById('cp').value+"&pais="+document.getElementById('pais').value+"&telefono="+document.getElementById('telefono').value+"&observaciones="+document.getElementById('observaciones').value+"&plataforma="+document.getElementById('plataforma').value+"&selpago="+valorpago+"&selperiodicidad="+valorselperiod+"&sel9="+valorsel9+cadenapago);	
}

function recalculaPrecio(){
	var contenedorPrecio = document.getElementById('precioPedido'); 
	var objAjax = nuevoAjax();
	objAjax.open("POST","/calculaprecio.php",true);
	objAjax.onreadystatechange = function() {
		if (objAjax.readyState==4){
		 if (objAjax.status == 200){
			contenedorPrecio.innerHTML = objAjax.responseText;
		 return true;
			} else alert('Hubo un problema obteniendo los datos.');
		}
	}
	if (document.formped.seladministracion){
		var indicesel1 = document.formped.seladministracion.selectedIndex;
		var valorsel1 = document.formped.seladministracion.options[indicesel1].value;
	} else {
		var valorsel1 = 0;
	}
	if (document.formped.selfirewall){
		var indicesel2 = document.formped.selfirewall.selectedIndex;
		var valorsel2 = document.formped.selfirewall.options[indicesel2].value; 
	} else {
		var valorsel2 = 0;
	}
	if (document.formped.selantivirus){
		var indicesel3 = document.formped.selantivirus.selectedIndex;
		var valorsel3 = document.formped.selantivirus.options[indicesel3].value; 
	} else {
		var valorsel3 = 0;
	}
	if (document.formped.selbackup){
		var indicesel4 = document.formped.selbackup.selectedIndex;
		var valorsel4 = document.formped.selbackup.options[indicesel4].value; 
	} else {
		var valorsel4 = 0;
	}
	if (document.formped.selplesk){
		var indicesel5 = document.formped.selplesk.selectedIndex;
		var valorsel5 = document.formped.selplesk.options[indicesel5].value; 
	} else {
		var valorsel5 = 0;
	}
	
	if (document.formped.selhd){
		var indicesel6 = document.formped.selhd.selectedIndex;
		var valorsel6 = document.formped.selhd.options[indicesel6].value; 
	} else {
		var valorsel6 = 0;
	}
	if (document.formped.selram){
		var indicesel7 = document.formped.selram.selectedIndex;
		var valorsel7 = document.formped.selram.options[indicesel7].value;
	} else {
		var valorsel7 = 0;
	}
	if (document.formped.seltransferencia){
		var indicesel8 = document.formped.seltransferencia.selectedIndex;
		var valorsel8 = document.formped.seltransferencia.options[indicesel8].value;
	} else {
		var valorsel8 = 0;
	}
	objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	objAjax.send("precioserv="+document.getElementById('precioserv').value+"&precioservtrim="+document.getElementById('precioservtrim').value+"&sel1="+valorsel1+"&sel2="+valorsel2+"&sel3="+valorsel3+"&sel4="+valorsel4+"&sel5="+valorsel5+"&sel6="+valorsel6+"&sel7="+valorsel7+"&sel8="+valorsel8);
}

function selectpago(){
	var indiceselectpago = document.formped.seltipopago.selectedIndex;
    var valorpago = document.formped.seltipopago.options[indiceselectpago].value;
	if (valorpago == 1){
		document.getElementById('divPagoTarjeta').style.display="block";
		document.getElementById('divPagoCCC').style.display="none";
	}else {
		document.getElementById('divPagoTarjeta').style.display="none";
		document.getElementById('divPagoCCC').style.display="block";
	}
}
