// JavaScript Document
var com = com || {};
com.as = com.as || {};

com.as.Buttons = function(){
	// variables globales
};
	
com.as.Buttons.prototype = {

	setBindHoverAllTagAOfMenu : function(selector) {
		$(selector).hover(
			function() {
				if ($(this).attr('name') != 'select'){
					$(this).css("color","#8dc83e").addClass("ahover");					
				}
			},
			function() {
				if ($(this).attr('name') != 'select'){
					$(this).css("color","#fff").removeClass("ahover");
				}
			}
		);
	},
    // for all
	setBindClickToLoadPage : function(selectorClick, selectorTagsAOfMenu, selectorLoading, selectorContent,requestPage){with (this){	
		$(selectorClick).bind('click', function(evento){								   
			$(selectorTagsAOfMenu).attr('name','unselect').css("color","#fff").removeClass("ahover");
			$(this).attr('name','select').css('color','#8dc83e').addClass("ahover");
			$(selectorContent).animate({opacity:0.1});
			$(selectorLoading).fadeIn(400, function(){
				$(selectorContent).load(requestPage, function(){		  
					$(this).animate({opacity:1});									
					$(selectorLoading).fadeOut();
                    
					fleXenv.fleXcrollMain('scrollable');					
					fleXenv.fleXcrollMain('scrollable_corina');
                    
                    var sendMail = new  com.as.SendAMail(); 
				});
			});	
			evento.preventDefault();
		});
	}},
    
    /* for option arranjos */
    setBindClickToLoadDataArr : function(id, selectorMenuGallery, containerGalleries, loading){with (this){
        $(selectorMenuGallery).attr('name','unselect').removeClass('ahover').css('color','#fff');
        $(id).attr('name','select').addClass('ahover').css('color','#8dc83e');
        
        $(containerGalleries).animate({opacity: 0.1});

        $(loading).fadeIn(400,function(){

            $(containerGalleries).load('/wp-content/themes/corinaTheme/galleries.php?post='+$(id).attr('href'),{id_gallery : id.substr(id.indexOf('_') + 1)}, function(){
                $(this).adGallery();
                $(this).animate({opacity: 1});
                $(loading).fadeOut();
                setHover('.ad-prev', '.ad-prev-image');
                setHover('.ad-next', '.ad-next-image');
            });
        });
    }},
    setHover : function(contElem, elemento){
        $(contElem).hover(
            function(){
                $(elemento).css('opacity', 1);
            },
            function(){
                $(elemento).css('opacity', 0.7);
            }
        );
    },                                   //'#arranjos',"#menu li a",'#ajax_loader','#container_right','arranjos.php','#gallery_container', '#menu_gallery li a'
    setBindClickToLoadPageArr : function(selectorClick, selectorTagsAOfMenu, selectorLoading, selectorContent,requestPage,containerGallery,menuGallery){with (this){
		$(selectorClick).bind('click', function(evento){
			$(selectorTagsAOfMenu).attr('name','unselect').css("color","#fff").removeClass("ahover");
			$(this).attr('name','select').css('color','#8dc83e').addClass("ahover");
			$(selectorContent).animate({opacity:0.1});
			$(selectorLoading).fadeIn(400, function(){
				$(selectorContent).load(requestPage, function(){
                                        
					$(this).animate({opacity:1});									
					$(selectorLoading).fadeOut();
                    $(containerGallery).adGallery();
                        setHover('.ad-prev', '.ad-prev-image');
                        setHover('.ad-next', '.ad-next-image');                                            
                    //$('#gallery_24').addClass('ahover');
                    setBindHoverAllTagAOfMenu(menuGallery);
                    $(menuGallery).click(function(evento){
                        evento.preventDefault();
                        setBindClickToLoadDataArr('#'+this.id, menuGallery, containerGallery, selectorLoading);    
                    });
                    $('#menu_gallery li a:first').trigger('click');
				});
			});
                        evento.preventDefault();
		});
	}},
    
	/* for option courses */
	setBindHoverAllTagsOfMenuCourses:function(selector){
		$(selector).hover(
			function(){
				if($(this).attr('name') != 'select'){
					$(this).addClass('divhover');
				}
			},
			function(){
				if($(this).attr('name') != 'select'){
					$(this).removeClass('divhover');	
				}
			}
		);	
	},
    /* Para cargar courses.php */
	setBindClickToLoadPageDataCourses : function( id, selectorTagsDOfMenuC ){
			
			$(selectorTagsDOfMenuC).attr('name','unselect').removeClass('divhover');
			$('#'+id).attr('name','select').addClass('divhover');
            // cargar contenido requerido
            $('#learn_more').load('/wp-content/themes/corinaTheme/coursesquery.php?post='+id, {id_c : id},function(){
                fleXenv.fleXcrollMain('requests');
            });
            
	},
	setBindClickToLoadPageCourses : function(selectorClick, selectorTagsAOfMenu, selectorLoading, selectorContent,requestPage, selectorTagsDOfMenuC ){with (this){	
	
		$(selectorClick).bind('click', function(evento){
			$(selectorTagsAOfMenu).attr('name','unselect').css("color","#fff").removeClass("ahover");
			$(this).attr('name','select').css('color','#8dc83e').addClass("ahover");
			$(selectorContent).animate({opacity:0.1});
			$(selectorLoading).fadeIn(400, function(){
													
				$(selectorContent).load(requestPage, function(){		  
					$(this).animate({opacity:1});									
					$(selectorLoading).fadeOut();
					$(selectorTagsDOfMenuC+':first-child').addClass('divhover');
                    var id_course = $(selectorTagsDOfMenuC+':first-child').attr('id');
					
                    // cargar por default 
                    $('#learn_more').load('/wp-content/themes/corinaTheme/coursesquery.php?post='+id_course,{id_c : id_course},function(){
                        fleXenv.fleXcrollMain('requests');
                    });   
                    // cargar cuando hacemos click en el menu                                  
					$(selectorTagsDOfMenuC).click( function(evento){
						setBindClickToLoadPageDataCourses(this.id, selectorTagsDOfMenuC);
					});
					setBindHoverAllTagsOfMenuCourses(selectorTagsDOfMenuC);
					fleXenv.fleXcrollMain('container_menu');
					evento.preventDefault();
				});
				
			});	
			evento.preventDefault();
		});
	}}
		
};
