
//-- Google Code for Info Request Conversion Page 

/* <![CDATA[ */
var google_conversion_id = 1040772163;
var google_conversion_language = "en";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "mYGOCJ3kmAEQw9ij8AM";
var google_conversion_value = 0;
if (10.00) {
  google_conversion_value = 10.00;
}
/* ]]> */

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18440930-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').data('rel'))
	.animate({opacity: 0.9}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').data('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
//	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({height: '40px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}
    var forwho;
    var forwhere;
$(document).ready(function() {	
$('button').button();
$('button').button( "enable" );	
$('input').attr('checked' , '');
$('input, textarea').val('');
	//Execute the slideShow


	 var signup = $('.signup').fancybox({
   			'href' : '#signupdiv',
        'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',			
				'onComplete' : function(){
           $("#fancybox-wrap").css({ 'position' : 'fixed'});
           $('#leadName').focus();
        }
   });
   
   $('#fancybox-wrap').css('margin-top' , '-340px');
   
  	$( ".radio" ).buttonset();

    $('#forMeadowlark').change(function(){
      forwhere = 'Meadowlark';
    });
    $('#forRiverbend').change(function(){
      forwhere = 'Riverbend';
    }); 
    $('#forWhyte').change(function(){
      forwhere = 'Whyte';
    });
    $('#forSherwood').change(function(){
      forwhere = 'Sherwood';
    });        
   
$('#forMyself').change(function(){
    forwho = 'adult';
    $('#childInfo').fadeOut(function(){ 
        $('.childOnly').fadeOut();
        $('#agegenderInfo').fadeIn(function(){ 
            $("#leadage").focus();
        });    
    });

 });
 
 $('#forMychild').change(function(){
     forwho = 'child';
     $('#childInfo').fadeIn(function(){
        $('.childOnly').fadeIn();      
        $('#agegenderInfo').fadeIn(function(){              
            $('#childName').focus();
        });      
     });
     
 });

	$("#leadage").keydown(function(event) {
		// Allow only backspace and delete
		if ( event.keyCode == 46 || event.keyCode == 8 ) {
			// let it happen, don't do anything
		}
		else {
			// Ensure that it is a number and stop the keypress
			if (event.keyCode < 48 || event.keyCode > 57 ) {
				event.preventDefault();	
			}	
		}
		
		$('#phoneInfo').fadeIn(function(){
       //signup.colorbox.resize();
       $("#leadage").focus();       
    });
	});

	$("#leadphone").keydown(function(event) {
		// Allow only backspace and delete
		if ( event.keyCode == 46 || event.keyCode == 8 ) {
			// let it happen, don't do anything
		}
		else {
			// Ensure that it is a number and stop the keypress
			if (event.keyCode < 48 || event.keyCode > 57 ) {
				event.preventDefault();	
			}	
		}
		
		$('#locationInfo').fadeIn(function(){
       $("#leadphone").focus();
    });              
	});

$('#locationInfo input').change(function(){
		$('#expectationsInfo').fadeIn(function(){
       $('#expectationsInfo textarea').focus();
    });  
});
 
$('#leadsubmit').click(function(){

  var leadname = $('#leadName').val();
  var childname = $('#childName').val();
  var age =  $('#leadage').val();
  var gender = $('#leadgender').val();
  var phone = $('#leadphone').val();
  var expectations = $('#expectations').val();
  
  if(phone.length == 10){
      if(leadname.length > 0){
				$.ajax({
				    type: 'POST',
					  url: 'handlelead.php',
					  dataType: "json",
					  data: {
              'name': leadname,
              'gender' : gender,
              'age' : age,
              'phone' : phone,
              'childname': childname,
              'location' : forwhere,
              'notes' : expectations,
              'do' : 'NEWLEAD',
              'forwho' : forwho
              },
					  beforeSend: function(){
               $('#leadsubmit').button( "disable" );
               $('#conv').attr('src' , 'http://www.googleadservices.com/pagead/conversion/1040772163/?value=10.00&amp;label=mYGOCJ3kmAEQw9ij8AM&amp;guid=ON&amp;script=0');  
            },              
					  success: function(data){
                 if(data.success == 1){
                     alert('Your information was successfully recieved.');
                     $.fancybox.close();
                 }else{
                     alert('There was an error processing your request. You may try again or call us at 780-481-9888');
                     $('#leadsubmit').button( "enable" );
                 }                               
            },

					});
          }else{
            alert('Please enter your full name.');
            $('#leadName').focus();
          }  
  }else{
      alert('Please enter a ten digit phone number');
      $('#leadphone').focus();
  }
  
});

});                                                    


