jQuery.noConflict();

//Start jQuery Document Ready
jQuery(document).ready(function() {
    
	/********************************************/
	//		Home Page Rotating Banners
	/********************************************/
	jQuery('#navPosition').before('<div id="pagernav">').cycle({ 
		fx:     'fade',             
		speed:   1000, 
		timeout: 5000, 
		pager:  '#pagernav' 
	});
	
	/**********************************/
	//		Equal Heights Calls
	/**********************************/
	equalHeight(jQuery(".equal"));
	equalHeight(jQuery(".equal2"));
	
	/**********************************/
	//		Random Rotation
	/**********************************/
	jQuery('#s6').cycle({
		fx:     'scrollLeft',
		timeout: 6000,
		delay:  -2000,
		random: 1
	});
	
	/**********************************/
	//		AUTOMATIC INFINITE CAROUSEL
	/**********************************/
	var autoscrolling = true;
	
	$('.infiniteCarousel').infiniteCarousel().mouseover(function () {
		autoscrolling = false;
	}).mouseout(function () {
		autoscrolling = true;
	});
	
	setInterval(function () {
		if (autoscrolling) {
			$('.infiniteCarousel').trigger('next');
		}
	}, 5000);
	
});
//End jQuery Document Ready


/////////////////////////////////////////////
/////////////////////////////////////////////

//jQuery Equal Heights
function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = jQuery(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

/////////////////////////////////////////////
/////////////////////////////////////////////

/*
* Random Content (from DIVs)
*/

if (document.getElementById)
document.documentElement.className = 'jsclass'; //hide content for DOM capable browsers


var randomcontentdisplay={
	divholders:new Object(),
	masterclass: "randomcontent",

	init:function(){
		if (!document.getElementById)
			return
		var alldivs=document.getElementsByTagName("div")
		var randomcontentsearch=new RegExp(this.masterclass+"\\s+(group\\d+)", "i") //check for CSS class="randomcontent groupX" (x=integer)
		for (var i=0; i<alldivs.length; i++){
			if (randomcontentsearch.test(alldivs[i].className)){
				if (typeof this.divholders[RegExp.$1]=="undefined") //if array to hold this group of divs doesn't exist yet
					this.divholders[RegExp.$1]=new Array() //create array first
					this.divholders[RegExp.$1].push(alldivs[i]) //add this div to the array
			}
		}
	this.showone()
	},

	showone:function(){
		for (group in this.divholders){ //loop thru each array within object
			var chosenOne=Math.floor(Math.random()*this.divholders[group].length) //randomly pick one entry from array
			this.divholders[group][chosenOne].style.display="block" //display content corresponding to the chosen entry
		}
	}
}

