$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function checkform(){
  submit =1;
  
  if (trim(document.order.fname.value) == ''){
    alert("Please enter a Firstname.")
      submit = 0;
      return false;
	}

  if (trim(document.order.sname.value) == ''){
    alert("Please enter a Secondname.")
    submit = 0;
    return false;
  }

  if ((trim(document.order.email.value).length < 9) || (document.order.email.value.indexOf('@') == -1) || (document.order.email.value.indexOf('.') == -1)){

    alert("Please enter a valid email address like you@domain.com")
    submit = 0;
    return false;
  }
  
  if (submit == 1) {
   document.order.submit();
  } else {
   return false;
  }
}