
// These functions are called when leaving the contact page either 
// via the "onunload" event handler or the submit button.
// The functions check if the form is empty, and if not, will ask the 
// user if (s)he wants to abandon the already entered data. Of course, 
// using the submit button will circumvent the checks to avoid an
// annoying un unnecessary dialog pop-up

// ================================================================

function setandsubmit() 
{
document.getElementById('jsass').value=2;
document.getElementById('contactform').submit();
}

// ================================================================

function formempty()
{

var names = new Array("yourname","address","city","zip","phone","email","feedback");
var k=0;

for (i=0;i<names.length;i++) {
   if (eval("document.getElementById('"+names[i]+"').value")) {
	return 1; break;
   }
}
}

// ================================================================

function emptytest() {

var status = document.getElementById('jsass').value;

  if ((status < 4) && (status != 2) && formempty()) {
     choice=confirm("Your data will be lost. Do you want to continue?");
     if (choice == false) {
	eval("window.location='contact.php'");
	if (status < 2) document.getElementById('jsass').value='1';
	else document.getElementById('jsass').value=status;
	document.getElementById('contactform').submit();
     }
  }

}

