// JavaScript Document
	gBaseUrl = "http://192.168.0.1/sites/whole_blossom/";
var progressBarString = "<div align=\"center\" style=\"background-color:#eeeeee;display:block;width:450px; height:250px;border:1px solid #673398;\"><br /><br /><br /><br /><img src=\"" + gBaseUrl+ "calendar/images/loading.gif\" width=\"70px\" height=\"25px\"><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 ,pname,l,t,shc)
{
var img = $(imgId);
	

//if($("calendarContainer").innerHTML == "" )
	//{
		$("calendarContainer").show();
		$("calendarContainer").update( progressBarString );	

		var calLeft	= parseInt( img.offsetLeft ) - parseInt(l) + img.offsetWidth  + "px";
		//var calTop	= parseInt( img.offsetTop )  - parseInt( img.offsetHeight ) - 250 +  "px";
		img.offsetTop==286;
		if (shc=='sc'){
		var calTop	= parseInt(t) +  "px";
		}else{
		var calTop	= parseInt( img.offsetTop )  - parseInt( img.offsetHeight ) - $("calendarContainer").offsetHeight + parseInt(t) +  "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://192.168.0.1/sites/whole_blossom/";	
		}
		else
		{
			gBaseUrl = "http://192.168.0.1/sites/whole_blossom/";		
		}
	}
	else 
	{
		if ( webUrl.match(/https:\/\/www/) == null)
		{
			gBaseUrl = "http://192.168.0.1/sites/whole_blossom/";	
		}
		else
		{
			gBaseUrl = "http://192.168.0.1/sites/whole_blossom/";	
		}
	}
	var calendarUrl	= gBaseUrl + "calendar/dateselect.php";
new Ajax.Request(calendarUrl, {
		  method		: "get"
		, parameters	: {"month":month, "year": year, "datebox":id, "imgid":imgId,"pname":pname}
		, 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,pname)
{
	if (yearMonthString != "")
	{
		yearMonthArray	= yearMonthString.split(/,/g);
		showCalendar( yearMonthArray[0], yearMonthArray[1], id, imgId,pname ) ;
	}
}

