
// 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;
}


//------------------------------------------------------------------------------------------------------


// 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;
	}


//---------------------------------------------------------------------------------------------------------


