/* Author: 

*/

// Banner SlideJS

$(function(){
	$('#slides').slides({
//		preload: true,
		effect: 'slide',
		crossfade: true,
		play: 4000,
		pause: 2000,
		fadeSpeed: 800,
		hoverPause: false,
		generatePagination: false,
		generateNextPrev: true, // boolean, Auto generate next/prev buttons
		next: 'next', // string, Class name for next button
		prev: 'prev' // string, Class name for previous button
	});
});


/* 
 
 1) Look for #click-to-contact, and on click toggle() 
     - http://api.jquery.com/toggle/
 
 */
 
 
 /* this is toggle slide */
/* $("#click-to-contact").click(function() {
   $(".quick-contact-box").toggle();
     return false;
 });*/
 
 
 
 /*  this is animate slide */
   $("#click-to-contact-open").click(function(){
    $(".qc-open").css("display","none");
    $(".qc-close").css("display","block");
    $(".top-qc").animate({right:"0px"},"slow");
  });

  $("#click-to-contact-close").click(function(){
    $(".qc-open").css("display","block");
    $(".qc-close").css("display","none");
    $(".top-qc").animate({right:"-250px"},"slow");
  });
 
 
 
 /* 
 
 1) First we're defining the fuction getParamterByName(name) which uses RegEx returning a matched value, then we're creating a variable for .quick-contact-form called gForm
 2) Next we're using RegEx to find out if there is a gForm html tag has a attribute and value containing 'validate=1'
    - If 'validate=1' does not exist we're using RegEx to see if there are any other query parameters in gForm, we add '?' or '&' appropriately to 'validate_query' variable
    - If 'validate=1' does not exist we're using jQuery to append validate_query variable to gForm action html attribute
 3) Last we're using RegEx to search the URL for 'validate' and if it exists we're using jQuery to toggle() the contact form keeping it shown with validation errors 	
 
 */
 
 function getParameterByName(name)
 {
   name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
   var regexS = "[\\?&]" + name + "=([^&#]*)";
   var regex = new RegExp(regexS);
   var results = regex.exec(window.location.href);
   if(results == null)
     return false;
   else
     return decodeURIComponent(results[1].replace(/\+/g, " "));
 }
 gForm = $('.quick-contact-form');
 
 if (!gForm.attr('action').match(/validate\=1/)) {
 
     validate_query = (gForm.attr('action').match(/\?/)?'&':'?') + 'validate=1';
     gForm.attr('action',gForm.attr('action') + validate_query);
 }
 
 
 if (getParameterByName('validate')) {
 //     $(".top-qc").toggle();
		$(".qc-open").css("display","none");
		$(".qc-close").css("display","block");
		$(".top-qc").animate({right:"0px"},"slow");
 }

