
function writeHeader()
{
	var oHeader = new FlashObject("images/Lisselan.swf", "tdHeader", "695", "107", 5);
	oHeader.addParam("menu", "false");
	oHeader.write("tdHeader");

}

function Trim(sString)
{
	return sString.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isDate(iDay, iMonth, iYear)
{
	//Check to make sure that they have selected a valid date
	var ary30Days = new Array("4","6","9","11");
	var bLeapYear = iYear / 4;
	
	//Is this a leap yer
	if (parseInt(bLeapYear) == bLeapYear)
		bLeapYear = true;
	else
		bLeapYear = false;
	
	//ensure that all values have been passed
	//if they havent, how can the date be correct
	if (isNaN(parseInt(iDay)) || isNaN(parseInt(iMonth)) || isNaN(parseInt(iYear)))
		return false;
	
	if (parseInt(iMonth) == 2)
	{
		if (bLeapYear && (parseInt(iDay) > 29))
			return false;
		else if (!bLeapYear && parseInt(iDay) > 28)
			return false;
	}
	else if (parseInt(iDay) > 30)
	{
		for (i = 0; i < ary30Days.length; i++)
		{
			if (parseInt(iMonth) == ary30Days[i])
				return false;
		}
	}
	return true;
}

function isEmail(sEmail)
{
	// Create the RegEx object
	var rgEmail = /([a-zA-Z0-9][-._a-zA-Z0-9]*)*[a-zA-Z0-9]+@?([a-zA-Z0-9][-_a-zA-Z0-9]*\.)+[a-zA-Z]{2,7}/g;
	var aryResult = sEmail.match(rgEmail);
	var bRtn = false;
	
	if (aryResult != null)
		bRtn = ((aryResult[0] == sEmail) ? true : false);
	
	return bRtn;
}

function IsNumeric(frm, sFields)
{
	// csv list of values to check
	var fieldlist = sFields.split(",");
	for(var element=0; element<fieldlist.length; element++)
	{
		var doc = eval('frm.' + fieldlist[element]);
		if(Trim(doc.value).length == 0 || isNaN(doc.value))
		{
			if (doc.alt)
				alert(doc.alt); 
			else if (doc.title)
				alert(doc.title);
			else
				alert('You must enter a numeric value for ' + fieldlist[element]); 
			if (Trim(doc.value) == 0)
				doc.value = 0;
			doc.focus();
			return false;
		}
	}
	return true;
}

function validateform(frm, sFields)
{
	// csv list of values to check
	var fieldlist = sFields.split(",");
	for(var element=0; element<fieldlist.length; element++)
	{
		var doc = eval('frm.' + fieldlist[element]);
		doc.value = Trim(doc.value);
		if(doc.value == "")
		{
			if (doc.alt)
				alert(doc.alt); 
			else if (doc.title)
				alert(doc.title);
			else
				alert('You must enter a value for ' + fieldlist[element]); 
			doc.focus();
			return false;
		}
	}
	return true;
}
