	function agregar(){
		if ((navigator.appName=="Microsoft Internet Explorer")){
		var url="http://www.mkempresas.es";
		var titulo="Especial Directivos - Publicaciones Profesionales para Directivos";
		window.external.AddFavorite(url,titulo);
		}
	}
	
	function Calcula_Descuento(valor){
		//if (valor <= 1000) return valor - (valor * 0.2)
		if (valor <= 1000) return valor - (valor * 0.2)
		if ((valor > 1000) && (valor <= 2000)) return valor - (valor * 0.25)
		if ((valor > 2000) && (valor <= 3000)) return valor - (valor * 0.3)
		if ((valor > 3000) && (valor <= 4000)) return valor - (valor * 0.35)
		if ((valor > 4000) && (valor <= 5000)) return valor - (valor * 0.4)		
		if ((valor > 5000) && (valor <= 6000)) return valor - (valor * 0.45)
		if (valor > 6000) return valor - (valor * 0.5)				
		//Calcula_Descuento = valor		
	}
		
	function calcular_subtotal_total(cantidad, subtotal, total){
	    //id_cantidad = document.getElementById(cantidad).name
		switch(cantidad)
		{
			case "cantidad_1":
			  precio_unidad = 230
			break;
			case "cantidad_2":
  			  precio_unidad = 308
			break;
			case "cantidad_3":
			  precio_unidad = 182
			break;
			case "cantidad_4":
			  precio_unidad = 95
			break;
			case "cantidad_5":
			  precio_unidad = 250
			break;
			case "cantidad_6":
			  precio_unidad = 308
			break;
			case "cantidad_7":
			  precio_unidad = 236
			break;
			case "cantidad_8":
			  precio_unidad = 83,17
			break;
			case "cantidad_9":
			  precio_unidad = 217
			break;
			case "cantidad_10":
			  precio_unidad = 238
			break;
			case "cantidad_11":
			  precio_unidad = 100
			break;
			case "cantidad_12":
			  precio_unidad = 205
			break;						
        }
	 //Si el subtotal que estamos calculando ya tenia valor, lo restamos primero del TOTAL antes de sumar el nuevo subtotal.
	 Vtotal = parseFloat(document.getElementById(total).value)
	 Vtotal_sin_descuento = parseFloat(document.getElementById("total_sin_descuento").value)
	 Vsubtotal = parseFloat(document.getElementById(subtotal).value)
	 if (Vsubtotal > 0){
		 Vtotal = Vtotal - Vsubtotal
	 }	
	 //Calculamos el subtotal
	 Vsubtotal = precio_unidad * parseFloat(document.getElementById(cantidad).value)	 	 
	 //Lo sumamos al Total	 
	 if (Vsubtotal > 0){	    
	    document.getElementById(subtotal).value = Vsubtotal + "€"
	 	if (Vtotal > 0){	 
	    	Vtotal = Vsubtotal + Vtotal
			Vtotal_sin_descuento = Vsubtotal + Vtotal_sin_descuento
		}else{	
		    Vtotal = Vsubtotal
			Vtotal_sin_descuento = Vsubtotal
	 	}			 
	 	//document.getElementById(total).value = Vtotal + "€"
        document.getElementById("total_sin_descuento").value = Vtotal_sin_descuento + "€" 
		document.getElementById(total).value = Calcula_Descuento(Vtotal_sin_descuento) + "€"
	 }	
	}

	function expandir(objeto) {
		var estilo = objeto.firstChild.nextSibling.style;
		if (estilo+"" == "undefined") {	estilo = objeto.firstChild.nextSibling.nextSibling.style; }
		if (estilo.display == "block") { estilo.display = "none" } else { estilo.display = "block" };
	}
	
	function abrirVentana(URL, nombre, parametros) {
		var ventana = window.open(URL, nombre, parametros);
		if (ventana==null || typeof(ventana)=="undefined") alert("El contenido que intenta ver se muestra en una ventana emergente y su navegador está bloqueandolas.\nNecesita deshabilitar esta funcionalidad para que se muestre el contenido solicitado.");
	}

	function check() {
		// DATOS MODIFICABLES
		
		// Identificador de organización a la que deseamos acceder.
		sel = 2
		
		// Url Completa Plataforma QS·tutor.
		str_url = 'http://213.134.35.25/qstutor'
		
		// FIN DATOS MODIFICABLES. NO EDITAR A PARTIR DE AQUI
		login 	 = document.logon.login.value
		password = document.logon.password.value
		str_url = str_url + '/plt/log_newtokken.cfm?'
		str_url = str_url + 'id_org=' + sel
		str_url = str_url + '&login=' + login
		str_url = str_url + '&password=' + password
		str_url = str_url + '&openmode=' + '2' 
		
		str_url = str_url + '&randid3=' + new Date()
		str_url = str_url + '&hid_qstutorenter=1'
		
		//alert (str_url)
		
		window.open(str_url, 'logueo','top=2000,left=2000,resizable=0,location=0,directories=0,status=1,scrollbars=0, toolbar=0,width=350,height=200');
	}

function abrirPOPUP(ruta,target,w,h,scrolls){	
	var ancho = w;
	var alto = h;
	var top = (screen.height/2) - (alto/2+40);

	var left = (screen.width/2) - (ancho/2);
	
	if(w!="")
	{
		window.open(ruta,target,"width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + ",scrollbars=" + scrolls + ",resizable=1,toolbar=" + 1);		
	}
	else
	{
		window.open(ruta,target)
	}
}
