	/**
	 *  Funciones generales javascript.
	 *
	 *
	 *
	 */    
 

	function doLogin(form_id, username_id, passowrd_id, method, base64_encode, url_script) {
			
		// TODO: Debe hacer una llamada por ajax de login al script o al action del formulairo. Method es un parametro que indica el algoritmo de codificacion. base64_encode es bool que indica si se envia encodado o no la info.
		
		
	}

	//TODO: Anexar todo lo necesario para upload de files con ajax
	
	/********************************
	*
	*	Manejo de Strings
	*
	*********************************/
	// Removes leading whitespaces
	function LTrim( value ) {
		
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");
		
	}
	
	// Removes ending whitespaces
	function RTrim( value ) {
		
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");
		
	}
	
	// Removes leading and ending whitespaces
	function trim( value ) {
		
		return LTrim(RTrim(value));
		
	}	
	
	

	/********************************
	*
	*	Manejo de Pantalla
	*
	*********************************/

	//Ancho del win
	function windowWidth(){
	  if (parseInt(navigator.appVersion)>3) {
	   if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
	   //winH = window.innerHeight;
	   }
	   if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		//winH = document.body.offsetHeight;
	   }
	  }
	  return winW;
	}
	//<--


	//Alto del win
	function windowHeight(){
	  if (parseInt(navigator.appVersion)>3) {
	   if (navigator.appName=="Netscape") {
		winH = window.innerHeight;
	   //winH = window.innerHeight;
	   }
	   if (navigator.appName.indexOf("Microsoft")!=-1) {
		winH = document.body.offsetHeight;
		//winH = document.body.offsetHeight;
	   }
	  }
	  return winH;
	}
	//<--

	//Tamaņo del Scroll en Y
	function getScrollY() {
	  var scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape
		scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM 
		scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 bill
		scrOfY = document.documentElement.scrollTop;
	  }
	  return  scrOfY;
	}
	

	/********************************
	*
	*	Funciones de Imagenes
	*
	*********************************/

	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];}}
	}


	/********************************
	*
	*	Funciones de HTML
	*
	*********************************/
	
	
	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_nbGroup(event, grpName) { //v6.0
	  var i,img,nbArr,args=MM_nbGroup.arguments;
	  if (event == "init" && args.length > 2) {
		if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
		  img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
		  if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
		  nbArr[nbArr.length] = img;
		  for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
			if (!img.MM_up) img.MM_up = img.src;
			img.src = img.MM_dn = args[i+1];
			nbArr[nbArr.length] = img;
		} }
	  } else if (event == "over") {
		document.MM_nbOver = nbArr = new Array();
		for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
		  if (!img.MM_up) img.MM_up = img.src;
		  img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
		  nbArr[nbArr.length] = img;
		}
	  } else if (event == "out" ) {
		for (i=0; i < document.MM_nbOver.length; i++) {
		  img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
	  } else if (event == "down") {
		nbArr = document[grpName];
		if (nbArr)
		  for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
		document[grpName] = nbArr = new Array();
		for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
		  if (!img.MM_up) img.MM_up = img.src;
		  img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
		  nbArr[nbArr.length] = img;
	  } }
	}



    function x_evaluateIntroKey(e){
    
        if(e && e.which){ //mozilla
            e = e
            characterCode = e.which 
        }
        else {
            if (typeof event =="undefined")
                return;
            e = event
            characterCode = e.keyCode //IE
        }
     
        if(characterCode == 13)
            return true;
        else
            return false;
    
    }


    function x_runJS(){
    
        var elements = $$(".js_code");                
        var code = "";
        var parent = ""
        for(var i=0; i<elements.length;i++){
            //fix para urls
            code =  elements[i].innerHTML.replace(/&amp;/gi, "&");                         
            try{
                eval(code);
            }catch(err){
                alert(code);
                alert(err.message);
            }
            
            //borra el elemento js_code
            parent = elements[i].parentNode;
            parent.removeChild( elements[i]);
            
        }
        
        
    }
	
   function slider(n){
        $("baner"+n).hide();
        if (n>=3){
            n=1;
        }else{
            if(n<1){
                n=1;
            }else{ 
                n++;
            }
        }
        $("baner"+n).show();
        
        setTimeout("slider("+n+")",20000);
   } 
   

	function showVentana(noticia){
        
        x_doAjaxCall("POST", "getImage.php?", "noticia="+noticia, "doShowVentana" ,"","", true,true ); 

    }

    var ventanaCreada = false
    function doShowVentana(responseText) {
        
        //Window.closeAll();
        if (!ventanaCreada){
            windows = new Window({className: "alphacube", title: "Image", width:610 , height:500, destroyOnClose: false, recenterAuto:false});
            ventanaCreada = true;
        }else{
            windows.setSize(610,500);
            windows.setTitle("Image");
        }     
        windows.getContent().update(unescape(responseText)); 
        windows.showCenter();
        
    }   


	function showPrivacy(){
        
        x_doAjaxCall("POST", "privacy.php", "", "doShowVentanaPrivacy" ,"","", true,true ); 

    }

    function doShowVentanaPrivacy(responseText) {
        
        //Window.closeAll();
        if (!ventanaCreada){
            windows = new Window({className: "alphacube", title: "", width:460 , height:630, destroyOnClose: false, recenterAuto:false});
            ventanaCreada = true;
        }else{
            windows.setSize(610,500);
            windows.setTitle("Image");
        }     
        windows.getContent().update(unescape(responseText)); 
        windows.showCenter();
        
    } 

	// Ventana more about Gift Sponsorship
	function moreAboutGiftSponsorship(){
        
		//x_doAjaxCall("POST", "win_giftsponsorship.php", "", "doMoreAboutGiftSponsorship" ,"","", true,true ); 
		x_doAjaxCall("POST", "wingiftsponsorship.php", "", "doMoreAboutGiftSponsorship" ,"","", true,true ); 

    }

	         
    function doMoreAboutGiftSponsorship(responseText) {
        
        //Window.closeAll();
        if (!ventanaCreada){
            windows = new Window({className: "alphacube", title: "", width:460 , height:300, destroyOnClose: false, recenterAuto:false});
            ventanaCreada = true;
        }else{
            windows.setSize(500,300);
            windows.setTitle("More about Gift Sponsorship");
        }
        windows.getContent().update(unescape(responseText)); 
        windows.showCenter();

    } 
	
	
		// Ventana more about Gift Sponsorship
	function moreAboutGiftDonation(){
        
		//x_doAjaxCall("POST", "win_giftsponsorship.php", "", "doMoreAboutGiftSponsorship" ,"","", true,true ); 
		x_doAjaxCall("POST", "wingiftdonation.php", "", "doMoreAboutGiftDonation" ,"","", true,true ); 

    }

	         
    function doMoreAboutGiftDonation(responseText) {
        
        //Window.closeAll();
        if (!ventanaCreada){
            windows = new Window({className: "alphacube", title: "", width:460 , height:300, destroyOnClose: false, recenterAuto:false});
            ventanaCreada = true;
        }else{
            windows.setSize(500,300);
            windows.setTitle("More about Gift Donation");
        }
        windows.getContent().update(unescape(responseText)); 
        windows.showCenter();

    } 
