function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// setup a controlled popup window
function screenCap(url, screenCap, options){
	// if you didn't give a location to open, just skip out using 'return'
	if(!url) return;
	var myscreenCap;
	// setup a place to save a list of opened windows
	if(!arguments.callee.popups) arguments.callee.popups = {};
	// if you previously opened this window-name re-use the window
	if(screenCap && arguments.callee.popups[screenCap]) myscreenCap = arguments.callee.popups[screenCap];
	// popup window chrome details: 0 is same as no/false, 1 is same as yes/true
	var details = (typeof options == 'string' && /=/.test(options))? options : 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+(screen.availWidth)+',height='+(screen.availHeight)+',top=0,left=0';
	// create the popup, or redirect an existing one to this place
	if(typeof myscreenCap != 'undefined' && !myscreenCap.closed) myscreenCap.location = url;
	else myscreenCap = window.open(url,(typeof screenCap == 'string' ? screenCap :''),details);
	if(typeof screenCap != 'undefined' && !arguments.callee.popups[screenCap]) arguments.callee.popups[screenCap] = myscreenCap;
	// bring the popup window into the foreground
	if(myscreenCap && myscreenCap.focus) myscreenCap.focus();
	myscreenCap.moveTo(15,145);
};

var type = "IE";	//Variable used to hold the browser name
BrowserSniffer();
function validateSendFeedback() {
    var formName = document.SendFeedback;
	if (validateEmail(formName.email.value) == false) {
		alert("Email is empty/invalid. Please provide a valid email.");		
		return false;
	} else {
		if (validateEmpty(formName.feedback.value) == false) {
			alert("Your comments are empty. Please provide comments.");			
			return false;
		} else {
			return true;
		}
	}
}

//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

function ChangeMessage(id, str) {
	if (type=="IE") {
		document.all[id].innerHTML = str;
	}
	if (type=="NN") { 
		document.layers[id].document.open();
		document.layers[id].document.write(str);
		document.layers[id].document.close();
	}
	if (type=="MO" || type=="OP") {
		document.getElementById(id).innerHTML = str;
	}
}

function ShowIt(current) {			
	if (type=="IE") {
		ms=document.all[current];
		ms.style.visibility = "visible";				
	}
	if (type=="NN") {
		ms=document.layers[current];
		ms.visibility = "visible";				
	}
	if (type=="MO" || type=="OP") {
		ms=document.getElementById(current);
		ms.style.visibility = "visible";				
	}	
}

function HideIt(current) {
	if (type=="IE") {
		ms=document.all[current];		
		ms.style.visibility = "hidden";
	}
	if (type=="NN") {
		ms=document.layers[current];
		ms.visibility = "hidden";
	}
	if (type=="MO" || type=="OP") {
		ms=document.getElementById(current);
		ms.style.visibility = "hidden";
	}		
}

// Trim leading and trailing white space
function trim(str) {
  return str.replace(/^\s+|\s+$/g, '')
};

// Validate the email address
function validateEmail(email) {
	var re = false;        
	var ea = trim(email);        
	var pattern = /^[a-zA-Z][\w\-\.]{0,19}\@[a-zA-Z][\-\w]+(\.[a-zA-Z\-][\-\w]+)+$/;
	if (ea != "" && pattern.test(ea)) {
		re = true;
	}
	return re;
}

// Validate the name
function validateName(name) {
	var re = false;        
	var na = trim(name);        
	var pattern = /^[a-zA-Z][a-zA-Z\d_\s\.\'\-]{1,49}$/;
	if (na != "" && pattern.test(na)) {
		re = true;
	}
	return re;
}

// Check whether it is empty or not
function validateEmpty(nm){
	var name = trim(nm);
	return name==""? false : true;
}