
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function validate_registration(item)
{
	
	var $e_mail;
	var $username;
	var $password1;
	var $password2;
	var $response;
	var $errors;

	$e_mail=item.email.value;
	$username=item.firstname.value;
	$password1=item.password1.value;
	$password2=item.password2.value;

	$response="There are errors on the form: \n";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\n- Ee-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\n- E-mail address invalid";
		$errors+=1;
	}

//	if (isEmpty($username) )
//	{

//		if ($errors!=0)
//		{
//			$response+=", ";
//		}

//		$response+="\n- Username not entered";
//		$errors+=1;
//	}

	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}

	
	
	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}


function validate_password_change(item)
{
	var $password1;
	var $password2;
	var $response;
	var $errors;

	$password1=item.newpassword1.value;
	$password2=item.newpassword2.value;

	$response="There are errors on the form: \n";
	$errors=0;


	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}


	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}



function validate_mail_form(item)
{
	var $e_mail;
	var $title;
	var $message;
	var $response;
	var $errors;

	$e_mail=item.messagefrom.value;
	$title=item.messagetitle.value;
	$message=item.message.value;

	$response="Errors:- ";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\nReturn e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\nReturn e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($title) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nMessage title not entered";
		$errors+=1;
	}

	if (isEmpty($message) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nBody of message not entered";
		$errors+=1;
	}

	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}

}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isEmail (s)
{   
   
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)

    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

    else 

return true;
}

function OpenWindow_Land(im, name)
{
features="";
features+="width=500, ";
features+="height=450, ";
features+="toolbars=no, ";
features+="resizable=no, ";
features+="location=no, ";
features+="directories=no, ";
features+="status=no, ";
features+="menubar=no, ";
features+="scrollbars=no, ";
features+="left=50, ";
features+="top=50";

file=im+"?filename="+name;
window.open(file, '', features);
//win.focus();

}

function OpenWindow_Land_(im, name)
{
	
features="";
features+="width=400, ";
features+="height=120, ";
features+="toolbars=no, ";
features+="resizable=no, ";
features+="location=no, ";
features+="directories=no, ";
features+="status=no, ";
features+="menubar=no, ";
features+="scrollbars=no, ";
features+="left=50, ";
features+="top=50";

file = im+"?filename="+name;

window.open(file,'', features);
//win.focus();

}

function OpenWindow_Land_v(im, name)
{
features="";
features+="width=580, ";
features+="height=465, ";
features+="toolbars=no, ";
features+="resizable=no, ";
features+="location=no, ";
features+="directories=no, ";
features+="status=no, ";
features+="menubar=no, ";
features+="scrollbars=no, ";
features+="left=50, ";
features+="top=50";

file=im+"?filename="+name;
window.open(file, '', features);
//win.focus();

}