function Ajax(objeto_ajax){
    objeto_ajax.datos+="&ran="+random_number();
    if(objeto_ajax.metodo.toUpperCase()=='GET'){
        if(objeto_ajax.tipo==1)$.get(objeto_ajax.url,objeto_ajax.datos,objeto_ajax.funcionEjecuta);
        else{
            if(objeto_ajax.response.toUpperCase()!='XML'){var html = $.ajax({url:objeto_ajax.url,async: false,data:objeto_ajax.datos,type:objeto_ajax.metodo.toUpperCase()}).responseText;}
            else{var html = $.ajax({url:objeto_ajax.url,async: false,data:objeto_ajax.datos,type:objeto_ajax.metodo.toUpperCase()}).responseXML;}
        }return html;
    }else if(objeto_ajax.metodo.toUpperCase()=='POST'){
        if(objeto_ajax.tipo==1)$.post(objeto_ajax.url,objeto_ajax.datos,objeto_ajax.funcionEjecuta);
        else{
            if(objeto_ajax.response.toUpperCase()!='XML'){var html = $.ajax({url:objeto_ajax.url,async: false,data:objeto_ajax.datos,type:objeto_ajax.metodo.toUpperCase()}).responseText;}
            else{var html = $.ajax({url:objeto_ajax.url,async: false,data:objeto_ajax.datos,type:objeto_ajax.metodo.toUpperCase()}).responseXML;}
        }return html;
    }
}
function random_number(){
	return Math.floor(Math.random()*10000);
}

function cargaSpam_join(){ //****** mandar ajax asincrono		
		Spam_Join=Make_Spam_image()+Make_Spam_image()+Make_Spam_image();
		var queryString="spam="+Spam_Join;																						 	
		Ajax({url:'join/php/grafSpam.php',datos:queryString,metodo:'get',tipo:'1',funcionEjecuta:function(data){$("#img_join_validation").html(data);},response:''});			
}
//hacer semilla spam
function Make_Spam_image(){
	var aLetras = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
	var aNumeros = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9');
	var cLetra = aLetras[Math.floor(Math.random() * aLetras.length)];
	var cNumero = aNumeros[Math.floor(Math.random() * aNumeros.length)];
	return (cLetra+cNumero).toUpperCase() ;
}

function change_layer1(destino){
           window.open('start.php?layer='+destino);
}

function gotolayer(destino){
        switch (begin_load){				
                case 1:
                        gotolayer2(destino);
                break;
                default:
                        if (new_tab==1)
                             new_tab_window(destino);
                        else                            
                            gotolayer2(destino);                                                      
                break;
            }                                                                        
}

function carrucel(){
    $.fn.infiniteCarousel = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
            });                
            
            return false;
        }
        
        $wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
        
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });
        
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    });  
};
}

//////////////////////////
function carrucel2(){
    $.fn.infiniteCarousel = function () {
    
    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        
        var $wrapper1 = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper1.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper1.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper1.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            $wrapper1.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper1.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper1.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
            });                
            
            return false;
        }
        
        $wrapper1.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
        
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });
        
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage1(page);
        });
    });  
};
}

function index_key(e,name){
	var KeyID = e.which;
	if (KeyID == 13){
	   if(name=='pass'){
	       $("#login").submit(); 	
	   }
	}
    
}
