function show_calendar(str_input,idioma){
	var texto;
	o_input = document.getElementById(str_input);
	var dt_datetime = new Date();
	if(o_input.value != null && o_input.value != ""){
		dt = str2dt(o_input.value);
		if(dt) dt_datetime = dt;
	}
	str_date = dt2dtstr(dt_datetime);
	if (idioma==1)
	  texto="Alquilamos normalmente periodos de 2 semanas, de sábado a sábado. Pueden consultar cualquier otra fecha por email o teléfono, incluso estancias de una semana. Para el mes de Agosto del 2008, los alquileres serán preferentemente del 2/8 al 16/8 o del 16/8 al 30/8, para esas fechas encontrarán la mayor disponibilidad.";
	else if (idioma==2)
	  texto="";
	else if (idioma==3)
	  texto="Nous louons préférentiellement périodes de 2 semaines. Pour l'été de l'année 2.008, les dates préférentielles seront en Août : du 26/7 au 9/8 ou du 2/8 au 16/8 ou du 16/8 au 30/8. Pour ces dates vous trouverez la plus grande disponibilité dans le mois d'Août. Vous pouvez consulter par email ou téléphone tout autre date, aussi séjours d'une semaine.";
	var vWinCal = window.open("", "Seleccione", "width=380,height=275,status=no,resizable=yes,top=200,left=200");
	
	str_buffer = "<html><head><title>Seleccione</title><script src=\"/gestion/ADDatePick/datepick.js\"></script></head><body bgcolor=\"White\" id=\"body\">\n";
	vWinCal.document.write(str_buffer+cal_update(str_input,str_date,str_date)+'<p style="font: 10px Verdana;color: #49577c;">' + texto + '</p></body></html>');
	vWinCal.document.close();
	vWinCal.focus();
}
function cal_rewrite(str_input,str_datetime,str_month){
	document.getElementById('body').innerHTML=cal_update(str_input,str_datetime,str_month);
}
function cal_update(str_input,str_datetime,str_curr_date){
	var arr_months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Augosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
	var week_days = ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = str2dt(str_datetime);
	var dt_curr_date = str2dt(str_curr_date);

	var dt_prev_month = new Date(dt_curr_date);
	dt_prev_month.setMonth(dt_curr_date.getMonth()-1);
	var dt_next_month = new Date(dt_curr_date);
	dt_next_month.setMonth(dt_curr_date.getMonth()+1);
	var dt_firstday = new Date(dt_curr_date);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);

	// print calendar header
	var str_buffer = new String (
		"<table cellspacing=\"0\" border=\"0\" width=\"100%\"><tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:cal_rewrite('"+str_input+"','"+str_datetime+"','"+dt2dtstr(dt_prev_month)+"');\">"+
		"<img src=\"/gestion/ADDatePick/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\" align=\"center\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_curr_date.getMonth()]+" "+dt_curr_date.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:cal_rewrite('"+str_input+"','"+str_datetime+"','"+dt2dtstr(dt_next_month)+"');\">"+
		"<img src=\"/gestion/ADDatePick/next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);

	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\" align=\"center\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	str_buffer += "</tr>\n";
	
	while (dt_current_day.getMonth() == dt_curr_date.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()){
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++){
			if ((dt_current_day.getDate() == dt_datetime.getDate()) && (dt_current_day.getMonth() == dt_datetime.getMonth())){
				str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
			}else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
				str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
			else
				str_buffer += "	<td bgcolor=\"white\" align=\"right\">";
			if (dt_current_day.getMonth() == dt_curr_date.getMonth()){
				str_buffer += "<a href=\"javascript:window.opener.document.getElementById('"+str_input+"').value='"+dt2dtstr(dt_current_day)+"'; window.close();\">";
				str_buffer +="<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate();
				str_buffer +="</font></a>";
			}
			str_buffer +="</td>\n";
			dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		str_buffer += "</tr>\n";
	}
	str_buffer +="</table></tr></td></table>";
	return str_buffer;
}
// datetime parsing and formatting routines. modify them if you wish another datetime format
function str2dt (str_datetime) {
	var re_date = /^(\d+)\-(\d+)\-(\d+)$/;
	if (!re_date.exec(str_datetime))
		return false;
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
}
function dt2dtstr (dt_datetime) {
	var month = dt_datetime.getMonth()+1;
	if (month < 10) month = "0"+month;
	var date = dt_datetime.getDate();
	if (date < 10) date = "0"+date;
	return (""+date+"-"+month+"-"+dt_datetime.getFullYear());
}
