<!-- Begin
function SelectCell(cell) {
	if (cell.bgColor != "#f8ad34"){
 	   cell.bgColor = "#EFE8C2";
	}
}

function unSelectCell(cell) {
	if (cell.bgColor != "#f8ad34"){
    	cell.bgColor = "ffffff";
	}
}
function MarkCell(cell) {
	if (cell.bgColor == "#f8ad34"){
    	cell.bgColor = "ffffff";
	} else {
    	cell.bgColor = "#f8ad34";
	}
}

function saveDate(date) {
	if (document.frmcartadd['cart_product_extrainfo[date]'].value.indexOf(date) ==-1 ) {
		document.frmcartadd['cart_product_extrainfo[date]'].value = document.frmcartadd['cart_product_extrainfo[date]'].value + date + ", ";
	} else {
		var str = document.frmcartadd['cart_product_extrainfo[date]'].value;
		var takeoff = date + ', ';
		document.frmcartadd['cart_product_extrainfo[date]'].value = str.replace(takeoff,"");
	}
	
}
function calendar(month,year,specials) {
	var special_days = new Array();
	special_days = specials.split(',');
	var day_of_week = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	var month_of_year = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

	month = month-1;
	var Calendar = new Date();
	var days_per_week = 7;
	var days_per_month = 31;
	var cal_html;

	Calendar.setDate(1);
	Calendar.setMonth(month);
	Calendar.setYear(year);

	var tr_open = '<tr>';
	var tr_close = '</tr>';
	var td_start = '<td style="border:solid #967226; border-width:0px 1px 1px 0px;" align="center" bgcolor="" width="28" class="small">';
	var td_open_txt = '<td align="center" style="background:#967226; color:white;" class="small" width="28">';
	var td_close = '</td>';

	cal_html =  '';
	cal_html += '<table style="" border="0" cellspacing="0" cellpadding="1">' + tr_open;
	cal_html += '<td colspan="' + days_per_week + '" class="small" align="center"><b>';
	cal_html += month_of_year[month]  + '&nbsp;' + year + '</b>' + td_close + tr_close;
	cal_html += tr_open;

	for(index=0; index < days_per_week; index++) {
		cal_html += td_open_txt + day_of_week[index] + td_close;
	}

	cal_html += td_close + tr_close;
	cal_html += tr_open;

	for(index=0; index < Calendar.getDay(); index++) {
		if(index == 0) {
			cal_html += '<td style="border:solid #967226; border-width:0px 1px 1px 0px; border-left:solid #967226 1px;" align="center" bgcolor="" width="28" class="small">' + '&nbsp;' + td_close;
		} else {
			cal_html += td_start + '&nbsp;' + td_close;
		}
	}

	for(index=0; index < days_per_month; index++) {
		if( Calendar.getDate() > index ) {
			week_day =Calendar.getDay();
			var lbord = '';
			if(week_day == 0) {
				lbord = 'border-left:solid #967226 1px;';
				cal_html += tr_open;
			}
			if(week_day != days_per_week) {
				var day  = Calendar.getDate();
				var day_found=0;
				for (i=0; i<special_days.length; i++){
					if(day==special_days[i]){
						day_found = 1;
					} 
				}	
				if(day_found == 1) {
					cal_html += '<td style="cursor:pointer; border:solid #967226; border-width:0px 1px 1px 0px;'+lbord+'" align="center" bgcolor="#ffffff" onmouseover="SelectCell(this);" onmouseout="unSelectCell(this);" onclick="MarkCell(this); saveDate(\'' + month_of_year[month] + ' ' + day + ' - ' + year + '\');" class="small"><b>' + day  + '</b>' + td_close;
				} else {
  					cal_html += td_start + day + td_close;
  				}
			}

		if(week_day == days_per_week)
			cal_html += tr_close;
		}
  		Calendar.setDate(Calendar.getDate()+1);
	}

	while(week_day++ < days_per_week - 1) {
		cal_html += td_start + '&nbsp;' + td_close;
	}




	cal_html += '</td></tr></table><br>';

	
	document.write(cal_html);

}

//  End -->
