///////////////TRIM KEY///////////////////
function trim(Key) {
	while(''+Key.charAt(Key.length-1)==' ')
		{ Key=Key.substring(0,Key.length-1); }
	return Key;
}
/////////////VALIDATE PROGRAMS//////////////

function validateCategory() {

	a = document.frmAddCtg;
	a.category.value = trim(a.category.value);
	if (a.category.value=="") {
		alert('Enter the category!');
		a.category.focus();
		return false;
	}
	
}

function validateResources() {

	a = document.frmAddRes;
	a.name.value = trim(a.name.value);
	if (a.name.value=="") {
		alert('Enter the name!');
		a.name.focus();
		return false;
	}
	a.link.value = trim(a.link.value);
	if (a.link.value=="" || a.link.value=="http://") {
		alert('Enter the link!');
		a.link.focus();
		return false;
	}
	
}

function validateCatering() {

	a = document.frmAddCatering;
	a.title.value = trim(a.title.value);
	if (a.title.value=="") {
		alert('Enter the title!');
		a.title.focus();
		return false;
	}
}

function validateBreakfast() {

	a = document.frmAddBreakfast;
	a.title.value = trim(a.title.value);
	if (a.title.value=="") {
		alert('Enter the title!');
		a.title.focus();
		return false;
	}
}

function validateLunch() {

	a = document.frmAddLunch;
	a.title.value = trim(a.title.value);
	if (a.title.value=="") {
		alert('Enter the title!');
		a.title.focus();
		return false;
	}
}

function validateBakery() {

	a = document.frmAddBakery;
	a.title.value = trim(a.title.value);
	if (a.title.value=="") {
		alert('Enter the title!');
		a.title.focus();
		return false;
	}
	/*a.price.value = trim(a.price.value);
	if (a.price.value=="") {
		alert('Enter the price!');
		a.price.focus();
		return false;
	}*/
	
}

/////////////OPEN NEW WINDOW//////////////////
function openWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

function validateContact() {

	a = document.frmContact;
	a.txtFirstName.value = trim(a.txtFirstName.value);
	if (a.txtFirstName.value=="") {
		alert('Please enter your First Name!');
		a.txtFirstName.focus();
		return false;
	}
	
	a.txtLastName.value = trim(a.txtLastName.value);
	if (a.txtLastName.value=="") {
		alert('Please enter your Last Name!');
		a.txtLastName.focus();
		return false;
	}
	
	a.txtCity.value = trim(a.txtCity.value);
	if (a.txtCity.value=="") {
		alert('Please enter City name!');
		a.txtCity.focus();
		return false;
	}
	
	a.txtEmail.value = trim(a.txtEmail.value);
	if (a.txtEmail.value=="") {
		alert('Please enter Email address!');
		a.txtEmail.focus();
		return false;
	}
	
}
