/*
* Atlas Greetings
*
*
*/

// This initializes the widgets
jQuery(function($) {

$('#first_last_name').val("");

$('#camphill_logo').qtip({
	content: {
	   url: ''+ location.protocol + '//' + location.host +'/happyholidays/camphill.html',
	   title: { text: 'Camphill' }
	},	
	style: { title: { 'color':'white','text-align': 'center', 'background-color':'#969291', 'font-family': 'Arial', 'font-size':'10pt', 'font-weight':'bold' }, width: {'min':'400'} },
	show: 'mouseover',
	hide: 'mouseout',
	position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   }
	
});


/* $('#redcross_logo').qtip({
	content: {
	   url: ''+ location.protocol + '//www.atlassystems.com/happyholidays/redcross.html',
	   title: { text: 'American Red Cross' }
	},	
	style: { title: { 'color':'white','text-align': 'center', 'background-color':'#969291', 'font-family': 'Arial', 'font-size':'10pt', 'font-weight':'bold' }, width: {'min':'400'} },
	show: 'mouseover',
	hide: 'mouseout',
	position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   }
	
}); */

$('#capp_logo').qtip({
	content: {
	   url: ''+ location.protocol + '//' + location.host + '/happyholidays/capp.html',
	   title: { text: 'CAPP' }
	},	
	style: { title: { 'color':'white','text-align': 'center', 'background-color':'#969291', 'font-family': 'Arial', 'font-size':'10pt', 'font-weight':'bold' }, width: {'min':'400'} },
	show: 'mouseover',
	hide: 'mouseout',
	position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   }
	
});


$('#msf_logo').qtip({
	content: {
	   url: ''+ location.protocol + '//' + location.host + '/happyholidays/msf.html',
	   title: { text: 'M&eacute;decins Sans Fronti&egrave;res (MSF)' }
	},	
	style: { title: { 'color':'white','text-align': 'center', 'background-color':'#969291', 'font-family': 'Arial', 'font-size':'10pt', 'font-weight':'bold' }, width: {'min':'400'} },
	show: 'mouseover',
	hide: 'mouseout',
	position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   }
	
}); 


/* $('#humansociety_logo').qtip({
	content: {
	   url: ''+ location.protocol + '//www.atlassystems.com/happyholidays/hsociety.html',
	   title: { text: 'The Human Society' }
	},	
	style: { title: { 'color':'white','text-align': 'center', 'background-color':'#969291', 'font-family': 'Arial', 'font-size':'10pt', 'font-weight':'bold' }, width: {'min':'400'} },
	show: 'mouseover',
	hide: 'mouseout',
	position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   }
	
}); */


$('#submit_choice').click(function(){
	var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

	if($("input[@name='organizationsGroup']:checked").val() && $('#first_last_name').val() && emailReg.test( $('#email_address').val() ) ){
		var first_last_name = $('#first_last_name').val().replace("'", "");
		var email_address = $('#email_address').val();
		var selection = $("input[@name='organizationsGroup']:checked").val();
		var d = new Date();
	
		$.ajax({
			dataType: "script",
            url: "http://184.106.106.86:3100/thankyou.aspx",
            data : "flname=" + first_last_name + "&sel=" + selection + "&email="+email_address+"&d=" + d.getTime(),
            async : false,
            success: function(data){ 
				$("#thanks_click").trigger('click');
            }
        }); 

		//$("#thanks_click").trigger('click');
	}
	else
	{
		alert("Please choose your worthy cause for the holiday gift and enter you first, last name and proper email address.");
	}
});


$('a[rel="modal"]:first').qtip(
   {
      content: {
         title: {
            text: '&nbsp;',
            button: 'Close'
         },
         url: ''+ location.protocol + '//' + location.host +'/happyholidays/thankyou.html'
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
		 //adjust: { x: 150, y: 0 }
      },
      show: {
         when: 'click', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { min: 450 },
         padding: '14px',
         border: {
            width: 9,
            radius: 9,
            color: '#666666'
         },
		 title: { 'text-align': 'center', 'font-family': 'Arial', 'font-size':'11pt', 'font-weight':'bold' },
         name: 'light'
      },
      api: {
         beforeShow: function()
         {
            // Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });

   // Create the modal backdrop on document load so all modal tooltips can use it
   $('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: $(document).scrollTop(), // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: $(document).height(), // Span the full document height...
         width: '100%', // ...and full width

         opacity: 0.7, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially

});


function validateEmail(email) {
	alert("Inside" + email);

	var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if( !emailReg.test( email ) ) {
		return false;
	} else {
		return true;
	}
}

(function($){

})(jQuery);

