﻿	function popitup(url) 
	{
		newwindow=window.open(url,'name','height=350,width=270');
		if (window.focus) 
		{
			newwindow.focus()
		}
		return false;
	}
	
	function clickIE() 
	{ 
		if (document.all) {return false} 
	} 
	function clickNS(e) 
	{ 
		if (document.layers || (document.getElementById && !document.all)) 
		{ 
			if (e.which==2 || e.which==3) {return false} 
		} 
	} 
	if (document.layers) 
	{ 
		document.captureEvents(Event.MOUSEDOWN); 
		document.onmousedown=clickNS; 
				
	} 
	else 
	{ 
		document.onmouseup=clickNS; 
		document.oncontextmenu=clickIE; 
	}
document.oncontextmenu = new Function("return false");


function ValidatePassword(newPasswordCtrl, oldPasswordCtrl, confirmNewPasswordCtrl, userName) {

	var password = document.getElementById(newPasswordCtrl);
	var oldPassword = document.getElementById(oldPasswordCtrl);
	var confirmPassword = document.getElementById(confirmNewPasswordCtrl);

	var regex;
	
	if (oldPassword.value.length <= 0) {        
		alert("Please enter old password.");
		ResetForm();
		oldPassword.focus();		
		return false;
	}
	

	if (password.value.length < 8 || password.value.length > 12) {
		alert("Password should be minimum 8 and maximum 12 characters long.");
		ResetForm();
		oldPassword.focus();
		return false;
}

regex = /[0-9]/;

if (!regex.test(password.value)) {
	alert("Password should contain atleast one number.");
	ResetForm();
	oldPassword.focus();
	return false;
}

regex = /[A-Za-z]/;

if (!regex.test(password.value)) {
    alert("Password should contain atleast one alphabet.");
    ResetForm();
    oldPassword.focus();
    return false;
}

if (password.value = userName) {
	alert("Password should not be same like your user name.");
	ResetForm();
	oldPassword.focus();
	return false;
}
if (password.value != confirmPassword.value) {
	alert("New password and Confirm new password value should be same.");
	ResetForm();
	oldPassword.focus();
	return false;
}


return true;
}

function ResetForm() {
	document.forms[0].reset();
}
