//jQuery.noConflict();
(function($) {
	//Custom Fontsizer App
	$.FontSizer = {

        level: -2.5,

        options : {            
                min: -4,
                max: 5
        },

        Init : function(options) {
                if(options)
		    $.FontSizer.options = $.extend($.FontSizer.options, options);

                //Get the current level from cookies.
                var level = ($.cookie('font_level') != null) ? $.cookie('font_level') : 0;                      

                //Set the font size to the current level.
                $.FontSizer.SetSize(level);

        },

        IncreaseSize : function() {

                if(($.FontSizer.level) + 1 <= $.FontSizer.options.max) {            
                        //If we have not exceded the max level,
                        //Get the next level and the set the size to this level.
                        var next = (parseFloat($.FontSizer.level) + 1);
						//alert('parseFloat =' + next);
						$.FontSizer.SetSize(next);  
                }

        },

        DecreaseSize : function() {
                if(($.FontSizer.level - 1) >= $.FontSizer.options.min) {
                        //If we have not exceded the min level,
                        //Get the next level and the set the size to this level.
                        var next = (parseFloat($.FontSizer.level) - 1);
                        $.FontSizer.SetSize(next);  
                }      
        },      

        SetSize: function(level) {

                //Set the current level in the member variable and the cookie.
                $.FontSizer.level = level;      
                $.cookie('font_level', level);

                //Work out the new em value and set it.
                var level = (level / 10) + 1;
				//alert('fontSize' + level + " ems");
                $("body").css("fontSize", level+"em");    

        },

        Reset: function() {
            
            //Reset the level back to 0
            $.FontSizer.SetSize(-2.5);
        
        }

	};
		$(function(){
		$('#menuList').jdMenu();
			// Add menu hiding on document click
			$(document).bind('click', function() {$('#menuList ul:visible').jdMenuHide();});
		});
		
		
		var randomnumber=Math.floor(Math.random()*2)
		$(document).ready(function(){
		 //$(".navigation").gradient({from: 'ffffff', to:'cccccc'});
		 $('.fontsizer tr:even').addClass("altfont");
		 $('.fontsizer tr').mouseover(function(){$(this).addClass("over")}).mouseout(function(){$(this).removeClass("over")});
		 $(".tx-wecconnector-button").removeClass().addClass("wecconnector-button");       
		 $("input").focus(function(){$(this).css("background-color", "#DFF1FF" )});
		 $("input").blur(function(){$(this).css("background-color","white")});
		 $("input.bank").focus(function(){$(this).parent().children("span.hint").show();});
		 $("input.bank").blur(function(){$(this).parent().children("span.hint").hide()});
		 $("ol.faq > li > div").hide();
		 $("ol.faq > li > h3").toggle( function(){ 
				$(this).parent().children("div").show("medium"); 
			}, function(){ 
				$(this).parent().children("div").hide(); 
			}
		   );
		//$('#tourcontainer').tabs({ remote: true });
		 /*
		 $('#tourcontainer ul li a span').click(function(){
											  var myimage = $(this).parent("a").attr("title");
											  var myurl = $(this).parent("a").attr("href");
											  $.get('http://www.trinityashland.org/fileadmin/images/tour.php',{tour_id:myimage},function(data){$('#tourplayer').empty().append(data);});
											  return false
											  });
		 */
		 $('li.submenu1 ul').parent().children("span").children("a").append(' &nbsp;<b>&raquo;<\/b>');
		 $('li.submenu2 ul').parent().children("span").children("a").append(' &nbsp;<b>&raquo;<\/b>');
		 $('li.submenu3 ul').parent().children("span").children("a").append(' &nbsp;<b>&raquo;<\/b>');
		 $('ul.adxm li').mouseover(function(){
									   $(this).css({background:"#6DA9C7"});
									   $('ul.adxm_vertical').hide();
									   })
		 				.mouseout(function(){
									   $(this).css({background:"#C93F00"});
									   $('ul.adxm_vertical').show();
									   });
		 $('ul.adxm_vertical li').mouseover(function(){$(this).css({background:"#FAFAFA"})}).mouseout(function(){$(this).css({background:"#EDF6FA"})}).children("span.act").parent().css({background:"#FADB3E"}).mouseover(function(){$(this).css({background:"#FAFAFA"})}).mouseout(function(){$(this).css({background:"#FADB3E"})});
		 
		 $("ol.faq > li > div").hide();
		 $("ol.faq > li > h3").toggle( function(){ 
				$(this).parent().children("div").show("medium"); 
			}, function(){ 
				$(this).parent().children("div").hide(); 
			}
		);
		
		//Begin new font-sizing
		
		//Get the current level from cookies.
        var level = ($.cookie('font_level') != null) ? $.cookie('font_level') : 16;
		$('html').css('font-size',level + 'px');
		// Reset Font Size
  		var originalFontSize = $('html').css('font-size');
    	$(".resetFont").click(function(){
    			$('html').css('font-size', '16px');
				return false;
  			});
  		// Increase Font Size
  		$(".increaseFont").click(function(){
    		var currentFontSize = $('html').css('font-size');
    		var currentFontSizeNum = parseFloat(currentFontSize, 10);
    		var newFontSize = currentFontSizeNum*1.2;
			$.cookie('font_level', newFontSize);
    		$("html").css('font-size', newFontSize);
    		return false;
 		 });
  		// Decrease Font Size
  		$(".decreaseFont").click(function(){
   			var currentFontSize = $("html").css('font-size');
    		var currentFontSizeNum = parseFloat(currentFontSize, 10);
    		var newFontSize = currentFontSizeNum*0.8;
			$.cookie('font_level', newFontSize);
    		$("html").css('font-size', newFontSize);
    		return false;
  		});
		
		//End new font-sizing 
		
		
// Preload all rollovers
		$(".rollover img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});

		// Navigation rollovers
		$(".rollover a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);

			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}

		});
		$(".rollover a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		var wrapperheight = $('#content-wrapper').outerHeight();
		var leftcolumnremain = wrapperheight + 188;
		//alert ('left height =' + leftcolumnremain);
		$('#left-column').height(leftcolumnremain);
		$('#main-content').height(wrapperheight);
		});
})(jQuery)
