//File: feriehuse-fayence.js with common functions 

//Function to display text in selected language
function ShowText(path) {
  // If no valid language code is set
	if ((lan == undefined) || ((lan != "da") && (lan != "en") && (lan != "de"))) {
  	//Read current language code in frame if any else in search string
    if (parent.lan) {
      lan = parent.lan;
    } else {
      lan = location.search.substr(5,2);
    }
  }
	//Check if this is valid. If not do something about it
	if ((lan != "da") && (lan != "en") && (lan != "de")) {
		//Do something serious here if no valid language code
    //Default to danish
    lan = "da";
//		alert("Du har ikke valgt sprog\n\nLanguage has not been selected\n\nSie haben keine Sprache gewählt");
		//Change location to index.html
//		self.location = path + "index.html";
	} 
  // Set lan in parent frame
  if (parent.lan) {
    parent.lan = lan;
  }
//alert("lan=" + lan);
  // Write style block for selected language class
  document.writeln('\<style type="text/css"\>.' + lan + '{display : block;}\<\/style\>');
}//end ShowText

// Function for showing enlarged image in new window
function enl_image (title,img_scr,wid,hei) {
  // Open new window
  w = open("", 'image', 'dependent=yes,resizable=yes,scrollbars=no,titlebar=yes,status=no,width=' + wid + ',height=' + hei + ',top=20,left=20');
  w.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>" + title + "<\/title>");
  w.document.write("<\/head><body style=\"margin: 0px;  margin-top: 0px;\" bgcolor=\"#FFFFFF\"> <div align=\"center\"> <img src=\"" + img_scr + "\" border=\"0\" alt=\"" + title + "\" title=\"" + title + "\"></div>");
  w.document.write("<\/body><\/html>");
  w.document.close();
} // End function enl_image

  // Function to set background color of iframe object
  function SetColor() {
    var col = location.search.substr(12,6);
    if (col != "") {
      var body_obj = document.getElementById("body");
      body_obj.style.backgroundColor = "#" + col;
    }
  } // End function SetColor
  
//Function to display ALT text or Status text in selected language
function ShowAlt(lan, t_da, t_de, t_en) {
	switch (lan) {
		case "da" :
			return t_da;
			break;
		case "de" :
			return t_de;
			break;
		case "en" :
			return t_en;
			break;
		default : return "";
	}//end switch
}//End ShowAlt

//Function to display Last Update time of page
function ShowLastUpdate(lan) {
	if (lan != "oo") {
		var LangText = ShowAlt(
    lan,
		"Sidst opdateret: ",
		"Zuletzt aktualisiert am: ",
    "Last updated: "
		)
		var a;
		a=new Date(document.lastModified);
		lm_year=a.getYear();
		if (lm_year<1000){ 		//just in case date is delivered with 4 digits
			if (lm_year<70){
			lm_year=2000+lm_year;
			}
			else lm_year=1900+lm_year;
		}								//end workaround
		lm_month=a.getMonth()+1;
		if (lm_month<10){
			lm_month='0'+lm_month;
		}
		lm_day=a.getDate();
		if (lm_day<10){
			lm_day='0'+lm_day;
		}
		document.write('<p align="center" class="' + lan + '"> ' +
			LangText + lm_day+'-'+lm_month+'-'+lm_year + '</p>'
		)
	}//End if
}//End ShowLastUpdate
