
// Validate Email Address


function validateEmail(formName,inputName) {
	
// Validate email address

	var inputObject = document.forms[formName].elements[inputName];
	var atSign = inputObject.value.indexOf('@');
	var dot = inputObject.value.lastIndexOf('.');
	var space = inputObject.value.indexOf(' ');
	var emailLength = inputObject.value.length - 1;

	if ((atSign < 1) || (space != -1) || (dot <= atSign + 1) || (dot == emailLength)) { 
 		alert('Please enter a valid email address');
		inputObject.focus();
		return false;
	}
	return true;
}


//------------------------------------------------------------------------------------------------------


// Validate Password to Submit


function validatepassword(formName,password,passwordconfirm) {

	var inputObject = document.forms[formName].elements[password];
	var first = document.forms[formName].elements[password].value;
	var second = document.forms[formName].elements[passwordconfirm].value;	

	if (first != second) { 
 		alert('Your password did not confirm, please try again');
		document.forms[formName].elements[password].value = "";
		document.forms[formName].elements[passwordconfirm].value = "";
		inputObject.focus();
		return false;
	}
	return true;
}


//------------------------------------------------------------------------------------------------------

// Swap Image



function swapimage(name,image){
		
	document[name].src = "images/" + image;
}


//------------------------------------------------------------------------------------------------------


// Login - Forgot Password


function forgotpass() {
var winTop = (screen.height / 2) - 250;
var winLeft = (screen.width / 2) - 175;
windowFeatures = "width=350, height=180,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=no, status=no";


     window.open('forgotpass.cfm', 'window3',windowFeatures);
}


//------------------------------------------------------------------------------------------------------


// Open Window - No Self Close



function newWindow(file,width,height,window,toolbar,resize,scroll,status){

var wintopval = (height/2) + 50;
var winleftval = (width/2) + 10;
	
var winTop = (screen.height / 2) - wintopval;
var winLeft = (screen.width / 2) - winleftval;

windowFeatures = "width= " + width + ", height= " + height + ",";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";

windowFeatures = windowFeatures + "toolbar= " + toolbar + ", location=no, resizable= " + resize + ", scrollbars= " + scroll + ", status= " + status;

	 msgWindow=open(file, window, windowFeatures);
    if (msgWindow.opener == null) msgWindow.opener = self;
	}


//---------------------------------------------------------------------------------------------------------


// Cert Window


function cert(number) {

var file = "cert_window.cfm?cert=" + number;

var winTop = (screen.height / 2) - 330;
var winLeft = (screen.width / 2) - 380;
windowFeatures = "width=765, height=550,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=yes, status=yes";


     window.open(file,'cert',windowFeatures);
}


//------------------------------------------------------------------------------------------------------



