var winModalWindow;

function clientvalidateDate(oSrc, args){
		    var f = document.forms[0];
			var day = f.ddlDia.options[f.ddlDia.selectedIndex].value;
			var month = f.ddlMes.options[f.ddlMes.selectedIndex].value;
			var year = f.ddlAno.options[f.ddlAno.selectedIndex].value;
			var err = 0;
			var leap = 0;
			
			if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
				leap = 1;
			}
			if ((month == 2) && (leap == 1) && (day > 29)) {
				err = 23;
			}
			if ((month == 2) && (leap != 1) && (day > 28)) {
				err = 24;
			}
			/* Validation of other months */
			if ((day > 31) && ((month == "1") || (month == "3") || (month == "5") || (month == "7") || (month == "8") || (month == "10") || (month == "12"))) {
				err = 25;
			}
			if ((day > 30) && ((month == "4") || (month == "6") || (month == "9") || (month == "11"))) {
				err = 26;
			}
			
			if (err==0){
				args.IsValid = true
			} else {
				args.IsValid = false
			}
   
        }

        
function clientvalidate(oSrc, args){
		    var f = document.forms[0];
			var s = f.hdnClose.value;
			var arrDate = s.split("/");
			if (f.UpperTemplate_Seeker_EndYear.value > arrDate[1]) {
				args.IsValid = false
			}
			else
			{
				if ((f.UpperTemplate_Seeker_EndYear.value == arrDate[1]) && (parseInt(f.UpperTemplate_Seeker_EndMonth.value) > parseInt(arrDate[0]))) {
					args.IsValid = false
				} else {
					args.IsValid = true
				}
			}
        }
function clientvalidateGT(oSrc, args){
		    var f = document.forms[0];
			var s = f.hdnClose.value;
			var arrDate = s.split("/");
			if (f.UpperTemplate_Seeker_EndYear.value > arrDate[1]) {
				args.IsValid = true
			}
			else
			{
				if ((f.UpperTemplate_Seeker_EndYear.value >= arrDate[1]) && (parseInt(f.UpperTemplate_Seeker_EndMonth.value) >= parseInt(arrDate[0]))) {
					args.IsValid = true
				}else {
					args.IsValid = false
				}
			}
        }		
        
function clientvalidateCP(oSrc, args){
		    var f = document.forms[0];

			if (f.UpperTemplate_Seeker_StartYear.value > f.UpperTemplate_Seeker_EndYear.value ) {
				args.IsValid = false
			}
			else
			{
				if ((f.UpperTemplate_Seeker_StartYear.value == f.UpperTemplate_Seeker_EndYear.value) && (parseInt(f.UpperTemplate_Seeker_StartMonth.value) > parseInt(f.UpperTemplate_Seeker_EndMonth.value))) {
					args.IsValid = false
				}else {
					args.IsValid = true
				}
			}
        }        
function ShowWindow(path,width,height) {
	if (window.showModalDialog) {
		rv = window.showModalDialog(path,null,"status:no;dialogWidth=" + width + "px;dialogHeight=" + height + "pxdialogHide:true;help:no;scroll:no;");
	}
	else {
		window.top.captureEvents (Event.CLICK|Event.FOCUS);
		window.top.onclick=IgnoreEvents;
		window.top.onfocus=HandleFocus;
		winModalWindow = window.open (path,"ModalChild","dependent=yes,width=" + width + ",height=" + height + "");
		winModalWindow.focus();
	}
}

function MM_swapImgRestore() {
	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() {
	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_swapImage() {
	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_findObj(n, d) {
	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 CreateScrollablePopup(id, url, popWidth, popHeight) {
	var xCenter = (screen.width - popWidth) / 2;
	var yCenter = (screen.height - popHeight) / 2;	id=window.open(url,id,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+popWidth+',height='+popHeight+',left='+xCenter+',top='+yCenter+'');
	return false;
}

function ClickOnForm(objectId, buttonId) {
	if ((objectId.which && objectId.which == 13) || (objectId.keyCode && objectId.keyCode == 13)) {
		buttonId.click();
		return false;
	} 
	else {
		return true;
	}
}

function ConfirmarEliminacion() {
	if (!(confirm("Está seguro que desea eliminar ese registro?"))){
		event.returnValue = false;
	}
	
}