/*************** Contents ****************
2009-10-27 07:17:57 Etc/GMT    /custom/defaults/s/WebServerResources/library/js/quicksearch.js          (newer than output)
2009-10-27 07:17:49 Etc/GMT    /custom/defaults/s/WebServerResources/library/js/initialise.js          (newer than output)
2009-10-27 07:17:57 Etc/GMT    /custom/defaults/s/WebServerResources/library/js/application.js          (newer than output)
2009-10-01 03:23:55 Etc/GMT    /onCourse/1019/custom/taslive/s/js/extra.js
/*************** End Contents ****************
*/
/*! 
 generated 2009-10-27 23:49:09 Etc/GMT as defined in /var/onCourse/1019/custom/defaults/config/js.conf
*//* Earlier output file date: 2009-10-09 04:58:13 Etc/GMT*/
/* Earlier minified output file date: 2009-10-09 04:58:13 Etc/GMT*/

/*********** quicksearch.js *************/
jQuery.fn.quickSearch = function(url, settings) {
	return this.each( function() {
		var minInput = 3;
		var textInput = $j(this);
		var divContainer = $j('.quicksearch-wrap');
		var thisObject = this;
		var selectedIndex = -1;
		
		// function triggered after contents is updated
		updatedFunction = function() {
			show();
			
			// observe checkboxes
			$j('.suburb-choice').each(function() {
				$j(this).bind("click", updateFunction);
			});
		};
		
		loadFunction = function(url, params, callbackFunction) {
			selectedIndex = -1;
			divContainer.load(url, params, callbackFunction);
		};
		
		// function for updating the list via site selections
		updateFunction = function withToggle(event) {
			var srcElement = null;
			if (event && (srcElement = event['srcElement'])) {
				
				// build array of query params
				var params = [];
				$j('.suburb-choice:checked').each(function() {
					var me = $j(this);
					var val = me.attr('value');
					params.push(val);
				});
				textInput.addClass('throbber');
				var terms = textInput.val();
				loadFunction(url, {text: terms, suburb: params}, updatedFunction);
			}
		};
		
		// take terms and query the server-side
		matchesFunction = function getMatches(terms) {
			if (!terms || terms.length < minInput) {
				hide();
				return;
			}
			textInput.addClass('throbber');
			loadFunction(url, {text: terms}, updatedFunction);
		};
		
		function show() {
			textInput.removeClass('throbber');
			$j('div.advanced-search-button').hide();
			hideAdvancedSearch();
			divContainer.removeShadow();
			divContainer.slideDown('slow', function() {
				divContainer.dropShadow();
			});
			
			// install watcher to detect clicks on the background
			$j(document).bind('mousedown.quicksearch', function(click) {
				// hide quicksearch if click was not inside quicksearch area
				if ($j(click.target).parents('div.quicksearch-wrap').length == 0 && click.target != thisObject) {
					hide();
				}
			});
		}
		
		function hide() {
			selectedIndex = -1;
			allItems = null;
			textInput.removeClass('throbber');
			divContainer.removeShadow();
			$j(document).unbind('mousedown.quicksearch');
			divContainer.slideUp(400);
			$j('div.advanced-search-button').show();
		}
		
		textInput.keyup(function(key) {
			if (key.which == 27) { // escape
				hide();
				return false;
			}

			// copy the text of the quick search field into the advanced search field
			$j("#adv_keyword").val($j(this).attr('value'));

			oldIndex = selectedIndex;
			allItems = divContainer.children('ul').children('li').not('.title');
			selectedItem = null;
			if (allItems.size() > 0) {
				if (selectedIndex >= 0) {
					selectedItem = allItems.eq(selectedIndex);
				}
				
				if (key.which == 13) { // return key
					if (selectedItem == null) {
						$j('form#search').submit();
						return true;
					} else {
						window.location = selectedItem.children('a').attr('href');
						key.preventDefault();
						return false;
					}
				}
				

				if (allItems.size() == 1 && (key.which == 40 || key.which == 9 || key.which == 38)) {
					selectedIndex = 0;
				}
				else
				{
					if (key.which == 40 || key.which == 9) { // down key
						if (selectedIndex >= (allItems.size() - 1)) {
							selectedIndex = 0;
						} else {
							selectedIndex++;
						}
					}
					
					if (key.which == 38) { // up key
						if (selectedIndex <= 0) {
							selectedIndex = allItems.size() - 1;
						} else {
							selectedIndex--;
						}
					}
					// update if necessary
					if (selectedIndex != oldIndex) {
						if (selectedItem != null) {
							selectedItem.removeClass('selected');
						}
						
						allItems.eq(selectedIndex).addClass('selected');
					}
				}
				
				return false;
			}
			return true;
		});
		
		// observe quicksearch field delay == 1.0seconds
		// depends on jquery-util/query.utils[.min].js
		textInput.delayedObserver(function() {
			matchesFunction(textInput.val());
		}, 1.0);
	});
};

jQuery.fn.hideQuickSearch = function(url, settings) {
	return this.each( function() {
		this.hide();
	})
};


/*********** initialise.js *************/
var $j = jQuery.noConflict();

$j(document).ready(function() {
	// Show the "add a student" section
	$j('#addstudent').click(function() {
	$j('#addstudent-block').slideToggle(400);
	});
	
	// if you hit the enter key in the EnrolmentContactEntry component, click "enrol" instead of paying
	// but not in the suburb autocomplete, where enter will select the suburb
	$j("fieldset#student_enrol_credentials input,fieldset#student_enrol_details input").keydown(function(e) { 
	  if (e.keyCode == 13 && $j(this).attr('class').indexOf('suburb-autocomplete')==-1) {
		  $j("#add-student-enrol").click(); 
	  } 
	}); 

	// Toggle elements that we do want to see, but only sometimes
	//		$j('.toggler').click(function() {
			// these conflict with liveClick
	//			$j(this).toggleClass('clicked');
	//			$j(this).toggleClass('toggler-expanded');
	//			$j(this).nextAll('.collapse:first').slideToggle(400);
	//		});

	// for ajax-inserted elements, register them to do the slide toggle
	$j('.toggler').live("click", function() {
	  	$j(this).toggleClass("clicked");
		$j(this).toggleClass('toggler-expanded');
	    $j(this).nextAll('.post-collapse:first').slideToggle(400);
		$j(this).nextAll('.collapse:first').slideToggle(400);
	});
	
	// show popup when mouse over class details
	// done this way because CSS-based hover reveal gives z-index problems in MSIE
	$j('.class_details').live("mouseover", function() {
		$j(this).children('.bubbleInfo').show();
	});
	
	// hide popup when mouse leaves class details
	$j('.class_details').live("mouseout", function() {
		$j(this).children('.bubbleInfo').hide();
	});

	// display hidden imperfectly matching classes
	$j('.more-classes-link').click(function() {
		$j(this).hide();
		$j(this).nextAll('.more-classes').slideToggle(400);
	});
	
	// display hidden cancelled or full classes
	$j('.other-classes-control').click(function() {
		$j(this).hide();
		$j(this).nextAll('.other-classes').slideToggle(400);
	});
	
	// highlight all the search criteria when hovering over the clear button
	$j('span.clear-search a').hover(
		  function() {$j('.search-criteria').addClass('clearing-search');},
		  function() {$j('.search-criteria').removeClass('clearing-search');}
	);
  
	$j('#toggle-results-map').click( function() {
		$j('#focus-map').slideToggle(400);
		$j(this).toggleClass('clicked');
		loaded = $j(this).attr('loaded');
		if (!loaded) {
			$j(this).attr({loaded:true});
			mapLoadForID('mapDelayed');
		}
		return false;
	});
	
	// hide the hints and errors at the start
	$j('.reason', '.hint').toggleClass('hidden-text');
  
	// Show us hints on entering the field if the input is not invalid
	$j('span.valid input').bind("focus blur", function() {
		$j(this).next().children('.hint').toggleClass('hidden-text');
		//$j(this).parent().nextAll('.hint:first').toggle();
	});
	
	// Show us reasons for errors on entering the field if the input IS invalid
	$j('span.validate input').bind("focus blur", function() {
		$j(this).next().children('.reason').toggleClass('hidden-text');
	});
	
	// When a user logs in, show them the company fields or the individual's fields
	$j("#iscompany").click ( function() {
		$j(this).nextAll('.company-details:first').slideToggle(400);
		$j(this).nextAll('.user-details:first').slideToggle(400);
	});   

	// set up the date picker fields
	//birthdate is disabled because the earliest date datepicker shows is 1981.
	//if ($j("#birthdate")) {
	//	$j("#birthdate").datepicker({ dateFormat:'dd/mm/yy', goToCurrent:true, 
	//		maxDate:0, minDate:-10000,  yearRange: '1900:2010',  hideIfNoPrevNext:true });
	//}

	if ($j("#datepicker")) {
		$j("#datepicker").datepicker();
	}
    
	// Google maps
	try {
		if ($j('#map').length) mapLoad(); 
	} catch(e) {
		// ignore this-- it means there was no real map on the page after all
	}
	if (document.getElementById("dirmap")) dirLoad();

	// Add items to the shortlist & update the add/remove link
	$j('li.class_addorder a').live("click", function(){
		var listid = this.id.match(/(\d+)/)[1];
		$j.ajax({
			type: "GET",
			url:  AppBaseURL + '/wa/Refresh/refresh?addShortlist=' + listid,
			success: function(msg){
				$j('#shortlist').html(msg);	
				$j.ajax({
					type: "GET",
					url: AppBaseURL + '/wa/Refresh/courseClass?id1=' + listid + '&x=ShortlistControl',
					success: function(msg){
						$j('#m' + listid).replaceWith(msg);
						// set up the 'email a friend' modal link for ajax-loaded content
						 $j('.nyromodaliframe').nyroModal( {
							 type:'iframe'
						 } );
					}
			 	});
			}
	 	});		 	
		return false; 
	});
	
	
	// Drop our shortlisted items in the shortlist box
	$j('li.onshortlist a.cutitem').live("click", function() {
		var itemId = this.id.match(/(\d+)/)[1];			
		$j(this).parent('li:first').css({'background-color':'666666'}).hide("drop", { direction: "up" }, 300, function () { 
			//$j(this).hide("slide", { direction: "down" }, 300);
			$j.ajax({
				type: "GET",
				url: AppBaseURL + '/wa/Refresh/refresh?cutShortlist=' + itemId,
				success: function(msg){
					$j('#shortlist').html(msg);
					$j.ajax({
						type: "GET",
						url: AppBaseURL + '/wa/Refresh/courseClass?id1=' + itemId + '&x=ShortlistControl',
						success: function(msg){
							$j('#m' + itemId).replaceWith(msg);
							// set up the 'email a friend' modal link for ajax-loaded content
							 $j('.nyromodaliframe').nyroModal( {
								 type:'iframe'
							 } );
						}
				 	});
				}
		 	});
		});
		return false;
	});

	// Drop our short listed items from the class description
	$j('li.shortlisted a').live("click", function() {
		var itemId = this.id.match(/(\d+)/)[1];
		$j('#shortlist a#x' + itemId).parent('li:first').css({'background-color':'666666'}).hide("drop", { direction: "up" }, 300, function () {
			$j(this).hide("slide", { direction: "down" }, 300);
			$j.ajax({
				type: "GET",
				url:  AppBaseURL + '/wa/Refresh/refresh?cutShortlist=' + itemId,
				success: function(msg){
					$j('#shortlist').html(msg);	
				 	$j.ajax({
						type: "GET",
						url: AppBaseURL + '/wa/Refresh/courseClass?id1=' + itemId + '&x=ShortlistControl',
						success: function(msg){
							$j('#m' + itemId).replaceWith(msg);
							// set up the 'email a friend' modal link for ajax-loaded content
							 $j('.nyromodaliframe').nyroModal( {
								 type:'iframe'
							 } );
						}
				 	});
				}
 			});		 	
 		});	
 		return false;
	});

	// form 
	if ($j(".suburb-autocomplete")) {
		var data = "/advanced/suburbs";
		$j(".suburb-autocomplete").autocomplete(data, 
				{mustMatch:false, matchContains:true, autoFill:false, scrollHeight: 220, selectFirst:false	});
	}

	
	$j(".suburb-autocomplete").result(function(event, data, formatted) {
		if (formatted && formatted.length>0) {
			setPostcodeAndStateFromSuburb($j(this).attr('id'), 'postcode', 'state');
		}
	});
	
	// return selects the suburb from the popup list. Eat it so it doesn't submit the form.
	$j(".suburb-autocomplete").keydown(function(key) {
		if (key.which == 13) {
			key.preventDefault();
			return false;
		}
	});
				

	// show default text in text fields with class defaultText using "default" attribute
	$j(".defaultText").focus(function(srcc)
    {
        if ($j(this).val() == $j(this).attr("default"))
        {
            $j(this).removeClass("defaultTextActive");
            $j(this).val("");
        }
    });
    
    $j(".defaultText").blur(function()
    {
        if ($j(this).val() == "")
        {
            $j(this).addClass("defaultTextActive");
            $j(this).val($j(this).attr("default"));
        }
    });
    $j(".defaultText").blur();        

	// clear default values when submitting any form
	$j('form').submit(function() {
		clearDefaultValues();
		return true;
	}); 
        
	// Advanced search
		
	$j('.search-terms,.show-advanced-search,div#advanced-search-background').click(function() {
		toggleAdvancedSearch();
	}); 
	
	$j('#cancel-search').click(function() {
		toggleAdvancedSearch();
	}); 
	
	// make the search string in the advanced search update the basic form search input area
	$j("#adv_keyword").keyup(function(e) { 
		text = $j(this).val();
		$j("form#search > input[type=text]").val(text);
		if (e.keyCode == 13) $j('form#search2').submit();
	});
	
	if ($j('input.quicksearch')) {
		$j('input.quicksearch').quickSearch("/advanced/keyword");
	}
	
	/*
	if ($j('#webContent')) {
		editWebContentWithCKEditor( 'webContent');
	}
*/
	var monday = 1;
	var tuesday = 2;
	var wednesday = 3;
	var thursday = 4;
	var friday = 5;
	var saturday = 6;
	var sunday = 7;
	var weekday = 8;
	var weekend = 9;
	var time = 10;
	var near = 11;
	var price = 12;
	
	$j.each([monday, tuesday,wednesday,thursday,friday,saturday,sunday, weekday, weekend, time, near, price], function(i,n) { 
		
		$j(".match-" +n).mouseover(function() { 
			$j(".match-" +n).addClass('search-highlight');  
		});    
		
		$j(".match-" +n).mouseout(function() { 
			$j(".match-" +n).removeClass('search-highlight');  
		}); 
	});

	// turn on all week days when "week days" is checked
	$j('#weekday-parent').click (
		function() {
		$j("#weekdays INPUT[type='checkbox']").attr('checked', $j('#weekday-parent').is(':checked'));
	});
	
	// turn off "week days" when any day is turned off, turn it on when all week days are on
	$j("#weekdays :checkbox").change( function(){
		if ( !$j(":checkbox:checked").length ) {
			//
		} else if ( $j("#weekdays :checkbox:not(:checked)").length ) {
			$j("#weekday-parent").attr('checked', false);      
		} else {
			$j("#weekday-parent").attr('checked', true);
		}
	});
	
	// turn on both weekend days when "weekends" is checked
	$j('#weekend-parent').click (
		function() {
		$j("#weekend INPUT[type='checkbox']").attr('checked', $j('#weekend-parent').is(':checked'));
	});
	
	// turn off "weekends" when any weekend day is turned off, turn it on when both weekend days are on
	$j("#weekend :checkbox").change( function(){
		if ( !$j(":checkbox:checked").length ) {
		}    
		
		else if ( $j("#weekend :checkbox:not(:checked)").length ) {
				$j("#weekend-parent").attr('checked', false);      
			}
			else {
				$j("#weekend-parent").attr('checked', true);
		}
	});	
	

	// display the Timeline when you click on any link with 'timeline' class. Needs to have the timeline content in the page.
	$j("a.timeline").click(function(e) {
		displayTimeline(this);
		return false;
	});
	$j('#overlay').click(function(e) {
		$('overlay').hide();
		$('timeline-wrap').style.visibility = 'hidden';
		return false;
	});
	
	// reload the tell-a-friend form using JQuery ajax. 
	// Have to do it this way because thickbox is incompatible with Wonder Ajax
	  $j("#submitTellAFriendLink").live("click", function() {  
		  submitTellAFriend();
		return false;  
	  });  

	  // on the course detail page, display the class info if it is small, or collapse it if it is too big, with a twiddle to expand
		 $j("#course_detail .detail_for_class").each( function(i) { 
	 		// only do this collapsing on the course list page
			elem = $j(this);
			if (elem.height() > 50) {
				var id = elem.attr('id');
				elem.before('<div class="show_more_class_info" style="clear:both;" id=x' + id + '><a href="javascript:void();"  >more</a></div>');
				$j('#x'+id).live('click', function() { 
					$j('#' + id).show();
					this.hide();
				});
				elem.hide();
			} else {
				this.show();
			}
		});
		 
		// if you give any HTML element the class "tooltip" then its title attribute will be displayed over the cursor on hover
		// requires jquery.tooltip plugin
		$j('.tooltip').tooltip( {
			top: 0,
		    track: true, 
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    fade: 250 
		} );
		
		 // Convenience methods for nyroModal lightbox library, the successor to thickbox. 
		 // Add one of these classes to a link, with the href pointing to the content to be loaded.
		 // See http://nyromodal.nyrodev.com/ for documentation
		 
		 // open an inline lightbox using ajax content fetched from the link.
		 $j('.nyromodal').nyroModal( {debug:false } );
		 
		 // open an iFrame box, so forms will submit inside the box.
		 // note that for the iframe to be generated, the link must include target="_blank"
		 $j('.nyromodaliframe').nyroModal( {
			 type:'iframe'
		 } );

		 // open an iFrame box and reload the parent page on closing
		 $j('.nyromodalreload').nyroModal( {
			 type:'iframe', 
			 endRemove: function() {window.location.reload(true);}
		 } );
		 
		// hide the location map after it has been filled by Google (above), then reveal it when its control is clicked.
		$j('.collapsedLocationMap').hide();
		$j('.showLocationMap').click( function() {
			$j('.showLocationMap').hide();
			$j('#location').show();
			//$j('#location').removeClass('collapsedLocationMap');
			//mapLoadForID('map');
			return false;
		});
		  
		 		 
});
	
function submitTellAFriend() {
	// process form here 
	var code = $j("input#code").val();  
	var name = $j("input#sendername").val();  
	var email = $j("input#senderemail").val();  
	var friendname = $j("input#friendname").val();  
	var friendemail = $j("input#friendemail").val();  
	var message = $j("#message").val();  
	var dataString = 'sendername='+ name + '&senderemail=' + email + '&code=' + code
		+ '&friendname='+ friendname + '&friendemail=' + friendemail + '&source=ajax';  
	if (message) dataString += '&message=' + message;
	$j.ajax({  
	  type: "POST",  
	  url: "/tellAFriend",  
	  data: dataString,  
	  error: function(XMLHttpRequest, textStatus, errorThrown) {
		  //alert("Error: " + textStatus);
	  },
	  success: function(msg) { 
		 // alert("Success: " + msg);
	    $j('#popup-content').html(msg);  
	  }
	});  
}


/*********** application.js *************/
// ------------------------ Timeline display ------------------

// displays a Timeline view by fetching class data.
// uses parameters defined in the (link) that was clicked:
// 		href = the url that will fetch the XML data
// 		rel = 'session' or 'class' determines which will be fetched and displayed
// 		timeZone = the time zone that will be used to position the classes
function displayTimeline(link) {
	var xmldata = link.href;
	var reldata = String(link.getAttribute('rel'));
	var timeZone = String(link.getAttribute('timeZone'));   // Nov 2008 - get timezone from request
	hideSelectBoxes();
	hideFlash();
	
	//
	// 10 Apr 2008 -- Fix to show lightbox/overlay within the page scroll
	//From:
	//--------------------------------------------------------
	// var arrayPageSize = getPageSize();
	// $('overlay').style.width = arrayPageSize[0] +'px';
	// $('overlay').style.height = arrayPageSize[1] +'px';
	// To:
	//--------------------------------------------------------
	var arrayPageSize = getPageSize();
	$('overlay').style.width = arrayPageSize[0] +'px';		
	$('overlay').style.height = arrayPageSize[1] +'px';	
	var arrayPageScroll = getPageScroll();
	var padding = 10; // $('timeline-wrap').style.padding; // hmm doesn't seem to be available
	$('timeline-wrap').style.top = (arrayPageScroll[1] + (padding * 4)) + 'px';
	$('timeline-wrap').style.bottom = '0px';
	$('timeline-wrap').style.margin = '0px 0pt 0pt -375px';
	//--------------------------------------------------------
	
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.4,
		afterFinish: function() { $('timeline-wrap').style.visibility = 'visible';} 
	});
	//tl = prepareTimeline(reldata);
	var today = new Date();
    var eventSource = new Timeline.DefaultEventSource(xmldata);
	if (reldata == 'session') {
		bandInfos = [
			Timeline.createBandInfo({
                timeZone:       timeZone,   // Nov 2008 - timezone from request
				date:           today,
				width:          "20%", 
				intervalUnit:   Timeline.DateTime.DAY, 
				intervalPixels: 100,
				eventSource:    eventSource
			}),
			Timeline.createBandInfo({
                timeZone:       timeZone,   // Nov 2008 - timezone from request
				date:           today,
				width:          "40%", 
				intervalUnit:   Timeline.DateTime.MONTH, 
				intervalPixels: 200,
				eventSource:    eventSource
			})
		];
	} 
	if (reldata == 'class') {
		bandInfos = [
			Timeline.createBandInfo({
                timeZone:       timeZone,   // Nov 2008 - timezone from request
				date:           today,
				width:          "60%", 
				intervalUnit:   Timeline.DateTime.MONTH, 
				intervalPixels: 100,
				eventSource:    eventSource
			}),
			Timeline.createBandInfo({
                timeZone:       timeZone,   // Nov 2008 - timezone from request
				date:           today,
				width:          "40%", 
				intervalUnit:   Timeline.DateTime.YEAR, 
				intervalPixels: 200,
				eventSource:    eventSource
			})
		];
	}

	bandInfos[1].syncWith = 0;
	bandInfos[1].highlight = true;
	tl = Timeline.create($('timeline'), bandInfos);
	
	tl.loadXML(xmldata, function(xml, url) { 
		eventSource.loadXML(xml, url); 
		//tl.getBand(0).scrollToCenter(eventSource.getEarliestDate());
		tl.getBand(0).setCenterVisibleDate(eventSource.getEarliestDate());
		
	});	
	// Sept 2009 - add table of sessions underneath the timeline bands in the lightbox
	if (reldata == 'session') {
		// copy the session table contents from the hidden div in the CourseClassListItem and display below bands
		var classID = '#sessions_for_class_' + xmldata.substring(xmldata.indexOf('?ids=')+5);
		$j('#timeline').append('<div class="timeline_stuffer" style="height:240px;"/>&nbsp;</div><div class="sessions_in_timeline" style="overflow:scroll; margin-left:30px; height:150px;">' + $j( classID).html() + '</div>' );
	}
	return false;
}

// Timeline support ----------------------

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}

function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//		console.log(self.innerWidth);
//		console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//		console.log("xScroll " + xScroll)
//		console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//		console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}



// ----------------- Google Maps -------------------------
	
function drawGIcon(map, title, latitude, longitude, focusMatch, 
					image, shadow, iconWidth, iconHeight, shadowWidth, shadowHeight,
					anchorx, anchory, infoWindowx, infoWindowy, suburb, url) {
	var icon = null;
	icon = new GIcon();
	icon.image = image;
	icon.shadow = shadow;
	icon.iconSize = new GSize(iconWidth, iconHeight);
	icon.shadowSize = new GSize(shadowWidth, shadowHeight);
	icon.iconAnchor = new GPoint(anchorx, anchory);
	icon.infoWindowAnchor = new GPoint(infoWindowx, infoWindowy);
	var point = new GLatLng(latitude,longitude);
	marker = new GMarker(point, {icon:icon, title:title});
	marker.title = title;
	marker.suburb = suburb;
	marker.url = url;
	map.addOverlay(marker);
	//console.log("drew marker " + title + " at " + latitude + "," + longitude + " with " + image);
	return marker;
}

function mapLoad() {
		mapLoadForID('map');
}

function mapLoadForID(mapID) {
	if ($j('#' + mapID).length && GBrowserIsCompatible() && window.map==null) {
		window.map = new GMap2(document.getElementById(mapID));
		window.map.setCenter(new GLatLng(vLatitude,vLongitude), 16);
		window.map.addControl(new GMapTypeControl());
		window.map.addControl(new GSmallMapControl());
		if (window.showNearMarker) {
			// show the marker that matches the "near" search term
			var nearmarker = drawGIcon(window.map, "Near", vLatitude, vLongitude, null, 
					"/s/img/box-blue-star.png", "/s/img/box-shadow.png", 35, 35, 52, 35,
					6, 30, 10, 5, window.near);
			window.showNearMarker = false;
		} else if (vLatitude!=0 && vLongitude!=0) {
			// Create our "tiny" marker icon
			drawGIcon(window.map, "Site", vLatitude, vLongitude, null, 
					"/s/img/marker1.png", "/s/img/marker-shadow1.png", 20, 34, 36, 34,
					10, 34, 10, 5);
		}
		
		if (window.showMapItems) {
			window.map.enableInfoWindow();
			GEvent.addListener(window.map, 'click', function(ol) {
				if (ol) {
					//console.log("clicked on " + ol + " at " + ol.getLatLng());
					window.map.openInfoWindowHtml(ol.getLatLng(), infoWindowContent(ol) );
				}
			});
	//		var dataURL = "/advanced/mapitems";
	//		if (window.searchParams.mapItemIDs != null) {
	//			dataURL += "?ids=" + window.searchParams.mapItemIDs;
	//		}
			$j.getJSON("/advanced/mapitems",function(data)
				{
					if ( data ) {
						var hadPerfect = false;
						bestBounds = new GLatLngBounds();
						otherBounds = new GLatLngBounds();
						if (vLatitude!=0 && vLongitude!=0) {
							bestBounds.extend(new GLatLng(vLatitude, vLongitude));
							otherBounds.extend(new GLatLng(vLatitude, vLongitude));
						}
						for (i=0; i<data.items.length; i++) {
							m = data.items[i];
							id = 'id' + m.id;
							window.siteMarkers[id] = drawGIcon(map, m.title, m.latitude, m.longitude, m.focusMatch, 
									m.imageSrc, m.shadowSrc, m.iconWidth, m.iconHeight, m.shadowWidth, m.shadowHeight,
									m.anchorx, m.anchory, m.infoWindowx, m.infoWindowy, m.suburb, m.url);
							//console.log('site ID = ' + id + " => " + window.siteMarkers[id]);
							otherBounds.extend(new GLatLng(m.latitude, m.longitude));
							//console.log("Extending bounds for match = " + m.focusMatch);
							if (m.focusMatch==1) {
								hadPerfect = true;
								bestBounds.extend(new GLatLng(m.latitude, m.longitude));
							}
						}
						bounds = hadPerfect ? bestBounds : otherBounds;
						zoom = window.map.getBoundsZoomLevel(bounds);
						window.map.setCenter(bounds.getCenter(), zoom);
						// if map was loaded by clicking on a site link, have to show the info window
						if (window.siteIDtoShow!=null) {
							showSiteOnMap(window.siteIDtoShow);
							window.siteIDtoShow = null;
						}
					}
				}
			);
		}
	}	
}

function dirLoad() {
	dirLoader('dirmap','dirtxt');
}

function dirLoader( dirmap, dirtxt ) {
	var geocoder = null;
	var addressMarker;
	var gMap = null;
	if (GBrowserIsCompatible()) {
		mapControl = document.getElementById('displayDirectionsMap');
		if (dirmap && document.getElementById(dirmap)) {
			document.getElementById(dirmap).innerHTML = '';
		}
		if (dirmap && document.getElementById(dirmap) && (mapControl==null || mapControl.value)) {
			dmap = document.getElementById(dirmap);
			dmap.removeClassName("mapCollapsed");
			dmap.addClassName("mapExpanded");
			gMap = new GMap2(dmap);
			gMap.setCenter(new GLatLng(vLatitude,vLongitude), 12);
			gMap.addControl(new GMapTypeControl());
			gMap.addControl(new GSmallMapControl());
		}
		if (dirtxt && document.getElementById(dirtxt)) {
			document.getElementById(dirtxt).innerHTML = '';
			var gDir = new GDirections(gMap, document.getElementById(dirtxt));
			gDir.load('from: ' + $F('from') + " to: " + vSiteAddress);
		}
	}
} 	
	
function dirLoad() {
	var geocoder = null;
	var addressMarker;
	dirmap = document.getElementById("dirmap");
	if (!dirmap) dirmap = document.getElementById("dirmapDelayed")
	if (dirmap && GBrowserIsCompatible()) {
		dirmap.removeClassName("mapCollapsed");
		dirmap.addClassName("mapExpanded");
		var gMap = new GMap2(dirmap);
		gMap.setCenter(new GLatLng(vLatitude,vLongitude), 12);
		gMap.addControl(new GMapTypeControl());
		gMap.addControl(new GSmallMapControl());
		document.getElementById("dirtxt").innerHTML = '';
		var gDir = new GDirections(gMap, document.getElementById('dirtxt'));
		gDir.load('from: ' + $F('from') + " to: " + vSiteAddress);
	}
}

// open the infoWindow on the map with the site details for the site ID specified
function showSiteOnMap(siteID) {
	$j('#focus-map').show();
	$j("body").animate({ scrollTop: 0 }, "slow"); 
	if (window.map==null) {
		window.siteIDtoShow = siteID;
		mapLoadForID('mapDelayed');
	} else {
		id = 'id' + siteID;
		//console.log(".......... loading site info for " + id);
		marker = window.siteMarkers[id];
		//console.log(".......... loading site info for " + marker.title);
		if (marker) {
			window.map.openInfoWindowHtml( marker.getLatLng(), infoWindowContent(marker));
		} else {
			//console.log("No marker for " + id);
		}
	}
}

function infoWindowContent(marker) {
	s = '<h4>' + marker.title + '</h4><h5>' + marker.suburb + '</h5>';
	if (marker.url!=null) s += '<p><a href="' + marker.url + '">Information and directions</a></p>';
	return s;
}

// Cookies

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

// Web Page Editing and Portal -----------------
function insertImage(fieldID, id, alt, w, h) { 
	ins = '{image id:"' + id + '" alt:"' + alt + '" width:"' + w + '" height:"' + h + '"}';
	el = $(fieldID);
	//alert("adding " + ins + " to " + el.value);
	if (el.setSelectionRange) { 
    	el.value = el.value.substring(0,el.selectionStart) + "\n" + ins + "\n" + el.value.substring(el.selectionEnd,el.value.length); 
		} else { 
    	el.value = el.value + "\n" + ins;
	} 
} 

// -------------- Enrolment -----------------

// calculates the total price when you change the enrolment checkboxes
function totalPrice() {
	$j('form#enrolmentform input:not(:checked)').each(function(i) {
		var id = $j(this).parent().attr('id').substring(1);
		$j('td#p' + id).addClass('price-crossed');
	});
	var total = 0;
	var discountTotal = 0;
	$j('form#enrolmentform input:checked').each(function(i) {
		var id = $j(this).parent().attr('id').substring(1);
		var price = $j('td#p' + id).removeClass('price-crossed');
		discountTotal += parseFloat($j('#d' + id).text());
		total += parseFloat(price.children('.fee-discounted').text().substring(1));
	});
	$j('#discounttotal').text(makeMoney(discountTotal));
	$j('#total').text(makeMoney(total));
	$j('#cardtotalstring').text(makeMoney(total));
}

function makeMoney(money) {
	var value = money.toString().split('.');
	var cent  = value.length==1 ? '00' : (value[1].length == 1 ? value[1]+'0' : value[1].substring(0,2));
	return '$' + value[0] + '.' + cent;
}

jQuery.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $j(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};


/* ----------------- Advanced Search ------------------------- */

//-------------------------------------------------------------------------------------------------------
// ClearTypeFadeTo / ClearTypeFadeIn / ClearTypeFadeOut
//
// Custom fade in and fade out functions for jQuery that will work around
// IE's bug with bold text in elements that have opacity filters set when
// also using Window's ClearType text rendering.
//
// New Parameter:
// bgColor    The color to set the background if none specified in the CSS (default is '#fff')
//
// Examples:
// $('div').ClearTypeFadeIn({ speed: 1500 });
// $('div').ClearTypeFadeIn({ speed: 1500, bgColor: '#ff6666', callback: myCallback });
// $('div').ClearTypeFadeOut({ speed: 1500, callback: function() { alert('Fade Out complete') } });
//
// Notes on the interaction of ClearType with DXTransforms in IE7
// http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx
	$j.fn.ClearTypeFadeTo = function(options) {
		if (options)
			$j(this)
				.show()
				.each(function() {
					if (jQuery.browser.msie) {
						// Save the original background color
						$j(this).attr('oBgColor', $j(this).css('background-color'));
						// Set the bgColor so that bold text renders correctly (bug with IE/ClearType/bold text)
						// !!! Disabled the following as it does not seem to be picking up the element bgColor, causing sites to be unviewable in IE (-cll)
						//$j(this).css({ 'background-color': (options.bgColor ? options.bgColor : '#fff') })
					}
				})
				.fadeTo(options.speed, options.opacity, function() {
					if (jQuery.browser.msie) {
						// ClearType can only be turned back on if this is a full fade in or
						// fade out. Partial opacity will still have the problem because the
						// filter style must remain. So, in the latter case, we will leave the
						// background color and 'filter' style in place.
						if (options.opacity == 0 || options.opacity == 1) {
							// Reset the background color if we saved it previously
							$j(this).css({ 'background-color': $j(this).attr('oBgColor') }).removeAttr('oBgColor');
							// Remove the 'filter' style to restore ClearType functionality.
							$j(this).get(0).style.removeAttribute('filter');
						}
					}
					if (options.callback != undefined) options.callback();
				});
	};

	$j.fn.ClearTypeFadeIn = function(options) {
		if (options)
			$j(this)
				.css({ opacity: 0 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 1, callback: options.callback });
	};

	$j.fn.ClearTypeFadeOut = function(options) {
		if (options)
			$j(this)
				.css({ opacity: 1 })
				.ClearTypeFadeTo({ speed: options.speed, opacity: 0, callback: options.callback });
	};

/* -----*/

function toggleAdvancedSearch() {
	if ($j('#advanced_search').is(':visible')) {
		hideAdvancedSearch();
	} else {
		showAdvancedSearch();
	}
}

function showAdvancedSearch() {
	$j('a.show-advanced-search').css('background','transparent url(/s/img/bg_advsearchbox.png)');
	$j('a.show-advanced-search').css('border-color',$j('div#advanced_search').css('border-left-color'));
	$j('a.show-advanced-search').css('border-style','solid');
	$j('a.show-advanced-search').css('border-width','1px 1px 0 1px');
	$j('a.show-advanced-search span').addClass('adv_search_active');
	$j('a.show-advanced-search span').css('background','transparent url(/s/img/arrow_up.png) no-repeat 100%')	
		.text("Fewer options");
	$j('form#search').ClearTypeFadeTo({ speed: 450, opacity: 0.4 });
	$j('div#content').ClearTypeFadeTo({ speed: 450, opacity: 0.4 });
	$j('#advanced_search').show('slow', function() {
	});

	// install watcher to detect clicks on the background					
	$j(document).bind('mousedown', function(e) { 
		// hide advanced search if click was not inside advanced search area
		if(!$j(e.target).is('#advanced_search_container *') && !$j(e.target).is('div.ac_results *')) {
			hideAdvancedSearch();
		}
		
	});
}

function hideAdvancedSearch() {
	$j(document).unbind('mousedown');
	$j('form#search').ClearTypeFadeTo({ speed: 450, opacity: 1 });
	$j('div#content').ClearTypeFadeTo({ speed: 450, opacity: 1 });	
	$j('#advanced_search').hide('slow');
	$j('a.show-advanced-search').css('background','');
	$j('a.show-advanced-search').css('border','none')
	$j('a.show-advanced-search span').removeClass('adv_search_active');
	$j('a.show-advanced-search span').css('background','transparent url(/s/img/arrow_down.png) no-repeat 100%')
	.text("More options");
}

function clearAdvancedSearch() {
	$j('#search2').clearForm();
}

// clear default values from text fields with class defaultText that match the "default" attribute
function clearDefaultValues() {
	$j(".defaultText").each(function(srcc)
    {
        if ($j(this).val() == $j(this).attr("default"))
        {
            $j(this).val("");
        }
    });
}

/* --------------- suburbs, states and postcodes ----------------- */

// extract suburb name, eg NEWTOWN from 'NEWTOWN 2042'
function suburbFromString(s) {
	postcodeLength = 4;
	if (s.length >= postcodeLength) {
		postcode = parseInt(s.substring(s.length-postcodeLength, s.length));
		if (postcode) {
			return jQuery.trim(s.substring(0,s.length-postcodeLength));
		}
	}
	return s;
}

//extract postcode, eg 2042 from 'NEWTOWN 2042'
function postcodeFromString(s) {
	postcodeLength = 4;
	if (s.length >= postcodeLength) {
		postcode = parseInt(s.substring(s.length-postcodeLength, s.length));
		if (postcode) {
			return "" + postcode;
		}
	}
	return '';
}

// work out state from an Australian postcode
function stateFromPostcode(postcode) {
	if (postcode.length < 4) return '';
	p = parseInt(postcode);
	if (p==null) return '';
	if (p >= 100 && p <= 2599 ) return "NSW";
	if (p >= 2619 && p <= 2898 ) return "NSW";
	if (p >= 2921 && p <= 2999 ) return "NSW";
	if (p >= 200 && p <= 299 ) return "ACT";
	if (p >= 2600 && p <= 2618 ) return "ACT";
	if (p >= 2900 && p <= 2920 ) return "ACT";
	if (p >= 3000 && p <= 3999 ) return "VIC";
	if (p >= 8000 && p <= 8999 ) return "VIC";
	if (p >= 4000 && p <= 4999 ) return "QLD";
	if (p >= 9000 && p <= 9999 ) return "QLD";
	if (p >= 5000 && p <= 5999 ) return "SA";
	if (p >= 6000 && p <= 6999 ) return "WA";
	if (p >= 7000 && p <= 7999 ) return "TAS";
	if (p >= 800 && p <= 999 ) return "NT";
	return '';
}


// set postcode and state fields from value of suburb field and remove the postcode from the suburb field
// if the postcode field does not exist, leave the suburb field alone
function setPostcodeAndStateFromSuburb(suburbID, postcodeID, stateID) {
	if (suburbID && $j("#"+suburbID).length > 0) {
		var s = $j("#"+suburbID).val();
		var suburb = suburbFromString(s);
		var postcode = postcodeFromString(s); // otherwise it thinks it's a number
		var state = postcode.length==0 ? '' : stateFromPostcode(postcode);
		if (suburb.length > 0) {
			if (postcodeID && postcode.length>0 && $j("#"+postcodeID).length > 0) {
				$j("#"+postcodeID).val(postcode);
				$j("#"+suburbID).val(suburb);
			}
			if (stateID && state.length>0 && $j("#"+stateID).length > 0) {
				$j("#"+stateID).val(state);
			}		
		}
	}
	return false;
}


// change the content editor to use CKEditor
function editWebContentWithCKEditor(fieldID) {
	CKEDITOR.config.toolbar_Full = [
		['PasteText','PasteFromWord','-', 'SpellChecker', 'Scayt'],
		['Undo','Redo','-','Find','Replace','-','RemoveFormat'],
		['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
		['Templates','-', 'Source'],
		'/',
		['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
		['Link','Unlink','Anchor'],	['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
		['Styles','Format', 'ShowBlocks']
	 ];
	//CKEDITOR.replace( fieldID, { customConfig : '../ckconfig.js' } );
	CKEDITOR.replace(fieldID );
}


/*********** extra.js *************/
var topTag;
var northWestNear = '7321';
var northNear = '7212';
var southNear = '7000';
var northWestDistance = 75;
var northDistance = 80;
var southDistance = 100;
var defaultDistance = 2;

// Tasmania-specific JQuery setup
$j(document).ready(
	function() {
	
		var head = document.getElementsByTagName('head')[0];

/* the following is disabled (replaced by the following block) because it causes MSIE to complain about it being insecure content.
		$j(document.createElement('link'))
			.attr({
				type: 'text/css', 
				href: '/s/css/tag-' + searchParams.browseTagRootID + '.css', 
				rel: 'stylesheet', 
				media:'screen'
				})
			.appendTo(head); 
*/
	
/* The new search controller does not know anything about the {tags} subject, so this is a hack to get it from the URL. */
	var browseRoot = searchParams.browseTagRootID;
	if (!(browseRoot )) {
		pathname = window.location.pathname;
		if (pathname.indexOf('/leisure')==0) browseRoot = 1311;
		if (pathname.indexOf('/work')==0) browseRoot = 1310;
		if (pathname.indexOf('/lifeskills')==0) browseRoot = 1312;
	}	

	
	// this works with MSIE in SSL mode	
		$j('<link></link>').appendTo(head).attr({
				type: 'text/css', 
				href: '/s/css/tag-' + browseRoot + '.css', 
				rel: 'stylesheet', 
				media:'screen'
		});

			
/* only works for original search controller
			$j(document.createElement('link'))
			.attr({
				type: 'text/css', 
				href: '/s/css/tag-' + browseTagLevel2 + '.css', 
				rel: 'stylesheet', 
				media:'screen'
				})
			.appendTo(head);
*/
	
	/* disabled 6 Aug because the region list no longer toggles	
		$j('dl.blue .region-link span').click(function() {
			$j('dl.blue .region-list').show();
		});
			
		$j('dl.orange .region-link span').click(function() {
			$j('dl.orange .region-list').show();
		});
			
		$j('dl.green .region-link span').click(function() {
			$j('dl.green .region-list').show();
		});
			
		 $j('.current-region').live('click', function() {
	  		$j('#advanced-search').toggle(100); 
		 }); 
		 
	*/
		
		var near = searchParams.near;
		if (near!=null && !('all'==near)) {
			reg = 'Near ' + near;
			near = near.toLowerCase();
			var hasRegion = false;
			if (southNear.toLowerCase() == near) {
				reg = "South";
				hasRegion = true;
			}
			if (northWestNear.toLowerCase() == near) {
				reg = "North-West";
				hasRegion = true;
			}
			if (northNear.toLowerCase() == near) {
				reg = "North";
				hasRegion = true;
			}
			/* disabled 6 Aug because the region list no longer toggles	
			if (hasRegion) {
				$j('.region-toggler').hide();
				$j('.region-link').show();
				$j('.region-link span').html(reg);
			}
			*/
			
			// add current search params to all tag group links so region is retained while browsing		
			$j('div.taggroup a').attr('href', function()
			   { 
			   	return this + window.location.search;
			   });
			
			
			
			h = $j('h2.webnodename').html();
			h = h==null ? '' : h.toLowerCase();
			if ('leisure'==h || 'work'==h || 'life skills'==h) {
				$j('h2.webnodename').prepend(reg + ' ');
			}
			//$j('.quicksearch-wrap').before('<div class="current-region">' + reg + '</div>');
			
		}
		
	    $j('input#keywords[type="text"]').focus(function() {
	    	if (this.value == this.defaultValue) this.value = '';
	    });
	    $j('input#keywords[type="text"]').blur(function() {
	        if (this.value == '') this.value = (this.defaultValue ? this.defaultValue : '');
	    });

	numRand = Math.floor(Math.random()*3);
	$j('dl.green').removeClass('leisure1').addClass('leisure' + (1+numRand));
	// reduced to 2 because Lifeskills3 supplied was wrong photo
	numRand = Math.floor(Math.random()*2);
	$j('dl.orange').removeClass('lifeskills1').addClass('lifeskills' + (1+numRand));
	numRand = Math.floor(Math.random()*3);
	$j('dl.blue').removeClass('work1').addClass('work' + (1+numRand));
	
	// show default text in text fields with class defaultText using "default" attribute
	$j(".defaultText").focus(function(srcc)
    {
        if ($j(this).val() == $j(this).attr("default"))
        {
            $j(this).removeClass("defaultTextActive");
            $j(this).val("");
        }
    });
    
    $j(".defaultText").blur(function()
    {
        if ($j(this).val() == "")
        {
            $j(this).addClass("defaultTextActive");
            $j(this).val($j(this).attr("default"));
        }
    });
    $j(".defaultText").blur();        
					
	
	$j("div#content div.post-collapse div.course-list-item:odd").css("background-color", "#F9F9F9"); 
	
	// make the search string in the basic search update the advanced form search input area
	// this doesn't happen automatically because quick search is turned off in taslive
	$j("form#search > input.not-quicksearch").keyup(function(e) { 
		text = $j(this).val();
		$j("#adv_keyword").val(text);
		if (e.keyCode == 13) $j('form#search').submit();
	});
	// end of document.ready function
	
	}
);
