﻿
var d = document;        

/*Email*/
function checkAt(email) {
  if (email.indexOf('@') == -1 || email.indexOf('.') < 3 || email.length < 5) { alert('This does not appear to be a valid e-mail address.  Please check it and try again.'); return false; }
  else return true;
}
 

/*Bookmark page*/ 
function bookmarkPage(){
  if(navigator.appVersion.indexOf("Safari") != -1) alert("Press Command-D to bookmark this page");
  else if(navigator.userAgent.indexOf("Opera/7")!=-1) alert("Press Control-T to bookmark this page");
  else if(navigator.userAgent.indexOf("Opera/8")!=-1) alert("Press Control-T to bookmark this page");
  else if(navigator.userAgent.indexOf("Opera/9")!=-1) alert("Press Control-D to bookmark this page");
  else if(navigator.userAgent.indexOf("Konqueror")!=-1) alert("Press Control-B to bookmark this page");
  else if(document.all) external.AddFavorite(document.location, document.title);
  else alert("Press Control-D to bookmark this page");
}

/*Print page*/
function printPage(){
  if(window.print) window.print();
  else printMsg()
}

/*Print*/
function printMsg(){
  if(navigator.appVersion.indexOf("Mac") != -1)alert("To print this page press Command-P.") 
  else alert("To print this page press Control-P.")
}

/*Email Page*/

function emailPage() {

  if(navigator.appVersion.indexOf("Safari") != -1) alert("Press Command-I to e-mail this page");
  else {

  body = document.getElementById("wrapper") || document.body;
  emailbox = document.createElement("FORM");
  emailbox.id = "emailMsg";
  emailshadow = document.createElement("DIV");
  emailshadow.id = "emailMsgShadow";

  h5 = document.createElement("H5");
  h5.appendChild(document.createTextNode("Email Page Link"));

  p = document.createElement("P");
  title = document.title.split(" - Weerstation Nijverdal"); 
  text = "Send the link for \u201C"+title[0]+"\u201D to the following email address:";
  p.appendChild(document.createTextNode(text));

  inputaddress = document.createElement("INPUT");
  inputaddress.id = "emailThis";
  inputaddress.className = "field";
  inputaddress.setAttribute("size","14");
  if(navigator.userAgent.toLowerCase().indexOf("mac") == -1) inputaddress.setAttribute("type","text"); /* MacIE5 no like */

  sendbutton = document.createElement("BUTTON");
  sendbutton.id = "emailSend";
  if(navigator.userAgent.toLowerCase().indexOf("msie") == -1) sendbutton.setAttribute("value","send");  /* WinIE applies both text and value */
  sendbutton.appendChild(document.createTextNode("send"));
  if(navigator.userAgent.toLowerCase().indexOf("mac") == -1) sendbutton.setAttribute("type","submit"); /* MacIE5 no like */
  sendbutton.onclick = emailThisPage;
  
  cancelbutton = document.createElement("BUTTON");
  cancelbutton.id = "emailCancel";
  if(navigator.userAgent.toLowerCase().indexOf("msie") == -1) cancelbutton.setAttribute("value","cancel");  /* WinIE applies both text and value */
  cancelbutton.appendChild(document.createTextNode("cancel"));
  if(navigator.userAgent.toLowerCase().indexOf("mac") == -1) cancelbutton.setAttribute("type","submit"); /* MacIE5 no like */
  cancelbutton.onclick = emailMsgClose;
  
  emailbox.appendChild(h5);
  emailbox.appendChild(p);
  emailbox.appendChild(inputaddress);
  emailbox.appendChild(sendbutton);
  emailbox.appendChild(cancelbutton);
  body.appendChild(emailbox);
  body.appendChild(emailshadow);
  
  inputaddress.focus();
  
  }

}

function emailMsgClose(){
  body = document.getElementById("wrapper") || document.body;
  body.removeChild(document.getElementById("emailMsg"))
  body.removeChild(document.getElementById("emailMsgShadow"))
  return false;
}

function emailThisPage(){
  title = document.title.split(" - Weerstation Nijverdal.com"); 
  email = document.getElementById("emailMsg").emailThis.value;
  if(checkAt(email)){
    var the_url = "http://"+location.host+location.pathname;
    window.location = "mailto:"+email+"?subject=Interesting page from the Weerstation Nijverdal web site&body=Read Weerstation Nijverdal.com's \""+title[0]+"\" at <"+the_url+">";
    email = "JoostBruls@hotmail.com";
    emailMsgClose()
  }
  else return false;
}


