// ---------- subrutinas para la cesta -----------------------------

// añadir articulo al carro 

	function ver(accio,id,precio,noucan){
		document.getElementById("layerBasket").style.visibility = "visible"

	//----------calculamos posicion horizontal -
	  var scrOfX = 0, scrOfY = 0;
  	if( typeof( window.pageYOffset ) == 'number' ) {
  	  scrOfY = window.pageYOffset;
   	 scrOfX = window.pageXOffset;
  	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
  	  scrOfY = document.body.scrollTop;
  	  scrOfX = document.body.scrollLeft;
 	 } else if( document.documentElement &&
 	     ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
 	   scrOfY = document.documentElement.scrollTop;
 	   scrOfX = document.documentElement.scrollLeft;
 	 }

		document.getElementById("layerBasket").style.visibility = "visible"
		document.getElementById("layerBasket").style.left=scrOfX+400+"px";
		document.getElementById("layerBasket").style.top=scrOfY+130+"px"
		top.frames['basket'].location="basket.asp?accio="+accio+"&NouId="+id+"&NouCan="+noucan+"&Precio="+precio;
	}

// cerrar ventana de compra
	function cerrar(){
		document.getElementById("layerBasket").style.visibility = "hidden"
	}

// redimensionar iframe pedido
	function resizeIframe(inc) { 
   		document.getElementById('baskett').height = inc;
	} 



//------------- desactivar control del flash
function fixFlash(elSwf,anchoSwf,altoSwf,bgcolorSwf,flashVarSwf,qualitySwf,menuSwf,idSwf,alignSwf)
{
            var muestraElSwf =  '<div id="capa"><object type="application/x-shockwave-flash" data="'+ elSwf +'" width="'+ anchoSwf +'" height="'+ altoSwf +'" id="'+ idSwf +'" name="'+ idSwf +'" align="'+ alignSwf +'">'
                        + '<param name="movie" value="'+ elSwf +'" />'
                        + '<param name="quality" value="'+ qualitySwf +'" />'
                        + '<param name="bgcolor" value="'+ bgcolorSwf +'" />'
                        + '<param name="allowScriptAccess" value="sameDomain" />'
                        + '<param name="FlashVars" value="'+ flashVarSwf +'" />'
                        + '<param name="swLiveConnect" value="true" />'
                        + '<param name="menu" value="'+ menuSwf +'" />'
                        + '<param name="scale" value="noscale" />'
                        + '<param name="wmode" value="transparent" />'
                        + '</object></div>';
            document.write(muestraElSwf);
}


function admin(w){
window.open(w,'_blank','width=1000,height=375,scrollbars=no,status=no')
}

//-------------- abrimos instalacion
function instalacion(w){
window.open("../include/instalacion.asp?peli="+w,'_blank','width=800,height=600,scrollbars=no,status=no')
}

//---------------------- validacion formularios ----------------------------------------
function usu_valida() {
	var errorMsg = "";
	var errorMsgLong = "";


	validar('email')
 	var direccionEmail = document.all['email'].value
	if (((direccionEmail=="") || (direccionEmail.indexOf(".")==-1)) || (direccionEmail.indexOf("@")==-1))  {
		errorMsg += "\n\t- Indica un email correcto";
	}

	validar('password')
	if (document.FormName.all['password'].value == ""){
		errorMsg += "\n\t- Indica la contraseña";
	}

	if (errorMsg != ""){
		MuestraError(errorMsg)
		return false;
	}
	
	return true;
}
function usu_recuerda() {
	var errorMsg = "";
	var errorMsgLong = "";


	validar('email')
 	var direccionEmail = document.all['email'].value
	if (((direccionEmail=="") || (direccionEmail.indexOf(".")==-1)) || (direccionEmail.indexOf("@")==-1))  {
		errorMsg += "\n\t- Indica un email correcto";
	}

	if (errorMsg != ""){
		MuestraError(errorMsg)
		return false;
	}
	
	return true;
}

function usu_alta() {
	var errorMsg = "";
	var errorMsgLong = "";


	validar('email')
 	var direccionEmail = document.all['email'].value
	if (((direccionEmail=="") || (direccionEmail.indexOf(".")==-1)) || (direccionEmail.indexOf("@")==-1))  {
		errorMsg += "\n\t- Indica un email correcto";
	}


	if (document.all['email'].value != document.FormName.all['email1'].value) { 
		errorMsg += "\n\t- Resive el email";
	}

	validar('password')
	if (document.all['password'].value == ""){
		errorMsg += "\n\t- Indica la contraseña";
	}

	if (document.all['password'].value != document.all['password1'].value) { 
		errorMsg += "\n\t- Resive la contraseña";
	}

	validar('nif')
	if (document.all['nif'].value == ""){
		errorMsg += "\n\t- Indica el CIF o NIF";
	}

	
	validar('empresa')
	if (document.all['empresa'].value == ""){
		errorMsg += "\n\t- Indicar el nombre completo";
	}

	validar('cp')
	if (document.all['cp'].value == ""){
		errorMsg += "\n\t- Indicar el codigo Postal";
	}

	validar('poblacion')
	if (document.all['poblacion'].value == ""){
		errorMsg += "\n\t- Indicar la poblacion";
	}


	validar('pais')
	if (document.all['pais'].value == ""){
		errorMsg += "\n\t- Indicar el pais";
	}

	validar('telefono')
	if (document.all['telefono'].value == ""){
		errorMsg += "\n\t- Indicar el telefono";
	}


	if (errorMsg != ""){
		MuestraError(errorMsg)
		return false;
	}
	
	return true;
}

function usu_rma() {
	var errorMsg = "";
	var errorMsgLong = "";


	validar('fechafactura')
	if (document.all['fechafactura'].value == ""){
		errorMsg += "\n\t- Indique la Fecha de la Factura";
	}

	validar('numfactura')
	if (document.all['numfactura'].value == ""){
		errorMsg += "\n\t- Indique el numero de factura";
	}

	validar('numnerie')
	if (document.all['numnerie'].value == ""){
		errorMsg += "\n\t- Indique el Numero de Serie";
	}

	
	validar('marca')
	if (document.all['marca'].value == ""){
		errorMsg += "\n\t- Indique la marca";
	}

	validar('modelo')
	if (document.all['modelo'].value == ""){
		errorMsg += "\n\t- Indique el modelo";
	}

	validar('descripcionproblema')
	if (document.all['descripcionproblema'].value == ""){
		errorMsg += "\n\t- Describa el problema que detecta";
	}

	if (errorMsg != ""){
		MuestraError(errorMsg)
		return false;
	}
	
	return true;
}
function usu_contactar() {
	var errorMsg = "";
	var errorMsgLong = "";


	validar('nombre')
	if (document.all['nombre'].value == ""){
		errorMsg += "\n\t- Indique su nombre";
	}


	validar('domicilio')
	if (document.all['domicilio'].value == ""){
		errorMsg += "\n\t- Indique su domicilio";
	}

	validar('poblacion')
	if (document.all['poblacion'].value == ""){
		errorMsg += "\n\t- Indique su poblacion";
	}

	validar('provincia')
	if (document.all['provincia'].value == ""){
		errorMsg += "\n\t- Indique su provincia";
	}

	validar('telefono')
	if (document.all['telefono'].value == ""){
		errorMsg += "\n\t- Indi1ue su Teléfono";
	}


	validar('email')
 	var direccionEmail = document.all['email'].value
	if (((direccionEmail=="") || (direccionEmail.indexOf(".")==-1)) || (direccionEmail.indexOf("@")==-1))  {
		errorMsg += "\n\t- Indica un email correcto";
	}


	validar('interes')
	if (document.all['interes'].value == ""){
		errorMsg += "\n\t- Indique su interes o consulta";
	}
	


	if (errorMsg != ""){
		MuestraError(errorMsg)
		return false;
	}
	
	return true;
}

//------------------- eliminamos caracteres no deseados 
function validar(cadena) 
	{
		cambia=document.all[cadena].value
		h=cambia.length
		for (i=0;i<h;i++){ 
			cambia=cambia.replace("'",".")
			cambia=cambia.replace('"','.')
		} 

		document.all[cadena].value=cambia;
	}


// --------------------- mensajes de error
function MuestraError (errorMsg){

	msg =  "_________________________________________________\n\n";
	msg += "\t Existen datos obligatorios.Por\n";
	msg += "\t favor corrige el problema.\n";
	msg += "__________________________________________________\n\n";
	msg += "El siguientes campos deben ser corregidos: -\n";
		
	errorMsg += alert(msg + errorMsg + "\n" );
}
