/*
 *	Global RioScripts - Ben
 *	NOTE: This must stay at the top of this file.	
 *	r$
 *		
 *		
*/
(function() {
	var RioScripts = function() {
		return new RioScripts.fn.init;
	};

	/* private variables */	
	RioScripts.browser = $.browser;
	
	var $head;
	var $contentarea;
	
	RioScripts['$'] = {};
	
	RioScripts.fn = RioScripts.prototype= {
		'init':function(){
			$head = $('head');
			RioScripts['$']['contentarea'] = $contentarea = $('#contentarea');
			DegreeTableHover();
			if( window.location.pathname.slice(0,9) == '/library/')
				TrackLibraryOutbound();
		}
	};
	
	
	
	RioScripts.fn.init.prototype = RioScripts.fn;
	/* Public methods */
		RioScripts.fn['getParameterByName'] = function(name) {
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if( results == null )
				return "";
			else
				return results[1];
		};
		
		RioScripts['getParameterByName'] = function(name) {
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if( results == null )
				return "";
			else
				return results[1];
		};

		
		RioScripts.fn['getHashParameterByName'] = function(name) {
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\#&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if( results == null )
				return "";
			else
				return results[1];
		};
		
		RioScripts['getHashParameterByName'] = function(name) {
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\#&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if( results == null )
				return "";
			else
				return results[1];
		};

		
		RioScripts.fn['ie6'] =  function(){
			return ($.browser.msie && $.browser.version.substr(0,1)<7) ? true : false;
		};
		
		RioScripts['ie6'] =  function(){
			return ($.browser.msie && $.browser.version.substr(0,1)<7) ? true : false;
		};

		
						
		RioScripts['createCookie'] = function(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		};

		
		RioScripts['readCookie'] = function(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		};
		
		RioScripts['eraseCookie'] = function(name) {
			RioScripts.createCookie(name,"",-1);
		};
		
		RioScripts['isBeingEdited'] = function(){
			//Checks if the page is currently being edited.
			//Used to disable modal window scripts etc. while trying to edit a page.
			var isbeingedited = false;
				if($('#ctl00_isBeingEdited').val() != 'false'){
					isbeingedited = true;
				}
			return isbeingedited;
		};
		
		RioScripts['tableAltRows'] = function($table){
			var $rows = $table.find('tr:not(:has(th))');
			for (var i=0, iL=$rows.length; i<iL; i++){
					if(i%2 == 0){
						$rows.eq(i).addClass('row-alt');
					}
				}
		};
		
		
		
	/* Private methods */
		function DegreeTableHover(){
			var $tables = $contentarea.find('table.degreetable:not(.degree-nohover)');
			var $tables_l = $tables.length;
			for(var i=0;i<$tables_l;i++){
				var $rows = $tables.eq(i).find('tr:not(:has(th))');
				var $rows_l = $rows.length;
				for (var n=0;n<$rows_l;n++){
					if(n%2 == 0){
						$rows.eq(n).addClass('row-alt');
					}
				}
			}
			$tables.find('tr:not(:has(th))').live('mouseover mouseout', function(e){
				var $this = $(this);
				if(e.type == 'mouseover')
					$this.addClass('row-hover');
				else if(e.type == 'mouseout')
					$this.removeClass('row-hover');
			});
		}
			
	//Outbound Library Article Links tracking
		function TrackLibraryOutbound(){
			var $links = $contentarea.find('a[href^="http://ezp1r.riosalado.edu/login?url="]');
			$links.bind('click', function(e){
				e.preventDefault();
				r$.recordOutboundLink(this.href, 'Outbound/Library', $(this).attr('href').slice(37), true);
			});
		}

	//Expose to Global
	r$ = RioScripts;
	rioScripts = RioScripts;
		
})();
$(function(){
	rioScripts();
});

/* End Global RioScripts */
/* Masterpage Scripts */

	$(function(){
		Surfboard.init();
	});
	(function() {
		/* private variables */
		var ie6 = r$.ie6();
		var currentDropBar = 1;
		
		var $showdropbar;
		var $bullet;
		
		var Surfboard = {
			'init' : function(){
				$showdropbar = $('#showdropbar');
				
				$bullet = $('#showdropbar-arrow');
				var panels = $('.panel a');
				for(var i=0;i<panels.length;i++){
					var $this = $(panels[i]);
					$this.attr('href', $this.attr('href') + '?et_category=QuickLinks&et_action=SiteIndex').addClass('ga-TrackEvent');
				}
				BindEvents();
				
			}
		};
		/* private functions */		
		
		function BindEvents(){
			$('#JawsQuickLinks').bind('click', function(e){
				e.preventDefault();
				openSurfboard();
			});
			$('#dropbarnav').delegate('.dropbar-leftnav', 'click hover', function(e){
					var $this = $(this);
					if(e.type == 'mouseover')
						$this.addClass('dropbar-leftnav-hover');
					else if(e.type == 'mouseout')
						$this.removeClass('dropbar-leftnav-hover');
					else if(e.type == 'click'){
						var showid = $(this).attr('id').toString().slice(15);
						showDropBarContent(showid);
					}
				});

					$showdropbar.bind('click', function(e){
						e.preventDefault();
						var $this = $(this);
						if(e.type == 'click'){
							if( $this.hasClass('showdropbar-open') ){
								$this.removeClass('showdropbar-open');
								closeSurfboard();
							}							
							else{
								$this.addClass('showdropbar-open');
								openSurfboard();
							}
						}				
					});
			$('#footer-sitemap').bind('click', function(e){
					currentDropBar = 1;
					$showdropbar.addClass('showdropbar-open');
					openSurfboard();
				});			
		}
		
		
		function openSurfboard(){
			$('#dropbar').slideDown('slow', function() {
				showDropBarContent(currentDropBar);
			});
		}
		function closeSurfboard(){
			$('#dropBarContent2, #dropBarContent3, #dropBarContent1, #mygallery').fadeOut('slow');
				$('#dropbar').slideUp('slow');
		}
		function showDropBarContent(barToShow) {
				if (barToShow == 1) {
					$('#dropBarContent2, #dropBarContent3').fadeOut('slow');
					$('#mygallery, #dropBarContent1').fadeIn('slow');
				}
				if (barToShow == 2) {
					$('#dropBarContent1, #dropBarContent3, #mygallery').fadeOut('slow');
					$('#dropBarContent2').fadeIn('slow');
				}
				if (barToShow == 3) {
					$('#dropBarContent1, #dropBarContent2, #mygallery').fadeOut('slow');
					$('#dropBarContent3').fadeIn('slow');
				}
				currentDropBar = barToShow;
			}
		if(!window['Surfboard'])
				window['Surfboard'] = Surfboard;	
	})();

//searchBar 
//- Refactored by Ben Russell
(function(){

	var $searchchoose;
	var $searchbox;
	var $searchpad1;
	var $searchType;
	var $searchbutton;
	var currentsearch = 0;
	
	var choicelocations = ['-202px 0', '0 0'];
	var defaulttext = ['search site...', 'search class schedule...', 'ask rio a question'];
	var SearchBar = {
		'init': function(){
			$searchbox = $("#searchText");
			$searchpad1 = $("#searchpad1");
			$searchType = $("#searchType");
			$searchbutton = $('#search-button');
			
			BindEvents();
			searchFix();
		}
	};
	
	function BindEvents(){
		$searchchoose = $('.search-choose').find('a').bind('click', searchClick);
		
		$searchbox.bind('blur focus keydown', function(e){
			var searchtext = $searchbox.val();
			if(e.type == 'blur'){
				if(searchtext == '' || searchtext == null || searchtext == 'null' || searchtext == defaulttext[currentsearch])
					$searchbox.val(defaulttext[currentsearch]);
			}
			else if(e.type =='focus'){
				if(searchtext == defaulttext[currentsearch])
					$searchbox.val('');
			}
			else if(e.type == 'keydown'){
				if(e.keyCode == 13){
					e.preventDefault();
					searchStart();
				}
			}
		});
		
		$searchbutton.bind('click', function(e){
			e.preventDefault();
			searchStart();
		});
		
	}
	
	function searchStart() {
		var searchtext = $searchbox.val();
		if (searchtext != defaulttext[currentsearch] && searchtext != '' && searchtext.length > 0) 
			Search(searchtext, currentsearch);
		else {
			window.alert("Please enter one or more search words.");
			$searchbox.focus();
		}
	}

	function Search(searchtext, searchtype){
		if(searchtype == 0)
			window.location = '/help/Pages/searchInstant.aspx?k=' + searchtext;
		else if(searchtype == 1){
			if (searchtext.length < 3 || containsInvalidCharacter(searchtext)) {
				window.alert("Please enter a valid search term. You can search by keyword, prefix, subject or prefix and number (Examples: Human Anatomy, BIO, Biology, or BIO160)");
			}
			else if (searchtext.length < 1) {
				window.location = "/schedule/Pages/subject.aspx";
			}
			else {
				if (searchtext.length == 3)
					window.location = '/schedule/Pages/schedule.aspx?prefix=' + searchtext;
				else
					window.location = '/schedule/Pages/schedule.aspx?search=' + searchtext;
			}
		}
	}

	
	function searchClick(e) {
		e.preventDefault();
		var $this = $(this);
		if(e.type == 'click'){
			newsearch = $searchchoose.index($this);
			swapSearch(newsearch);
		}		
	}
	
	function swapSearch(newsearch){
		var searchtext = $searchbox.val();
		$searchpad1.css('background-position', choicelocations[newsearch]);
		$searchType.val(newsearch);
		if(searchtext == '' || searchtext == null || searchtext == 'null' || searchtext == defaulttext[currentsearch])
			$searchbox.val(defaulttext[newsearch]);
		currentsearch = newsearch;
				
	}
		
	function searchFix() {
		var address = window.top.location.toString();
		if (address.indexOf('/schedule/') != -1){
			swapSearch(1);
		}
	}

	$(function(){
		SearchBar.init();
	});
	
})();


(function(jQuery){
//jQuery extensions
	jQuery.extend({
		//get data from a sharepoint list -in dev
		'SPList': function(options){
			var settings = {
				'guid': '069491DD-235A-4D27-BFEA-267389535157',
				'webURL': '/cafe/menu/',
				'dataType': 'html',
				'success': function(data, textStatus, XMLHttpRequest){}				
			};
			jQuery.extend(settings, options);
			
			jQuery.ajax({
				'url': '/pages/listviewer.aspx?ListID='+settings.guid+'&URL='+settings.webURL+'&dataType='+settings.dataType,
				'success': settings.success,
				'dataType': settings.dataType,
				'type': 'POST',
				'context': document.getElementById('list')
			});
		}
	});
})(jQuery);
/* End Masterpage Scripts */


//Search Bar
var text = ['search site...', 'search class schedule...', 'ask rio a question'];
var label = ['site', 'class schedule', 'ask rio'];

/*	
function searchBarEnterKey(e) {
	var characterCode;
	if(e && e.which) {
		e = e;
		characterCode = e.which;
	}
	else {
		e = event;
		characterCode = e.keyCode;
	}
	if(characterCode == 13) {
		searchBar();
		return false;
	}
	else
		return true;
}
	
	
function searchBar() {
	var searchType = $("#searchType").val();
	var searchText = $("#searchText").val();
	if (searchType == 2 && searchText != text[2] && searchText != "") 
		askRioSearch(searchText);
	else if (searchType == 0 && searchText != text[0] && searchText != text[1])
			siteSearch(searchText);
	else if (searchType == 1 && searchText != text[0] && searchText != text[2])
			scheduleSearch(searchText);
	else {
		window.alert("Please enter one or more search words.");
		$("#searchText").focus();
	}
}
*/


//-Refactored by Ben Russell
function containsInvalidCharacter(thistext) {
	var invalidchars = ['?', '#', '&', '+', '%', '[', ']'];
	var containsinvalidcharacter = false;
	for(var i=0; i<invalidchars.length; i++){
		if(thistext == invalidchars[i]){
			valid = true;
			break;
		}
	}
	return containsinvalidcharacter;
}

/*
function scheduleSearchError() {
	window.alert("Please enter a valid search term. You can search by keyword, prefix, subject or prefix and number (Examples: Human Anatomy, BIO, Biology, or BIO160)");
}
function siteSearch(searchText) {
	window.location = '/help/Pages/search.aspx?k=' + searchText;
	return false;
}

function scheduleSearch(searchText) {
	if ((searchText.length < 3 && searchText.length > 0) || containsInvalidCharacter(searchText)) {
		scheduleSearchError();
		return true;
	}
	else if (searchText.length < 1 || searchText == text[1]) {
		window.location = "/schedule/Pages/subject.aspx";
	}
	else {
		if (searchText.length == 3)
			window.location = '/schedule/Pages/schedule.aspx?prefix=' + searchText;
		else
			window.location = '/schedule/Pages/schedule.aspx?search=' + searchText;
		return false;
	}
}

function askRioSearch(searchText) {
	window.location = '/help/Pages/askrio.aspx?q=' + searchText;
	return false;
}
*/

//Surfboard
function openSurfboard() {
	var barNum = $("#currentDropBar").val();
	if (barNum != 1 && barNum != 2 && barNum != 3)
		barNum = 1;
	$("#dropbar").slideDown("slow", function() {
		showDropBarContent(barNum);
		$("a.showdropbar").hide();
		$("a.hidedropbar").show();
	});
}

function closeSurfboard() {
	$("#dropBarContent2, #dropBarContent3, #dropBarContent1, #mygallery").fadeOut("slow");
	$("a.hidedropbar").hide(200, function() {
		$("#dropbar").slideUp("slow");
		$("a.showdropbar").show();
	});
}

function showDropBarContent(barToShow) {
	if (barToShow == 1) {
		$("#dropBarContent2, #dropBarContent3").fadeOut("slow");
		$("#mygallery, #dropBarContent1").fadeIn("slow");
	}
	if (barToShow == 2) {
		$("#dropBarContent1, #dropBarContent3, #mygallery").fadeOut("slow");
		$("#dropBarContent2").fadeIn("slow");
	}
	if (barToShow == 3) {
		$("#dropBarContent1, #dropBarContent2, #mygallery").fadeOut("slow");
		$("#dropBarContent3").fadeIn("slow");
	}
	$("#currentDropBar").val(barToShow);
}

var stepcarousel={
	ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>', //customize HTML to show while fetching Ajax content
	defaultbuttonsfade: 0.4, //Fade degree for disabled nav buttons (0=completely transparent, 1=completely opaque)
	configholder: {},

	getCSSValue:function(val){ //Returns either 0 (if val contains 'auto') or val as an integer
		return (val=="auto")? 0 : parseInt(val)
	},

	getremotepanels:function($, config){ //function to fetch external page containing the panel DIVs
		config.$belt.html(this.ajaxloadingmsg)
		$.ajax({
			url: config.contenttype[1], //path to external content
			async: true,
			error:function(ajaxrequest){
				config.$belt.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
			},
			success:function(content){
				config.$belt.html(content)
				config.$panels=config.$gallery.find('.'+config.panelclass)
				stepcarousel.alignpanels($, config)
			}
		})
	},

	getoffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name+"="+value
	},

	fadebuttons:function(config, currentpanel){
		config.$leftnavbutton.fadeTo('fast', currentpanel==0? this.defaultbuttonsfade : 1)
		config.$rightnavbutton.fadeTo('fast', currentpanel==config.lastvisiblepanel? this.defaultbuttonsfade : 1)
	},

	addnavbuttons:function(config, currentpanel){
		config.$leftnavbutton=$('<img src="'+config.defaultbuttons.leftnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Back '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$rightnavbutton=$('<img src="'+config.defaultbuttons.rightnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Forward '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$leftnavbutton.bind('click', function(){ //assign nav button event handlers
			stepcarousel.stepBy(config.galleryid, -config.defaultbuttons.moveby)
		})
		config.$rightnavbutton.bind('click', function(){ //assign nav button event handlers
			stepcarousel.stepBy(config.galleryid, config.defaultbuttons.moveby)
		})
		if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			this.fadebuttons(config, currentpanel)
		}
		return config.$leftnavbutton.add(config.$rightnavbutton)
	},

	stopautostep:function(config){
		clearTimeout(config.steptimer)
		clearTimeout(config.resumeautostep)
	},

	alignpanels:function($, config){
		var paneloffset=0
		config.paneloffsets=[paneloffset] //array to store upper left offset of each panel (1st element=0)
		config.panelwidths=[] //array to store widths of each panel
		config.$panels.each(function(index){ //loop through panels
			var $currentpanel=$(this)
			$currentpanel.css({'float': 'none', position: 'absolute', left: paneloffset+'px'}) //position panel
			$currentpanel.bind('click', function(e){return config.onpanelclick(e.target)}) //bind onpanelclick() to onclick event
			paneloffset+=stepcarousel.getCSSValue($currentpanel.css('marginRight')) + parseInt($currentpanel.get(0).offsetWidth || $currentpanel.css('width')) //calculate next panel offset
			config.paneloffsets.push(paneloffset) //remember this offset
			config.panelwidths.push(paneloffset-config.paneloffsets[config.paneloffsets.length-2]) //remember panel width
		})
		config.paneloffsets.pop() //delete last offset (redundant)
		var addpanelwidths=0
		var lastpanelindex=config.$panels.length-1
		config.lastvisiblepanel=lastpanelindex
		for (var i=config.$panels.length-1; i>=0; i--){
			addpanelwidths+=(i==lastpanelindex? config.panelwidths[lastpanelindex] : config.paneloffsets[i+1]-config.paneloffsets[i])
			if (config.gallerywidth>addpanelwidths){
				config.lastvisiblepanel=i //calculate index of panel that when in 1st position reveals the very last panel all at once based on gallery width
			}
		}
		config.$belt.css({width: paneloffset+'px'}) //Set Belt DIV to total panels' widths
		config.currentpanel=(config.panelbehavior.persist)? parseInt(this.getCookie(window[config.galleryid+"persist"])) : 0 //determine 1st panel to show by default
		config.currentpanel=(typeof config.currentpanel=="number" && config.currentpanel<config.$panels.length)? config.currentpanel : 0
		if (config.currentpanel!=0){
			var endpoint=config.paneloffsets[config.currentpanel]+(config.currentpanel==0? 0 : config.beltoffset)
			config.$belt.css({left: -endpoint+'px'})
		}
		if (config.defaultbuttons.enable==true){ //if enable default back/forth nav buttons
			var $navbuttons=this.addnavbuttons(config, config.currentpanel)
			$(window).bind("load resize", function(){ //refresh position of nav buttons when page loads/resizes, in case offsets weren't available document.oncontentload
				config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
				config.$leftnavbutton.css({left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px'})
				config.$rightnavbutton.css({left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px'})
			})
		}
		if (config.autostep && config.autostep.enable){ //enable auto stepping of Carousel?		
			var $carouselparts=config.$gallery.add(typeof $navbuttons!="undefined"? $navbuttons : null)
			$carouselparts.bind('click', function(){
				stepcarousel.stopautostep(config)
				config.autostep.status="stopped"
			})
			$carouselparts.hover(function(){ //onMouseover
				stepcarousel.stopautostep(config)
				config.autostep.hoverstate="over"
			}, function(){ //onMouseout
				if (config.steptimer && config.autostep.hoverstate=="over" && config.autostep.status!="stopped"){
					config.resumeautostep=setTimeout(function(){
						stepcarousel.autorotate(config.galleryid)
						config.autostep.hoverstate="out"
					}, 500)
				}
			})
			config.steptimer=setTimeout(function(){stepcarousel.autorotate(config.galleryid)}, config.autostep.pause) //automatically rotate Carousel Viewer
		} //end enable auto stepping check
		this.statusreport(config.galleryid)
		config.oninit()
		config.onslideaction(this)
	},

	stepTo:function(galleryid, pindex){ /*User entered pindex starts at 1 for intuitiveness. Internally pindex still starts at 0 */
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		stepcarousel.stopautostep(config)
		var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
		if (config.panelbehavior.wraparound==false && config.defaultbuttons.enable==true){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			this.fadebuttons(config, pindex)
		}
		config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	stepBy:function(galleryid, steps){ //isauto if defined indicates stepBy() is being called automatically
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		stepcarousel.stopautostep(config)
		var direction=(steps>0)? 'forward' : 'back' //If "steps" is negative, that means backwards
		var pindex=config.currentpanel+steps //index of panel to stop at
		if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			pindex=(direction=="back" && pindex<=0)? 0 : (direction=="forward")? Math.min(pindex, config.lastvisiblepanel) : pindex
			if (config.defaultbuttons.enable==true){ //if default nav buttons are enabled, fade them in and out depending on if at start or end of carousel
				stepcarousel.fadebuttons(config, pindex)
			}	
		}
		else{ //else, for normal stepBy behavior
			if (pindex>config.lastvisiblepanel && direction=="forward"){
				//if destination pindex is greater than last visible panel, yet we're currently not at the end of the carousel yet
				pindex=(config.currentpanel<config.lastvisiblepanel)? config.lastvisiblepanel : 0
			}
			else if (pindex<0 && direction=="back"){
				//if destination pindex is less than 0, yet we're currently not at the beginning of the carousel yet
				pindex=(config.currentpanel>0)? 0 : config.lastvisiblepanel /*wrap around left*/
			}
		}
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) //left distance for Belt DIV to travel to
		if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back' && config.panelbehavior.wraparound==true){ //decide whether to apply "push pull" effect
			config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){
				config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
			})
		}
		else
			config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	autorotate:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		if (config.$gallery.attr('_ismouseover')!="yes"){
			this.stepBy(galleryid, config.autostep.moveby)
		}
		config.steptimer=setTimeout(function(){stepcarousel.autorotate(galleryid)}, config.autostep.pause)
	},

	statusreport:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		var startpoint=config.currentpanel //index of first visible panel 
		var visiblewidth=0
		for (var endpoint=startpoint; endpoint<config.paneloffsets.length; endpoint++){ //index (endpoint) of last visible panel
			visiblewidth+=config.panelwidths[endpoint]
			if (visiblewidth>config.gallerywidth){
				break
			}
		}
		startpoint+=1 //format startpoint for user friendiness
		endpoint=(endpoint+1==startpoint)? startpoint : endpoint //If only one image visible on the screen and partially hidden, set endpoint to startpoint
		var valuearray=[startpoint, endpoint, config.panelwidths.length]
		for (var i=0; i<config.statusvars.length; i++){
			window[config.statusvars[i]]=valuearray[i] //Define variable (with user specified name) and set to one of the status values
			config.$statusobjs[i].text(valuearray[i]+" ") //Populate element on page with ID="user specified name" with one of the status values
		}
	},

	setup:function(config){
		//Disable Step Gallery scrollbars ASAP dynamically (enabled for sake of users with JS disabled)
		document.write('<style type="text/css">\n#'+config.galleryid+'{overflow: hidden;}\n</style>');
		$(document).ready(function($){
			config.$gallery=$('#'+config.galleryid);
			config.gallerywidth=config.$gallery.width();
			config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")};
			config.$belt=config.$gallery.find('.'+config.beltclass); //Find Belt DIV that contains all the panels
			config.$panels=config.$gallery.find('.'+config.panelclass); //Find Panel DIVs that each contain a slide
			config.panelbehavior.wraparound=(config.autostep && config.autostep.enable)? true : config.panelbehavior.wraparound; //if auto step enabled, set "wraparound" to true
			config.onpanelclick=(typeof config.onpanelclick=="undefined")? function(target){} : config.onpanelclick; //attach custom "onpanelclick" event handler
			config.onslideaction=(typeof config.onslide=="undefined")? function(){} : function(beltobj){$(beltobj).stop(); config.onslide()}; //attach custom "onslide" event handler
			config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit; //attach custom "oninit" event handler
			config.beltoffset=stepcarousel.getCSSValue(config.$belt.css('marginLeft')); //Find length of Belt DIV's left margin
			config.statusvars=config.statusvars || [];  //get variable names that will hold "start", "end", and "total" slides info
			config.$statusobjs=[$('#'+config.statusvars[0]), $('#'+config.statusvars[1]), $('#'+config.statusvars[2])];
			config.currentpanel=0;
			stepcarousel.configholder[config.galleryid]=config; //store config parameter as a variable
			if (config.contenttype[0]=="ajax" && typeof config.contenttype[1]!="undefined") //fetch ajax content?
				stepcarousel.getremotepanels($, config);
			else
				stepcarousel.alignpanels($, config); //align panels and initialize gallery
		}) //end document.ready
		$(window).bind('unload', function(){ //clean up
			if (config.panelbehavior.persist){
				stepcarousel.setCookie(window[config.galleryid+"persist"], config.currentpanel)
			}
			$.each(config, function(ai, oi){
				oi=null
			})
			config=null
		})
	}
}

//Class links
/* This code provides dynamic AJAX updates for classes and links them to the class schedule */
/* How to use: wrap a class name (Ex. CIS105) with a <span> tag and class="classlink" */
/* It should look like this: <span class="classlink">CIS105</span> */
/* After the page loads, the browser will make asynchronous requests to the class schedule for each tag. */
/* Tags are replaced with a link to that class in the schedule if it exists. */
/* Links are update automatically as responses are received in the background. */
/* */
/* NEW: Links now accept a parameter for Class Instruction Mode */
/* To use, the instruction mode must be the 2nd class of the span.  */
/* IE. <span class="classlink online">CIS105</span> Will create a link ONLY if there are */
/* CIS105 classes with the instruction mode IN (online) */
/* VALID MODES: 'online', 'print-based', 'in-person', 'mixed-media', 'hybrid' */
/* */
/* NOTE: If other classes are applied to the span, the mode must still be the 2nd class, */
/* regardless of where the 'classlink' class is. */
/* IE. <span class="classlink online class">CIS105</span> OR <span class="class online classlink">CIS105</span> */
/* BUT NOT!: <span class="class classlink online">CIS105</span> */

function isThisPageBeingEdited() {
	if ($('#ctl00_isBeingEdited').attr("value") == "false")
		return false;
	else
		return true;
}

function updateClassLinks() {
	//only execute if page is not in edit mode
	if (!isThisPageBeingEdited()) {
		$('#pagecopy .classlink').each(function(i, n){
			
			//Builds an Array of all CSS Classes of the classlink span
			var cssclass = $(n).attr('class').split(' ');
				
				//Checks the 2nd class of the span
				switch(cssclass [1]) {
					case 'online':
						classLinkAjax(n,'IN');
						break;
					case 'print-based':
						classLinkAjax(n,'PB');
						break;
					case 'in-person':
						classLinkAjax(n,'P');
						break;
					case 'mixed-media':
						classLinkAjax(n,'MM');
						break;
					case 'hybrid':
						classLinkAjax(n,'HY');
						break;
						
					//Used if there is no Instruction Mode set
					default:
						classLinkAjax(n);
				}
		});	
	}
}

function classLinkAjax(classObj, classMode) {
	
	//Defaults to building URL using the  Instruction Mode parameter
	var thisUrl = "/schedule/Pages/getclasslink.aspx?search=" + $(classObj).html() + "&instructionmode="+ classMode;
	
	//Checks if function is an overload
	if (classMode==undefined)
		
		//If function is an overload, build URL without Instruction Mode parameter
		var thisUrl = "/schedule/Pages/getclasslink.aspx?search=" + $(classObj).html();
	$.ajax({
		url: thisUrl,
		success: function(data, textStatus) {
			//only update page if response was valid
			if (data.length < 2000) {
				$(classObj).html(data);
				$(classObj).html($(classObj).find("div:first").html());
			}
		}
	});
}

function getParameter (queryString, parameterName)
{
	var parameterName = parameterName + "=";
	if (queryString.length > 0) {
		var begin = queryString.indexOf (parameterName);
		if (begin != -1) {
			begin += parameterName.length;
			var end = queryString.indexOf ("&" , begin);
			if (end == -1)
				end = queryString.length;
			return decodeURIComponent(queryString.substring (begin, end));
		}
	}
	return null;
}

//Page Title Bar //Quick Links Fix: when fixed corner.js, it caused to break rounded corners so commeting this out until we figure this out. 
//function roundMe() {
//	$("#ctl00_roundedcorners").corner("7px");
//}

//Image reflection
if (!document.myGetElementsByClassName) {
	document.myGetElementsByClassName = function(className) {
		var children = document.getElementsByTagName('*') || document.all;
		var elements = [];
		for (var i = 0, chL = children.length; i < chL; i++) {
			var child = children[i];
			var classNames = child.className.split(' ');
			for (var j = 0, cnL = classNames.length; j < cnL; j++) {
				if (classNames[j] == className) {
					elements.push(child);
					break;
				}
			}
		}
		return elements;
	}
}

var Reflection = {
	defaultHeight : 0.25,
	defaultOpacity: 0.5,
	add: function(image, options) {
		Reflection.remove(image);
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i])
					options[i] = doptions[i];
			}
		} else
			options = doptions;
		try {
			var d = document.createElement('div');
			var p = image;
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses)
						newClasses += ' ';
					newClasses += classes[j];
				}
			}
			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			var reflectionWidth = p.width;
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.display = 'block';
				reflection.style.height = p.height+"px";
				reflection.style.border = '0px';				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
					var context = canvas.getContext("2d");
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					d.appendChild(p);
					d.appendChild(canvas);
					context.save();
					context.translate(0,image.height-1);
					context.scale(1,-1);
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
					context.restore();
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
					context.fillStyle = gradient;
					context.rect(0, 0, reflectionWidth, reflectionHeight*2);
					context.fill();
				}
			}
		} catch (e) {
	    }
	},
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	if (!isThisPageBeingEdited()) {
		var rimages = $('.reflect');
		for (i=0, aL = rimages.length; i<aL; i++) {
			var rheight = null;
			var ropacity = null;
			var classes = rimages[i].className.split(' ');
			for (j=0;j<classes.length;j++) {
				if (classes[j].indexOf("rheight") == 0)
					var rheight = classes[j].substring(7)/100;
				else if (classes[j].indexOf("ropacity") == 0)
					var ropacity = classes[j].substring(8)/100;
			}
			Reflection.add(rimages[i], { height: rheight, opacity : ropacity});			
		}
		$("img.reflected").css("border", "0px");
	}
}

//Form mail
function formMail() {
      if (!isThisPageBeingEdited()) {
            if ($("#aspnetForm").valid()) {
                  var viewState = document.getElementById('__VIEWSTATE');
                  if (viewState)
                  {
                        document.forms[0].elements['__VIEWSTATE'].value = '';
					}
                  document.forms[0].action = "https://matrix.riosalado.edu/riowebapps/public/mailer/formmail.aspx";
                  document.forms[0].method = "POST";
                  document.forms[0].submit();
            }
      }
      else
            window.alert("This page is being edited.  You cannot submit a form until it is checked in.");
}

//Translation (requires jquery.translate-1.2.2.min.js)
function translatePage(language) {
	$('#contentwrapper').translate(language, { start: function() {$('#translateButton').fadeOut(1000);}, complete: function() {$('#translateLink').attr("href", "javascript:window.location.reload();");$('#translateButton').attr("src", "/PublishingImages/in-english.jpg");$('#translateButton').fadeIn(1000);} });  //translate content only		
}

function rioLocationsHover() {
	$('#dropBarContent2 table tr.hoverrow, #dropBarContent3 table tr.hoverrow').hover(function() {

	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});
}

//Class Schedule, Wishlist, and related functions
function AddSectionNumber(course, section, credits, term) {
	//add spaces if course length too long
	var hasDash = course.indexOf("-");
	var hasUnderscore = course.indexOf("_");
	if (hasUnderscore != -1)
		course = course.substring(0, hasUnderscore + 3) + " " + course.substring(hasUnderscore + 3);
	if (hasDash != -1 && hasUnderscore == -1)
		course = course.substring(0, hasDash) + " " + course.substring(hasDash);
		
	//update wishlist cookie
	var wishlistArray = new Array();
	wishlistArray = getWishlistArray();
	var newWishlist = "";
	if (wishlistArray.length > 1)
		newWishlist = "$$";
	newWishlist += section + "$$" + credits + "$$" + course + "$$" + term;
	if (wishlistArray.length != undefined)
		newWishlist = readCookie("wishlist") + newWishlist;
	storeWishlistFromString(newWishlist);
	sortWishlist();
	
	//update mini wishlist on page
	MiniWishlist("true");
}
function NumberOfClasses(wishlistArray) {
	var numberOfClasses = 0;
	if (wishlistArray.length > 3)
		numberOfClasses = wishlistArray.length / 4;
	return numberOfClasses;
}
function NumberOfCredits(wishlistArray) {
	var numberOfCredits = 0 * 1;
	if (wishlistArray != undefined) {
		for (var i = 1; i < wishlistArray.length; i = i + 4)
			numberOfCredits += (wishlistArray[i]) * 1;
	}
	return numberOfCredits * 1;
}
function MiniWishlist(animate) {
	var wishlistArray = [];
	wishlistArray = getWishlistArray();
	var numberOfClasses = NumberOfClasses(wishlistArray);
	var numberOfCredits = NumberOfCredits(wishlistArray);
	
	var wishlist = "<h2>How To Register</h2><a href='/schedule/Pages/subject.aspx'><img class='wishlistSteps' border='0' src='/schedule/PublishingImages/step1.gif'/></a><br class='wishlistSteps' /><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx?print=print\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'><img class='wishlistSteps' border='0' src='/schedule/PublishingImages/step2.gif'/></a><br class='wishlistSteps' /><a target='_blank' href='/worryfree/Pages/default.aspx?et_category=MyMaricopa&et_action=Wishlist'><img class='wishlistSteps' border='0' src='/schedule/PublishingImages/step3.gif'/></a>";

	wishlist += "<fieldset id='wishlist'><legend>My Wishlist</legend><div id='wishlistbody'>";

	if (numberOfClasses != 0 && numberOfClasses != null) {
		//update header
		wishlist += "<p style='margin-bottom:6px;'>" + numberOfClasses;
		if (numberOfClasses == 1)
			wishlist += " class (";
		else
			wishlist += " classes ("
		wishlist += numberOfCredits;
		if (numberOfCredits == 1)
			wishlist += " credit)</p>";
		else
			wishlist += " credits)</p>";
	
		wishlist +="<table cellspacing=0 cellpadding=0 border=0>";
	
		//update classes
		var previousSemester = "";
		var currentSemester = "";
		for (var i = 0; i < wishlistArray.length; i = i + 4) {
			currentSemester = wishlistArray[i + 3];
			if (currentSemester != previousSemester) {
				wishlist += "<tr><td class='term" + wishlistArray[i + 3].substring(3) + "' colspan=2><span class='left'>" + semesterAsString(wishlistArray[i + 3]) + "</span>";
				wishlist += "<span class='right' style='text-align:right;'>(" + getCreditsPerSemester(currentSemester, wishlistArray) + ")</span></td></tr>";
			}
			wishlist += "<tr><td>" + wishlistArray[i + 2] + "</td>";
			wishlist += "<td align=right><span class='removeable'>#" + wishlistArray[i] + "</span><a class='deleteme' href='javascript:removeSectionNumber(\"" + wishlistArray[i] + "\",\"" + wishlistArray[i + 1] + "\",\"" + wishlistArray[i + 2] + "\",\"" + wishlistArray[i + 3] + "\");'>delete</a></td></tr>";
			previousSemester = currentSemester;
		}
		wishlist += "</table>";
		wishlist += "</div></fieldset>";
		wishlist += "<div id='wishlistControls'><a href='javascript:editWishlist();'>edit</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>view</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx?print=print\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>print</a></div>";
	}
	else
		wishlist += "<strong>You have no classes on your wishlist!</strong></div></fieldset>";
		
	//Summer Banner
	//wishlist += "<a id='summerBanner' href='/schedule/Pages/subject.aspx?semester=4094&amp;semester2=4095'><img src='/schedule/PublishingImages/summer-schedule.jpg' alt='The summer schedule has arrived. Enroll today!' title='The summer schedule has arrived. Enroll today!' width='140' height='140' border='0'></a>";
	
	//Student Resources
	wishlist += "<fieldset id='wishlistResources'><legend>Student Resources</legend>";
	//wishlist += "<a href='http://matrix.pstest.pst/RioWebApps/Public/FinancialAid/TermBlocks/StudentTermBlocks.aspx'>Find Block Start Dates</a><br/>";
	wishlist += "<a href='/advisement/Pages/default.aspx'>Advisement</a><br/>";
	wishlist += "<a href='/selfserve/Pages/default.aspx'>Self-Serve</a><br/>";
	wishlist += "<a href='/selfserve/Pages/options.aspx'>Registration Options</a><br/>";
	wishlist += "<a href='/quickstart/Pages/default.aspx'>New Student Guide</a><br/>";
	wishlist += "<a target='_blank' href='/worryfree/Pages/default.aspx?et_category=MyMaricopa&et_action=ScheduleStudentResources'>My.maricopa.edu</a><br/>";
	wishlist += "<a href='javascript:void(0)' onclick='javascript:$(\".catalog\").toggle();'>College Catalog</a><br/>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/1011catalog.pdf'>2010 - 2011<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0910catalog.pdf'>2009 - 2010<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0809catalog.pdf'>2008 - 2009<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0708catalog.pdf'>2007 - 2008<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0607catalog.pdf'>2006 - 2007<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0506catalog.pdf'>2005 - 2006<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0405catalog.pdf'>2004 - 2005<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0304catalog.pdf'>2003 - 2004<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0203catalog.pdf'>2002 - 2003<br/></a></span>";
	wishlist += "<span class='catalog'>&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='/catalog/Documents/0102catalog.pdf'>2001 - 2002<br/></a></span>";
	wishlist += "</fieldset>";
	
	$("#schedule_right").html(wishlist);
	if (animate)
		$('#wishlistbody').effect('highlight', {}, 1000);
}
function getCreditsPerSemester(semester, wishlistArray) {
	var creditsPerSemester = 0 * 1;
	for (var i = 0; i < wishlistArray.length; i = i + 4) {
		if (wishlistArray[i + 3] == semester)
			creditsPerSemester += wishlistArray[i + 1] * 1;
	}
	return creditsPerSemester;
}

function getWishlistArray() {
	var wishlistArray = new Array();
	var wishlistString = readCookie("wishlist");
	if (wishlistString == null || wishlistString == "null" || wishlistString == "undefined" || wishlistString == "")
		return false;
	else {
		wishlistArray = wishlistString.split("$$");
		return wishlistArray;
	}
}
function removeSectionNumber(section, credits, course, term) {
	var wishlistArray = getWishlistArray();
	for (var i = 0; i < wishlistArray.length; i = i + 4) {
		if (section == wishlistArray[i]) {
			wishlistArray[i] = '';
			wishlistArray[i + 1] = '';
			wishlistArray[i + 2] = '';
			wishlistArray[i + 3] = '';
		}
	}
	var newWishlistArray = trimWishlist(wishlistArray)
	storeWishlistFromArray(newWishlistArray);
	MiniWishlist("true");
	if (NumberOfClasses(newWishlistArray) != 0)	
		editWishlist();	
	$(".wishlist" + section).removeClass("checkmark").addClass("addclass").html("Add Class").hover(function() {$(this).addClass('hover');}, function() {$(this).removeClass('hover');});
	$(".wishlist" + section).click(function () {
		$(this).removeClass("addclass").unbind().attr("onclick","").removeClass("hover").addClass("checkmark").html("&nbsp;");
		var $this = $(this);
		AddSectionNumber(course, section, credits, term);
	});
}

function doNothing() {}

function editWishlist() {
	$("#wishlist .removeable").hide();
	$("#wishlist .deleteme").fadeIn();
	$("#wishlistControls").html("<a href='javascript:doneEditWishlist();'>done</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>view</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx?print=print\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>print</a>");
}

function doneEditWishlist() {
	$("#wishlist .deleteme").hide();
	$("#wishlist .removeable").show();
	$("#wishlistControls").html("<a href='javascript:editWishlist();'>edit</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>view</a><br class='wishlistSteps'><a href='javascript:new_window(\"/schedule/Pages/wishlist.aspx?print=print\",\"wishlist\",\"height=320,width=320,scrollbars=yes,resizable=no,toolbar=no\");'>print</a>");	
}

function sortWishlist() {
	var wishlistArray = getWishlistArray();
	var semesterList = new Array();
	for (var i = 0; i < wishlistArray.length; i = i + 4) {
		if (jQuery.inArray(wishlistArray[i + 3], semesterList) == -1)
			semesterList.push(wishlistArray[i + 3]);
	}
	semesterList.sort();
	var newWishlistArray = new Array();
	for (var i = 0; i < semesterList.length; i++) {
		for (var j = 0; j < wishlistArray.length; j = j+ 4) {
			if (wishlistArray[j + 3] == semesterList[i]) {
				newWishlistArray.push(wishlistArray[j], wishlistArray[j + 1], wishlistArray[j + 2], wishlistArray[j + 3]);
			}
		}
	}
	storeWishlistFromArray(newWishlistArray);
}
function trimWishlist(wishlistArray) {
	for (var i = 0; i < wishlistArray.length; i = i +4) {
		if (wishlistArray[i] == '' && ((i + 4) < wishlistArray.length)) {
			wishlistArray[i] = wishlistArray[i + 4];
			wishlistArray[i + 1] = wishlistArray[i + 5];
			wishlistArray[i + 2] = wishlistArray[i + 6];
			wishlistArray[i + 3] = wishlistArray[i + 7];
			wishlistArray[i + 4] = '';
			wishlistArray[i + 5] = '';
			wishlistArray[i + 6] = '';
			wishlistArray[i + 7] = '';
		}
	}
	wishlistArray.pop();wishlistArray.pop();wishlistArray.pop();wishlistArray.pop();
	return wishlistArray;
}
function storeWishlistFromArray(wishlistArray) {
	createCookie('wishlist', wishlistArray.join("$$"), "7");
}
function storeWishlistFromString(wishlistString) {
	createCookie('wishlist', wishlistString, "7");
}
function semesterAsString(term) {
	var year = term.substring(1,3);
	var semester = term.substring(3);
	var semesterName;
	switch(semester) {
		case "2":
			semesterName = "Spring";
			break;
		case "4":
			semesterName = "Summer I";
			break;
		case "5":
			semesterName = "Summer II";
			break;
		case "6":
			semesterName = "Fall";
			break;
		default:
			semesterName = "Unknown";
	}
	return (semesterName + " " + "20" + year);
}
function semesterColor(term) {
	term = term.substring(3);
	var color;
	switch(term) {
		case "2":
			color = "#39B54A";
			break;
		case "4":
			color = "#FF6E24";
			break;
		case "5":
			color = "#ED1C24";
			break;
		case "6":
			color = "#750C10";
			break;
		default:
			color = "#ffffff";
	}
	return color;
}
function tagWishlist() {
	var wishlistArray = getWishlistArray();
	for (var i = 0; i < wishlistArray.length; i = i + 4) {
		$(".wishlist" + wishlistArray[i]).removeClass("addclass").addClass("checkmark").html("&nbsp;").attr("onclick", "");
	}
	$(".addclass").hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
}
function emptyWishlist() {
	createCookie('wishlist', '', '-1');
	window.location.reload();
}
function scheduleSearchNav() {
	var searchNav = '';
	searchNav += '<h2>Class Search</h2>';
	searchNav += '<fieldset id="keyword">';
	searchNav += '<legend>Keywords/Course Number</legend>';
		searchNav += '<input type="text" id="customScheduleKeyword" value="" alt="Keyword Search" onKeyPress="return customScheduleEnterKey(event)"/>';
	searchNav += '</fieldset>';
	
	searchNav += '<fieldset id="terms">';
		searchNav += '<legend>Semester</legend>';
		//always keep semester1, 2, 3 value right in comparison to the number one semeter

	//	searchNav += '<input type="radio" name="semester" class="semesterRadio" id="semester1" value="4114">';
	//	searchNav += '<label for="semester1">Summer I 2011</label><br/>';
	//	searchNav += '<input type="radio" name="semester" class="semesterRadio" id="semester1" value="4115">';
	//	searchNav += '<label for="semester1">Summer II 2011</label><br/>';

	//	searchNav += '<input type="radio" name="semester" class="semesterRadio" id="semester1" value="4116">';
	//	searchNav += '<label for="semester1">Fall 2011</label><br/>';
		searchNav += '<input type="radio" name="semester" class="semesterRadio" id="semester1" value="4122">';
		searchNav += '<label for="semester1">Spring 2012</label><br/>';
		
		searchNav += '<input type="radio" name="semester" class="semesterRadio" id="semesterAll" value="">';
		searchNav += '<label for="semesterAll">All Semesters</label>';
	searchNav += '</fieldset>';
			
	searchNav += '<fieldset id="instruction_modes">';
	searchNav += '<legend>Delivery</legend>';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_IN" value="IN"/>';
		searchNav += '<label for="delivery_IN">Online</label><br />';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_PB" value="PB"/>';
		searchNav += '<label for="delivery_PB">Print-Based</label><br />';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_P" value="P"/>';
		searchNav += '<label for="delivery_P">In Person</label><br />';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_MM" value="MM"/>';
		searchNav += '<label for="delivery_MM">Mixed Media</label><br />';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_HY" value="HY"/>';
		searchNav += '<label for="delivery_HY">Hybrid</label><br />';
		searchNav += '<input type="radio" name="instructionMode" class="instructionMode" id="delivery_ALL" value=""/>';
		searchNav += '<label for="delivery_ALL">All Delivery Methods</label><br />';
	searchNav += '</fieldset>';

	searchNav += '<a href="javascript:customScheduleSearch();"><img border="0" style="margin-bottom:5px;" src="/schedule/PublishingImages/schedule-search-button.gif" onmouseover="javascript:this.src=\'/schedule/PublishingImages/schedule-search-button-hover.gif\'" onmouseout="javascript:this.src=\'/schedule/PublishingImages/schedule-search-button.gif\'"/></a>';
	
	searchNav += '<fieldset>';
	searchNav += '<legend>Find It Faster</legend>';
		searchNav += '<a href="/schedule/Pages/subject.aspx">Search by Subject</a><br/>';
		searchNav += '<a href="/schedule/Pages/location.aspx">Search by Location</a><br/>';
		//searchNav += '<a href="/schedule/Pages/program.aspx">Search by Degree or Program</a><br/>';
		searchNav += '<a href="/community/students/honors/Pages/schedule0910.aspx">Honors Courses</a><br/>';
	searchNav += '</fieldset>';

	return searchNav;
}
function customScheduleSearch() {
	var searchPhrase = $("#customScheduleKeyword").val();
	var semester = $(".semesterRadio:checked").val();
	var deliveryMethod = $(".instructionMode:checked").val();
	var newSearch = "/schedule/Pages/";
	if (!containsInvalidCharacter(searchPhrase) && searchPhrase.length >= 3) {
		newSearch += "schedule.aspx?";
		if (searchPhrase.length == 3)
			newSearch += "prefix=";
		else
			newSearch += "search=";
		newSearch += searchPhrase;
		if (semester != undefined && semester != "")
			newSearch += "&semester=" + semester;
		if (deliveryMethod != undefined && deliveryMethod != "")
			newSearch += "&instructionmode=" + deliveryMethod;
		window.location = newSearch;
	}
	else if (!containsInvalidCharacter(searchPhrase) && searchPhrase.length < 1) {	
		newSearch += "subject.aspx?custom=yes";
		if (semester != undefined && semester != "")
			newSearch += "&semester=" + semester;
		if (deliveryMethod != undefined && deliveryMethod != "")
			newSearch += "&instructionmode=" + deliveryMethod;
		window.location = newSearch;
	}
	else
		window.alert("Please enter a valid search term. You can search by keyword, prefix, subject or prefix and number (Examples: Human Anatomy, BIO, Biology, or BIO160)");
}

function customScheduleEnterKey(e) {
	var characterCode;
	if(e && e.which) {
		e = e;
		characterCode = e.which;
	}
	else {
		e = event;
		characterCode = e.keyCode;
	}
	if(characterCode == 13) {
		customScheduleSearch();
		return false;
	}
	else
		return true;
}


//When semester image is clicked, sort by semester clicked
//term = 4 digit term code (e.g. 4082 = Spring 2008)
function semesterSort(term) {
	//Are there search parameters? 1 = yes, -1 = no
	var questioncount = window.location.toString().indexOf('?');
	
	//Get querystring parameters
	var qs = new Querystring();
	var semester = qs.get('semester', 'null');
	var semester2 = qs.get('semester2', 'null');
	
	// Should it be sorted and are there NO search parameters?
	if (semester == 'null' && questioncount == -1)
		window.location = window.location + '?semester=' + term;

	// Determine previous search parameters
	var addons = '';
	var accelerated = qs.get('accelerated', 'null');
	if (accelerated != 'null')
		addons = addons + "&accelerated=" + accelerated;
	var honors = qs.get('honors', 'null');
	if (honors != 'null')
		addons = addons + "&honors=" + honors;
	var location = qs.get('location', 'null');
	if (location != 'null')
		addons = addons + "&location=" + location;
	var building = qs.get('building', 'null');
	if (building != 'null')
		addons = addons + "&building=" + building;
	var instructionmode = qs.get('instructionmode', 'null');
	if (instructionmode != 'null')
		addons = addons + "&instructionmode=" + instructionmode;
	var search = qs.get('search', 'null');
	if (search != 'null')
		addons = addons + "&search=" + search;
	var prefix = qs.get('prefix', 'null');
	if (prefix != 'null')
		addons = addons + "&prefix=" + prefix;
	var subject = qs.get('subject', 'null');
	if (subject != 'null')
		addons = addons + "&subject=" + subject;
	
	//Isolate url without parameters
	var urlonly = window.location.toString().substring(0, window.location.toString().indexOf('?'));
	
	//Should it be sorted and are there other search parameters?
	if (((semester == 'null' && semester2 == 'null') || (semester != 'null' && semester2 != 'null')) && questioncount >= 1)
	{
		//Redirect to url + new semester sort + include previous search parameters
		window.location = urlonly + '?semester=' + term + addons;
	}
}

//When semester image is rolled over
function semesterSortRollOver(imageLoc) {
	var qs = new Querystring();
	var qs2 = qs.get("semester", "null");
	var qs3 = new Querystring();
	var qs4 = qs3.get("semester2", "null");
	if ((qs2 == "null" && qs4 == "null") || (qs2 != "null" && qs4 != "null")) {
		document.getElementById(imageLoc).style.display = 'block';
	}
}

//When semester image is no longer rolled over
function semesterSortRollOut(imageLoc) {
	var qs = new Querystring();
	var qs2 = qs.get("semester", "null");
	var qs3 = new Querystring();
	var qs4 = qs3.get("semester2", "null");
	if ((qs2 == "null" && qs4 == "null") || (qs2 != "null" && qs4 != "null")) {
		document.getElementById(imageLoc).style.display = 'none';
	}
}

function new_window(url,name,window_properties) {
	link = window.open(url,name,window_properties);
	link.focus();
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object();
	this.get = Querystring_get;
	if (qs == null)
		qs = location.search.substring(1,location.search.length);
	if (qs.length == 0)
		return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var value;
		var pair = args[i].split('=');
		var name = unescape(pair[0]);
		if (pair.length == 2)
			value = unescape(pair[1]);
		else
			value = name;
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null)
		default_ = null;
	var value = this.params[key];
	if (value==null)
		value=default_;
	return value
}

function subjectFilter(link) {
	var qs = new Querystring();
	var semester1 = qs.get('semester', null);
	var semester2 = qs.get('semester2', null);

	//Start filters
	var addons = '';
	//Filter for location	
	var location = qs.get('location', null);
	if (location != null)
		addons = addons + "&location=" + location;
	//Filter for accelerated
	var accelerated = qs.get('accelerated', null);
	if (accelerated != null)
		addons = addons + "&accelerated=" + accelerated;
	//Filter for instructionmode
	var instructionmode = qs.get('instructionmode', null);
	if (instructionmode != null)
		addons = addons + "&instructionmode=" + instructionmode;
			
	if (semester1 != null && semester2 != null)
		window.location = link + '&semester=' + semester1 + '&semester2=' + semester2 + addons;
	if (semester1 != null && semester2 == null)
		window.location = link + '&semester=' + semester1 + addons;
	if (semester1 == null && semester2 != null)
		window.location = link + '&semester=' + semester2 + addons;
	if (semester1 == null && semester2 == null)
		window.location = link + addons;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

//this script is to make the querystringfeedback when a user clicks 'Rate this page'
function createQueryStringFeedback(go, varName, url){
	var nu = go + "?" + varName + "=" + url;
	return nu;
}

//On Load
$(document).ready(function(){
	//roundMe();//Quick Links Fix: when fixed corner.js, it caused to break rounded corners so commeting this out until we figure this out.
	updateClassLinks();
	rioLocationsHover();
});

/*	Ben rotating Banner Display
	Call this function on page load to automatically fill the div 'divBanners'.  
	ex:  
		$(document).ready(function(){
			var rotatingbanners = new RotatingBanners(); 
			rotatingbanners.DisplayBanners("programs", 4);
		});
	ps. Make sure divBanners is added on the page.
	NOTE: Please List here what pages use this function for future updates:
		/programs/Pages/default.aspx
		/programs/Pages/default2.aspx
		/current/Pages/default.aspx
*/
$(function(){
	(function() {
	
		/* Private Variables */
			var banners = {
					'programs': [
					// Row = ['Location of Image', 'Link', Highlighted(boolean), Open in New Window(boolean), EventTracking]
					
							['/PublishingImages/rightsidebanners/TeachingProgramNYT.jpg', 'http://www.discoverteaching.net/default.aspx?et_category=Teaching&et_action=RightBanner&et_label=NewYorkTimesTeachingProgram', true, true, true],
							['/PublishingImages/rightsidebanners/UatRio2012Spring2.jpg', 'http://issuu.com/riosaladocollege/docs/uatriospring2012?mode=window&backgroundColor=%23222222', true, true, true],
							['/PublishingImages/rightsidebanners/mathSuccessAward228.jpg', 'http://www.riosalado.edu/counseling/Pages/StudentSuccessAward.aspx?et_category=MathSuccessAward&et_action=RightBanner&et_label=Programs', true, false, true],
							['/PublishingImages/rightsidebanners/Paralegal3.jpg','/programs/paralegal/Pages/default.aspx?et_category=Paralegal&et_action=RightBanner&et_label=Programs', false, false, true],		             
							['/PublishingImages/rightsidebanners/dental_hygiene.jpg', '/programs/Pages/dental-programs.aspx?et_category=DentalHygiene&et_action=RightBanner&et_label=Programs', false, false, true],
							['/PublishingImages/rightsidebanners/ECH.jpg','/programs/earlychildhood/Pages/default.aspx?et_category=EarlyChildhoodDevelopment&et_action=RightBanner&et_label=Programs', false, false, true],
							['/PublishingImages/rightsidebanners/creative-writing.jpg','/programs/creative-writing/Pages/default.aspx?et_category=CreativeWriting&et_action=RightBanner&et_label=Programs', false, false, true],
							['/PublishingImages/rightsidebanners/org_mngmnt.jpg','/programs/organizational_management/Pages/default.aspx?et_category=OrganizationalManagement&et_action=RightBanner&et_label=Programs', false, false, true],
							['/PublishingImages/rightsidebanners/dual.jpg','/about/teaching-learning/early-college/Pages/default.aspx?et_category=DualEnrollment&et_action=RightBanner&et_label=Programs', false, false, true],					 
							['/PublishingImages/rightsidebanners/comp_tech2.jpg','/programs/computers/Pages/default.aspx?et_category=ComputerTech&et_action=RightBanner&et_label=Programs', false, false, true],			
							['/PublishingImages/rightsidebanners/food.JPG','/food/?et_category=SustainableFood&et_action=RightBanner&et_label=Programs', false, false, true],						 
							['/PublishingImages/rightsidebanners/accounting.jpg','/programs/accounting/pages/default.aspx?et_category=Accounting&et_action=RightBanner&et_label=Programs', false, false, true],						 
							['/PublishingImages/rightsidebanners/tbd5.jpg','/transparency/Pages/default.aspx?et_category=SustainableFood&et_action=RightBanner&et_label=Programs', false, false, true],						 
							['/PublishingImages/rightsidebanners/ForeignLanguage.jpg','/programs/general_education/Pages/languages.aspx?et_category=Language&et_action=RightBanner&et_label=Programs', false, false, true]
							
					],
					'current students': [
					
							['/PublishingImages/rightsidebanners/book-advances.jpg', 'http://www.riosalado.edu/advisement/Pages/group-advisement-webinar.aspx?et_category=WebinarAdvising&et_action=RightBanner&et_label=CurrentStudents', true, false, true],
							['/PublishingImages/rightsidebanners/webinar-success-right-banner.jpg', 'http://www.riosalado.edu/advisement/Pages/group-advisement-webinar.aspx?et_category=WebinarAdvising&et_action=RightBanner&et_label=CurrentStudents', true, false, true],
							['/PublishingImages/rightsidebanners/math-success.jpg', 'http://www.riosalado.edu/counseling/Pages/StudentSuccessAward.aspx?et_category=MathSuccessAward&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/onAir.jpg', '/about/leadership-divisions/public-service/Pages/default.aspx?et_category=PublicDivision&et_action=RightBanner&et_label=CurrentStudents', true, true, true],
							['/PublishingImages/rightsidebanners/gmail.jpg', '/selfserve/gmail/Pages/default.aspx?et_category=Gmail&et_action=RightBanner&et_label=CurrentStudents', true, true, true],
							['/PublishingImages/rightsidebanners/BannerCurrentStudentsMSRP-2.jpg', '/cashier/Pages/MaricopaStudentRefundProgram.aspx?et_category=MSRP&et_action=RightBanner&et_label=CurrentStudents', true, true, true],
							['/PublishingImages/rightsidebanners/banner-MCC-foundation.jpg', 'http://www.maricopa.edu/foundation/apply/index.php?et_category=MCCFscholarships&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/8weekbanner.jpg', '/8week/Pages/default.aspx?et_category=8WeeksOption&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/taxcredit-HitBooks.jpg', '/financial_aid/Pages/American_Opportunity_Tax_Credit.aspx?et_category=TaxCreditForBooks&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/InstHelp.jpg', '/help/instructional/Pages/default.aspx?et_category=InstructionalHelpdesk&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/studentpurchase.jpg', '/advantages/Pages/student_purchase.aspx?et_category=SoftwarePurchase&et_action=RightBanner&et_label=CurrentStudents', false, false, true],
							['/PublishingImages/rightsidebanners/greenChamber.jpg', '/about/sustainability/Pages/greenchamberofcommerce.aspx?et_category=PhxGreenChamberCommerce&et_action=RightBanner&et_label=CurrentStudents', false, false, true]
														
					]
				};
	

		var RotatingBanners= {
			'DisplayBanners': function(pageName, maxToDisplay) {
											
				var numToDisplay = maxToDisplay;
				var selectedBanners = [];
				var randomIndex = -1;
				var displayOrder = [];
				pageName = pageName.toLowerCase(); //Make sure pageName is all lower case
				
				if(banners[pageName] != null) { //Makes sure there is a page name. If not, does nothing.
					// Update number of banners to display if less than max are defined
					if(banners[pageName].length < maxToDisplay)
						numToDisplay = banners[pageName].length;						
					
					// Select Highlighted banners
					for(var i = 0; i < banners[pageName].length; i++)	{
						if(banners[pageName][i][2]) {
								selectedBanners[selectedBanners.length] = i; // Add Banner to Array				
								if(selectedBanners.length == numToDisplay) //Check if Banner limit is reached
									break;
						}
					}
					// Randomly select the rest
					for(var i = selectedBanners.length; i < numToDisplay; i++) {
						// Checks that banner isn't a duplicate
						do {
							randomIndex = Math.floor(Math.random() * banners[pageName].length);
						} while(ExistsInArray(selectedBanners, randomIndex));		
						selectedBanners[selectedBanners.length] = randomIndex; //Add Banner to Array
					}	
					// Randomize the display order
					for(var i = 0; i < selectedBanners.length; i++)	{
						// Get random Banner
						do	{
							randomIndex = Math.floor(Math.random() * selectedBanners.length);
						} while(ExistsInArray(displayOrder, randomIndex));
						// Add Banner to Display
						displayOrder[displayOrder.length] = randomIndex;
					}				
					// Write HTML to Display banners
					var _append = '';
					var thisbanner = [];
					for(var i = 0; i < displayOrder.length; i++) {
						thisbanner = banners[pageName][selectedBanners[displayOrder[i]]];
						_append+= '<p><a class="banner'+i+(thisbanner[4]?' '+'ga-TrackEvent':'')+'" href="' + thisbanner[1] + '"';
						_append+= thisbanner[3] ? 'target="_blank"' : '';
						_append+= '><img class="banner'+i+'" src="' + thisbanner[0] + '" style="border: 0px solid;" /></a></p>';
					
					}
					$('#divBanners').html(_append);
				}
			}
		};
			
			// Checks if value is already in the Array
			function ExistsInArray(arrayToSearch, valueToFind) {
				var found = false;				
				for(var i = 0; i < arrayToSearch.length; i++) {
					if(arrayToSearch[i] == valueToFind)	{	
						found = true;
						// Stop the loop
						break;
					}
				}
				return found;
			}
		if(!window['RotatingBanners']) {window['RotatingBanners'] = RotatingBanners;}
	})();
	
});	
// End Ben Rotating banner display

// Start Ben PDF Google Analytics Fix
function CreateGoogleAnalytics(){
	//Grabs href from any link on the page with the class 'AddAnalytics'
	var originalLink = $("a.AddAnalytics").attr("href");
	//Changes the onclick event to call the google function to track the link
	$("a.AddAnalytics").click(function(){
								pageTracker._trackPageview(originalLink);
							});
}
$(document).ready(CreateGoogleAnalytics);
//End Ben PDF Google Analytics Fix

// Start Ben UatRio Google Analytics Fix
// Call this function on a page you want tracked by adding a <div id='UatRioAnalytics' /> anywhere on the page
function AddGoogleAnalytics(){
	//Google Script
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
		try {
			var pageTracker = _gat._getTracker("UA-8155745-1");
			pageTracker._trackPageview();
		} catch(err) {}
}
// Calls function on page load
$(document).ready(function(){
	if ( $('#UatRioAnalytics').length > 0)
		AddGoogleAnalytics;
});
//End Ben UatRio Google Analytics Fix
//add this script by Harpreet for bookmarking feature on Left navigation
var addthis_config = {
     ui_header_color: "#ffffff",
     ui_header_background: "#2b6fa8",
	 ui_cobrand: "Rio Salado College",
	 data_track_linkback: true
};
//end addthis script

// ~b Testimonials script (moved from /Documents/)

function randomtestimonial(){

	var testimonials=[
			"<p>\"With all the other things going on in my life, Rio Salado's <a href=\"/online/pages/default.aspx\">online classes</a> provided me the opportunity to go to college.\"<br /><span class=\"studentname\">Elisa R.</span></p>"
		,	"<p>\"Rio Salado opened up doors for me to <a href=\"/programs/pages/default.aspx\">earn my degree</a>!\"<br /><span class=\"studentname\">Amy M.</span></p>"
		,	"<p>\"College is an investment, but Rio Salado makes it possible to find ways to afford it through <a href=\"/financial_aid/pages/default.aspx\">financial aid</a>, <a href=\"/financial_aid/Pages/scholarships.aspx\">scholarships</a> & <a href=\"/cashier/Pages/options.aspx\">payment plan options</a>.\"<br /><span class=\"studentname\">Anthony B.</span></p>"
		,	"<p>\"Without Rio Salado's <a href=\"/programs/education/pages/default.aspx\">online teacher education program</a>, my dream of a classroom of my own would never have been possible.\"<br /><span class=\"studentname\">Steve S.</span></p>"
		,	"<p>\"My relationships with Rio Salado's online instructors were stronger than any I have ever had.  They really supported me and made it possible to <a href=\"/programs/pages/default.aspx\">earn my degree</a>.\"<br /><span class=\"studentname\">Jim H.</span></p>"
		,	"<p>\"With the odd hours at my job,  a wife and a family, <a href=\"/online/pages/default.aspx\">online classes</a> made it possible to fit college into my life.\"<br /><span class=\"studentname\">Scott B.</span></p>"
		,	"<p>\"I am a mother, a wife, a sibling, a friend and an <a href=\"/online/pages/default.aspx\">online student</a>.  Rio Salado gave me the chance to go to college.\"<br /><span class=\"studentname\">Stacy M.</span></p>"
		,	"<p>\"Rio Salado <a href=\"/online/pages/default.aspx\">online classes</a> are structured in a way that makes learning the subject matter easier to understand.  I learned more from Rio Salado than I did with other colleges' classes.\"<br /><span class=\"studentname\">Dana A.</span></p>"
		,	"<p>\"I think some people believe <a href=\"/online/pages/default.aspx\">online classes</a> are easy and you're not really learning.  Every class I've taken through <a href=\"/riolearn/pages/default.aspx\">RioLearn</a> was very thorough and I've learned a lot.\"<br /><span class=\"studentname\">Elsa R.</span></p>"
		,	"<p>\"Rio Salado counselors and instructors are very understanding and really understand <a href=\"/military/pages/default.aspx\">military service members</a>.\"<br /><span class=\"studentname\">Dane C.</span></p>"
		,	"<p>\"Rio Salado <a href=\"/online/pages/default.aspx\">online classes</a> are really easy to navigate and the instructors are very responsive.\"<br /><span class=\"studentname\">Kari T.</span></p>"
		,	"<p>\"Rio Salado made it more personable and approachable as an <a href=\"/online/pages/default.aspx\">online student</a> than most traditional programs as a whole.\"<br /><span class=\"studentname\">Dianne D.</span></p>"
		,	"<p>\"It was fun taking <a href=\"/online/pages/default.aspx\">classes online</a>.  The communication with instructors was smooth and the support services were very wonderful.\"<br /><span class=\"studentname\">Jim W.</span></p>"
		,	"<p>\"I was worried about taking an <a href=\"/online/pages/default.aspx\">online course</a> for the first time - but Rio Salado was so supportive all around & the experience was great!\"<br /><span class=\"studentname\">Mollie P.</span></p>"
		,	"<p>\"Being able to <a href=\"/online/pages/default.aspx\">study online</a> made my dream come true...Rio Salado impressed me!\"<br /><span class=\"studentname\">Catherine G.</span></p>"
		,	"<p>\"With <a href=\"/riolearn/pages/default.aspx\">RioLearn</a>, Rio Salado instructors are great with grading and getting right back to you...great with feedback and unbelievably helpful.\"<br /><span class=\"studentname\">Heather R.</span></p>"
		,	"<p>\"Rio Salado makes it possible to <a href=\"/online/pages/default.aspx\">devote the time that I need for my family</a>, give them priority and still be able to go to school\"<br /><span class=\"studentname\">Gigi G.</span></p>"
		,	"<p>\"There was no way I could have <a href=\"/online/pages/default.aspx\">kept my job and gone to college</a> without doing it through Rio Salado.\"<br /><span class=\"studentname\">Stephanie T.</span></p>"
		,	"<p>\"To be honest, Rio Salado has done everything that I could ask for and more...<a href=\"/advantages/pages/default.aspx\">the Rio Experience</a> was great!\"<br /><span class=\"studentname\">Steven V.</span></p>"
		,	"<p>\"The <a href=\"/advisement/pages/default.aspx\">personal attention</a>, even across a thousand miles, has been great-I feel like a valued student in an important program.\"<br /><span class=\"studentname\">Paul G.</span></p>"
	]
	var add = testimonials[Math.floor(Math.random()*testimonials.length)]
	return(add)
}


