/**
 * OnLoad events associated with "complete-solution" retail campaign
 * 
 * @author Jon Trumbul
 * @copyright 2009 Melbourne IT
 * @dependencies Mootools 1.2 Core
 * 
 * @return none
 */
function getParameter ( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return "null";
   }
}

window.addEvent('domready', function() {
	
	var percent = $('percentButton');
	percent.addEvent('click', function() {
		myFx = new Fx.Scroll(window).toElement('eoiForm');    
	});
	
	var enquire = $('enquireButton');
	enquire.addEvent('click', function() {
		myFx = new Fx.Scroll(window).toElement('eoiForm');    
	});
	
	var queryString = window.top.location.search.substring(1);
	
	if(getParameter(queryString, "enquiry") == "sent") {
		$('booking_conf').style.display = "block";
		myFx = new Fx.Scroll(window).toElement('quotePrompt');
	} else {
		$('booking_conf').style.display = "none";
	}
	
});

ONEGEEK.forms.GValidator.options = {
    // Generic GValidator options that will be applied to any form without a specific section below.    
    // Edit to suit your environment
    reqShow: true,            // Automatically add the required char to labels?
    reqChar: '*',             // Character used to indicate a required field
    reqPlacement: 'after',   // Position of required character. Can be 'before' or 'after'  
    autoFocus: 'false' 
}

ONEGEEK.forms.GValidator.plugins = {  
    company: {
      _extends: "NameField",
      contextMsg: "Please enter your company name",
      errorMsg: "Company is required, please complete.",
      regex: /^([a-zA-Z0-9\-\'\s]{2,30})$/g,
      cleanRegex: /[^a-zA-Z1-9\-\'\s]/g
    },   
    
    url: {
      _extends: "AbstractTextField",
      regex: /^(http:\/\/|)(www\.|)[A-Za-z0-9][A-Za-z0-9-]{2,61}[A-Za-z0-9](\.([a-z])*)+$/i,
      errorMsg: 'Please enter a valid website address',
      contextMsg: 'Your website address will be kept confidential'     
    }

};

ONEGEEK.forms.GValidator.translation.EN = {  
    defaults: {
      emptyMsg: "Field is required, please complete."
    },
    
    name: {
      cleanRegex: /[^a-zA-Z1-9\-\'\s]/g
    },
    
    phone: {
      errorMsg: "Please enter a valid phone number",  
      contextMsg: "Your phone number will be kept confidential",
	  regex: /^([0-9]{6,14})$/g,
      cleanRegex: /[^a-zA-Z0-9]/g
    }           
};

