function pageFunctions(){
    if (!$("form#contact").size()){
        pageTeam();
    } else {
        contactForm();
    }
}

function pageTeam(){
    // Define active class if not defined
    //if (!$(".active").size()){
    //    $(".user:first").addClass("active");
    //}
    // Hide all except active class + swap image
    $(".team_body").hide();
    
    
    if ($(".active").size()){
    	$(".active .team_body").show(function(){$(this).show()});
    	ImageSwap($(".active .team_head img"), "open.gif", "close.gif");
    };
    // RollOver on team_head
    $(".team_head").hover( function() {
        ImageSwap($(this).find("img"), ".gif", "_hover.gif");
    }, function() {
        ImageSwap($(this).find("img"), "_hover.gif", ".gif");
    });

    // Click behaviour
    $(".team_head").click(function(){
    
    
    	if (!$(".active").size()){
        	$(this).parent().addClass("active");
        	$(".active .team_body").show(function(){$(this).show()});	
        }
        else
        {	
        	$(this).parent().addClass("next");
        	$(this).find("img").attr("src", "/images/layout/close.gif");
        
        	// Hide opened element
       	 	$(".team_body:visible").slideUp(function(){
            	$(this).parent().find(".team_head").find("img")
                	.attr("src", "/images/layout/open.gif");
            
           	 $(".next").removeClass("next").find(".team_body").show(function(){
                	$(this).show();
            	});
       		 });
        }
    });
}

/*  CONTACT    */

function callContactForm(){
    dataStr  = "user="+$("#user").attr("value");
    dataStr += "&name="+$("#name").attr("value");
    dataStr += "&email="+$("#email").attr("value");
    dataStr += "&message="+$("#message").attr("value");
    
    $("#loader").show();
    $.ajax({
        type: "GET",
        url: $("form#contact").attr('action'),
        data: dataStr,
        success: function(data){
            $("#block").html(data);
            contactForm();
            $("#loader").hide();
        }
    });
}

function contactForm(){

    $("#submit").click(function(){
        callContactForm();
        return false;
    });
}
