function meteFecha(data) {

document.Form1.fecha.value=data;

}


function confirmaBorrarTicket(msg,url) {

//if (confirm(msg)) {
//window.location=(url);
//} 
window.location=('avisa.asp?msg='+msg+'&url='+url);
}

				var linea='c';
				var linea_old='z';
				var base_linea_old='z';


				function cambiaColor(id, src, color)
				{
				document.all[id].bgColor = color;
				src.style.cursor="hand";
				}

				function cambiaColor3(color) {
				if (linea_old!='z') {
				document.all[linea_old].bgColor = color;
				document.all[base_linea_old].bgColor = '#C0C0C0';
				}
				}



				function cambiaColor2(id, t, src, color1, color2) {

				if (id==linea) {
				document.all[id].bgColor = color2;
				//document.all[t].bgColor =  '#C0C0C0';
				}
				else {
				document.all[id].bgColor = color1;
				//document.all[t].bgColor =   '#C0C0C0';
				}

				src.style.cursor="hand";
				}
				
function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}

function isDigit(c)
{
	return ((c >=0) && (c <=9));
}

function isInteger (s)
{
	if (isEmpty(s.value)) return false;
	for (var i = 0; i < s.value.length; i++)
		if (!isDigit(s.value.charAt(i))) return false;
	return true;
}

function isFloat(s)
{
	if (isEmpty(s.value))return false;
	if (isNaN(parseFloat(s.value))) return false;
	return true;
}

		
function isDecimalComa(s)
{
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (c==".") return false;
	}
	data = s.split(",");
	if (data.length > 2) return false;
	parteEntera = data[0];
	if (isEmpty(parteEntera)) return false;
	for (i = 0; i < parteEntera.length; i++)
	{
		var c = parteEntera.charAt(i);
		if (!isDigit(c)) return false;
	}
	if (data.length > 1)
	{
		parteDecimal = data[1];
		if(parteDecimal.length > 2) //numero de decimales
			return false;
		if (isEmpty(parteDecimal)) return false;
		for (i = 0; i < parteDecimal.length; i++)
		{
			var c = parteDecimal.charAt(i);
			if (!isDigit(c)) return false;
		}
	}
	return true;
}

function confirma_borrar_barco(item) {
if (confirm("Está seguro de borrar el barco "+item)) {
window.location = ('edit_barco_action.asp?p_delete='+item);
}  
}  

function confirma_borrar_lugar(item) {
if (confirm("Está seguro de borrar el lugar '"+item+"'")) {
window.location = ('edit_lugares_action.asp?p_delete='+item);
}  
}  

function confirma_borrar_user(item) {
if (confirm("Está seguro de borrar el usuario "+item)) {
window.location = ('edit_users_action.asp?p_delete='+item);
}  
}  


function confirma_borrar_reserva(item) {
if (confirm("Está seguro de borrar la Reserva Número "+item+". Se borrarán también todas las líneas de inmersiones.")) {
window.location = ('edit_reservas_action.asp?p_delete='+item);
}  
}  


function anyCheck() {
var total = 0;
var max = document.delForm.p_dely.length;
if (eval("document.delForm.p_dely.checked") == true) {
    total += 1;
   }
for (var idx=0; idx < max; idx++) {
if (eval("document.delForm.p_dely[" + idx + "].checked") == true) {
    total += 1;
   }
}
if (total < 1) {
alert("No se ha seleccionado ninguna linea.");
return false;
}
else {
if (confirm("Está seguro de borrar las líneas seleccionadas")) {
return true;
}
else {
return false;
}
}
}

var checkflag = "false";
function check(field) {
if (checkflag == "false") {
document.delForm.p_dely.checked = true;
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
document.delForm.p_dely.checked = false; 
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}



function ValidarForm() {



if (document.MyForm.nombre.value =='' ) {
alert ("El campo Nombre no puede quedar en blanco");
return false;
}
else if (document.MyForm.dir.value =='' ) {
alert ("El campo Dirección no puede quedar en blanco");
return false;
}
else if (document.MyForm.pob.value =='' ) {
alert ("El campo Población no puede quedar en blanco");
return false;
}
else if (document.MyForm.cp.value =='' ) {
alert ("El campo Cód. Postal no puede quedar en blanco");
return false;
}
else if (document.MyForm.email.value =='' ) {
alert ("El campo E-mail no puede quedar en blanco");
return false;
}
else if (document.MyForm.codigoInn.value.length<5) {
		alert ("Introduzca los caracteres tal como aparecen en la imágen")
return false;
} 
else {


url='/miraCodigo.asp?codigo='+document.MyForm.codigo.value+'&codigoinn='+document.MyForm.codigoInn.value

xmlHttp=GetXmlHttpObject()
url=url+"&sid="+Math.random()

	xmlHttp.onreadystatechange=function () {

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
verCodigo= xmlHttp.responseText 


			if (verCodigo==1) {
			//alert ("El código es correcto")
			document.MyForm.submit()
			} else if (verCodigo==0) {
			alert ("El código no es correcto")
			return false;
			}
			
		}
		
	}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

return false;

}

}
		

function sumar(x, valor, max) { 
if (x < max) { 
x=(x*1)+(valor*1);
}
return x;
} 

function restar(x, valor) { 
if (x > 0) { 
x=x-valor; 
} 
return x;
} 


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_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_findObj(n, d) { //v3.0
  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); 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 MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function new_window(url) {
popupWin = window.open(url,'','width=780,height=500,left=0,top=0,scrollbars=yes')
}
function new_window2(url) {
popupWin = window.open(url,'','width=780,height=400,left=0,top=0,scrollbars=yes')
}

function smallWindow(url) {
var l=320;
var t=470;
var winl = (screen.width - l) / 2;
var wint = (screen.height - t) / 2;
popupWin = window.open(url,'datos','width='+l+',height='+t+',left='+winl+',top='+wint+',status=no,scrollbars=0')
}

function small_window2(url) {
var winl = (screen.width - 600) / 2;
var wint = (screen.height - 500) / 2;
popupWin = window.open(url,'datos2','width=600,height=500,left='+winl+',top='+wint+',scrollbars=1')
}

function small_window3(url) {
var winl = (screen.width - 740) / 2;
var wint = (screen.height - 580) / 2;
popupWin = window.open(url,'datos3','width=740,height=580,left='+winl+',top='+wint+',scrollbars=1')
}

function finestra2(url) {
var winl = (screen.width - 640) / 2;
var wint = (screen.height - 780) / 2;
popupWin = window.open(url,'printTicket','width=640,height=780,left='+winl+',top='+wint+',scrollbars=1')
}





function mail(mypage, myname, w, h, scroll) {		
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function padout(number) { return (number<10) ? '0' + number : number; }
