function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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);

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//*****************************************************************************************
//*			Neferete_Survey_Cookie to pass data between survey forms.			*
//*															*
//*			Done By : Deepa Gupta	Date : 2 November 2007					*
//*															*
//*****************************************************************************************

function Cookie(document, name, hours, path, domain, secure)
{ 
 this.$document = document; 
this.$name = name; 
if (hours) this.$expiration = new Date((new Date()).getTime( ) + hours*3600000); 
else this.$expiration = null; 
if (path) this.$path = path; 
else this.$path = null; 
if (domain) this.$domain = domain; 
else this.$domain = null; 
if (secure) this.$secure = true; 
else this.$secure = false;
 } 

Cookie.prototype.store = function ( ) 
{ 
var cookieval = ""; 
for(var prop in this) { 
	if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
		continue; 
	if (cookieval != "") 
		cookieval += '&'; 
	cookieval += prop + ':' + escape(this[prop]); 
	} 
var cookie = this.$name + '=' + cookieval; 
if (this.$expiration) 
cookie += '; expires=' + this.$expiration.toGMTString( ); 
if (this.$path) cookie += '; path=' + this.$path; 
if (this.$domain) cookie += '; domain=' + this.$domain; 
if (this.$secure) cookie += '; secure'; 
this.$document.cookie = cookie; 
} 
Cookie.prototype.load = function( ) 
{
var allcookies = this.$document.cookie; 
if (allcookies == "") return false; 
var start = allcookies.indexOf(this.$name + '='); 
if (start == -1) return false; 
start += this.$name.length + 1;
var end = allcookies.indexOf(';', start); 
if (end == -1) end = allcookies.length; 
var cookieval = allcookies.substring(start, end); 

var a = cookieval.split('&'); 
for(var i=0; i < a.length; i++) 
a[i] = a[i].split(':'); 

for(var i = 0; i < a.length; i++) { 
this[a[i][0]] = unescape(a[i][1]); 
}
return true; 
}
Cookie.prototype.remove = function( ) 
{ 
var cookie; 
cookie = this.$name + '='; 
if (this.$path) cookie += '; path=' + this.$path; 
if (this.$domain) cookie += '; domain=' + this.$domain; 
cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT'; 
this.$document.cookie = cookie; 
} 

//***********************************************************************************
//*			Validations Apllied on Member Details Form.				*
//*														*
//*			Done By : Deepa Gupta	Date : 5 November 2007				*
//*														*
//***********************************************************************************

function validateTelephone(messageId, fieldName, valueStr) 
{ 
	var valueEntered = valueStr.trim();
	valueStr = valueEntered; 

	if (!(valueStr == null || valueStr== "")) 
	{ 
		if(!(validateCharIllegal(messageId, fieldName, valueStr) && isNum(messageId, fieldName, valueStr) ))
		{
			return false;
		}
	
		if(!(valueStr.length == 10 || valueStr.length == 8))
		{
			writeMessage(messageId,""+fieldName+" length should be either 8 or 10 characters.");
			return false;
		}

		if(valueStr.length == 10 && valueStr.charAt(0) != '0')
		{
			writeMessage(messageId,""+fieldName+" area code should start with 0.");
			return false;
		}
	}
	writeMessage(messageId,""); 
	return true;
}

function validateEmail(messageId, fieldName, valueStr) 
{ 
	if(!validateNullLength(messageId, fieldName, valueStr, 100))
	{
		return false;
	}else
	{
		var apos = valueStr.indexOf("@");
		var dotpos = valueStr.lastIndexOf(".");

		if (apos == -1) 
  		{
			writeMessage(messageId," Invalid "+fieldName+". char '@' is missing !");
			return false;
		}
		if (dotpos == -1) 
  		{
			writeMessage(messageId," Invalid "+fieldName+". char '.' is missing !");
			return false;
		}
		if (apos < 1 || dotpos-apos < 2 || (valueStr.length-1) <= dotpos) 
  		{
			writeMessage(messageId," Invalid "+fieldName+" !");
			return false;
		}
	}
	writeMessage(messageId,""); 
	return true;
}

function validateNullLength(messageId, fieldName, valueStr, valuelength) 
{ 
if (valueStr == null || valueStr== "") 
{ 
	writeMessage(messageId,""+fieldName+ " missing !"); 
	return false;
}else {
	var valueEntered = valueStr.trim();
	valueStr = valueEntered;
	if (valueStr == "") 
	{ 
		writeMessage(messageId,""+fieldName+" can't be a blank string !");
		return false;
	}
	if (valueStr.length > valuelength) 
	{
		writeMessage(messageId,""+fieldName+" can't be of length more than "+valuelength+" characters!");
		return false;
	}
} 
writeMessage(messageId,""); 
return true;
}

function validateCharIllegal(messageId, fieldName, valueStr) 
{ 
	if (!(valueStr == null || valueStr== "")) 
	{ 
		var valueEntered = valueStr.trim(); 
		valueStr = valueEntered;
		var iChars = "*|,\":<>[]{}`\';()@&$#%";
		for (var i = 0; i < valueStr.length; i++) 
		{
			if (iChars.indexOf(valueStr.charAt(i)) != -1)
			{
				writeMessage(messageId,""+fieldName+" contains illegal characters!"); 
				return false;
			} 
		}
	} 
writeMessage(messageId,""); 
return true;
}

function writeMessage(placeId, message)
{
	var output = "";
output += "<font style='FONT-SIZE: 8pt; FONT-WEIGHT: bold; DISPLAY: inline; LETTER-SPACING: 2pt; FONT-FAMILY: Arial; COLOR:orange;'>"+message+"</font>";	placeId.innerHTML = output;
}

var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

function isValid(parm,val) {
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}

function isNum(messageId, fieldName, valueStr) 
{
	if(!isValid(valueStr,numb))
	{
		writeMessage(messageId,""+fieldName+" is not numeric !");
		return false;
	}
writeMessage(messageId,""); 
return true;
}
function isAlphaWithSpace(messageId, fieldName, valueStr) 
{	
	if(!isValid(valueStr,lwr+" "+upr))
	{
		writeMessage(messageId,""+fieldName+" contains non Alphabetic characters !");
		return false;
	}
writeMessage(messageId,""); 
return true;
}

String.prototype.trim = function() 
{ 
	a = this.replace(/^\s+/, ''); 
	return a.replace(/\s+$/, ''); 
}; 
