
function objetoAjax(){
        var xmlhttp=false;
        try {
               xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
               try {
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
               } catch (E) {
                       xmlhttp = false;
               }
        }

        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
               xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}

function selectMonth(ts) {
	document.main.CalendarDate.value=ts;
	document.main.submit();
}

function selectDay(ts,p,l) {
	document.main.CalendarDate.value=ts;
	process(p,l);
}

function process(name,level) 
{
	setAction(name,level);
	document.main.submit();
}

function setAction(name,level)
{
	lastActions = document.main.lastAction.value;

   j = 0;
   k = lastActions.length;
   i = 0;
   actions = Array();
   actions = lastActions.split("|");
   actions[level] = name;
   
   newLastActions = "";

   for(i=0;i<(level+1);i++) {
       newLastActions = newLastActions + (actions[i]+"|");
   }

   document.main.lastAction.value = newLastActions;
}


function clearAll() {
   //document.main.lastAction.value='';
}

function setcookie(name,value){
   cookiestring=name+"="+escape(value);
   document.cookie=cookiestring;
}

/*function para marcar o desmarcar los checkbox de busqueda*/
function marcarTodo(name_form,thestate)
{
	var formulario=document.forms[name_form];
	  for (var i=0;i<formulario.elements.length;i++)
	  {
			 var e = formulario.elements[i];		
			 if (e.type == 'checkbox')
				 e.checked = thestate;						 		 
	  }
} 



/*insercion de funcion de validacionde email de formularios*/
 function validaEmail(control){
			var str=control.value;
		 	if(str=='')				
				return true;
				
			var at='@'
			var dot='.'
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			var msg='El email debe ser válido';
			if (str.indexOf(at)==-1){
			   alert(msg)
			   return false
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert(msg)
			   return false
			}	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				alert(msg)
				return false
			}	
			if (str.indexOf(at,(lat+1))!=-1){
				alert(msg)
				return false
			}	
			if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				alert(msg)
				return false
			}	
			if (str.indexOf(dot,(lat+2))==-1){
				alert(msg)
				return false
			}			
			if (str.indexOf(' ')!=-1){
				alert(msg)
				return false
			}	
			return true					
}

function fullScreen(theURL) {
window.open(theURL, '', 'menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no,scrollbars=auto');
}


