// ----------------------------------------------------------------------
//
// FUNCTIONS.JS
//
// By Gary Smith - August 2009
//
// Defines Javascript functions for use throughout the application
//
function checkClear(el, defaultText) {
	if (el.value==defaultText) {
		el.value="";
	}
}
function checkBlank(el, defaultText) {
	if (el.value.length==0) {
		el.value=defaultText;
	}
}

// garden tooltips
$(function() {
	$.preloadImages(
		"../../images/popup.png" 
	);		   
});

// image preloader
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}

function showFlowerPopup (x_pos, y_pos, flower_width, purchaser, recipient, message) {
	var x_offset=$(window).width() - $("#thegarden").width();
	x_offset=Math.ceil(x_offset/2);
	y_pos=parseInt(y_pos)+24;	
	x_pos=x_offset+x_pos-130+Math.ceil(flower_width/2);
	$("#flower_popup").css({left: x_pos+"px"});
	$("#flower_popup").css({top: y_pos+"px"});	
	var html='<h1>';
	if (recipient.length) {
		html+='<span class="small">TO:</span> ' + recipient + '&nbsp&nbsp;&nbsp;';
	}
	html+='<span class="small">FROM:</span> ' + purchaser;
	html+='</h1>';
	html+='<p>' + message + '</p>';
	$("#flower_popup").html(html);	
	$("#flower_popup").fadeIn("normal");
}
function hideFlowerPopup() {
	$("#flower_popup").oneTime(50, function() {	
		$("#flower_popup").fadeOut("normal"); // css({display: "none"});
	});
}
function stopFlowerHide() {
	$("#flower_popup").stopTime();
}


