// UI Functions

function backToProfile()
{
    return;
}

jQuery(function() {

    jQuery('ul.sf-menu').superfish();
    $("div.both").hide();
    $("div.web").show();
    $("a#inv_tab").click(function() {
        $("div.web").hide();
        $("div.inv").css({ 'display': 'block', 'background': '#133880 url(/asset/img/top_tab_bgrd.gif) scroll no-repeat left bottom' });
        return true;
    });
    $("a#web_tab").click(function() {
        $("div.inv").hide();
        $("div.web").css({ 'display': 'block', 'background': '#133880 url(/asset/img/top_tab_bgrd.gif) scroll no-repeat left top' });
        return true;
    });
    $("div.team_member").hover(
	    function() {
	        $(this).css({ 'cursor': 'pointer' });
	    });

    $("div.team_member").click(
	    function(e) {
	        var desc = $(this).find(".popup_member_desc");
	        var descm = $(this).find(".popup_member_desc_more");
	        var pop = $(this).find(".popup");
	        var pointer = $(this).find(".popup_pointer");
	        if (e.target == "javascript:void(0);") {
	            //user clicked on the link under the person's description text. Show more description.
	            var diff = $(desc).height() - $(descm).height();
	            var poppos = parseInt($(pop).offset().top);
	            var ogtop = parseInt($(pop).attr("rev"));

	            var newtop = poppos + diff;
	            if ($.browser.msie && ($.browser.version.substr(0, 1) == "8")) {
	                newtop = newtop - 20;
	            }
	            //alert($(desc).height() + ", " + $(descm).height() + ", diff=" + diff + ", poppos=" + poppos + ", ogtop=" + ogtop + " newtop=" + newtop);

	            $(desc).slideUp(700);
	            $(descm).slideDown(700);
	            $(pop).animate({
	                top: newtop + "px"
	            }, 700);

	            return;
	        }

	        if (e.target == "javascript:backToProfile();") {
	            //user clicked on the link "Back to Profile" under the Member blurb
	            var poppos = parseInt($(pop).offset().top);

	            var newtop = poppos;
	            var ogtop = parseInt($(pop).attr("rev"));
	            if ($.browser.msie && ($.browser.version.substr(0, 1) == "8")) {
	                newtop = newtop - 20;
	            }

	            $(descm).slideUp(700);
	            $(desc).slideDown(700);
	            $(pop).animate({
	                top: ogtop + "px"
	            }, 700);

	            return;
	        }

	        if ($(pop).css("display") == 'block') {
	            $(pop).hide();
	            $(descm).hide();
	            $(desc).hide();
	            return;
	        } else {
	            $(".popup").hide();
	        }
	        //var t = $(this).find(".popup");
	        if ($(pop).attr("rel") == "" || $(pop).attr("rel") == null) {
	            $(pop).attr({ 'rel': $(pop).height() });
	        }
	        // console.log("");
	        var w = ($(window).width() - 980) / 2;
	        var x = $(this).offset().left;
	        var xx = (x - w - 300);
	        var y = $(this).offset().top;
	        var h = $(pop).attr("rel");

	        var yy = (y - h + 100);
	        if (yy < 0) {
	            yy = 0;
	            if ($(pop).attr("rev") == "" || $(pop).attr("rev") == null) {
	                $(pop).attr({ 'rev': yy });
	            }
	        } else {
	            $(pop).attr({ 'rev': yy });
	        }
	        //alert($(pop).attr("rev"));
	        //alert(this + "::: " + " x = " + x + " y = " + y + " w = " + w + " h = " + h);
	        $(pop).css({ 'left': (w + 300) + 'px' });
	        $(pop).css({ 'top': yy + 'px' });
	        $(pointer).css({ 'top': (11) + 'px' });
	        $(pointer).css({ 'left': (x - w - 260) + 'px' });
	        $(pop).show();
	        $(descm).hide();
	        $(desc).show();

	    }
	);

    $("div.team_member_no_pic").hover(
        function() {
            $(this).css({ 'cursor': 'pointer' });
        }
    );
    $("div.team_member_no_pic").click(
		function() {
		    var w = ($(window).width() - 980) / 2;
		    var x = $(this).offset().left;
		    var y = $(this).offset().top;
		    var h = $(this).find(".popup").height();
		    //alert(this + "::: " + e.target +" x = " + x + " y = " + y + " w = " + w);
		    $(this).find(".popup").css({ 'left': (500) + 'px' });
		    $(this).find(".popup").css({ 'top': (y - h) + 'px' });
		    $(this).find(".popup_pointer").css({ 'top': (8) + 'px' });
		    $(this).find(".popup_pointer").css({ 'left': (x - w - 350) + 'px' });
		    $(this).find(".popup").show();

		},
		function() {
		    $(this).find(".popup").hide();
		}
	);

    $("div.rt_btn").hover(
		function() {
		    $(this).find("div.small_cog_gif").hide();
		    $(this).find("div.small_cog_swf").show();
		},
		function() {
		    $(this).find("div.small_cog_gif").show();
		    $(this).find("div.small_cog_swf").hide();
		}
	);
    $(".tab_mid a").click(function(e) {
        $("div.product_tab").removeClass("active");
        $(e.target).closest("div.product_tab").toggleClass("active");
        var cssclass = $(e.target).attr("class");
        $("div.product_content").each(function(i) {
            if (this.style.display != "none") {
                this.style.display = "none";
            }
        });
        $("div." + cssclass).show();
        return true;
    });

    $("a#my-link1").click(function() {
        $.floatbox({
            content: $("#ctl00_RegionContent_FundsTCLightBox1_pnlTCForm").html(),
            closemsg: "Please, make sure you indicate whether you accept the terms and conditions.",
            fade: true
        });
    });


    // Reset Font Size
    var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function() {
        $('html').css('font-size', originalFontSize);
    });

    // Increase Font Size
    $(".large_text").click(function() {
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.1;
        //$('html').css('font-size', newFontSize);      
        $("div.main_text").css('font-size', newFontSize);
        if ($("div.tab_mid") != null)
            $("div.tab_mid").css('height', 40);
        if($("div.left_side") != null)
        {           
            $("div.left_side").css('font-size', newFontSize);
        }         

        return false;
    });

    // Decrease Font Size
    $(".small_text").click(function() {
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.8;
        //$('html').css('font-size', newFontSize);
        $("div.main_text").css('font-size', newFontSize);
        if ($("div.tab_mid") != null)
            $("div.tab_mid").css('height', 31);
        if($("div.left_side") != null)
        {           
            $("div.left_side").css('font-size', newFontSize);
        }   
        return false;
    });
    
    

});

