﻿//define the options and function for opening a new window

var strOptions = 'location=no';

strOptions += ',toolbar=no';

strOptions += ',menubar=no';

strOptions += ',status=no';

strOptions += ',scrollbars=no';

strOptions += ',resizable=no';

strOptions += ',top=40';

strOptions += ',left=300';

strOptions += ',width=640';

strOptions += ',height=920';

function OpenNewWin(strUrl)

	{window.open(strUrl,'newwindow',strOptions);

}


function isValidEmail($emailAddress) {
    //returns True if the email address is a valid email
	$themailAddress = $emailAddress; 
	$openBracket_num = strpos($emailAddress, '<'); 
	$closeBracket_num = strpos($emailAddress, '>'); 
	// check, if mailaddress has an illegal combination of brackets 
	if ( (($openBracket_num !== false) and ( $closeBracket_num === false )) or 
	(($openBracket_num === false) and ( $closeBracket_num !== false)) ) { 
	return false; 
	} 

	// check, if mailaddress has a name (e.g. 'John Smith <john@smith.com>') 
	// if so, get the emailaddress within the brackets for further checks 
	if (( $openBracket_num !== false ) and ( $closeBracket_num !== false )) { 
	$themailAddress = substr( $emailAddress, ++$openBracket_num, $closeBracket_num - $openBracket_num ); 
	} 

	// we now check that there's exactly one @ symbol, and that the lengths are right 
	if (!ereg("[^@]{1,64}@[^@]{1,255}", $themailAddress)) { 
	return false; 
	} 

	// Split it into sections to make life easier 
	$email_array = explode("@", $themailAddress); 
	$local_array = explode(".", $email_array[0]); 
	foreach ($local_array as $entry) { 
	if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $entry)) { 
	return false; 
	} 
	} 

	if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name 
	$domain_array = explode(".", $email_array[1]); 

	if (sizeof($domain_array) < 2) { 
	return false; // Not enough parts to domain 
	} 

	foreach ($domain_array as $entry) { 
	if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $entry)) { 
	return false; 
	} 
	} 
	} 
	return true;
}

function confirmEmail($edEmail,$edConfirmEmail) {
	// compare the two email addresses provided
	if ($edEmail != $edConfirmEmail) {
		return false;
	}
	else
	{
		return true;
	}
}