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

// Main menu links
Cufon.replace('.main-heading, .subpage-main-heading, .subpage-sub-heading, .sidebar-sub-heading', { hover:true, fontFamily: 'Tungsten Medium' });
Cufon.replace('.sub-heading', { hover:true, fontFamily: 'Tungsten Semibold' });
//Cufon.replace('.monb-title, #home-caption h2, .program-title,', { hover:true, fontFamily: 'Apex New Light' });

// Page content headings
//Cufon.replace('.replace-reg', { hover:true, fontFamily: 'Auto-3' });
//Cufon.replace('.replace', { hover:true, fontFamily: 'Auto-3-SC' });

// Footer, Sidebar, and gallery headings
//Cufon.replace('#footer-tabs h2, #gallery h2, .sidebar-item h2', { hover:true, fontFamily: 'Calibri-bold' });

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

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

var ran = Math.floor(Math.random() *3);

$j(document).ready(function(){

	// Define easing type
	jQuery.easing.def = 'easeOutSine';
	
	/*
		Add carousel functionality
	*/
    $j(".news-carousel").jCarouselLite({
    	scroll: 1,
    	visible: 1,
    	speed: 750,
    	start: ran,
        btnNext: ".next",
        btnPrev: ".prev",
        <!-- easing: "easeOutSine" -->
    });
    
    $j("#slider-controls").mouseleave(function () {
    	$j(this).fadeOut(500);
  	});
  	
  	$j("#slider-controls").mouseenter(function () {
    	window.clearTimeout(timeoutID);
  	});
  	
  	$j("#slider-list").mouseenter(function () {
    	$j("#slider-controls").fadeIn(500);
  	});
    
    
    setFeaturedInfo("item" + (ran+1));
    
    
    
    $j("#ffcf-logo").hover(
    	function() {
    		$j("#head-wrapper").css("background-position", "0 -150px");
    	},
    	function () {
    		$j("#head-wrapper").css("background-position", "0 0");
    	}
    );
    
    $j("#ffcf-support").hover(
    	function() {
    		$j("#head-wrapper").css("background-position", "0 -300px");
    	},
    	function () {
    		$j("#head-wrapper").css("background-position", "0 0");
    	}
    );
    
    
    $j("#facebook").hover(
    	function() {
    		$j("#social").css("background-position", "0 -31px");
    	},
    	function () {
    		$j("#social").css("background-position", "0 0");
    	}
    );
    
    $j("#twitter").hover(
    	function() {
    		$j("#social").css("background-position", "0 -66px");
    	},
    	function () {
    		$j("#social").css("background-position", "0 0");
    	}
    );
	
	/*
		* open links in _blank window if tagged with external 
	*/
	$j('a[rel*=external]').click(function(){
  		this.target = "_blank";
	})
	
	
	// ************* DEFINE - Roll over events for any image tagged with .over
	$j('img.over').each(function() 
	{
    	var t = $j(this);
    	var src = t.attr('src'); // initial src
    	var path = src.substring(0,src.lastIndexOf('/')); // path to file
    	var filename = src.substring(src.lastIndexOf('/'), src.lastIndexOf('.')); // let's get file name without extension
    	
    	t.hover(function(){
        	$j(this).attr('src', path + filename + '-over.' + /[^.]+$/.exec(src)); //last part is for extension 
        	
        	//alert(path+filename+ '-over.' + /[^.]+$/.exec(src));
        	
    	}, function(){
        	$j(this).attr('src', path + filename + '.' + /[^.]+$/.exec(src)); //removing '-over' from the name
        	
        	//alert(path + filname + '.' + /[^.]+$/.exec(src));
    	});
	});
	
	
	var config = {    
     	over: makeTall, // function = onMouseOver callback (REQUIRED)    
     	timeout: 500, // number = milliseconds delay before onMouseOut    
     	out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	
	var config_ = {    
     	over: makeTall_, // function = onMouseOver callback (REQUIRED)    
     	timeout: 500, // number = milliseconds delay before onMouseOut    
     	out: makeShort_ // function = onMouseOut callback (REQUIRED)    
	};

	$j("li.menu-item").hoverIntent( config );
	
	$j("ul.submenu li").hoverIntent( config_ );
	//$j("li.menu-item").hover( showArrow, removeArrow );
	
	//setTimeout("showHeading()", 500);
	
	
	/*var config_filter = {    
     	over: dropOpen,    
     	timeout: 750,    
     	out: dropClose  
	};

	$j("li.filter-item").hoverIntent( config_filter );*/
	
	
	/* PRODUCT PAGES 
	$j("div.product").hover( showBorder, removeBorder );
	$j("div.product").click(function(){

  		 Shadowbox.open( {player:'inline', content:"#sb-html", width:586, height:506 } );
	});*/
	
var col_height = $j(".collection-block").height();
	
$j("ul.thumb li").hover(function() {

	var offset = $j(this).position();
	
	
	var amount = col_height - (offset.top + 120);
	
	//alert("amount is: " + offset.top);

	var thumb = $j(this).find('.thumb-title');
	if($j(this).attr('class') == 'btm') $j("#content-body-home").stop().animate({height:(col_height + 60 +'px')});
	
	$j(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
	$j(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			top: '-41px',
			left: '-41px',
			width: '120px', /* Set new width */
			height: '120px' /* Set new height */
		}, 200, function() { thumb.show(); }); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	$j(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	$j(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			top: '0',
			left: '0',
			width: '32px', /* Set width back to default */
			height: '32px' /* Set height back to default */
		}, 400);
		
	$j(this).find('.thumb-title').stop().hide();
	if($j(this).attr('class') == 'btm') $j("#content-body-home").stop().animate({height:(col_height +'px')});
});
	
	$j(window).resize(function() {
  		centerLogo();
	});

	centerLogo();
});


var timeoutID = window.setTimeout(removeInfo, 3000);

function removeInfo() {
	$j("#slider-controls").fadeOut(500);
	window.clearTimeout(timeoutID);
}


/*function showHeading() {
	$j(".main-header").css("visibility","visible");
}*/

function centerLogo() {
	var offset = $j("#content").offset();
	$j("#logo").css('left',offset.left - 51);
}

function makeTall() {
	var desc = $j(this).find("ul.submenu");
	desc.slideDown('fast');
}

function makeShort() {
	var desc = $j(this).find("ul.submenu");
	desc.slideUp('fast');
}

function makeTall_() {
	var desc = $j(this).find("ul.termenu");
	desc.slideDown('fast');
}

function makeShort_() {
	var desc = $j(this).find("ul.termenu");
	desc.slideUp('fast');
}

function showArrow() {
	$j(this).addClass("over-arrow");
}

function removeArrow() {
	$j(this).removeClass("over-arrow");
}

function setFeaturedInfo(id) 
{
	//hide all
	$j("#item1").hide();
	$j("#item2").hide();
	//$j("#item3").hide();
	//$j("#item4").hide();
	
	//show current
	$j("#" + id).fadeIn("slow");
	
	//remove all indicator classes
	/*$j("#indicator").removeClass("item1-ind");
	$j("#indicator").removeClass("item2-ind");
	$j("#indicator").removeClass("item3-ind");
	$j("#indicator").removeClass("item4-ind");
	
	//add current indicator class
	$j("#indicator").addClass(id + "-ind");*/
}

