var updates = 0;

window.onbeforeunload = function() {return checkupdates()};

// window.onload = function() {initAll(); initForms()};

function validForm() {
	var ok = false;
	updates = 0;
	ok = email_valid();
	if (ok == true) ok = cell_valid();
	if (ok == true) ok = yearofbirth_valid();
	return ok;
}

function update() {
	result = validForm();
	if (result) {
		document.f3.submit();
	}
}

function renewal() {
}

function initAll() {

	// alert("Check Running InitAll()");
			
	var inpTags = document.getElementsByTagName('input');
		
	for (var i=0; i<inpTags.length; i++) {
		if (inpTags[i].className != "skip") {
			if (inpTags[i].getAttribute("type") == "text") {
			
				inpTags[i].onfocus = function() { hlight(this) };
				if (inpTags[i].onblur == null) {
					inpTags[i].onblur = function() { wlight(this) };
				}
				else {
					alert("Already Defined ..." + inpTags[i].name );
					var oldFunc = inpTags[i].onblur;
					inpTags[i].onblur = function()
					{
						wlight(this);
						if (typeof (oldFunc == "function")) {
							oldFunc();
						}
					}
				}
			}
		}
		// don't monitor data changes if class = xoff  ...
		if (inpTags[i].className != "xoff") { 
			inpTags[i].onchange = function() { updates++ };
		}
	} 

	inpTags = document.getElementsByTagName('select');
	
	for (var i=0; i<inpTags.length; i++) {
		// if (inpTags[i].className == "udata") {
			// alert("Checkfield: " + inpTags[i].name);
			inpTags[i].onfocus = function() { hlight(this) };
			inpTags[i].onblur = function() { wlight(this) };
			inpTags[i].onchange = function() { updates++ };
		// }
	}

	return true;
}

function checkupdates() {
	// alert("Updates : " + updates);
	if (updates > 0) {
		return ("Data has been changed and not updated ......");
	}
	// else
	//	return (null);
}

function yearofbirth_valid() {
	// alert("Validate Year of Birth");
	result = true;	
	return (result)
}


