// alert('Starting script_txtblocks.js ...');
var x=document.URL.lastIndexOf('/');
/* IE */ if (x==6) x=document.URL.lastIndexOf('\\');
var y=document.URL.lastIndexOf('/',x-1);
/* IE */ if (y==6) y=document.URL.lastIndexOf('\\',x-1);
var lang=document.URL.slice(y+3,y+5);
var urldoc=document.URL.slice(x+1);
var a=new Array;
a[0]  = '0nopage.html';
a[1]  = '1local.html';
a[2]  = '2instal.html';
a[3]  = '3lazer.html';
a[4]  = '4eventos.html';
a[5]  = '5teatro.html';
a[6]  = '6cidade.html';
a[7]  = '7gastro.html';
a[8]  = '8book.html';
a[9]  = '9links.html';
a[10] = '10contacto.html';
// a[11] = '11reveillon.html';
var b = new Array;
if (lang=='pt') {
	b[0]  = 'P&aacute;gina&nbsp;indispon&iacute;vel';
	b[1]  = 'Localiza&ccedil;&atilde;o';
	b[2]  = 'Instala&ccedil;&otilde;es';
	b[3]  = 'Lazer&nbsp;na&nbsp;Quinta';
	b[4]  = 'Eventos';
	b[5]  = 'Teatro';
	b[6]  = 'Anima&ccedil;&atilde;o&nbsp;na&nbsp;cidade';
	b[7]  = 'Gastronomia';
	b[8]  = 'Reservas';
	b[9]  = 'Links';
	b[10] = 'Contacto';
 	b[11] = 'Reveillon 2011 - 2012';
} else {
	b[0]  = 'Page&nbsp;unavailable';
	b[1]  = 'Location';
	b[2]  = 'Lodgings';
	b[3]  = 'At&nbsp;the&nbsp;Farm';
	b[4]  = 'Events';
	b[5]  = 'Theater';
	b[6]  = 'City&nbsp;entertainment';
	b[7]  = 'Gastronomy';
	b[8]  = 'Booking';
	b[9]  = 'Links';
	b[10] = 'Contact';
	b[11] = 'Reveillon 2011 - 2012';
}
var Bidx, Fidx, idx = parseInt(urldoc.slice(0,1));
if (idx==1 && urldoc.slice(1,2)=='0') idx=10;
if (idx==1 && urldoc.slice(1,2)=='1') idx=11;
//alert('var idx = ' + idx);
Bidx = (idx<=1) ? a.length-1 : (idx==6 && lang!='pt') ? 4 : idx-1;
Fidx = (idx>=a.length-1) ? 1 : (idx==4 && lang!='pt') ? 6 : idx+1;

function setBackGround() { // ------------------------------------------------//
	var img_src = (idx==0) ? 'index' : urldoc.slice(0,urldoc.indexOf('.html'));
	document.write("<div id=\"bg_image\"><img src=\"../pics/bg_" + img_src + ".jpg\"");
	document.write("	width=\"100%\" height=\"100%\" alt=\"\"></div>");
}

function topNav() { // -------------------------------------------------------//
	var flaglang = (lang=='en') ? 'pt' : 'en';
	var flagtxt = (lang=='en')
		? 'esta p&aacute;gina em Portugu&ecirc;s'
		: 'this page in English';
	document.write("<div id=\"div_top\">");
	document.write("<table width=\"810\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr>");
	document.write("	<td width=\"210\">");
	if (idx>0) {
		document.write("	<table width=\"192\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin: 8px 9px 0 9px;\"><tr>");
		document.write("			<td width=\"20\"><a");
		if (urldoc.indexOf('mapa')>0) {
			document.write("			href=\"" + a[1] + "\"><img src=\"../pics/nav_back.gif\" width=\"20\" heigth=\"20\"");
			document.write("				alt=\"" + b[1] + "\" title=\"" + b[1] + "\"></a></td>");
		} else {
			document.write("			href=\"" + a[Bidx] + "\"><img src=\"../pics/nav_back.gif\" width=\"20\" heigth=\"20\"");
			document.write("				alt=\"" + b[Bidx] + "\" title=\"" + b[Bidx] + "\"></a></td>");
		}
		document.write("			<td width=\"152\" align=\"center\" valign=\"middle\"><a");
		document.write("				href=\"javascript:void(null);\" onMouseOver=\"showMenu('menu');\"><img");
		document.write("				src=\"../pics/nav_menu.gif\" alt=\"Menu\"></a></td>");
		document.write("			<td width=\"20\"><a href=\"" + a[Fidx] + "\"><img src=\"../pics/nav_fwrd.gif\" width=\"20\" heigth=\"20\"");
		document.write("				alt=\"" + b[Fidx] + "\" title=\"" + b[Fidx] + "\"></a></td>");
		document.write("		</tr></table>");
	}
	document.write("	</td>");
	document.write("	<td width=\"390\" align=\"center\"></td>");
	document.write("	<td width=\"210\" align=\"right\">");
	if (idx==0) document.write("		<a href=\"javascript:history.back()\"")
	else if ((idx==5 || idx==11) && lang=='pt')
		document.write("		<a href=\"../v_" + flaglang + "/0nopage.html\"");
	else document.write("		<a href=\"../v_" + flaglang + "/" + urldoc + "\"");
	document.write("			><img");
	document.write("			id=\"flang\" src=\"../pics/nav_" + flaglang + ".gif\" width=\"30\" height=\"30\"");
	document.write("			title=\"" + flagtxt + "\" alt=\"" + flagtxt + "\"></a></td>");
	document.write("</tr></table>");
	document.write("</div>");
}

function menuTable() { // ----------------------------------------------------//
	if (menuTable.arguments.length==0)
		document.write("<div id=\"menu\" onMouseOver=\"clearTimeout(menuTime);\" onMouseOut=\"hideMenu('menu');\">");
	document.write("<table class=\"menu\" cellSpacing=\"0\" width=\"210\">");
	document.write("	<tr><td class=\"menuH\" colspan=\"3\"></td></tr>");
	document.write("	<tr><td class=\"menuV\" rowspan=\"2\"></td>");
	document.write("		<td style=\"padding: 5px 5px 0 5px;\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>");
	document.write("			<td width=\"20\"><a href=\"" + a[Bidx] + "\"><img");
	document.write("				src=\"../pics/nav_back.gif\" width=\"20\" heigth=\"20\"");
	document.write("				alt=\"" + b[Bidx] + "\" title=\"" + b[Bidx] + "\"></a></td>");
	document.write("			<td width=\"160\" align=\"center\" valign=\"middle\"><img src=\"../pics/nav_menu.gif\" alt=\"Menu\"></a></td>");
	document.write("			<td width=\"20\"><a href=\"" + a[Fidx] + "\"><img");
	document.write("				src=\"../pics/nav_fwrd.gif\" width=\"20\" heigth=\"20\"");
	document.write("				alt=\"" + b[Fidx] + "\" title=\"" + b[Fidx] + "\"></a></td>");
	document.write("		</tr></table></td>");
	document.write("		<td class=\"menuV\" rowspan=\"2\"></td></tr>");
	document.write("	<tr><td class=\"menu\">");
	for(i=1;i<a.length;i++)
		if (lang=='pt' || (i!=5 && i!=11))
			if (i==idx && urldoc.indexOf('mapa')<0) document.write("			<img style=\"vertical-align: middle;\" src=\"../pics/azulejoONb.gif\" alt=\"\">&nbsp;" + b[i] + "<br>");
			else {
				document.write("			<a href=\"" + a[i] + "\"");
				document.write("				onMouseOver=\"SwapOnList(Imenu" + i + ",'../pics/azulejoON.gif')\"");
				if (i==11) {
					document.write("				onMouseOut=\"SwapOnList(Imenu" + i + ",'../pics/azulejoT.gif')\"><img id =\"Imenu" + i + "\"");
					document.write("				style=\"vertical-align: middle;\" src=\"../pics/azulejoT.gif\" alt=\"\" >&nbsp;" + b[i] + "</a><br>");
				}
				else {
					document.write("				onMouseOut=\"SwapOnList(Imenu" + i + ",'../pics/azulejoOFF.gif')\"><img id =\"Imenu" + i + "\"");
					document.write("				style=\"vertical-align: middle;\" src=\"../pics/azulejoOFF.gif\" alt=\"\" >&nbsp;" + b[i] + "</a><br>");
				}
			}
	document.write("	</td></tr>");
	document.write("	<tr><td class=\"menuH\" colspan=\"3\"></td></tr>");
	document.write("</table>");
	if (menuTable.arguments.length==0)
		document.write("</div>");
}

function techInfo() { // -----------------------------------------------------//
	var p = (techInfo.arguments.length>0) ? '' : '../';
	document.write("<div id=\"div_bottom\">");
	document.write("<table width=\"790\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"");
	document.write("	style=\"font-size:8pt;\"><tr>");
	document.write("	<td align=\"left\" valign=\"top\"><a");
	document.write("		href=\"http://validator.w3.org/check/referer\"><img");
	document.write("		src=\"" + p + "pics/W3C_HTML401_1_gold.png\" style=\"width:80px;height:15px\"");
	document.write("		title=\"Valid HTML 4.01!\" alt=\"Valid HTML 4.01!\"></a></td>");
/*
	document.write("		src=\"" + p + "pics/0.gif\" alt=\"\" width=\"5\" height=\"0\"><a");
	document.write("		href=\"http://jigsaw.w3.org/css-validator/validator?uri=http://www.moinhossaofilipe.com/style.css&profile=css3&usermedium=all&warning=1&lang="+lang+"\"><img");
	document.write("		src=\"" + p + "pics/W3C_CSS_1_gold.png\" style=\"width:80px;height:15px\"");
	document.write("		title=\"Valid CSS!\" alt=\"Valid CSS!\"></a></td>");
	*/
	document.write("	<td align=\"center\" valign=\"top\"><a");
	document.write("		href=\"mailto:tao-webdesign@clix.pt?subject=www.MoinhosSaoFilipe.com\"");
	document.write("		onMouseOver=\"author.src='" + p + "pics/authorON.png';\"");
	document.write("		onMouseOut=\"author.src='" + p + "pics/authorOFF.png';\"><img class=\"beige\" id=\"author\"");
	document.write("		src=\"" + p + "pics/authorOFF.png\" style=\"width:144px;height:14px\" alt=\"&copy;2012 tao - webmaster\"></a></td>");
	document.write("	<td align=\"right\" valign=\"top\"><img");
	document.write("		src=\"" + p + "pics/0.gif\" alt=\"\" style=\"width:80px;height:15px\"></td>");
	document.write("</tr></table>");
	document.write("</div>");
}

function header() { // -------------------------------------------------------//
	var pictxt,picurl,subtitle = '';
	if (lang=='pt') {
		pictxt = 'Clique para voltar &agrave; entrada da Quinta dos Moinhos de S. Filipe';
		picurl = '';
	} else {
		pictxt = 'Click to return to the entrance of Quinta dos Moinhos de S. Filipe';
		picurl = '_en';
		}
//	if (idx==5 && urldoc.slice(7,8)!='.') subtitle = ' - '+urldoc.slice(7,8);
	if (urldoc.indexOf('mapa')>0) subtitle = (lang=='pt') ? ' - Mapa' : ' - Map';
	document.write("<table cellspacing=\"0\" cellpadding=\"0\" width=\"810\"><tr>");
	document.write("	<td width=\"655\"><table class=\"titleT\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>");
	document.write("			<td class=\"titleV\"></td>");
	document.write("			<td class=\"titleH\" align=\"center\" width=\"50\"><img src=\"../pics/azulejoOFF.gif\" alt=\"\"></td>");
	document.write("			<td class=\"titleH\" align=\"left\">" + b[idx] + subtitle + "</td>");
	document.write("		</tr></table></td>");
	document.write("	<td width=\"120\"><a href=\"../index" + picurl + ".html\" target=\"_top\"><img");
	document.write("		src=\"../pics/logo.png\" width=\"125\" height=\"100\"");
	document.write("		title=\"" + pictxt + "\"");
	document.write("		alt=\"" + pictxt + "\"></a></td>");
	document.write("	<td width=\"30\"><table class=\"titleT\" cellSpacing=\"0\" width=\"100%\">");
	document.write("			<tr><td width=\"25\"></td><td class=\"titleV\"></td></tr>");
	document.write("		</table></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("	<td colspan=\"3\"><img src=\"../pics/0.gif\" height=\"20\" alt=\"\"></td>");
	document.write("</tr></table>");
}

function menuTeatro() { // ---------------------------------------------------//
	var c = new Array, tidx = (urldoc.slice(7,8)== '.') ? 0 : parseInt(urldoc.slice(7,8));
	c[0]  = 'Contacto';
	c[1]  = 'Teatro de fantoches';
	c[2]  = 'Teatro';
	c[3]  = 'Hist&oacute;ria interactiva';
	c[4]  = 'Ca&ccedil;a ao Tesouro,<br>Pinturas faciais, Extras';
	c[5]  = 'Hist&oacute;ria / dan&ccedil;a interactiva';
	c[6]  = 'Jogo I';
	c[7]  = 'Jogo II';
	c[8]  = 'Concurso de imita&ccedil;&atilde;o';
	c[9] = 'Ca&ccedil;a ao Tesouro,<br>Pinturas faciais';
	document.write("<table class=\"menu\" cellSpacing=\"0\" width=\"225\">");
	if (menuTeatro.arguments.length>0) {
		document.write("	<tr><td class=\"menuV\" rowspan=\"3\"></td>");
		document.write("		<td class=\"menuH\" colspan=\"2\"></td></tr>");
	}
	document.write("	<tr>");
	document.write("		<td class=\"menu\">");
	document.write("			<ul class=\"menuT\" start=\"0\">");
	if (tidx==0) document.write("				<li><span class=\"light\">" + c[0] + "</span>");
	else document.write("				<li><a href=\"5teatro.html\">" + c[0] + "</a>");
	document.write("			</ul>");
	document.write("			<span class=\"brick\">Programas dos 0 aos 6 anos</span>");
	document.write("			<ul class=\"menuT\" start=\"1\">");
	for(i=1;i<5;i++) {
		if (i==tidx) document.write("				<li><span class=\"light\">" + c[i] + "</span>");
		else {
			document.write("				<li><a href=\"5teatro" + i + ".html\">");
			document.write("					<span class=\"thin\">" + c[i] + "</span></a>");
		}
	}
	document.write("			</ul>");
	document.write("			<span class=\"brick\">Programas dos 7 aos 12 anos</span>");
	document.write("			<ul class=\"menuT\" start=\"5\">");
	for(i=5;i<c.length;i++) {
		if (i==tidx) document.write("				<li><span class=\"light\">" + c[i] + "</span>");
		else {
			document.write("				<li><a href=\"5teatro" + i + ".html\">");
			document.write("					<span class=\"thin\">" + c[i] + "</span></a>");
		}
	}
	document.write("			</ul>");
	document.write("		<td class=\"menuV\"></td>");
	document.write("	</tr>");
	document.write("	<tr><td class=\"menuH\" colspan=\"2\"></td></tr>");
	document.write("</table>");
}

function booking() {
	var DD=new Date(), YYYY=DD.getFullYear(), MM=DD.getMonth()+1, DD=DD.getDate();
	var i,j,k,sel,DDn,MMn;
	var months = new Array;
	if (lang=='pt') {
		chkI = "Data de check-in";
		chkO = "Data de check-out";
		chkB = "Ver disponibilidade";
		chkT = "abre numa nova janela";
		months[1] = 'Janeiro';
		months[2] = 'Fevereiro';
		months[3] = 'Mar&ccedil;o';
		months[4] = 'Abril';
		months[5] = 'Maio';
		months[6] = 'Junho';
		months[7] = 'Julho';
		months[8] = 'Agosto';
		months[9] = 'Setembro';
		months[10] = 'Outubro';
		months[11] = 'Novembro';
		months[12] = 'Dezembro';
	} else {
		chkI = "Check-in date";
		chkO = "Check-out date";
		chkB = "Check availability";
		chkT = "opens in a new window";
		months[1] = 'January';
		months[2] = 'February';
		months[3] = 'March';
		months[4] = 'April';
		months[5] = 'May';
		months[6] = 'June';
		months[7] = 'July';
		months[8] = 'August';
		months[9] = 'September';
		months[10] = 'October';
		months[11] = 'November';
		months[12] = 'December';
	}
	if (MM == 4 || MM == 6 || MM == 9 || MM == 11) k=30;
	else if (MM == 2) k = (YYYY%4 == 0) ? 29 : 28;
	else k=31;
	DDn = (DD<k) ? DD+1 : 1;
	MMn = (DDn>1) ? MM : (MM==12) ? 1 : MM+1;
	document.write("<form id=\"b_availFrm\" class=\"b_availForm\" action=\"https://secure.booking.com/book.html\"");
	document.write("	method=\"get\" target=\"_blank\">");
	document.write("<input name=\"aid\" value=\"330843\" type=\"hidden\">");
	document.write("<input name=\"hotel_id\" value=\"40773\" type=\"hidden\">");
	document.write("<input name=\"lang\" value=\"" + lang + "\" type=\"hidden\">");
	document.write("<input name=\"pb\" value=\"\" type=\"hidden\">");
	document.write("<input name=\"stage\" value=\"0\" type=\"hidden\">");
	document.write("<input name=\"hostname\" value=\"www.booking.com\" type=\"hidden\">");
	document.write("<span class=\"light\">" +chkI+ "</span><br>");
	document.write("<select id=\"b_checkin_day\" name=\"checkin_monthday\">");
	for(i=1;i<=31;i++) {
		sel = (i==DD) ? ' selected="selected"' : '';
		document.write("<option value=\"" +i+ "\" + " +sel+ ">&nbsp;" +i+ "&nbsp;</option>");
	}
	document.write("</select>");
	document.write("<select id=\"b_checkin_month\" name=\"checkin_year_month\">");
	document.write("<option value=\"" +YYYY+ "-" +MM+ "\" selected=\"selected\">&nbsp;" +months[MM]+ " " +YYYY+ "&nbsp;</option>");
	for(i=1;i<12;i++) {
		j = (MM+i>12) ? MM+i-12 : MM+i;
		k = (j<MM) ? YYYY+1 : YYYY;
		document.write("<option value=\"" +k+ "-" +j+ "\">&nbsp;"+months[j]+ " " +k+ "&nbsp;</option>");
	}
	document.write("</select><br><br>");
	document.write("<span class=\"light\">" +chkO+ "</span><br>");
	document.write("<select id=\"b_checkout_day\" name=\"checkout_monthday\">");
	 for(i=1;i<=31;i++) {
		sel = (i==DDn) ? ' selected="selected"' : '';
		document.write("<option value=\"" +i+ "\" + " +sel+ ">&nbsp;" +i+ "&nbsp;</option>");
	}
	document.write("</select>");
	document.write("<select id=\"b_checkout_month\" name=\"checkout_year_month\">");
	for(i=0;i<12;i++) {
		j = (MM+i>12) ? MM+i-12 : MM+i;
		k = (j<MM) ? YYYY+1 : YYYY;
		sel = (j==MMn) ? ' selected="selected"' : '';
		document.write("<option value=\"" +k+ "-" +j+ "\"" +sel+ ">&nbsp;"+months[j]+ " " +k+ "&nbsp;</option>");
	}
	document.write("</select><br><br><p align=\"right\">");
	document.write("<input type=\"submit\" value=\"" +chkB+ "\"");
	document.write("	style=\"width:140px;\" title=\"" +chkT+ "\">");
	document.write("</p></form>");
}

