function getBaseUrl() {

 strBaseUrl = $('base').attr('href');

 if (strBaseUrl.indexOf('http://') !== -1) {
  strBaseUrl = strBaseUrl.replace('http://', '');
  strBaseUrl = strBaseUrl.substring(strBaseUrl.indexOf('/'));
 }//if

 return strBaseUrl;

}//function

doAlternateRowHighlights = function() {

	//Remove any existing alternate classes
	$('div#content table.data tbody tr').removeClass('alternate');

	//Apply alternate class to alternate table rows
	$('div#content table.data tbody tr:even').addClass('alternate');

}//function

function doRequiredLabels() {

 //Remove all existing markers
	$('span.required').remove();

 $('div.required label').each( function() {
 	if (! $(this).hasClass('inline')) {
   $(this).prepend('<span class="required">* </span>');
 	}//if

 });

}//function


$(document).ready(function() {

 var baseURL = getBaseUrl();
	doRequiredLabels();
	doAlternateRowHighlights();

 //Fix links to bookmarks that aren't preceded with a url
 $('a[href^="#"]').each( function(index) {
  $(this).attr('href', jQuery.url.attr("path") + $(this).attr('href'));
 });

 //Fix relative image map links
 $('map area:not([href^="/"])').each( function(index) {
  $(this).attr('href', jQuery.url.attr("path") + '/' + $(this).attr('href'));
 });

	//Do date picker stuff
	if ($('div.datepicker input').length > 0) {
		$('div.datepicker input').datepicker({
				showButtonPanel: true
			,gotoCurrent: true
			,showOn: 'button'
			,buttonImage: baseURL + 'images/calendar.gif'
			,buttonImageOnly: true
			,changeMonth: true
			,changeYear: true
			,yearRange: '-1:+3'
			,dateFormat: 'dd/mm/yy'
		});
	}//if

 doAlternateRowHighlights();
 
 //Lightbox stuff
 if ($('div.christmasCard a').length > 0) {
  $('div.christmasCard a').lightBox({txtImage: "iceMailer Christmas Card"});
 }//if

});
