/*==================================================
    => core 2nd level
==================================================*/


/*==================================================
    => fontsizer
==================================================*/

$(document).ready(function(){
	fontsizer();
});

function fontsizer(){
	$("ul.fontsizer").mouseenter(function () {
		if ($("ul.fontsizerShowHide").is(":hidden")) {
		$("ul.fontsizerShowHide").fadeIn("normal");
		}
	});
	
	$("ul.fontsizer").mouseleave(function () {
		if ($("ul.fontsizerShowHide").is(":visible")) {
		$("ul.fontsizerShowHide").fadeOut("normal");
		}
	});
}

/*==================================================
    => background resizer
==================================================*/

var iHeaderImgHeight = 1200;
var iHeaderImgWidth = 1600; 

$(window).resize(function(){
	resize_window();
	var win_height = $(window).height();				 					
	resize_HeaderImg();					
	}
);

function resize_window(){
	var win_height = $(window).height();
	var win_width =  $(window).width();
	if (win_height <= 675){
		$('body').css('height', 675);
		win_height = 675;
	}else {
		$('body').css('height', '100%');
	} 
	if (win_width <= 900){
		$('body').css('width', 900);
		win_width  = 900;
	}else {
		$('body').css('width', '100%');
	}
}

function resize_HeaderImg(img){
	var win_h = $('body').height();
	var win_w = $('body').width();
	var img_h = iHeaderImgHeight;
	var img_w = iHeaderImgWidth;
	var dim_h = (win_h/img_h);
	var dim_w = (win_w/img_w);
	if(!img) img = $("#wrapper img");
	if(dim_w > dim_h){
		var new_h = parseInt(img_h*dim_w);
		var new_w = parseInt(img_w*dim_w);
		img
		.css("height",new_h)
		.css("width",new_w)
		.css("top",parseInt((new_h-win_h)/-2))
		.css("left",0); 
		} else {
		var new_h = parseInt(img_h*dim_h);
		var new_w = parseInt(img_w*dim_h);
		img
		.css("height",new_h)
		.css("width",new_w)
		.css("left",parseInt((new_w-win_w)/-2))
		.css("top",0); 
	}
}

$().ready(function(){
	resize_window();
	resize_HeaderImg();
});

/*==================================================
    => tooltip
==================================================*/

(function($) {
	$.fn.easyTooltip = function(options){
		// default configuration properties
		var defaults = {	
			xOffset: -125,		
			yOffset: -25,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");
			$(this).hover(function(e){						 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")				
						.css("display","none")
						.fadeIn("normal")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	};
})(jQuery);