// JavaScript Document
$(document).ready(function() {
    // Clear Fix
    $('<style type="text/css">.clearfix:after {visibility: hidden;display: block;font-size: 0;content: " ";clear: both;height: 0;}* html .clearfix { zoom: 1; }*:first-child+html .clearfix { zoom: 1; }textarea{resize:none;}</style>').appendTo("head");
    // Back to Top
    $('a.backToTop').click(function() {
        $('body,html').animate({
            scrollTop: 0
        });
        return false;
    });
    $('a.decrease_font').click(function() {
        var currentFontSize = $('#contentWra div.wrapper').css('font-size');        
        if (currentFontSize != "12px") {
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var newFontSize = currentFontSizeNum - 1;
            $('#contentWra div.wrapper').css('font-size', newFontSize);
        }
        return false;
    });
    $('a.increae_font').click(function() {
        var currentFontSize = $('#contentWra div.wrapper').css('font-size');
        if (currentFontSize != "14px") {
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var newFontSize = currentFontSizeNum + 1;
            $('#contentWra div.wrapper').css('font-size', newFontSize);
        }
        return false;
    });
    
    // Sub Menu
// Sub Menu
	$("ul.navigation li a.mainmenu").hover(function() {
	$(this).parent().find("ul.subnav").stop(true, true).fadeIn('fast');
	$(this).parent().find("ul.subnav").css('width', 'auto');
	var ulWidth = $(this).parent().find("ul.subnav").width();
	$(this).parent().find("ul.subnav li").css('width', ulWidth); 
		$(this).parent().find("a.mainmenu").addClass("active"); 		  
			var LiPos = $($(this).parent()).position();
			var LiLeftPos = LiPos.left;
			var LiTopPos = LiPos.top + 123;
			$(this).parent().find("ul.subnav").css("left",LiLeftPos+'px');
			$(this).parent().find("ul.subnav").css("top",LiTopPos+'px');			
	
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").fadeOut('fast'); //When the mouse hovers out of the subnav, move it back up
			$(this).parent().find("a.mainmenu").removeClass("active"); 
		});
	});
	
	
});
