// JavaScript Document
function ver_imagen(what){
	wout = window.open("about:blank", "foto", OUTPUT="width=110,height=50,top=0,left=50,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");
	wout.document.write("<html><head><title>Galeria de Imagenes</title></head><body onLoad=self.resizeTo(document.all['vista'].document.images['foto'].width,document.all['vista'].document.images['foto'].height+25);document.all['vista'].style.visibility='visible';document.all['conectando'].style.visibility='hidden'; leftmargin=0 topmargin=0><div id='vista' style='position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:2; visibility: hidden'><img id=foto src='"+what+"' border=0></div><div id='conectando' style='position:absolute; left:0px; top:0px; width:100%; height:100%; z-index:1; visibility: visible'><font face='Verdana' size=-1>Cargando ...</font></div></body></html>");
	wout.document.close();
	wout.focus();
}

function jugar(what,myW,myH){
	window.open(what, "juego", OUTPUT="width="+myW+",height="+myH+",top=0,left=50,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");
}

function actualiza(){
	var total = 0;
	var concepto = "";
	var importe = 0;
	var curdate = new Date();
	var max = document.form1.conceptos.length;
	for (var idx = 0; idx < max; idx++) {		
	if (eval("document.form1.conceptos[" + idx + "].checked") == true) {		
		var conceptos_array=document.form1.conceptos[idx].value.split("@");
		concepto += conceptos_array[0] + " ";
		importe += parseFloat(conceptos_array[1]);
	   }
	}
	if (document.form1.otro_concepto.value!='') concepto+=document.form1.otro_concepto.value;
	if (document.form1.otro_importe.value>0) importe += parseFloat(document.form1.otro_importe.value);
	if (document.form1.mes.options[document.form1.mes.selectedIndex].text!='Seleccione el Mes') {
		concepto+=' de '+document.form1.mes.options[document.form1.mes.selectedIndex].text;
		document.form1.mes2.value=document.form1.mes.options[document.form1.mes.selectedIndex].value;
		//document.form1.fecha.value="01/"+document.form1.mes.options[document.form1.mes.selectedIndex].value+"/"+document.form1.curso.options[document.form1.curso.selectedIndex].value;
		document.form1.fecha.value="01/"+document.form1.mes.options[document.form1.mes.selectedIndex].value+"/"+curdate.getUTCFullYear();
		window.frames[0].location="numero_de_recibo.php?curso="+document.form1.curso.options[document.form1.curso.selectedIndex].value+"&mes="+document.form1.mes.options[document.form1.mes.selectedIndex].value;
	}
	document.form1.concepto.value=concepto;
	document.form1.importe.value=importe;	
	document.form1.concepto_label.value=concepto;
	document.form1.importe_label.value=importe;
}

function abrir(what,myW,myH){
	retorno = window.showModalDialog(what, "nueva", OUTPUT="width="+myW+",height="+myH+",top=0,left=50,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");
	window.location.href = "?"+retorno;
	//window.open(what, "conceptos", OUTPUT="width="+myW+",height="+myH+",top=0,left=50,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");
}

function imprimir(){
	win = window.open("intranet_recibos_imprimir.php",'popup','width=640,height=480,toolbar=no,status=no,resizable=no,scrollbars=no');
	if (focus) win.focus();		
}

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (test=='isChecked') {
	  if (!IsChecked(val)){ nm=val[0].name; errors += '- '+nm+' debe seleccionarse.\n'};
  	}  
	if (val) { nm=val.name; if ((val=val.value)!="") {
	  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una dirección de correo.\n';
      } else if (test!='R' && test!='isChecked') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe ser un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe ser un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n';}
  } if (errors) alert('ha ocurrido el siguiente error:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

setInterval('blinkIt()',500);
