var ShowHiddenIframe = true;
function ToggleHiddenIframe() {
   HiF = document.getElementById('Hidden-iFrame');
   if (ShowHiddenIframe) {
      HiF.width  = 0;
      HiF.height = 0;
   } else {
      HiF.width  = "100%";
      HiF.height = 500;
   };
   ShowHiddenIframe = !ShowHiddenIframe;
}

function MenuEntry(Text,Link) {
   text ='<tr><td class=menu onmouseover="this.bgColor='
               + "'#FCF918';this.style.cursor='pointer'"
               + '" onmouseout="this.bgColor='
               + "'#A09E8F'"
               + '" id="'
               + Link
               + '" onclick="location.href=\'http://'
               + Host+Lang+Link
               + '/\'" valign="top"><a id="a'
               + Link
               + '" class=ntd href="http://'
               + Host+Lang+Link
               + '/">'
               + Text
               + '</a></td></tr>';
   document.write(text);
};

function MenuIcon(Title,Image,Link) {
   document.write(
        '<a href="'
      + Link
      + '"><img width="15" height="15" border="0" onmouseover="this.style.backgroundColor=\'#FCF918\'"'
      +                                           ' onmouseout="this.style.backgroundColor=\'#A09E8F\'" title="'
      + Title
      + '" src="'
      + URL
      + '/images/Side/'
      + Image
      + '.gif"></a> '
   );
};

function EmptyCell(text1) {
   document.write('<tr><td ondblclick="ToggleHiddenIframe()" class=menuseperator>'+text1+'</td></tr>');
};

function PrintMain() {
	if (document.getElementById != null) {
		var html = '<html><head>';
		if (document.getElementsByTagName != null) {
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0) {
				html += headTags[0].innerHTML;
		   };
		};
		html += '</head><body>';
		html += '<img src="' + URL + '/images/Logos/Current.gif" width="100%"><p>';
		var printReadyElem = document.getElementById("Print");
		if (printReadyElem != null) {
				PrintBody = printReadyElem.innerHTML;
				// strip innerscripts
			   pos = PrintBody.indexOf("<SCRIPT");
			   while (pos >=0) {
				   end  = PrintBody.indexOf("SCRIPT>");
   		      PrintBody = PrintBody.substr(0,pos) + PrintBody.substr(end+7);
				   pos  = PrintBody.indexOf("<SCRIPT");
			   };
			   html += PrintBody;
			   // end of strip
		} else {
			alert("There is no printable part on this page");
			return;
		}		
		html += '</body></html>';
      var iFrame = document.getElementById("Hidden-iFrame");
      var doc = iFrame.contentDocument;
      if (doc == undefined || doc == null)
          doc = iFrame.contentWindow.document;
      doc.open();
      doc.write(html);
      doc.close();
      iFrame.contentWindow.focus();
      iFrame.contentWindow.print();
	};
}

Host = location.hostname;
Path = location.pathname;
Lang = Path.substr(0,4);
if (Lang == '/bar') {
   Host = Host + Path.substr(0,16);
   Path = Path.substr(16);
   Lang = Path.substr(0,4);
};
Dir     = Path.substr(4);
Slash   = Dir.search('/');
MainDir = Dir.substr(0,Slash);
if ((Host == 'home')
 || (Host == '192.168.3.100'))
   URL = 'http://' + Host + '/barra-de-potosi'
else
   URL = 'http://' + Host;

if (Lang == '/es/') {
   Universal    = 'Página Universal';
   Home         = 'Página Principal';
   Up           = 'Un nivo ariba';
   Print        = 'Imprime amistal';
   Animals      = 'Animales';
   Archive      = 'Archivo';
   Background   = 'Antecedentes';
   Environment  = 'Medio ambiente';

   FUQ          = 'FUQ';
   Gallery      = 'Galeria';
   General      = 'Generalidades';
   Hotspot      = 'Hotspot';
   HowToGetHere = 'Cómo llegar';
   Maps         = 'Mapas';
   References   = 'Referencias';
   WebCam       = 'Cámara Web';
   WhatToDo     = 'Que hacer';
   WhenToCome   = 'Cuándo visitar';
   WhereToGo    = 'A dónde ir';
   WhyVisit     = 'Por qué visitar';
   ForSale      = 'En Venta';
   SiteInfo     = 'Info del Sitio';
   OtherSites   = 'Otro Sitios Locales';
   Language     = '&#9658; English';
} else {
   Universal    = 'Universal Page';
   Home         = 'Home Page';
   Up           = 'One level up';
   Print        = 'Print friendly';
   Animals      = 'Animals';
   Archive      = 'Archive';
   Background   = 'Background';
   Environment  = 'Environment';
   ForSale      = 'For Sale';
   FUQ          = 'FUQ';
   Gallery      = 'Gallery';
   General      = 'General';
   Hotspot      = 'Hotspot';
   HowToGetHere = 'How to get here';
   Maps         = 'Maps';
   References   = 'References';
   WebCam       = 'WebCam';
   WhatToDo     = 'What to do';
   WhenToCome   = 'When to come';
   WhereToGo    = 'Where to go';
   WhyVisit     = 'Why visit';
   SiteInfo     = 'Site Info';
   OtherSites   = 'Other Local Sites';
   Language     = '&#9658; Español';
};

   document.write('<tr><td class=menu>');
   MenuIcon(Home,'Home',URL);
   MenuIcon(Up,  'Up',  '..');
   MenuIcon(Print,'Print','javascript:PrintMain()');
   document.write('</td></tr>');
   MenuEntry(Language,'Language');
   EmptyCell('<hr>');

if ( Lang == '/en/' ) {
   MenuEntry(Animals,'Animals');
   MenuEntry(Archive,'Archive');
   MenuEntry(Background,'Background');
   MenuEntry(Environment,'Environment');
   MenuEntry(ForSale,'ForSale');
   MenuEntry(FUQ,'FUQ');
   MenuEntry(Gallery,'Gallery');
   MenuEntry(General,'General');
// MenuEntry(Hotspot,'Hotspot');
   MenuEntry(HowToGetHere,'HowToGetHere');
   MenuEntry(Maps,'Maps');
   MenuEntry(References,'References');
// MenuEntry(WebCam,'WebCam');
   MenuEntry(WhatToDo,'WhatToDo');
   MenuEntry(WhenToCome,'WhenToCome');
   MenuEntry(WhereToGo,'WhereToGo');
   MenuEntry(WhyVisit,'WhyVisit');
   EmptyCell('&nbsp;');
   MenuEntry(SiteInfo,'SiteInfo');
   MenuEntry(OtherSites,'OtherSites');
   NextLang = '/es/';
} else {
   MenuEntry(WhereToGo,'WhereToGo');
   MenuEntry(Animals,'Animals');
   MenuEntry(Background,'Background');
   MenuEntry(Archive,'Archive');
// MenuEntry(WebCam,'WebCam');
   MenuEntry(HowToGetHere,'HowToGetHere');
   MenuEntry(WhenToCome,'WhenToCome');
   MenuEntry(ForSale,'ForSale');
   MenuEntry(FUQ,'FUQ');
   MenuEntry(Gallery,'Gallery');
   MenuEntry(General,'General');
// MenuEntry(Hotspot,'Hotspot');
   MenuEntry(Maps,'Maps');
   MenuEntry(Environment,'Environment');
   MenuEntry(WhyVisit,'WhyVisit');
   MenuEntry(WhatToDo,'WhatToDo');
   MenuEntry(References,'References');
   EmptyCell('&nbsp;');
   MenuEntry(SiteInfo,'SiteInfo');
   MenuEntry(OtherSites,'OtherSites');
   NextLang = '/en/';
};

Href = 'http://'+Host+NextLang+Dir;
document.getElementById('aLanguage').href   = Href;
Language.onclick = Href;

Id = document.getElementById(MainDir);
if (Id) {
   if ((MainDir+'/' == Dir)
    || (MainDir+'/index.html' == Dir)) {
      aId = document.getElementById('a'+MainDir);
      Id.innerHTML = aId.innerHTML;
      Id.onmouseover = '';
      Id.onmouseout  = '';
      Id.style.color = '#A09E8F';
      Id.bgColor     = '#FFFFFF';
      Id.className   = 'menu';
   } else {
      Id.bgColor     = '#FFFFFF';
      Id.style.color = '#A09E8F';
      Id.onmouseout  = function() {this.bgColor='#FFFFFF'};
      Id.onmouseover = function() {this.bgColor='#FCF918'};
   };
};
