/**
 * @author rgaumond
 */
var the_calendar;
var cal_on = false;
function showcalendars(the_date_field){
       var options = Object.extend({
            titleformat:'mmmm yyyy',
            closebutton:'<img src="js/calendar/styles/images/close.gif" />',
            dayheadlength:2,
            prevbutton: '<img src="js/calendar/styles/images/prev.gif" />',
            nextbutton: '<img src="js/calendar/styles/images/next.gif" />',
            yearnext: '<img src="js/calendar/styles/images/nexty.gif" />',
            yearprev: '<img src="js/calendar/styles/images/prevy.gif" />',
            weekdaystart:0,
            tabular: true,
            planner: false
        });
		
		var updateyear = function(d){ $(the_date_field).value = d.format('yyyy-MM-dd'); };	
        the_calendar = new scal('samplecal', updateyear, options);
		place_calendar($(the_date_field));
    }
	
	
function toggle_me(the_date_field)
{
	if (!cal_on) {
		showcalendars(the_date_field);
		cal_on=true;
	}
	else 
		return false;
}

function place_calendar(the_date_field)
{
	var the_pos = Element.cumulativeOffset(the_date_field);
	$("samplecal").style.left=the_pos.left-89;
	$("samplecal").style.top=the_pos.top-header.getHeight()-35;
}
