function getCookie(name){
var cname = name + "=";               
var dc = document.cookie;             
if (dc.length > 0) {              
begin = dc.indexOf(cname);       
if (begin != -1) {           
begin += cname.length;       
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
   } 
}
return null;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) + 
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
   }
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:support@westoverconsulting.co.uk?subject=Enterprise Service Suite";
else if (Subject.selectedIndex == 2) action = "mailto:support@westoverconsulting.co.uk?subject=Web demo request";
else if (Subject.selectedIndex == 3) action = "mailto:support@westoverconsulting.co.uk?subject=Consulting";
else if (Subject.selectedIndex == 4) action = "mailto:support@westoverconsulting.co.uk?subject=Sales Central @ Work";
else if (Subject.selectedIndex == 5) action = "mailto:support@westoverconsulting.co.uk?subject=Support request";
else if (Subject.selectedIndex == 6) action = "mailto:support@westoverconsulting.co.uk?subject=Comment";
else if (Subject.selectedIndex == 7) action = "mailto:support@westoverconsulting.co.uk?subject=Question";
else if (Subject.selectedIndex == 8) action = "mailto:support@westoverconsulting.co.uk?subject=Suggestion";
else if (Subject.selectedIndex == 9) action = "mailto:support@westoverconsulting.co.uk?subject=Broken Link";
else action = "mailto:webmaster@westoverconsulting.co.uk?subject=ESS - Other";
   }
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) { 
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (Email.value == "") {
alert("Please inlcude your email address.");
Email.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
   }
}
else {
process();
passed = true;
   }
}
return passed;
}

