	var sentido = new Array();
	var lineas = new Array();

	function Validar_formulario(){		var correcto = true;		if (document.getElementById('f_nombre').value==""){			alert('Debe ingresar el Nombre o la razón Social');
			document.getElementById('f_nombre').focus();
			correcto=false;
		}
		return correcto;
	}

	function Verificar()
	{
		var tecla=window.event.keyCode;
		if (tecla==116) {alert("ERROR!"); event.keyCode=0;
			event.returnValue=false;
		}
 	}


	function trim(cadena){
	    for(i=0; i<cadena.length; )
	    {
	        if(cadena.charAt(i)==" ")
	            cadena=cadena.substring(i+1, cadena.length);
	        else
	            break;
	    }

	    for(i=cadena.length-1; i>=0; i=cadena.length-1)
	    {
	        if(cadena.charAt(i)==" ")
	            cadena=cadena.substring(0,i);
	        else
	            break;
	    }

	    return cadena;
	}

	function clavar(obj, posic){
		dObj =document.getElementById(obj);
		dObj.style.posbottom = document.body.scrollbottom+posic;
	}

	function openw(src){
		window.w = window.open(src,'busqueda','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=620')
	}

	function Permut (flag,img){
		if (document.images) {
	        if (document.images[img].permloaded) {
	            if (flag==1)
	            	document.images[img].src = document.images[img].perm.src
	            else
	            document.images[img].src = document.images[img].perm.oldsrc
	        }
	   	}
	}

	function preloadPermut (img,adresse){
	   	if (document.images) {
	        img.onload = null;
	        img.perm = new Image ();
	        img.perm.oldsrc = img.src;
	        img.perm.src = adresse;
	        img.permloaded = true;
		}
	}

	function AceptaNumero(evt)
    {
        var nav4 = window.Event ? true : false;
        var key = nav4 ? evt.which : evt.keyCode;
        return (key <= 13 || key==46 ||  (key >= 38 && key <= 57));

    }


 function isValidCif(abc){    par = 0;
    non = 0;
    letras = "ABCDEFGHKLMNPQS";
    let = abc.charAt(0);

    if (abc.length!=9) {
    	alert('El CIF/NIF debe tener 9 dígitos');
    	return false;
    }

    if (letras.indexOf(let.toUpperCase())==-1) {
    	//alert("El comienzo del Cif no es válido");
    	return false;
    }

    for (zz=2;zz<8;zz+=2) {
    	par = par+parseInt(abc.charAt(zz));
    }

    for (zz=1;zz<9;zz+=2) {
    	nn = 2*parseInt(abc.charAt(zz));
    	if (nn > 9) nn = 1+(nn-10);
    	non = non+nn;
    }

    parcial = par + non;
    control = (10 - ( parcial % 10));

    if (control==10)
    	control=0;

    if (control!=abc.charAt(8)) {
    	//alert("El Cif no es válido");
    	return false;
    }
    //alert("El Cif es válido");
    return true;
 }

 function isValidNif(abc){	if(abc.substring(0,1)=="X" || abc.substring(0,1)=="x"){		dni=abc.substring(1,abc.length-1);	}else{		dni=abc.substring(0,abc.length-1);	}


 	let=abc.charAt(abc.length-1);
 	if (!isNaN(let)) {
 		//alert('Falta la letra');
 		return false;
 	}else{
 		cadena = "TRWAGMYFPDXBNJZSQVHLCKET";
 		posicion = dni % 23;
 		letra = cadena.substring(posicion,posicion+1);

 		if (letra!=let){
 			//alert("Nif no válido");
 			return false;
 		}
 	}

 	//alert("Nif válido")
 	return true;
 }


 function isValidEmail(str){
 	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
 	return (filter.test(str));}

 function isValidTelef(num){
 	if(num.length < 9){
 		return false;
 	}else if(isNaN( num )){
 		return false;
 	}else{
 		return true;
 	}
 }

 function isValidDateFormat(str){
 	var filter=/^(\d{1,2}\/\d{1,2}\/\d{2})$/i;
 	return (filter.test(str));
 }







	//*****************************************************************************
	// Do not remove this notice.
	//
	// Copyright 2001 by Mike Hall.
	// See http://www.brainjar.com for terms of use.
	//*****************************************************************************

	// Esto permite mover un div

	function Browser() {

	  var ua, s, i;

	  this.isIE    = false;
	  this.isNS    = false;
	  this.version = null;

	  ua = navigator.userAgent;

	  s = "MSIE";
	  if ((i = ua.indexOf(s)) >= 0) {
	    this.isIE = true;
	    this.version = parseFloat(ua.substr(i + s.length));
	    return;
	  }

	  s = "Netscape6/";
	  if ((i = ua.indexOf(s)) >= 0) {
	    this.isNS = true;
	    this.version = parseFloat(ua.substr(i + s.length));
	    return;
	  }

	  // Treat any other "Gecko" browser as NS 6.1.

	  s = "Gecko";
	  if ((i = ua.indexOf(s)) >= 0) {
	    this.isNS = true;
	    this.version = 6.1;
	    return;
	  }
	}

	var browser = new Browser();

	// Global object to hold drag information.

	var dragObj = new Object();
	dragObj.zIndex = 0;

	function dragStart(event, id) {

	  var el;
	  var x, y;

	  // If an element id was given, find it. Otherwise use the element being
	  // clicked on.

	  if (id)
	    dragObj.elNode = document.getElementById(id);
	  else {
	    if (browser.isIE)
	      dragObj.elNode = window.event.srcElement;
	    if (browser.isNS)
	      dragObj.elNode = event.target;

	    // If this is a text node, use its parent element.

	    if (dragObj.elNode.nodeType == 3)
	      dragObj.elNode = dragObj.elNode.parentNode;
	  }

	  // Get cursor position with respect to the page.

	  if (browser.isIE) {
	    x = window.event.clientX + document.documentElement.scrollLeft
	      + document.body.scrollLeft;
	    y = window.event.clientY + document.documentElement.scrollTop
	      + document.body.scrollTop;
	  }
	  if (browser.isNS) {
	    x = event.clientX + window.scrollX;
	    y = event.clientY + window.scrollY;
	  }

	  // Save starting positions of cursor and element.

	  dragObj.cursorStartX = x;
	  dragObj.cursorStartY = y;
	  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
	  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

	  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
	  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

	  // Update element's z-index.

	  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

	  // Capture mousemove and mouseup events on the page.

	  if (browser.isIE) {
	    document.attachEvent("onmousemove", dragGo);
	    document.attachEvent("onmouseup",	dragStop);
	    window.event.cancelBubble = true;
	    window.event.returnValue = false;
	  }
	  if (browser.isNS) {
	    document.addEventListener("mousemove", dragGo,   true);
	    document.addEventListener("mouseup",   dragStop, true);
	    event.preventDefault();
	  }
	}

	function dragGo(event) {

	  var x, y;

	  // Get cursor position with respect to the page.

	  if (browser.isIE) {
	    x = window.event.clientX + document.documentElement.scrollLeft
	      + document.body.scrollLeft;
	    y = window.event.clientY + document.documentElement.scrollTop
	      + document.body.scrollTop;
	  }
	  if (browser.isNS) {
	    x = event.clientX + window.scrollX;
	    y = event.clientY + window.scrollY;
	  }

	  // Move drag element by the same amount the cursor has moved.

	  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
	  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

	  if (browser.isIE) {
	    window.event.cancelBubble = true;
	    window.event.returnValue = false;
	  }
	  if (browser.isNS)
	    event.preventDefault();
	}

	function dragStop(event) {

	  // Stop capturing mousemove and mouseup events.

	  if (browser.isIE) {
	    document.detachEvent("onmousemove", dragGo);
	    document.detachEvent("onmouseup",	dragStop);
	  }
	  if (browser.isNS) {
	    document.removeEventListener("mousemove", dragGo,	true);
	    document.removeEventListener("mouseup",   dragStop, true);
	  }
	}

	var statSend = false;
	function checkSubmit() {
	    if (!statSend) {
	        statSend = true;
	        return true;
	    } else {
	        alert("Pedido enviado, espere un momento hasta la confirmación");
	        return false;
	    }
	}


