var sPath = window.location.pathname;
var re_checkoutpage = new RegExp('/basket.zi/');
var re_paypalpayment = new RegExp('/paypalpdt.cgi/');
var re_product = new RegExp('/Events/[A-Z,a-z,0-9,\-]+.html');
var re_newcastle = new RegExp('newcastle');
var re_edinburgh = new RegExp('edinburgh');
var re_butler =  new RegExp('butler-packages-newcastle-leeds-manchester');
var re_weekends = new RegExp('weekend-packages-newcastle-manchester-leeds');

var re_CreditCard = new RegExp('Credit Card: ');
window.onload=initAll;

function initAll(){
  //display noda for newcastle only
  if (sPath.match(re_weekends)) {
    setDisplayOff('navCatBlock7');
    setDisplayOff('navCatBlock13');
  } else {
    if ((readCookie('cookie_location')=='newcastle') ||(sPath.match(re_newcastle))) {  
      setDisplayOn('navCatBlock7');
    } else {
      setDisplayOff('navCatBlock7');
    }
    if ((readCookie('cookie_location')=='edinburgh') ||(sPath.match(re_edinburgh))) {
      setDisplayOn('navCatBlock13');
    } else {
      setDisplayOff('navCatBlock13');
    }
  }

  if (sPath.match(re_product)) {
    // if this is a product page
    setTheProductPageWidth(); 
    setTheShoppingHeader();
    setHeadlineSize();
    movethepricebox();
    setTheProductBackground();
    setTheShoppingFooter();
  } else {
    //normal page
    displayTheNormalHeader();
    displayTheNormalBackground();
  }
  if (sPath.match(re_checkoutpage)) {
    hideContinueShopping();
    var pageheader= document.getElementById('shopcartheadline'); 
    var thisTitle = document.title;
    if (thisTitle=="Shopping Cart"){
       pageheader.innerText="Booking: Customer Info";
       hideContinueShopping();
    } else if (thisTitle=="Order Checkout: Customer Info"){ 
      pageheader.innerText="Booking: Customer Info"; 
      hideshippinginfopart();
    } else if (thisTitle=="Order Checkout: Payment"){
      pageheader.innerText="Booking: Payment"; 
      //payment page
      hideshippingonpaymentpage();
      amendselectpaymentoptions();
    } else if (thisTitle=="Order Checkout: Review"){ 
      //payment page
      pageheader.innerText="Booking: Review"; 
      hideshippingonreviewpage();
    } else if (thisTitle=="Order Checkout: Thank You") {      
      pageheader.innerText="Booking: Thank You"; 
      //thank you page
      hideshippingonthankyoupage();
    }
    document.getElementById('shopcartheadline').style.color="#21527b";
    setTheShoppingHeader();
    setTheShoppingArea();
    setTheTableToHoldBasketDetails();
    setTheShoppingFooter();
  }
  if (sPath.match(re_paypalpayment)) {
    //Paypal payment page
    hideshippingonpaypalpage();
  } 
}

function setTheProductPageWidth() {
  var aryClassElements = getElementsByClassName('maincontent', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'maincontent') {
      /*aryClassElements[i].style.width="900px";
      aryClassElements[i].style.marginRight="70px";*/
      aryClassElements[i].style.padding="5px 65px 5px 9px";
      /*aryClassElements[i].style.border="1px solid black"; */    
    }
   } 
}

function setHeadlineSize() {
 var Headline= document.getElementById('headline');
 Headline.style.fontSize="18px";
}

function amendselectpaymentoptions() {
    var optiondropdown = document.getElementsByTagName('option');    
    if (optiondropdown.length>0) {
      for ( var i = 0; i < optiondropdown.length; i++ ) {        
          if (optiondropdown[i].text.match(re_CreditCard)) {
            newtext = optiondropdown[i].text 
            optiondropdown[i].text = newtext.replace(re_CreditCard, "");
          } 
      }
    }
}

function movethepricebox() {
  var tableelement;
  //get table price table(1) element on this page
  tableelement = document.getElementsByTagName("table")[2];
  //table id moved from 1 to 2 as now we have slogan panel in
  tableelement.style.width = "35%";
  tableelement.style.marginRight = "20px";
}

function setTheShoppingHeader() {
    //Set the top nav on the shopping pages
    var TopNavPanel = document.getElementById('topnavpanel');    
    TopNavPanel.style.backgroundImage="url('https://www.zinestudio.co.uk/northeastevents/images/shoppingtopnav.gif')";
    TopNavPanel.style.height="67px";
    TopNavPanel.style.visible="visible";
    TopNavPanel.style.display="block"; 
}

function displayTheNormalHeader() {
    //Set the top nav on the other pages
    var TopNavPanel = document.getElementById('topnavpanel');    
    TopNavPanel.style.backgroundImage="url('https://www.zinestudio.co.uk/northeastevents/images/sty_topnavback.jpg')";
    TopNavPanel.style.height="55px";
    TopNavPanel.style.visible="visible";
    TopNavPanel.style.display="block"; 
}

function setTheShoppingArea() {
    //set the td class maincontent
    var shoppingarea = document.getElementById('mainbody').getElementsByTagName('td')[0];
    shoppingarea.style.width="950px";
    shoppingarea.style.background="url('https://www.zinestudio.co.uk/northeastevents/images/shoppingbackground.jpg') repeat-y";
    //shoppingarea.style.border="1px solid red";
}

function setTheTableToHoldBasketDetails() {
    //set the div holds the table for shopping
    var shoppingdiv = document.getElementById('mainbody').getElementsByTagName('div')[0];
    shoppingdiv.style.width="950px";
    shoppingdiv.style.background="transparent";
    shoppingdiv.style.top="0px";
    shoppingdiv.style.marginLeft="auto";
    shoppingdiv.style.marginRight="auto";
    shoppingdiv.style.marginLeft="5px";
}

function hideshippingonpaypalpage() {
  //set table width to half
  var aryClassTable = getElementsByClassName('custbasicinfotable', document.body );    
  aryClassTable[0].parentNode.className = "";
  aryClassTable[0].style.width="50%";
  //change shipping title to billing  
  var aryClassElements = getElementsByClassName('custbasicinfoheader', document.body );    
  aryClassElements[0].innerText="Billing To:";
  //get Paypal Order summary
  var aryClassPaypal = getElementsByClassName('paypalOrderSummary', document.body );    
  aryClassPaypal[0].getElementsByTagName('table')[0].getElementsByTagName('tr')[2].getElementsByTagName('td')[0].innerHTML="<b>Payment Handeling fee:</b>";

}

function setTheShoppingFooter() {
    //Set the footer & bottom nav on the shopping pages
    var BotNavPanel = document.getElementById('botnavpanel');    
    BotNavPanel.style.backgroundImage="url('https://www.zinestudio.co.uk/northeastevents/images/sty_botnavback.jpg')";
    var shoppingFooter = document.getElementById('footerpanel');
    shoppingFooter.style.backgroundImage="url('https://www.zinestudio.co.uk/northeastevents/images/sty_footback.gif')";
}

function setTheProductBackground() {
  //set the product background to white
  var aryClassElements = getElementsByClassName('maincontent', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'maincontent') {
      aryClassElements[i].style.background="url('https://www.zinestudio.co.uk/northeastevents/images/productbackground.jpg') repeat-y";      
    }
   } 
}

function displayTheNormalBackground() {
  //set the normal background
  var aryClassElements = getElementsByClassName('maincontent', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'maincontent') {
      aryClassElements[i].style.background="transparent url('https://www.zinestudio.co.uk/northeastevents/images/sty_maincontentback.jpg') left top no-repeat";      
    }
   } 
}

function hideContinueShopping() {
  var aryClassElements = getElementsByClassName( 'cartlink', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'cartlink') {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
}

function hideshippinginfopart() {
  document.all.ch_shipSame.checked = true ;
  var aryClassElements = getElementsByClassName( 'cart', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'cart' && (i==3 || i==4)) {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
}


function hideFirstContinueShopping(){
  var aryClassElements = getElementsByClassName( 'cartlinkhidden', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'cartlinkhidden') {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
}

function hideshippingonpaymentpage() {
  var tableelement;
  var aryClassElements = getElementsByClassName('ordertotalline', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'ordertotalline' && (i>=0 && i<=5)) {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
  aryClassElements = getElementsByClassName('cart', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'cart' && i==5) {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
}

function hideshippingonreviewpage() {
  var tableelement;
  //get table shipping table(8) element on this page
  tableelement = document.getElementsByTagName("table")[9];
  //table id moved from 8 to 9 as now we have slogan panel in
  tableelement.style.visibility = "hidden";
  tableelement.style.display = "none";
  var aryClassElements = getElementsByClassName('ordertotalline', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'ordertotalline' && (i>=0 && i<=5)) {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
}

function hideshippingonthankyoupage() {
  var aryClassElements = getElementsByClassName('custbasicinfotable', document.body );    
  for ( var i = 0; i < aryClassElements.length; i++ ) {        
    if (aryClassElements[i].className = 'custbasicinfotable' && (i==1)) {
      aryClassElements[i].style.visibility = "hidden";
      aryClassElements[i].style.display = "none";
    }
   }
  var aryClassElementsship = getElementsByClassName('ordertotalline', document.body );    
  for ( var i = 0; i < aryClassElementsship.length; i++ ) {        
    if (aryClassElementsship[i].className = 'ordertotalline' && (i>=0 && i<=5)) {
      aryClassElementsship[i].style.visibility = "hidden";
      aryClassElementsship[i].style.display = "none";
    }
   }
}


function readCookie(cookie_name) {   
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if (results)
    return (unescape(results[2]));
  else
    return null;
}

function capitaliseforformheader(value)
{
 if (value != "") {
   var words = value.split(" "); 
   for (var i=0 ; i < words.length ; i++){ 
      var testwd = words[i]; 
      var firLet = testwd.substr(0,1); 
      var rest = testwd.substr(1, testwd.length -1) 
      words[i] = firLet.toUpperCase() + rest 
   } 
  }
  return words.join(" ");
}

function capitalise(value)
{
 if (value != "") {
   var firstLetter = value.substring(0, 1).toUpperCase();
   var restOfWord = value.substring(1, value.length).toLowerCase(); 
   value = firstLetter + restOfWord;
   var newvalue= value.replace(/\+/g," ");
 }
  return newvalue;
}

function setDisplayOn(e){
  element = document.getElementById(e);
  if (element){
   //if IE
   if (element.currentStyle){
       element.style.display='block';
       element.style.visible='visible';
   } else {
    //if FF
    element.setAttribute( 'style', 'display:block');
   }
  }
}

function setDisplayOff(e){
  element = document.getElementById(e);
  if (element){
   //if IE
   if (element.currentStyle){
       element.style.display='none';
       element.style.visible='hidden';
   } else {
    //if FF
    element.setAttribute( 'style', 'display:none');
   }
  }
}

function capitaliseall(value)
{
 if (value!= "") {
    var word = value.toUpperCase(); 
    var newword = word.replace(/\+/g," ");
 }  
  return newword;
}

function deletedayactivity(deleteitem) {
  var i;
  var cookiestring="";
  var cookiecontent=readCookie("cookie_day");
  var mySplitResult = cookiecontent.split("|");
  for(i = 0; i < mySplitResult.length; i++){
    if(i!=deleteitem) {
      //build cookie string
      cookiestring = cookiestring+escape(mySplitResult[i])+"|";
    }
 }
  var strLen =cookiestring.length;
  var last_char=cookiestring.charAt(strLen -1);
  if(last_char=="|") {
    cookiestring = cookiestring.slice(0,-1); 
  }
  //delete cookie
  var d = new Date();
  document.cookie = "cookie_day;expires=" + d.toGMTString() + ";" + ";";
  document.cookie = "cookie_day="+cookiestring ; 
  alert('Your daytime activity has been removed');
  location.reload(true);
}

function deleteeveningactivity(deleteitem) {
  var i;
  var cookiestring="";
  var cookiecontent=readCookie("cookie_evening");
  var mySplitResult = cookiecontent.split("|");
  for(i = 0; i < mySplitResult.length; i++){
    if(i!=deleteitem) {
      //build cookie string
      cookiestring = cookiestring+escape(mySplitResult[i])+"|";
    }
 }
  var strLen =cookiestring.length;
  var last_char=cookiestring.charAt(strLen -1);
  if(last_char=="|") {
    cookiestring = cookiestring.slice(0,-1); 
  }
  //delete cookie
  var d = new Date();
  document.cookie = "cookie_evening;expires=" + d.toGMTString() + ";" + ";";
  //create new cookie
  document.cookie = "cookie_evening="+cookiestring; 
  alert('Your evening activity has been removed');
  location.reload(true);
}

function deleteaccommodation(deleteitem) {
  var i;
  var cookiestring="";
  var cookiecontent=readCookie("cookie_acc");
  var mySplitResult = cookiecontent.split("|");
  for(i = 0; i < mySplitResult.length; i++){
    if(i!=deleteitem) {
      //build cookie string
      cookiestring = cookiestring+escape(mySplitResult[i])+"|";
    }
 }
  var strLen =cookiestring.length;
  var last_char=cookiestring.charAt(strLen -1);
  if(last_char=="|") {
   cookiestring = cookiestring.slice(0,-1); 
  }
  //delete cookie
  var d = new Date();
  document.cookie = "cookie_acc;expires=" + d.toGMTString() + ";" + ";";
  document.cookie = "cookie_acc="+cookiestring; //
  alert('Your accommodation selection has been removed');
  location.reload(true);
}

function deleterestaurant(deleteitem) {
  var i;
  var cookiestring="";
  var cookiecontent=readCookie("cookie_restaurant");
  var mySplitResult = cookiecontent.split("|");
  for(i = 0; i < mySplitResult.length; i++){
    if(i!=deleteitem) {
      //build cookie string
      cookiestring = cookiestring+escape(mySplitResult[i])+"|";
    }
  }
  var strLen =cookiestring.length;
  var last_char=cookiestring.charAt(strLen -1);
  if(last_char=="|") {
    cookiestring = cookiestring.slice(0,-1); 
  }
  //delete cookie
  var d = new Date();
  document.cookie = "cookie_restaurant;expires=" + d.toGMTString() + ";" + ";";
  document.cookie = "cookie_restaurant="+cookiestring;
  alert('Your restaurant selection has been removed');
  location.reload(true);
}

function deletevideo(deleteitem) {
  var i;
  var cookiestring="";
  var cookiecontent=readCookie("cookie_video");
  var mySplitResult = cookiecontent.split("|");
  for(i = 0; i < mySplitResult.length; i++){
    if(i!=deleteitem) {
      //build cookie string
      cookiestring = cookiestring+escape(mySplitResult[i])+"|";
    }
  }
  var strLen =cookiestring.length;
  var last_char=cookiestring.charAt(strLen -1);
  if(last_char=="|") {
    cookiestring = cookiestring.slice(0,-1); 
  }
  //delete cookie
  var d = new Date();
  document.cookie = "cookie_video;expires=" + d.toGMTString() + ";" + ";";
  document.cookie = "cookie_video="+cookiestring;
  alert('Your video option has been removed');
  location.reload(true);
}

function validatesupplierform(frm)
{
    // Check the Name field is not blank
    if (frm.txtname.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.txtname.focus();
        return false;
    }
    // Check the postal address field is not blank
    if (frm.txtpostaladdress.value.length == 0)
    {
        alert("Please enter postal address.");
        frm.txtpostaladdress.focus();
        return false;
    }
    // Check the city field is not blank
    if (frm.txtcity.value.length == 0)
    {
        alert("Please enter city.");
        frm.txtcity.focus();
        return false;
    }
    // Check the county field is not blank
    if (frm.txtcounty.value.length == 0)
    {
        alert("Please enter county.");
        frm.txtcounty.focus();
        return false;
    }
    // Check the postcode field is not blank
    if (frm.txtpostcode.value.length == 0)
    {
        alert("Please enter postcode.");
        frm.txtpostcode.focus();
        return false;
    }
    // Check the Email field to see if any characters were entered
    if (frm.txtemail.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    // Now check the Email field for the "@" symbol
    if (frm.txtemail.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    // Check the mobile is not blank
    if (frm.txtmobile.value.length == 0)
    {
        alert("Please enter contact number.");
        frm.txtmobile.focus();
        return false;
    }

    // Check the category is not blank
    if (frm.txtcategory.value.length == 0)
    {
        alert("Please enter some category details.");
        frm.txtcategory.focus();
        return false;
    }
    // Check the category is not blank
    if (frm.txtdescription.value.length == 0)
    {
        alert("Please enter some description details.");
        frm.txtdescription.focus();
        return false;
    }
}

function validatepoledancingform(frm) 
{
    // Check the Name field is not blank
    if (frm.txtname.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.txtname.focus();
        return false;
    }
    // Check the tel and mobile are not blank
    if (frm.txttelephone.value.length == 0 && frm.txtmobile.value.length == 0)
    {
        alert("Please enter either a telephone or mobile number.");
        frm.txttelephone.focus();
        return false;
    }
    // Check the Email field to see if any characters were entered
    if (frm.txtemail.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    // Now check the Email field for the "@" symbol
    if (frm.txtemail.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.txtemail.focus();
        return false;
    }
}

function validatebutlerandpamperform(frm) {
      // Check the Name field is not blank
    if (frm.txtname.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.txtname.focus();
        return false;
    }
    // Check the Email field to see if any characters were entered
    if (frm.txtemail.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    // Now check the Email field for the "@" symbol
    if (frm.txtemail.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    // Check the mobile is not blank
    if (frm.txtmobile.value.length == 0)
    {
        alert("Please enter contact number.");
        frm.txtmobile.focus();
        return false;
    }
    // Check the option is not blank, if applicable
    if (frm.cmboption.value != '0') {
      if (frm.cmboption.value.length == 0)
      {
        alert("Please select your activity option.");
        frm.cmboption.focus();
        return false;
      }
    }
    // Check the type of group is not blank
    if (frm.cmbgroup.value.length == 0)
    {
        alert("Please select your kind of group.");
        frm.cmbgroup.focus();
        return false;
    }
    // Check the date is not blank
    if (frm.txtarrival.value.length == 0)
    {
        alert("Please select a date.");
        frm.txtarrival.focus();
        return false;
    }
    // Check the people is not blank
    if (frm.txtpeople.value.length == 0)
    {
        alert("Please enter the number of people.");
        frm.txtpeople.focus();
        return false;
    }
    // Check the call time is not blank
    if (frm.cmbtimetocall.value.length == 0)
    {
        alert("Please select the best time to call you.");
        frm.cmbtimetocall.focus();
        return false;
    }
    // Check the where you hear about us is not blank
    if (frm.cmbhear.value.length == 0)
    {
        alert("Please select where you heard about us from.");
        frm.cmbhear.focus();
        return false;
    }

}

function validatespecialofferform(frm) 
{
    // Check the Name field is not blank
    if (frm.txtname.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.txtname.focus();
        return false;
    }
    // Check the Email field to see if any characters were entered    if (frm.txtemail.value.length == 0)
        if (frm.txtemail.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    //
    // Now check the Email field for the "@" symbol
    //
    if (frm.txtemail.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    
    // Check the mobile is not blank
    if (frm.txtmobile.value.length == 0)
    {
        alert("Please enter contact number.");
        frm.txtmobile.focus();
        return false;
    }
    // Check the city is not blank
    if (frm.cmbhotel.value.length == 0)
    {
        alert("Please select your hotel choice.");
        frm.cmbhotel.focus();
        return false;
    }
    
    // Check the date is not blank
    if (frm.txtarrival.value.length == 0)
    {
        alert("Please select a date.");
        frm.txtarrival.focus();
        return false;
    }
    // Check the people is not blank
    if (frm.txtpeople.value.length == 0)
    {
        alert("Please enter the number of people.");
        frm.txtpeople.focus();
        return false;
    }
    // Check the kind of group is not blank
    if (frm.cmbgroup.value.length == 0)
    {
        alert("Please select the kind of group.");
        frm.cmbgroup.focus();
        return false;
    }
    // Check the call time is not blank
    if (frm.cmbtimetocall.value.length == 0)
    {
        alert("Please select the best time to call you.");
        frm.cmbtimetocall.focus();
        return false;
    }
    // Check the where you hear about us is not blank
    if (frm.cmbhear.value.length == 0)
    {
        alert("Please select where you heard about us from.");
        frm.cmbhear.focus();
        return false;
    }
}


function validatecontactusform(frm) 
{
    // Check the Name field is not blank
    if (frm.txtname.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.txtname.focus();
        return false;
    }
    // Check the Email field to see if any characters were entered
    //
    if (frm.txtemail.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    //
    // Now check the Email field for the "@" symbol
    //
    if (frm.txtemail.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.txtemail.focus();
        return false;
    }
    
    // Check the mobile is not blank
    if (frm.txtmobile.value.length == 0)
    {
        alert("Please enter contact number.");
        frm.txtmobile.focus();
        return false;
    }
    // Check the city is not blank
    if (frm.city.value.length == 0)
    {
        alert("Please select a city.");
        frm.city.focus();
        return false;
    }
    
    // Check the date is not blank
    if (frm.txtdate.value.length == 0)
    {
        alert("Please select a date.");
        frm.txtdate.focus();
        return false;
    }
    // Check the people is not blank
    if (frm.txtpeople.value.length == 0)
    {
        alert("Please enter the number of people.");
        frm.txtpeople.focus();
        return false;
    }
    // Check the kind of group is not blank
    if (frm.kind.value.length == 0)
    {
        alert("Please select the kind of group.");
        frm.kind.focus();
        return false;
    }
    // Check the call time is not blank
    if (frm.call.value.length == 0)
    {
        alert("Please select the best time to call you.");
        frm.call.focus();
        return false;
    }
    // Check the where you hear about us is not blank
    if (frm.hear.value.length == 0)
    {
        alert("Please select where you heard about us from.");
        frm.hear.focus();
        return false;
    }
}

function validatecreateform (frm) 
{
    if (frm.date.value.length == 0)
    {
        alert("Please enter the date required.");
        frm.date.focus();
        return false;
    }
    if (frm.people.value.length == 0)
    {
        alert("Please enter the number of people.");
        frm.people.focus();
        return false;
    }
    if (frm.cmbinterested.value.length == 0)
    {
        alert("Please select your interest.");
        frm.cmbinterested.focus();
        return false;
    }
    if (frm.name.value.length == 0)
    {
        alert("Please enter contact name.");
        frm.name.focus();
        return false;
    }
    if (frm.email.value.length == 0)
    {
        alert("Please enter an e-mail address.");
        frm.email.focus();
        return false;
    }
    if (frm.email.value.indexOf("@") == -1)
    {
        alert("Please enter a valid e-mail address.");
        frm.email.focus();
        return false;
    }
    if (frm.telephone.value.length == 0)
    {
        alert("Please enter contact number.");
        frm.telephone.focus();
        return false;
    }
    if (frm.cmbcall.value.length == 0)
    {
        alert("Please select the best time for contact.");
        frm.cmbcall.focus();
        return false;
    }
    if (frm.cmbhear.value.length == 0)
    {
        alert("Please select how you heard about us.");
        frm.cmbhear.focus();
        return false;
    }
    if (frm.chkterms.checked != 1)
    {
        alert("Please accept out terms and conditions to submit your enquiry.");
        frm.chkterms.focus();
        return false;
    }
}

function getElementsByClassName( strClassName, obj ) {    
  var ar = arguments[2] || new Array();    
  var re = new RegExp("\\b" + strClassName + "\\b", "g");    
  if ( re.test(obj.className) ) {        
    ar.push( obj );    
  }    
  for ( var i = 0; i < obj.childNodes.length; i++ ) getElementsByClassName( strClassName, obj.childNodes[i], ar );        
  return ar;
}

/**
* A tracker for first- and multi-touch tracking using Google Analytics. In 
* addition, the script also tracks time-to-conversion. Further reading at
* http://weblog.scanyours.com/2010/06/23/multi-touch-conversion-tracking-with-google-analytics-part-3-implementation/
*
* Please keep this header intact when distributing.
*
* @author     A.G. Gideonse
* @version    0.1
* @license    GNU General Public License (GPL)
* @copyright  ScanYours 2010
*/
var Tracert = Tracert ? Tracert : {

   // Initializes Multi-Touch / Time-To-Conversion tracking
   init : function() {
      return Tracert._track();
   },

   // METHOD :: Returns the current referrer
   _getSource : function() {

      var regex = /^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]+)?#?(\w*)/;
      var referrer = '(direct)';

      if (document.referrer) {

          referrer = document.referrer.replace(regex, '$6');
          
          // Internal referal (same host)
          if (referrer == window.location.host) {
             return false;
          }

          // Google (organic)
          var regex = /[a-z0-9\-\.]+\.google\.[a-zA-Z]{2,3}/i;
          if (regex.test(referrer)) {

             referrer = 'Google';
             if (Tracert._getParameter('url').substr(1, 4) == 'aclk') {
                referrer = 'Google_adwords';
             }
          }
      }

      return referrer;
   },
   
   // METHOD :: Actual tracking of the data
   _track : function(referrer) {

      var referrer = Tracert._getSource();
      if (!referrer) {
         return false;
      }

      // Calculate Time-To-Conversion
      var timeToConversion = 0;
      var currentTouch = Math.round(new Date().getTime() / 1000);

      if (pageTracker._getVisitorCustomVar(1)) {

         var firstTouch = parseInt(Tracert.readCookie('firstTouch'));

         if (firstTouch) {
            timeToConversion = Math.round((currentTouch - firstTouch) / 3600);
         }

      }

      // Save Time-To-Conversion (as String to track zero)
      timeToConversion = String(timeToConversion);
      pageTracker._setCustomVar(3, 'time-to-conversion', timeToConversion, 1);      
      
      // Save original source (first-touch)
      if (!pageTracker._getVisitorCustomVar(1)) {
         pageTracker._setCustomVar(1, 'ref-origin', referrer, 1);
         Tracert.createCookie('firstTouch', currentTouch, 180);
      }

      // Save assisting source (new)
      if (!pageTracker._getVisitorCustomVar(2)) {
         pageTracker._setCustomVar(2, 'ref-route', referrer, 1);
         return true;
      }

      // Skip assisting source (already-in-route)
      var cRoute = pageTracker._getVisitorCustomVar(2).split('~');
      if (cRoute.find(referrer) != -1) {
         return false;
      }

      // Save assisting source (new-in-route)
      cRoute[cRoute.length] = referrer;
      if (cRoute.join('~').length > 55) {
         return false;
      }

      cRoute.sort();
      pageTracker._setCustomVar(2, 'ref-route', cRoute.join('~'), 1);
   },

   // METHOD :: Returns the requested GET-parameter
   _getParameter : function(p) {
      var regex  = new RegExp('[\\?&]' + p + '=([^&#]*)');
      var result = regex.exec(document.referrer);
      return (result == null) ? '' : result[1];
   },

   // METHOD :: Utility method to add events
   addListener : function(el, type, expression) {

      // Add event (FF & other)
      if (window.addEventListener) {
         el.addEventListener(type, expression, false);
         return true;
      }

      // Add event (IE)
      if (window.attachEvent) {
         el.attachEvent('on' + type, expression);
        return true;
      }

      return false;
   },

   // METHOD :: Write a cookie
   // SOURCE: http://www.quirksmode.org/ (and many others)
   createCookie : function(name, value, days) {
	   if (days) {
		   var date = new Date();
		   date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		   var expires = '; expires=' + date.toGMTString();
	   } else {
	      var expires = '';
	   }

	   document.cookie = name + '=' + value + expires + '; path=/';
   },
   
   // METHOD :: Read a cookie
   // SOURCE: http://www.quirksmode.org/ (and many others)
   readCookie : function(name) {

	   var nameEQ = name + "=";
	   var ca = document.cookie.split(';');

	   for(var i = 0; i < ca.length; i++) {

		   var c = ca[i];
		   while (c.charAt(0)==' ') {
		      c = c.substring(1, c.length);
		   }
		   
		   if (c.indexOf(nameEQ) == 0) {
		      return c.substring(nameEQ.length, c.length);
		   }

	   }

	   return 0;
   }

}
Tracert.addListener(window, 'load', Tracert.init);

// METHOD :: Adds search functionality to Arrays
Array.prototype.find = function (element) {

   for (var keys in this) {
      if (this[keys] == element) {
         return keys;
      }
   }

   return -1;
};




