function isFilled( elm ) { 
				if (  elm != null ) {
					if ( elm.value == "" || elm.value == null ) {
						return false									;
					}
					else {
						return true									;
					}
				}
			}

function confirmDelete(garbage,url)
{
	if(confirm("Are you sure you wish to delete " + garbage + "?"))
	{
		self.location = url;
	}	
}


function confirmRestore(garbage,url)
{
	if(confirm("Are you sure you wish to restore " + garbage + "?"))
	{
		self.location = url;
	}	
}

function RequiredInput(Input,ErrorMessage)
{
	if(Input.value == '')
	{
		alert(ErrorMessage);
		Input.focus();
		return false;
	}
	return true;
}

function RequiredInputEditor(Input,ErrorMessage)
{
	var fck = FCKeditorAPI.GetInstance(Input); 
	var yourcontent = fck.GetHTML(); 	
	if(yourcontent==''){
		alert(ErrorMessage);		
		fck.Focus();
	return false;
	}
	return true;
}

function RequiredSelect(Select,ErrorMessage)
{
	if(Select.value == 0)
	{
		alert(ErrorMessage);
		Select.focus();
		return false;
	}
	return true;
}

function RequiredCheckboxes(Input,Message)
{
	if(Input.length)
	{
		var i;
		for( i = 0 ; i < Input.length ; i++ )
		{
			Input[i].style.background = '';
		}
		for( i = 0 ; i < Input.length ; i++ )
		{
			if(Input[i].checked)
			{
				return true;
			}
		}
		for( i = 0 ; i < Input.length ; i++ )
		{
			Input[i].style.background = 'red';
		}
	}
	else
	{
		if(Input.checked)
			{
				return true;
			}
	}
	alert(Message);
	return false;
}

function RequiredRadio(Input,Message) {
	var radioCheck = false;
	for (i = 0; i < Input.length; i++) {
		if (Input[i].checked)
			radioCheck = true; 
	}
	if (radioCheck) {
		return true;
	}
	alert(Message);
	return false;
}

function ValidateField(Input,Pattern,Message)
{
	var myRegExp = eval('/'+Pattern+'/');
	if ( Input.value.search(myRegExp) == -1 )
	{
		alert(Message);
		Input.focus();
		return false;
	}
	return true;
}

function ValidateEmail(Input,Message)
{
	return ValidateField(Input,"^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$",Message);
}

function ValidateDate(Input)
{
	var regex = /^([0-9]{1,2})[\/.]([0-9]{1,2})[\/.]([0-9]{2}|[0-9]{4})$/;
	var matches = Input.value.match(regex);
	
	if( matches != null )
	{
		var Day, Month, Year;
		day = matches[1];
		month = matches[2]-1;
		year = matches[3];
		
		var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
		var daysInMonth = new Array(12);
		daysInMonth[0] = 31; // January
		daysInMonth[1] = (year % 4 == 0) ? 29 : 28; // February
		daysInMonth[2] = 31; // March
		daysInMonth[3] = 30; // April
		daysInMonth[4] = 31; // May
		daysInMonth[5] = 30; // June
		daysInMonth[6] = 31; // July
		daysInMonth[7] = 31; // August
		daysInMonth[8] = 30; // September
		daysInMonth[9] = 31; // October
		daysInMonth[10] = 30; // November
		daysInMonth[11] = 31; // December

		if ( month < 0 || month > 11 )
		{
			alert( "Please enter a valid date\n\nThe month must be between 01 and 12" );
			return false;
		}
		if ( day > daysInMonth[month] )
		{
			alert( "Please enter a valid date.\n\nThe number of days in " + months[month] + " cannot be more than " + daysInMonth[month] );
			return false;
		}
		var date = new Date(matches[3],matches[2]-1,matches[1]);
	}
	else
	{
		alert( "Please enter a valid date format (dd/mm/yyyy)" );
		return false;
	}
	return true;
}

function ReformatDate(Input)
{
	var regex = /^([0-9]{1,2})[\/.]([0-9]{1,2})[\/.]([0-9]{2}|[0-9]{4})$/;
	var matches = Input.value.match(regex);
	if ( matches[1].length == 1 ) { matches[1] = "0"+matches[1]; }
	if ( matches[2].length == 1 ) { matches[2] = "0"+matches[2]; }
	if ( matches[3].length == 2 ) { 
		if ( matches[3] > 67 )
		{ matches[3] = "19"+matches[3]; }
		else
		{ matches[3] = "20"+matches[3]; }
	}
	Input.value = matches[1] + "/" + matches[2] + "/" + matches[3];
}

function ValidateTime(Input)
{
	var regex = /^([0-9]{1,2})[:. ]([0-9]{1,2})$/;
	var matches = Input.value.match(regex);
	if ( matches != null )
	{
		if ( matches[1] < 0 || matches[1] > 24 )
		{
			alert( "Please enter a valid 24hr time\n\nThe hour must be between 00 and 24" );
			return false;
		}
		if ( matches[2] < 0 || matches[2] > 59 )
		{
			alert( "Please enter a valid 24hr time\n\nThe minute must be between 00 and 59" );
			return false;
		}
	}
	else
	{
		alert( "Please enter a valid 24hr time format (hh:mm)" );
		return false;

	}
	return true;
}

function ReformatTime(Input)
{
	var regex = /^([0-9]{1,2})[:. ]([0-9]{1,2})$/;
	var matches = Input.value.match(regex);
	if ( matches[1].length == 1 ) { matches[1] = "0"+matches[1]; }
	if ( matches[2].length == 1 ) { matches[2] = "0"+matches[2]; }
	
	Input.value = matches[1] + ":" + matches[2];
}

function Reserved(){
	var theForm = document.PageForm;
	var value=String(theForm.FriendlyURL.value);			
	var warning='Sorry this is a reserved word. Please select another one for your friendlyURL';
	//RESERVED WORD LIST
	var words=new Array('admin','stylesheet','login','images','upload','secure','unsecure','safari','shop','checkout','virtual','affiliatehome','print','preview','browser');
	for(i=0;i<=words.length;i++){
		if (value.toLowerCase()==words[i]){alert(warning);theForm.FriendlyURL.value='';}
	}
}