(function($) {
	$.fn.currentPage = function(options){ // default configuration properties
        var path = location.pathname
        this.each(function() {
			var obj = $(this);
            if(obj.attr("href") == path.replace("/",""))
                obj.addClass("currentPage");
        });
	}
	$.fn.loadFacebookMenu = function(options){ // default configuration properties
        this.each(function() {
			var obj = $(this);
            var timer;
            obj.click(function(){ 
                $("#facebookMenu").slideDown()
                $("#twitterMenu").stop().hide()
                $("#clientLogInMenu").stop().hide()

            })
            obj.bind("mouseover",function(){ clearTimeout(timer) })
            obj.bind("mouseout",function(){
                timer = setTimeout(function(){$( "#facebookMenu").stop().hide() },250)
            }) 
            $("#facebookMenu").bind("mouseover",function(){clearTimeout(timer)})
            $("#facebookMenu").bind("mouseout",function(){
                timer = setTimeout(function(){ $("#facebookMenu").stop().hide() },250)
            })
            
        });
	}
    $.fn.loadTwitterMenu = function(options){ // default configuration properties
        this.each(function() {
			var obj = $(this);
            var timer;
            obj.click(function(){
                $("#twitterMenu").slideDown()
                $("#facebookMenu").stop().hide()
                $("#clientLogInMenu").stop().hide()

            })
            obj.bind("mouseover",function(){ clearTimeout(timer) })
            obj.bind("mouseout",function(){
                timer = setTimeout(function(){$( "#twitterMenu").stop().hide() },250)
            })
            $("#twitterMenu").bind("mouseover",function(){clearTimeout(timer)})
            $("#twitterMenu").bind("mouseout",function(){
                timer = setTimeout(function(){ $("#twitterMenu").stop().hide() },250)
            })

        });
	}
    $.fn.loadClientMenu = function(options){ // default configuration properties
        this.each(function() {
			var obj = $(this);
            var timer;
            obj.click(function(){
                $("#clientLogInMenu").slideDown()
                $("#facebookMenu").stop().hide()
                $("#twitterMenu").stop().hide()

            })
            obj.bind("mouseover",function(){ clearTimeout(timer) })
            obj.bind("mouseout",function(){
                timer = setTimeout(function(){$( "#clientLogInMenu").stop().hide() },250)
            })
            $("#clientLogInMenu").bind("mouseover",function(){clearTimeout(timer)})
            $("#clientLogInMenu").bind("mouseout",function(){
                timer = setTimeout(function(){ $("#clientLogInMenu").stop().hide() },250)
            })

        });
	}

    $.fn.autoScroller = function(options){ // default configuration properties
        this.each(function() {
			var obj = $(this);
            setInterval(function(){
                if(obj.position().top == (obj.children().length-1)* -70 )
                    nextPosition = "0px";
                else
                    nextPosition = obj.position().top - 70 + "px";
                obj.animate({top: nextPosition}, 600, "swing");
                if(obj.position().top % 70 != 0)
                    obj.css("top",floor(obj.position().top/70)*70 + "px")
            },7000);

        });
	}
})(jQuery);

$(document).ready(function(){
    $("#menu a").currentPage();
    $(".mouseOver").css("cursor","pointer").hover(
	  function () {$(this).css("opacity","0.9");},
	  function () {$(this).css("opacity","1");}
	);
    $("#facebookIcon").loadFacebookMenu({});
    $("#twitterIcon").loadTwitterMenu({});
    $("#clientLogInIcon").loadClientMenu({});
    $("#tweets").load('php/twitterFeed.php',function(){$("#tweets").autoScroller();});
});





