//////////////////////////////////////////////////////////////////////////////////////////////////
// JAVASCRIPTS.JS - Created by Mike Voss, 2004							//
// This is the JavaScript File for my homepage at www.mikevoss.de.				//
// If you can make use of any of these simple scripts that I utilize to run the site's		//
// neccessary automations, please feel free to copy and paste them as you need them.		//
// If you have any specific questions, I recommend the (German) reference at www.selfhtml.de,	//
// or various other JavaScript references that you can google for.				//	
// Should you have a question about any of the functions below that are not answered in these	//
// references, please email me at m.voss@gmx.net.						//
//////////////////////////////////////////////////////////////////////////////////////////////////

function redirect()
{
      if(navigator.language == "de")
            window.location.href = "deutsch/index.htm";
      else
            window.location.href = "english/index.htm";
}

/*
The above identifies the language that the user's browser is using and redirects him or her to the appropriate
language version of the site. This does however only work with netscape compatible browsers, as the IE is kind
enough to remain totally silent about the "browser.language" object.
*/

function languagechange(language)
{
      var pfadname = window.location.href;
      var dateiname = pfadname.substring(pfadname.lastIndexOf("/") + 1,pfadname.lastIndexOf(".") + 4);
      window.location.href = "../" + language + "/" + dateiname
}

/*
The above extracts the file name from the full pathname by finding the last "/" and the last "m" (as in ".htm") and
reading the string between these two characters, which is the filename I am looking for. The last line then simply
takes the parameter that my webpage has handed to this function and builds the new href for the page to be displayed.
IMPORTANT: To make this work, the directory structure has to be correctly broken down into the language versions of the site!
*/

function bigpicshow(Bild)
{
window.open( Bild.substring(0,Bild.lastIndexOf("tn")) + ".jpg","FullSizeView", "location=no,menubar=no,status=no,dependent=yes");
}

/*
The above function opens a new window with a fullsize view of the thumbnail that has been clicked to evoke this
function. To do so, the src of the thumbnail is taken and changed through the substring method. The tn is removed
and hence the src for the fullsize version of the pic is distilled and used to open a new window with the 
name FullSizeView. In order to work, the thumbnail must have the same src except that it has "tn" at the end.
*/

function CheckForm()
{
if(document.signform.UserName.value == "")
	{
    alert("Please enter a name. \nBitte einen Namen eingeben.");
    document.signform.UserName.focus();
    return false;
    }
if(document.signform.mail.value.indexOf('@') == -1)
	{
    alert("Please enter a valid email address.\nBitte eine gültige Emailadresse eingeben.");
    document.signform.mail.focus();
    return false;
    }
if(document.signform.comment.value == "")
	{
    alert("Please enter a comment.\nBitte einen Kommentar eingeben.");
    document.signform.comment.focus();
    return false;
    }
}

/*
The above function validates the guestbook enter form. It checks if the user has entered a name, comment and a valid email 
address (that contains the character @) and if that condition is not met, alerts the user with an error message. The forms
contents are not posted to the guestbook building script in that case.
*/
