var timeOn = null;

function hide(das)
{
	document.getElementById(das).style.display='none';
}

function unhide(das)
{
	document.getElementById(das).style.display='block';
}

function show(das)
{
  if (document.getElementById(das).style.display=='none')
    document.getElementById(das).style.display='';
  else
    document.getElementById(das).style.display='none';
}

// switches the class of an element
function switchClass(das,klasse)
{				
	document.getElementById(das).className=klasse;
}

// checks the form for adding a comment
function checkForm()
{
	var error = false;
	
	// AuthorName
	if (document.addComment.AuthorName.value == "")
	{
		document.getElementById('errorProviderName').innerHTML = "Bitte Namen eingeben!";
		error = true;
	}
	else {
		document.getElementById('errorProviderName').innerHTML = "";
	}
	
	
	// Title
	if (document.addComment.Title.value == "")
	{
		document.getElementById('errorProviderTitle').innerHTML = "Bitte Titel eingeben!";
		error = true;
	}
	else {
		document.getElementById('errorProviderTitle').innerHTML = "";
	}
	
	
	// Text
	if (document.addComment.Text.value == "")
	{
		document.getElementById('errorProviderText').innerHTML = "Bitte Text eingeben!";
		error = true;
	}
	else {
		document.getElementById('errorProviderText').innerHTML = "";
	}
	
	
	// AuthorMail
	if (document.addComment.AuthorMail.value != "" & !validEmail(document.addComment.AuthorMail.value))
	{
		document.getElementById('errorProviderMail').innerHTML = "Bitte nur korrekte E-Mail-Adressen angeben!";
		error = true;
	}
	else
	{
		document.getElementById('errorProviderMail').innerHTML = "";
	}
	
	
	// AuthorWebsite
	if (document.addComment.AuthorWebsite.value != "" & !validWebsite(document.addComment.AuthorWebsite.value))
	{
		document.getElementById('errorProviderWebsite').innerHTML = "Bitte nur korrekte Internet-Adressen angeben!";
		error = true;
	}
	else
	{
		document.getElementById('errorProviderWebsite').innerHTML = "";
	}
	return(!error);
}

function maybeEnableNotifierCheckbox() {
	var EmailBox             = document.addComment.AuthorMail;
	var NotifierCheckboxArea = document.getElementById('NotifyOnResponses');
	var NotifierCheckbox     = document.addComment.NotifyOnResponses;
	if (validEmail(EmailBox.value)) {
		NotifierCheckboxArea.style.display = 'block';
		NotifierCheckboxArea.style.color = 'black';
		NotifierCheckboxArea.style.fontStyle = 'normal';
		NotifierCheckbox.checked = 'checked';
		NotifierCheckbox.disabled = '';
	}
	else {
		NotifierCheckboxArea.style.color = 'grey';
		NotifierCheckboxArea.style.fontStyle = 'italic';
		NotifierCheckbox.checked = '';
		NotifierCheckbox.disabled = 'disabled';
	}
	
}

// validates an email adress
function validEmail(email) {
		var strReg = "^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$";
		var regex = new RegExp(strReg);
		return(regex.test(email));
}

// validates an web adress
function validWebsite(website) {
		var regex = /((ftp|http|https):\/\/)?(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
		return(regex.test(website));
}

function FlashMovie(src, movie, width, height, version, quality, menu, bgcolor, flashvars)
{
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+version+",0,0,0' width='" +width+ "' height='" +height+ "' id='" +movie+ "'>");
	document.write("<param name='movie' value='" +src+ "' />");
	document.write("<param name='FlashVars' value='" +flashvars+ "'>");
	document.write("<param name='quality' value='" +quality+ "' />");
	document.write("<param name='menu' value='" +menu+ "' />");
	document.write("<param name='bgcolor' value='" +bgcolor+ "' />");
	document.write("<embed src='" +src+ "' swLiveConnect='true' menu='" +menu+ "' FlashVars='" +flashvars+ "' quality='" +quality+ "' bgcolor='" +bgcolor+ "' width='" +width+ "' height='" +height+ "' name='" +movie+ "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}

function fillFlashBanner() {
  document.getElementById('FlashBanner').innerHTML = "<object width=\"1000\" height=\"280\">"
    + "  <param name=\"movie\" VALUE=\"img/banner.swf\">"
    + "  <param name=\"quality\" value=\"high\">"
    + "  <param name=\"bgcolor\" value=\"white\">"
    + "  <embed src=\"img/banner.swf\"  style=\"margin-bottom: -2px\" quality=\"high\" menu=\"false\" bgcolor=\"#000000\" width=\"1000\" height=\"280\" swLiveConnect=\"false\" type=\"application/x-shockwave-flash\"></embed>"
    + "</object>";
}

