//IE still does not  support javascript 1.6
if(!Array.indexOf){    
	Array.prototype.indexOf = function(obj, start){        
		for(var i=(start||0); i<this.length; i++){            
			if(this[i]==obj){                
				return i;            
			}        
		}    
	}
}


Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
};

function getFlashReference(appName) {
		
        if (navigator.appName.indexOf ("Microsoft") !=-1) {
              return document.getElementById(appName);
        } else {
            return document[appName];
        }
}

function setFeatureVideoTabs(i) {
	
	try {
		if (i !=0) getFlashReference('forwardThinking_0').pauseTheVideo('');
	}
	catch (err){}
	
	try {
		if (i !=1) getFlashReference('forwardThinking_1').pauseTheVideo('');
	}
	catch (err){}
	
	try {
		if (i !=2) getFlashReference('forwardThinking_2').pauseTheVideo('');
	}
	catch (err){}
	
		
	
	
	//reset the tabs and hide all content
	$('.tabs li').removeClass('active');
	$('._mainTabContent').hide();
	//set the active elements
	$('.tabs li:eq('+i+')').addClass('active');
	$('._mainTabContent:eq('+i+')').show();
		
		
}

$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

function slideShow() {
	//Set the opacity of all images to 0
	$('#featureImageRotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('#featureImageRotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',5000);
}
function rotate() {	
	//Get the first image
	var current = ($('#featureImageRotator ul li.show')?  $('#featureImageRotator ul li.show') : $('#featureImageRotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#featureImageRotator ul li:first') :current.next()) : $('#featureImageRotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};

