var config = 'center:yes; resizable:no; help:no; dialogWidth:300px; dialogHeight:200px'

//Esto pone la franja gris del submenu a la misma largura que la web
window.onload = redimensionar;
function redimensionar(){
	id="producto_izq"
	var e=document.getElementById(id);
	if(!e) {
		return false
	}else{
		n1 = document.getElementById('producto_izq').offsetHeight//+'px'
		n2 = document.getElementById('producto_der').offsetHeight//+'px'
		if(n2>n1){
			document.getElementById('producto_izq').style.height = n2+'px'
		}else{
			document.getElementById('producto_der').style.height = (n1-20)+'px'
		}
	}
}
	
//Quitar espacios en blanco de un campo
function espacios(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(v = 0; v < splitstring.length; v++)
	temp += splitstring[v];
	//devuelve vacio o relleno
	return temp;
}

function ignoreSpaces(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(v = 0; v < splitstring.length; v++)
	temp += splitstring[v];
	//devuelve vacio o relleno
	return temp;
}

//Introduccion de fecha correcta
function fecha(campo){
	if (!/\d{2}\/\d{2}\/\d{4}/.test(campo)){
		return true
	}else{
		return false
	}
}

//Introduccion de hora correcta
function tiphora(campo){
	var t=campo
	t=t.replace(".","$")
	t=t.replace(",","$")
	var h=t
	var m=t
	var p=h.indexOf(":")
	h=h.substring(0,p)
	m=m.substring(p+1)
	if (h > 23 || h < 0 || m > 59 || m < 0 || isNaN(h) || isNaN(m)) {
		return true;		
	}else{
		return false;
	}
}

//Introducción de e-mail correcto
function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
     return false;
   else 
      return true;
}
//------------------------------------------------
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function makeArray(n) {
   for (var i = 1; i <= n; i++) {
      this[i] = 0;
   } 
   return this;
}

function daysInFebruary(whichYear) {
    return (whichYear % 4 == 0 && (!(whichYear % 100 == 0)
 || (whichYear % 400 == 0)) ? 29 : 28);
}

function isDate(campo) {
	dd=campo.substring(0,2)*1
	mm=campo.substring(3,5)*1
	yyyy=campo.substring(6,10)*1
	if (mm !="" && !(mm > 0 && mm < 13)){
		alert ("¡Fecha no existente!");
		return false;
	}
	if (dd !="" && !(dd > 0 && dd < 32)){
		alert ("¡Fecha no existente!");
		return false;
	}
	if ((dd!="" && mm!="") && dd > daysInMonth[mm]){
		alert ("¡Fecha no existente!")
		return false;
	}
	if ((mm=="2" || mm=="02" && dd!="" && yyyy!="") && dd > daysInFebruary(yyyy)){
		alert ("¡Fecha no existente!")
		return false;
	}
return true;
}
function ventana(page, x, y){
		posx = (screen.availWidth-x)/2;
	   	posy = (screen.availHeight-y)/2;
		return window.open(page, 'DATOS','toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width='+x+', height='+y+', top='+posy+', left='+posx);
}
function ventanar(page, x, y){
		posx = (screen.availWidth-x)/2;
	   	posy = (screen.availHeight-y)/2;
		window.open(page, 'DATOS','toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width='+x+', height='+y+', top='+posy+', left='+posx);
}
function ventanascroll(page, x, y){
		posx = (screen.availWidth-x)/2;
	   	posy = (screen.availHeight-y)/2;
		window.open(page, 'DATOS','toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, width='+x+', height='+y+', top='+posy+', left='+posx);
}

function mueveReloj(){
	if(document.getElementById('mueve').value==0){
		momentoActual = new Date()
		hora = momentoActual.getHours()
		minuto = momentoActual.getMinutes()
		segundo = momentoActual.getSeconds()
		
		str_segundo = new String (segundo) 
	    if (str_segundo.length == 1) 
    	   segundo = "0" + segundo 

	    str_minuto = new String (minuto) 
    	if (str_minuto.length == 1) 
	       minuto = "0" + minuto 

    	str_hora = new String (hora) 
	    if (str_hora.length == 1) 
    	   hora = "0" + hora
	
		horaImprimible = hora + ":" + minuto + ":" + segundo
		document.getElementById('hor').value = horaImprimible
		setTimeout("mueveReloj()",1000)
	}
}

function salto (tamano, campo, sig){
	val = campo.value.replace(".",",")
	nval = campo.value.length
	if (isNaN(val)){
		alert('Ha de ser un valor numérico')
		campo.value = campo.value.substring(0, nval-1)
		return false
	}
	if(nval*1>tamano*1){
		alert('Longitud del campo incorrecta')
		campo.value = campo.value.substring(0, nval-1)
		return false
	}
	if (nval*1==tamano*1 && sig!=''){
		document.getElementById(sig).focus()
	}
}

function redondear(cantidad, decimales) {
	var cantidad = parseFloat(cantidad);
	var decimales = parseFloat(decimales);
	decimales = (!decimales ? 2 : decimales);
	return Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);
} 

function conver_tot(valor,cod){
	//tot = document.getElementById('tot_linea_'+cod).value.replace(',','.')*1
	total=document.getElementById('tot_linea_'+cod).value.split('.')
	tot=total.join('')
	tot = tot.replace(',','.')*1
	iva = document.getElementById('iva_'+cod).value.replace(',','.')*1
	if (isNaN(tot)){
		alert('El valor del total ha de ser numérico')
	}else{
		final=tot/((iva/100)+1)
		final=final.toFixed(2)
		/*final= Math.round(final * Math.pow(10, 2)) / Math.pow(10, 2);
		final="a"+final
		fin=final.split('.')
		final=fin.join(',')
		final=final.replace("a","")*/

		document.getElementById('imp_'+cod).value = final
		if (document.getElementById('id').value==0){
			//document.getElementById('pre_nueva').value=0
			for (i=1;i<=5;i++){
				j=(i*1)-1
				lin=document.getElementById('tot_linea_nueva_'+i).value.replace(',','.')*1
				if (isNaN(lin)==false){
					/*valor=(document.getElementById('pre_nueva').value*1)+(lin*1)
					valor= Math.round(valor * Math.pow(10, 2)) / Math.pow(10, 2);
					valor="a"+valor
					va=valor.split('.')
					valor=va.join(',')
					valor=valor.replace("a","")

					document.getElementById('pre_nueva').value=valor*/
				}
			}
		}
	}
}
function fun_concepto(){
	if (document.getElementById('id').value==0){
		document.getElementById('con_nueva_1').value=document.getElementById('concepto').value
	}
}
function conver_iva(valor,cod){
	impo = document.getElementById('imp_'+cod).value.replace(',','.')*1
	iva = document.getElementById('iva_'+cod).value.replace(',','.')*1
	if (isNaN(iva)){
		alert('El valor del iva ha de ser numérico')
	}else{
		final=impo+((impo*iva)/100)
		final=final.toFixed(2)
		document.getElementById('tot_linea_'+cod).value = final
	}
}
function conver_imp(valor,cod){
	impo = document.getElementById('imp_'+cod).value.replace(',','.')*1
	iva = document.getElementById('iva_'+cod).value.replace(',','.')*1
	if (isNaN(impo)){
		alert('El valor del importe ha de ser numérico')
	}else{
		final=impo+((impo*iva)/100)
		final=final.toFixed(2)
		document.getElementById('tot_linea_'+cod).value = final
	}
}
function mktg(){
	alert('Pestaña deshabilitada temporalmente\nPerdone las molestias')
}




<!--
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 GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
//-->