
/*==================================================*
 $Id: verifynotify.js,v 1.1 2003/09/18 02:48:36 pat Exp $
 Copyright 2003 Patrick Fitzgerald
 http://www.barelyfitz.com/webdesign/articles/verify-notify/

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *==================================================*/
 
 	function emailverifyrequest(field1, field2, result_id_1, match_html, nomatch_html) {

	this.field1 = field1;
	this.field2 = field2;
	this.result_id_1 = result_id_1;
	this.match_html = match_html;
	this.nomatch_html = nomatch_html;
 
	this.check = function() 
		{
		
			// Make sure we don't cause an error
			// for browsers that do not support getElementById
			if (!this.result_id_1) { return false; }
			if (!document.getElementById){ return false; }
			r_1 = document.getElementById(this.result_id_1);
			if (!r_1){ return false; }
			
			if (this.field1.value != "" && this.field1.value == this.field2.value) {
				r_1.innerHTML = this.match_html;
			} else {
				r_1.innerHTML = this.nomatch_html;
			}
			
			if (this.field1.value != "" && this.field1.value == this.field2.value) {
				r_1.innerHTML = this.match_html;
				document.request_form.btnsubmit.disabled = false; 
				document.request_form.btnsubmit2.disabled = false; 
			} else {
				r_1.innerHTML = this.nomatch_html;
				document.request_form.btnsubmit.disabled = true; 
				document.request_form.btnsubmit2.disabled = true; 
			}
			
		}
	}
 
	function emailverifynotify(field1, field2, result_id_1, match_html, nomatch_html) {

	this.field1 = field1;
	this.field2 = field2;
	this.result_id_1 = result_id_1;
	this.match_html = match_html;
	this.nomatch_html = nomatch_html;
 
	this.check = function() 
		{
		
			// Make sure we don't cause an error
			// for browsers that do not support getElementById
			if (!this.result_id_1) { return false; }
			if (!document.getElementById){ return false; }
			r_1 = document.getElementById(this.result_id_1);
			if (!r_1){ return false; }
			
			if (this.field1.value != "" && this.field1.value == this.field2.value) {
				r_1.innerHTML = this.match_html;
			} else {
				r_1.innerHTML = this.nomatch_html;
			}
		}
	}

	function passwordverifynotify(field1, field2, result_id_1, result_id_2, match_html, nomatch_html, strength_html, nostrength_html) {

	this.field1 = field1;
	this.field2 = field2;
	this.result_id_1 = result_id_1;
	this.result_id_2 = result_id_2;
	this.match_html = match_html;
	this.nomatch_html = nomatch_html;
	this.strength_html = strength_html;
	this.nostrength_html = nostrength_html;
 
	var regex_password = /(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{5,25})$/;

	this.check = function() 
		{
		
			// Make sure we don't cause an error
			// for browsers that do not support getElementById
			if (!this.result_id_1) { return false; }
			if (!document.getElementById){ return false; }
			r_1 = document.getElementById(this.result_id_1);
			if (!r_1){ return false; }
			
			if (!this.result_id_2) { return false; }
			if (!document.getElementById){ return false; }
			r_2 = document.getElementById(this.result_id_2);
			if (!r_2){ return false; }
			
			if (!regex_password.test(this.field1.value)) {
				r_2.innerHTML = this.nostrength_html;
				document.password_form.btnsubmit.disabled = true; 
				document.password_form.btnsubmit2.disabled = true; 
			} else {
				r_2.innerHTML = this.strength_html;
				document.password_form.btnsubmit.disabled = false;
				document.password_form.btnsubmit2.disabled = false;
			}   
			
			if (this.field1.value != "" && this.field1.value == this.field2.value) {
				r_1.innerHTML = this.match_html;
				document.password_form.btnsubmit.disabled = false;
				document.password_form.btnsubmit2.disabled = false;  
			} else {
				r_1.innerHTML = this.nomatch_html;
				document.password_form.btnsubmit.disabled = true; 
				document.password_form.btnsubmit2.disabled = true; 
			}
		}
	}
	
	function outliner () {
		oMe = window.event.srcElement
		//get child element
		var child = document.all[event.srcElement.getAttribute("child",false)];
		//if child element exists, expand or collapse it.
		if (null != child)
			child.className = child.className == "collapsed" ? "expanded" : "collapsed";
	}

	function changepic() {
		uMe = window.event.srcElement;
		var check = uMe.src.toLowerCase();
		if (check.lastIndexOf("plus.gif") != -1)
			{uMe.src = "../../images/Minus.gif"}
		else
			{uMe.src = "../../images/Plus.gif"}
	}

	function modelesswin(url,mwidth,mheight,mtype)
	{
		if (document.all&&window.print)
		{
			if (mtype==1)
				{
					eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
				}
			else
				{
					eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=0,scrollbars=1")')
				}
		}			
		else
			eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
	}
	

	function checkCheckBox(f)
	{
		if (f.agree.checked == false )
		{
			alert("Please check the 'I Accept' checkbox for the Terms and Conditions to continue.");
			return false;
		}
		else
			return true;
		}

	var newwindow = '';
	
	function openHelp(url)
	{
		if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
		else
		{
			newwindow=window.open(url,'help','height=600,width=800 scrollbars=1');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;
	}
	
	function openExam(url)
	{
		if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
		else
		{
			newwindow=window.open(url,'exam','height=600,width=800, scrollbars=1');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;
	}
	
	function openReceipt(url)
	{
		if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
		else
		{
			newwindow=window.open(url,'receipt','height=600,width=800, scrollbars=1');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;
	}
	
	function openCertificate(url)
	{
		if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
		else
		{
			newwindow=window.open(url,'cert','height=600,width=800, scrollbars=1');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;
	}
	
	function openPrint(url)
	{
		if (!newwindow.closed && newwindow.location)
		{
			newwindow.location.href = url;
		}
		else
		{
			newwindow=window.open(url,'print','height=600,width=800, scrollbars=1');
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;
	}


