	function popDialog(id) {
		$(id).dialog('open');
	}
	
	function DownloadFreeMessage() {
		window.location = 'http://www.shanewillardmedia.org/streaming/video/ThePressuresOffMessage1.zip';
	}

	var current_rotation = 0;
	
	function getKeyPress(e){
		var unicode=e.keyCode? e.keyCode : e.charCode
		var actualkey=String.fromCharCode(unicode)
		return actualkey;
	}
	
	var key;
	function TurnTheWorldUpsideDown(){
		if (key == "t") {
			if (current_rotation == 0) {
				current_rotation = 360;
				$("#main-content-wrapper").animate(
					{rotate: 360},
					{
						duration: 5000,
						complete: function(){
							$("#tw").attr("title","<Strong>Turn Someone's World Upside Down</strong>");
							$("#tw").html("It's not hard to turn someone's world upside down. You can make a huge difference with a monthly donation to Shane Willard Ministries.<p>Almost ALL of our online partnership go directly toward supporting orphanages, widows, those who are poor and medical clinics. Soon, monthly donaions will be used to help set free women and children that are held in the bondage of sex slavery. <p>We appreciate you considering partnering with Shane Willard Ministries.");

							$("#tw").dialog({
								width: 400,
								autoOpen: true,
								open: "drop", 
								hide: "drop",
								modal: true,
								stack: true,
								position: "center",
								zIndex: 11000,
								draggable: false,
								resizable: false
							});															
						}
						
				});
			}
			else {
				current_rotation = 0;
				$("#main-content-wrapper").animate(
					{rotate: 0},
					{
						duration: 5000,
						complete: function(){
							$("#tw").attr("title","<Strong>Turn Someone's World Upside Down</strong>");
							$("#tw").html("It's not hard to turn someone's world upside down. You can make a huge difference with a monthly donation to Shane Willard Ministries.<p>Almost ALL of our online partnership go directly toward supporting orphanages, widows, those who are poor and medical clinics. Soon, monthly donaions will be used to help set free women and children that are held in the bondage of sex slavery. <p>We appreciate you considering partnering with Shane Willard Ministries.");
							
							$("#tw").dialog({
								width: 400,
								autoOpen: true,
								open: "drop", 
								hide: "drop",
								modal: true,
								stack: true,
								position: "center",
								zIndex: 11000,
								draggable: false,
								resizable: false
							});
						}
						
					});
			}
		}
	}
	
	$(function() {
		
		(function($){
		 	var _e = document.createElement("canvas").width
		 	
			$.fn.cssrotate = function(d) {  
		    	return this.css({
		  				'-moz-transform':'rotate('+d+'deg)',
		  				'-webkit-transform':'rotate('+d+'deg)',
		  				'-o-transform':'rotate('+d+'deg)',
		  				'-ms-transform':'rotate('+d+'deg)'
		 				}).prop("rotate", _e ? d : null)
		 	}; 
		 
		 	var $_fx_step_default = $.fx.step._default;
		 
		 	$.fx.step._default = function (fx) {
		 			if(fx.prop != "rotate")return $_fx_step_default(fx);
		 			if(typeof fx.elem.rotate == "undefined")fx.start = fx.elem.rotate = 0;
		 			$(fx.elem).cssrotate(fx.now)
		 		}; 
		})(jQuery);

		$("#fd").attr("title","<strong>Congratulations You Found A Secret!</strong>");
		$("#fd").html("<p>To congratulate you, we are offering a free download of one of the messages from Shane's new series, The Pressure's Off.</p><p>We hope this new message blesses you!</p><p><a href='javascript:DownloadFreeMessage();'>Click here</a> to download it now.</p>");
		
		$( "#main-content-wrapper" ).draggable({ delay: 5000 });
		$( "#luggage").data("name", "luggage").draggable({ cursor: 'move'});
		$( "#money" ).data("name", "money").draggable({ cursor: 'move'});
		
		$( "#polaroid2" ).data("name", "polaroid2").draggable({ cursor: 'move'});
		$("#polaroid2").attr("title","Did you know that almost all partner donations are given to feed, clothe and medically treat the poor?");
		$("#polaroid2").tooltip({position: "top", offset: [130, -275]});
		
		$( "#polaroid1" ).data("name", "polaroid1").draggable({ cursor: 'move'});
		$("#polaroid1").attr("title","Help provide for the freedom initiative... setting people free from the atrocity of sexual slavery.");
		$("#polaroid1").tooltip({position: "top", offset: [100, -288]});

		$( "#coffee-cup" ).data("name", "coffee-cup").draggable({ cursor: 'move'});

		$( "#sticky_note" ).data("name", "sticky_note").draggable({ cursor: 'move'});
		$( "#sticky_note" ).data("stained", false);

		$( "#pencil" ).data("name", "pencil").draggable({ cursor: 'move'});
		
		$( "#sticky_note" ).droppable({
			tolerance: 'fit',
			drop: function( event, ui ) {
				var elementName = ui.draggable.data('name');

				if (!$("#sticky_note").data("stained")) {
					
					if (elementName == 'pencil') {
						document.getElementById('note').src = 'images/sticky_note.png';
					}
					else if (elementName == 'coffee-cup') {
						document.getElementById('note').src = 'images/sticky_note_coffee_stain.png';
						$( "#sticky_note" ).data("stained", true);
					}
				}
			},
			out: function( event, ui ) {
				var elementName = ui.draggable.data('name');
				var blnStainedSticky = $("#sticky_note").data("stained");
				
				if (!blnStainedSticky) {
					if (elementName == 'pencil') {
						document.getElementById('note').src = 'images/sticky_note.png';
					}
				}
			},
			over: function( event, ui ) {
				var elementName = ui.draggable.data('name');
				var blnStainedSticky = $("#sticky_note").data("stained");
				
				if (elementName == 'pencil') {
					$( "#sticky_note" ).droppable( "option", "tolerance", 'intersect');
				}
				else {$( "#sticky_note" ).droppable( "option", "tolerance", 'touch');}
					
				if (!blnStainedSticky) {
					if (elementName == 'pencil') {
						document.getElementById('note').src = 'images/sticky_note_eraseattempt.png';
					}
				}
				
			} 
		});
		
		$( "#coffee-stain").droppable({
			tolerance: 'intersect',
			drop: function( event, ui ) {
				var elementName = ui.draggable.data('name');
				if (elementName == 'coffee-cup') { 
					$("#fd").dialog({
						width: 400,
						autoOpen: true,
						open: "drop", 
						hide: "drop",
						modal: true,
						stack: true,
						position: "center",
						zIndex: 11000,
						draggable: false,
						resizable: false
					});
				}
			}
		});
		
		$( "#coffee-cup").droppable({
			accept: '#money',
			tolerance: 'fit',
			drop: function( event, ui ) {
				$('#money').hide('fade'); 
			}
		});
		
		$( "#polaroid1").droppable({
			accept: '#money',
			tolerance: 'touch',
			drop: function( event, ui ) {
				$('#money').hide('fade');
				
				$("#polaroid1").animate({rotate: 45}, {duration: 800});
				$("#polaroid1").animate({rotate: -15}, {duration: 800});
				$("#polaroid1").animate({rotate: 45}, {duration: 800});
				$("#polaroid1").animate({rotate: -15}, {duration: 800});
				$("#polaroid1").animate({rotate: 0}, {duration: 800});
				$(".tooltip:first").text("Many people think that it's the size of the donation that matters! Every little bit helps us accomplish our mission.")
				$(".tooltip:last").text("Every little bit that we receive goes toward helping others. Want to help out today? Partner with us to spread God's love.")
				
				$("#polaroid2").animate({rotate: 90}, {duration: 800});
				$("#polaroid2").animate({rotate: -90}, {duration: 800});
				$("#polaroid2").animate({rotate: 90}, {duration: 800});
				$("#polaroid2").animate({rotate: 0}, {duration: 800});
			}
		});
		
		$( "#polaroid2").droppable({
			accept: '#money',
			tolerance: 'touch',
			drop: function( event, ui ) {
				$('#money').hide('fade');
				$("#polaroid1").animate({
					rotate: 360
					}, {
						duration: 3000
				});
				$("#polaroid2").animate({
					rotate: 360
					}, {
						duration: 3000
				});
				$("#polaroid1").attr("title","Thank you so much for your help. Your donations to Shane Willard Ministries funds feeding programs throughout the world.");
				$("#polaroid1").tooltip({position: "top", offset: [100, -285]});
				$("#polaroid2").attr("title","Thank you so much for your help. Your donations to Shane Willard Ministries funds feeding programs throughout the world.");
				$("#polaroid2").tooltip({position: "top", offset: [135, -275]});
			}
		});
	});

	
