// ************* DEFINE CUFON TEXT REPLACMENTS

// Main menu links
Cufon.replace('a.mi', { hover:true, fontFamily: 'Rockwell' });

// Main header and home column headers
Cufon.replace('#tag-line, .home-column h2', { hover:true, fontFamily: 'Rockwell' });

//Page content headings
Cufon.replace('#page-content h2, #page-content h3, #page-content h4, #page-content h5', { hover:true, fontFamily: 'Rockwell' });

//Right sidebar headings
Cufon.replace('#right-sidebar h2, #left-sidebar h2, .newsletter', { hover:true, fontFamily: 'Rockwell' });

//homepage headings
Cufon.replace('#showcase h2', { hover:true, fontFamily: 'Rockwell' });


// make jQuery no conflic with other APIs
var $j = jQuery.noConflict();

var storyID = 1;

var img_domain = "http://www.jumpmanagementcoaching.com/wp-content/themes/jumpmanagement/";

// define on load font size (in %)
var fontSize = 100;

// extend jquery 
$j.fn.wait = function(time, type) {
	time = time || 500;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
        setTimeout(function() {
        	$j(self).dequeue();
        }, time);
    });
};

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


// ************* DEFINE jQuery functions
$j(document).ready(function(){

	/* prelaod the images */
	jQuery.preLoadImages((img_domain + "images/homepage/inspired.jpg"),(img_domain + "images/homepage/energized.jpg"),(img_domain + "images/homepage/balanced.jpg"),(img_domain + "/images/menu-item-back-over.png"));

	// Define easing type
	jQuery.easing.def = 'easeOutSine';
	
	$j("div.showcase-block:first").wait(500).fadeIn("normal");
	
	$j("div.sidebar-item").find("li:last").addClass("no-border");
	
	
	$j("li.submenu-item").hover(
		function () {
			/* mouse over */
			$j(this).addClass("submenu-bullet");
      	}, 
      	function () {
			/* mouse out */
        	$j(this).removeClass("submenu-bullet");
      	}

	);
	
	$j("li.catmenu-item").hover(
		function () {
			/* mouse over */
			$j(this).addClass("catmenu-bullet");
      	}, 
      	function () {
			/* mouse out */
        	$j(this).removeClass("catmenu-bullet");
      	}

	);
	
});


/* function - loops headline on the homepage */
var wait = setInterval(showHeadline,5000);

function showHeadline() 
{
	// get object to fade out
	var f_out = "#showcase-block-" + storyID;
	
	// get the id of object to fade in
	if(storyID >= 3) storyID = 1;
	else storyID ++;
	
	// get object to fade in
	var f_in = "#showcase-block-" + storyID;

	$j(f_out).fadeOut(1000,function() {
		// Animation complete now fade in new story
		$j(f_in).fadeIn("normal");
	});
}

function initHeadline()
{
	// ************* DEFINE - home page fadein headline and headline-back
	$j("#headline-back").wait(1000).slideDown(1000,function() {
		// Animation complete now fade in new story
		$j("#headline-1").find('p').wait(500).fadeIn("fast");
	});
}


/* function - sets the active menu section and change link style 
function setActiveMenu(title)
{
	var t = title.toLowerCase();
	var id = "#mi-";
	
	if(t.indexOf('our firm') != -1) id += "firm";
	if(t.indexOf('meet our lawyers') != -1) id += "lawyers";
	if(t.indexOf('areas of practice') != -1) id += "practice";
	if(t.indexOf('useful links') != -1) id += "links";
	if(t.indexOf('news') != -1) id += "news";
	if(t.indexOf('contact') != -1) id += "contact";
	
	if(id != "#mi-")
	{
		var obj = $j(id).find('a.menu-link');
		obj.addClass("menu-link-active");
		obj.removeClass("menu-link");
	}
	
	// special case for resizing contact page
	if(t.indexOf('contact') != -1)
	{
		$j("#content-overlay").css('width','910px');
	}
	
	// special case for meet our lawyers
	if(t.indexOf('meet our lawyers') != -1)
	{
		$j("div.lThumb").fadeTo(100, 0.5);
	}
}*/
	

/* Preload images and rollover functions 

var imgPreloads = ["../images/homepage/inspired.jpg","../images/homepage/energized.jpg","../images/homepage/balanced.jpg"];
var imgObj = new Image();

for(var i=0; i<imgPreloads; i++)
{
	imgObj.src = imgPreloads[i];
}


function swapImg(obj,img) 
{
	obj.src = img;
}

*/
	
	
	
	
	
	
	
	
	
	
