/**********************************************************************************************
IE6 Drop down menu fix 
***********************************************************************************************/

sfHover = function() {
	var sfEls = document.getElementById("main-navigation").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/*******************************
onFocus field clearers
********************************/
var isl = isl || {};

isl.instructor = {};
isl.instructor.init = function(){
	if($('.instruction-widget')){ //check if widget exists
	
		$('.instruction-widget-image ul li').css('display', 'none'); //initially hide all images
		$('.instruction-widget-image ul li').eq(0).css('display', 'block'); //display first image
		$('.instruction-widget-controls li a').eq(0).addClass('active'); //add active to first control item
		
		// add events to controls
		this.addHandlers();
		
	}
};

// add control event handlers
isl.instructor.addHandlers = function(){
	var that = this;
	
	$('.instruction-widget-controls li a').click( function(e){
		e.preventDefault();
		
		$this = $(this);
		$('.instruction-widget-controls li a').removeClass('active');
		$this.addClass('active');
		
		var parentLi = $this.parent();
		var index = $this.parent().parent().children('li').index(parentLi);
		
		that.changeImage(index);
	});
};

isl.instructor.changeImage = function(index){
	$('.instruction-widget-image ul li').css('display', 'none');
	$('.instruction-widget-image ul li').eq(index).css('display', 'block');
};

$(document).ready(function(){
	
/** Installation section **/
	isl.instructor.init();
	
/** Replace fonts **/
	Cufon.replace('.hero-header h1, h2, h3, h4, h5, .submit button'); 
	
/** PiroBox Lightbox - Used in Instructions on ADD-A-STEP **/
	$(".pirobox").piroBox({
		my_speed: 300, //animation speed
		bg_alpha: 0.6, //background opacity
		slideShow: 'false', // true == slideshow on, false == slideshow off
		slideSpeed: 3, //slideshow
		close_all: '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
	});

});
