// JavaScript Document
	gBaseUrl = "http://www.wholeblossoms.com/";
var progressBarString = "<div align=\"center\" style=\"background-color:#eeeeee;display:block;width:450px; height:250px;border:1px solid #555555;\"><br /><br /><br /><br /><img src=\"" + gBaseUrl+ "calendar/images/loading.gif\" width=\"75px\" height=\"75px\"><br /><br /><br /></div>";
function hideCalendar(  )
{
	var id="calendarContainer";
	$(id).update("");
	$(id).hide();
	// for hiding the select box in ie 6 and below to fix the z-index problem
	if($("DropColor") != undefined )
	{
		$("DropColor").show();
	}
	if($("DropColor1") != undefined )
	{
		$("DropColor1").show();	
	}
	
}
function showCalendar( month, year, id, imgId )
{
	var img = $(imgId);
	//if($("calendarContainer").innerHTML == "" )
	//{
		$("calendarContainer").show();
		$("calendarContainer").update( progressBarString );	
		var calLeft	= parseInt( img.offsetLeft ) - 380 + img.offsetWidth  + "px";
		//var calTop	= parseInt( img.offsetTop )  - parseInt( img.offsetHeight ) - 250 +  "px";
		var calTop	= parseInt( img.offsetTop )  - parseInt( img.offsetHeight ) - $("calendarContainer").offsetHeight - 10 +  "px";
		$("calendarContainer").setStyle( {"left":calLeft,"top":calTop, "position":"absolute", "width":"450px", "z-index":"30000"} );		
		
	//}
	var webUrl = window.location.href;
	// check that the url is secured 
	if( webUrl.match(/https:/) == null)
	{		
		if ( webUrl.match(/http:\/\/www/) == null )
		{
			gBaseUrl = "http://wholeblossoms.com/";	
		}
		else
		{
			gBaseUrl = "http://www.wholeblossoms.com/";		
		}
	}
	else 
	{
		if ( webUrl.match(/https:\/\/www/) == null)
		{
			gBaseUrl = "https://wholeblossoms.com/";	
		}
		else
		{
			gBaseUrl = "https://www.wholeblossoms.com/";	
		}
	}
	var calendarUrl	= gBaseUrl + "calendar/dateselect.php";
	new Ajax.Request(calendarUrl, {
		  method		: "get"
		, parameters	: {"month":month, "year": year, "datebox":id, "imgid":imgId}
		, onSuccess		: function(response ) {
			$("calendarContainer").update( response.responseText );	
			$("calendarContainer").show();
		}
	});
	// for hiding the select box in ie5 to fix the z-index problem
	if($("DropColor") != undefined )
	{
		$("DropColor").hide();
	}
	if($("DropColor1") != undefined )
	{
		$("DropColor1").hide();	
	}
	
}
function selectDate(day, month, year, id)
{
	if (day < 10)
	{
		day = "0" + day;	
	}
	if (month < 10)
	{
		month = "0" + month;	
	}
	// Y-m-d format
//	$(id).value = year + "-" + month  + "-" + day ;
	$(id).value = month + "-" + day + "-" + year ;
	hideCalendar();
}
function showCalendarForSelectBox( yearMonthString, id , imgId)
{
	if (yearMonthString != "")
	{
		yearMonthArray	= yearMonthString.split(/,/g);
		showCalendar( yearMonthArray[0], yearMonthArray[1], id, imgId ) ;
	}
}
