function ValidateFormFileAComplaint (form) { // Used in File a complaint page (pageid=7&ctype=bm)
  var fname = form.firstname.value;   
  var lname = form.lastname.value;   
  var email = form.email.value;   
  if (!fname)	{
    alert("You must enter first name.");
    return false;
	}  else	{
		if (!lname)	{
			alert("You must enter last name.");
			return false;
		}  else	{
			if (!email)		{
				alert("You must enter email.");
				return false;
			}		else		{
				return true;
			}
		}
	}
}

function ValidateFormGiveUsYourFeedback (form) { // Used in Give us your feedback page (pageid=5&ctype=bm)
  var fname = form.firstname.value;   
  var lname = form.lastname.value;   
  var email = form.email.value;   
  if (!fname)	{
    alert("You must enter first name.");
    return false;
	}  else	{
		if (!lname)	{
			alert("You must enter last name.");
			return false;
		}  else	{
			if (!email)		{
				alert("You must enter email.");
				return false;
			}		else		{
				return true;
			}
		}
	}
}

function ValidateFormDownloadTestResults (form) {
  var fname = form.firstname.value;   
  var lname = form.lastname.value;   
  var address = form.address.value;   
  var phone = form.phone.value;   
  var email = form.email.value;   
  if (!fname)	{
    alert("You must enter first name.");
    return false;
	} else	if (!lname)	{
		alert("You must enter last name.");
		return false;
	} else	if (!address)	{
		alert("You must enter address.");
		return false;
	} else	if (!phone)	{
		alert("You must enter telephone.");
		return false;
	} else	if (!email)		{
		alert("You must enter email.");
		return false;
	}	else {
		return true;
	}
}

function printPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 595;
	w_height = 500;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'print.php'+lochref;
  window.showPrintWindow = open(fparam, 'showPrintWindow', theWindowParam);
	setTimeout('if(showPrintWindow&&!showPrintWindow.closed)showPrintWindow.focus()',100);
}
function emailPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 420;
	w_height = 300;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'tools/emailpage/index.php'+lochref;
  window.showEmailWindow = open(fparam, 'showEmailWindow', theWindowParam);
	setTimeout('if(showEmailWindow&&!showEmailWindow.closed)showEmailWindow.focus()',100);
}
function popupWindow (theWindow, theParam) {

//	newLeft = screen.width
//	newTop = screen.height
	switch (theWindow)
	{
		case 'newmenu':
			window.open('menuform.php?'+theParam, 'NewMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		case 'editmenu':
			window.open('menuform.php?'+theParam, 'EditMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		default:
			return;
	}
}
function changeLang(theLang, theQueryString) {
  lochref = '';
	// Check if already lang parameter is sent
	if (theQueryString.match('lang=') != null) {
		langPos = theQueryString.indexOf('lang=');
		theQueryString = theQueryString.substring(0,(langPos-1))+theQueryString.substring((langPos-1)+8);
	}
	// Check all parameters that 'index.php' files handles
	if (theQueryString != '') {
		lochref = 'index.php?'+theQueryString+'&lang='+theLang;
	} else {
		lochref = 'index.php?lang='+theLang;
	}
	location = lochref;
}
function goToSearch(theform) {
  var theSearchQuery = theform.searchquery.value;
	
  lochref = 'index.php?pageaction=search&searchquery=' + theSearchQuery;
	
	location = lochref;
}
function goToSitemap() {

  lochref = 'index.php?pageaction=sitemap';

	location = lochref;
}
function goToMember(theAction) {

  lochref = 'index.php?pageaction=member&action='+theAction;
	
	location = lochref;
}

function popupInvoice(theInvId) {
	invid='';
	if (theInvId!='') {
		invid='?pageaction=cca&modid=UsrInvoice&invid='+theInvId;
	}

	w_width = 595;
	w_height = 500;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'popupinvoice.php'+invid;
  window.showPopupWindow = open(fparam, 'showPopupWindow', theWindowParam);
	setTimeout('if(showPopupWindow&&!showPopupWindow.closed)showPopupWindow.focus()',100);
}
