if (jQuery())
{
	$(function() {
	
		var content = $("#content");
		var menu 	= $("#menu");
		var sidebar = $("#sidebar");
		
		if (content)
		{
			//alert("["+sidebar.position.bottom+"]");
				
			if (menu && content.height() < menu.height())
				content.height( menu.height() );
			
			if (sidebar && content.height() < sidebar.height())
				content.height( sidebar.height() );
		}
		
	});
}


function changeHeader(cTitle)
{
	document.getElementById("header").innerHTML = cTitle;
}

function showLoginForm()
{
	document.getElementById("login-fields").style.display="block";
	document.getElementById("login-buttons").style.display="none";
	document.formLogin.UserName.focus();
}

function register()
{
	document.location.href="register.php";
}

function viewProfile()
{
	try
	{
		window.open("ViewProfile.php", "_blank", "width=500,height=500,scrollbars=yes,resizable=yes,status=yes");
	}
	catch (ex)
	{
		alert(ex);
	}
}

function logout()
{
	document.location.href="logout.php";
}

function isValidDate(ctrlDate)
{
	var d = new Date();
	var nCurrent_Year = d.getFullYear();
	if (ctrlDate.value == '') return true;
	d.setTime(Date.parse(ctrlDate.value));
	if (isNaN(d) || d.getFullYear() < 1900 || d.getFullYear() > (nCurrent_Year+5))
	{
		alert("Date format should be 'MM/DD/YYYY'.");
		ctrlDate.value = '';
		ctrlDate.focus();
		return false;
	}
	else
	{
		ctrlDate.value = formatShortDate(d);
		return true;
	}
}

function formatShortDate(d)
{
  var cDate  = '';
  var nDays  = d.getDate();
  var nMonth = d.getMonth()+1;
  var nYear  = d.getFullYear();
  if (nYear < 1920) nYear += 100;

  cDate += ((nMonth < 10) ? '0' : '') + nMonth + '/' + ((nDays < 10) ? '0' : '') + nDays + '/' + nYear;

  return cDate;
}

<!-- Original:  Sandeep Tamhankar (stamhankar@hotmail.com) -->
<!-- Web Site:  http://207.20.242.93 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function isValidTime(ctrl)
{
	var timeStr = ctrl.value;

	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null)
	{
		alert("Time is not in a valid format.");
		return false;
	}

	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second == "") { second = null; }
	if (ampm == "") { ampm = null }

	if (hour < 0  || hour > 23)
	{
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	if (hour <= 12 && ampm == null)
	{
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time"))
		{
			alert("You must specify AM or PM.");
			return false;
	   	}
	}

	if  (hour > 12 && ampm != null)
	{
		alert("You can't specify AM or PM for military time.");
		return false;
	}

	if (minute<0 || minute > 59)
	{
		alert ("Minute must be between 0 and 59.");
		return false;
	}

	if (second != null && (second < 0 || second > 59))
	{
		alert ("Second must be between 0 and 59.");
		return false;
	}

	return false;
}


function getObjectProperties(obj)
{
	var result = "";
	for(var i in obj)
	result += "" + i + " = " + obj[i] + "\n";
	return (result);
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function parseCurrency(num) 
{
   return num.replace(/([^0-9\.\-])/g,'')*1;
}
