function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var old_menus = [];
var delay = 500;

function MM_showHideLayers() {
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i += 3) {
		if ((obj=MM_findObj(args[i])) != null) {
			v = args[i+2];
			if (obj.style) {
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
				showhide(obj, v);
			}
		}
	}
}
function hideAllOthers()
{
	while(old_menus.length) {
		var menu = old_menus.pop();
		if(typeof menu.timeout != "undefined") window.clearTimeout(menu.timeout);
		//$(menu).stop(true, true).hide();
		menu.style.visibility = "hidden";
	}
}

function showhide(e, v)
{
	if(typeof e == "undefined") return;
	if(v == "visible") {
		hideAllOthers();
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.style.visibility = v;
	} else {
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.hideAfterDelay = function(){ var me = e; me.timeout = window.setTimeout(function(){ me.style.visibility = "hidden"}, delay) };
		e.hideAfterDelay();
		old_menus.push(e);
	}
}

/***********************************************************************/

$(document).ready(function(){
	$('.mainMenuHolder ul li a:last').addClass('lastLink')
});


/**************************************/
$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").mouseover(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});



/********************Change Font Size************************************/

var max_font_size = 18;
var min_font_size = 10;

$(function(){
	$('a.controls').click(function(){
		var ourText = $('.main-content, .main-content td, .main-content a').not(".more a");
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 12);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'large') {
			if(finalNum < max_font_size) finalNum += 2;
		}
		else if (this.id == 'small'){
			if(finalNum > min_font_size) finalNum -=2;
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});

/********************************************/

var hide_timeout;
$(document).ready(function() {
	$('div.dropmenu').hide();
	$('li.showhideMenu').hover(
	function(){
		if(typeof hide_timeout != "undefined") {
			clearTimeout(hide_timeout);	
		}
		$('li.showhideMenu').not(this).find('div div.dropmenu').stop(true, true).slideUp(300);
		$(this).find('div div.dropmenu').slideDown(400);
	},
	function(){
		if(typeof hide_timeout != "undefined") {
			clearTimeout(hide_timeout);	
		}
		var menu = this;
		hide_timeout = setTimeout(function(){$(menu).find('div div.dropmenu').stop(true, true).slideUp(400)} ,400)}
	);
});

function integrateLike() {
    document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + escape(document.location.toString()) + '&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:75px; height:30px;" allowTransparency="true"></iframe>')
}

function integrateLikeHome() {
    document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + escape(document.location.toString()) + '&amp;layout=standard&amp;show_faces=false&amp;width=259&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:259px; height:30px;" allowTransparency="true"></iframe>')
}
