function ShowPositionedLayer(thisimg, thislayer, xoffset, yoffset) {
	x = s_getStart("x", thisimg) + xoffset;
	y = s_getStart("y", thisimg) + yoffset;
	objlayer = MM_findObj(thislayer);
	objlayer.style.left = x-1+1;	
	objlayer.style.top = y-1+1;
	MM_showHideLayers(thislayer,'','show');
}

function MM_showHideLayers() { //v6.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; }
}


// SAMPLE FUNCTION USED FOR RELATIVE POSITIONING
s_ua=navigator.userAgent.toLowerCase();
s_dl=document.getElementById?1:0;
s_iE=document.all&&!window.innerWidth&&s_ua.indexOf("msie")!=-1?1:0;
s_oP=s_ua.indexOf("opera")!=-1&&document.clear?1:0;
s_oP7=s_oP&&document.appendChild?1:0;
s_oP7m=s_oP&&!s_oP7?1:0;
s_nS=s_dl&&!document.all&&s_ua.indexOf("opera")==-1?1:0;
s_nS4=document.layers?1:0;
s_kNv=s_ua.indexOf("konqueror")!=-1?parseFloat(s_ua.substring(s_ua.indexOf("konqueror/")+10)):0;
s_kN=s_kNv>=2.2?1:0;s_kN3p=s_kNv>=3?1:0;
s_kN31p=s_kNv>=3.1?1:0;s_kN32p=s_kNv>=3.2?1:0;
s_mC=s_ua.indexOf("mac")!=-1?1:0;
s_sF=s_mC&&s_ua.indexOf("safari")!=-1?1:0;
s_iE5M=s_mC&&s_iE&&s_dl?1:0;
s_iE4M=s_mC&&s_iE&&!s_dl?1:0;
s_iE4=!s_mC&&s_iE&&!s_dl?1:0;
s_ct=0;

function s_getStart(a, img){
var bodyStyleMarginTop=0;// specify manually to kill a bug in Opera 5/6
var o=document.images[img];if(!o)return a=="x"?-630:0;
if(s_nS4)return a=="x"?o.x:o.y;
var oP,oC,ieW;oP=o.offsetParent;oC=a=="x"?o.offsetLeft:o.offsetTop;
ieW=s_iE&&!s_mC?1:0;
while(oP){if(ieW&&oP.tagName&&oP.tagName.toLowerCase()=="table"&&oP.border&&oP.border>0)oC++;oC+=a=="x"?oP.offsetLeft:oP.offsetTop;oP=oP.offsetParent};
if(s_kN31p&&!s_kN32p){return a=="x"?(document.body.style&&document.body.style.marginLeft?parseInt(document.body.style.marginLeft)+oC:document.body.marginWidth?parseInt(document.body.marginWidth)+oC:document.body.leftMargin?parseInt(document.body.leftMargin)+oC:oC+10):(document.body.style&&document.body.style.marginTop?parseInt(document.body.style.marginTop)+oC:document.body.marginHeight?parseInt(document.body.marginHeight)+oC:document.body.topMargin?parseInt(document.body.topMargin)+oC:oC+10)};
return s_oP7m?a=="x"?oC:oC+bodyStyleMarginTop:s_iE5M?a=="x"?oC+parseInt(document.body.currentStyle.marginLeft):oC+parseInt(document.body.currentStyle.marginTop):oC};
/*
 All browsers have problems with finding the real position of an
 element on the page in certain cases. I have tried to go round some
 browser bugs with the above function- that's why it's so long & complex.
*/
// SAMPLE FUNCTION USED FOR RELATIVE POSITIONING






//Fuctions to mimmick LTrim,  RTrim, and Trim...
//==================================================================
//LTrim(string) : Returns a copy of a string without leading spaces.
//==================================================================
function LTrim(str)
/*
        PURPOSE: Remove leading blanks from our string.
        IN: str - the string we want to LTrim
*/
{
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...

            var j=0, i = s.length;

            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;


            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }

        return s;
}

//==================================================================
//RTrim(string) : Returns a copy of a string without trailing spaces.
//=================================================================//=
function RTrim(str)
/*
        PURPOSE: Remove trailing blanks from our string.
        IN: str - the string we want to RTrim

*/
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in Whitespace
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...

            var i = s.length - 1;       // Get length of string

            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;


            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }

        return s;
}


//=============================================================
//Trim(string) : Returns a copy of a string without leading or trailing spaces
//=============================================================
        function Trim(str)
        /*
                PURPOSE: Remove trailing and leading blanks from our string.
                IN: str - the string we want to Trim

                RETVAL: A Trimmed string!
        */
        {
                return RTrim(LTrim(str));
        }



function validEmail(email) {
	 invalidChars = " /:,;"
	
	if (email == "") {	// cannot be empty
	    //alert("Please enter your email address.");
	    return false
         }
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
	badChar = invalidChars.charAt(i)
	if (email.indexOf(badChar,0) > -1) {
	   return false
	}
      }
      atPos = email.indexOf("@",1)	// there must be one "@" symbol
      if (atPos == -1) {
	 return false
      }
      if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
	  return false
      }
      periodPos = email.indexOf(".",atPos)
      if (periodPos == -1) {			// and at least one "." after the "@"
	 return false
      }
      if (periodPos+3 > email.length)	{ // must be at least 2 characters after the "."
	 return false
      }
      return true
}

var SubmitForm;
var confirmExitText = "If you leave this page now, all your information on this page will be lost."

//######### ValidateForm #########/////////////////////
//This function performs form validation for required fields. 
//The required fields are indicated by the hidden field "_required". 
//The value is a list of the field ids plus the question number, 
//separated by comma. Note that here we use field ids so that we can 
//group fields have the different names but the same ids, for example, 
//a group of checkboxes. 
function ValidateForm(thisform) {
var errormsg = "Please complete question ";
if (thisform._required != null) {
	if (Trim(thisform._required.value).length != "") {
	var fieldnames = thisform._required.value.split(",");
		for (m=0; m<fieldnames.length; m++) {
			fieldnamearr = fieldnames[m].split("|");
			fieldname = Trim(fieldnamearr[0]);
			errormsg = "Please complete all required fields.";
			if (fieldnamearr.length > 1) {
				fieldlabel = Trim(fieldnamearr[1]);
				errormsg = errormsg + fieldlabel + ".";
				}
			if (fieldnamearr.length > 2) {
				errormsg = Trim(fieldnamearr[2]);
				}
			//if (thisform.elements[fieldname].disabled == false || thisform.elements[fieldname].disabled===undefined) {
			//status = thisform.elements[fieldname].disabled;
			//errormsg = status;
				if (thisform.elements[fieldname].length===undefined) {		
					errormsg = "Please complete all required fields.";
					if (thisform.elements[fieldname].disabled == false || thisform.elements[fieldname].disabled===undefined) {
						if (Trim(thisform.elements[fieldname].value).length=="" || Trim(thisform.elements[fieldname].value).length==0) {
							alert(errormsg);
							thisform.elements[fieldname].focus();
							return false;
							}
						emailfield = fieldname.toLowerCase();
						if (emailfield.indexOf("email")>=0) {
							if (validEmail(Trim(thisform.elements[fieldname].value))==false) {
							thisform.elements[fieldname].focus();
							alert("Please enter a valid email address.");
							return false;
								}
							}
						}
					}
				else {
					//errormsg = "Please select.";
					//if (thisform.elements[fieldname][0].type == "radio") {
						//errormsg = "Please select one.";
						//}
					//if (thisform.elements[fieldname][0].type == "checkbox") {
						//errormsg = "Please select at least one.";
						//}
					if (thisform.elements[fieldname][0].disabled == false || thisform.elements[fieldname][0].disabled===undefined) {
						thischecked = -1
						for (i=0; i<thisform.elements[fieldname].length; i++) {
							if ((thisform.elements[fieldname][i].checked  && thisform.elements[fieldname][i].value.length!="") || (thisform.elements[fieldname][i].selected && thisform.elements[fieldname][i].value.length!="")) {
							thischecked = i;
								}
							}
						if (thischecked == -1) {
							thisform.elements[fieldname][0].focus();
							alert(errormsg);
							return false;
							
							}
						}
					}
				//}
			}
		}
	}
	
SubmitForm = true;
}
//######### ValidateForm #########/////////////////////

function confirmExit() {
	if (SubmitForm == true) {
		return;
	}
	return confirmExitText;
}

function InitBody() {
	DoLock(document.forms[0]);
}

function DoLock(thisform) {
	var fieldname;
	for (n=0; n<thisform.elements.length; n++) {
		fieldname = thisform.elements[n].name;
		if (fieldname.indexOf("othertext") > 0) {
			thisform.elements[n].disabled = true;
			}
		}
}

function LockTextBox(name, status) {
	var x;
	x = document.getElementById(name);
	if (x != null) {
		if (status) x.value = "";
		x.disabled = status;
		}
}

function JumpForm(elementID) {
	if (elementID.length > 0)
		document.getElementById(elementID).focus();
	else
		document.getElementById("Button1").click();
	return;
}


//######### LockAll #########/////////////////////
//This function will disable all the fields except 
//the unlockfield and the fields for the submit button and ASP.NET field. 
//All disabled field will be cleared of any data.
//unlockfield: the field that will remain unlocked.
function LockAll(thisform, unlockfield) {
	var fieldname;
	for (n=0; n<thisform.elements.length; n++) {
		fieldname = thisform.elements[n].name;
		if (fieldname != unlockfield && fieldname != "Button1" && fieldname != "__VIEWSTATE") {
			ClearField(thisform.elements[n]);
			thisform.elements[n].disabled = true;
			}
		}
	//SubmitForm = true;
	//thisform.submit();
}
//######### LockAll #########/////////////////////

//######### unLockAll #########/////////////////////
//This function will unlock (enable) all the fields except 
//the lockfield and the fields for text next to a check box. 
//lockfield: the field that will remain locked.
function unLockAll(thisform, lockfield) {
	var fieldname;
	for (n=0; n<thisform.elements.length; n++) {
		fieldname = thisform.elements[n].name;
		if (fieldname != lockfield && fieldname.indexOf("othertext") == -1 ) {
			thisform.elements[n].disabled = false;
			}
		};
}
//######### unLockAll #########/////////////////////

//######### LockSelected #########/////////////////////
//This function will change the "disabled" status of the field. 
//theform: form object
//fieldprefixstr: a list of field name prefixes separated by comma. 
//Note that "field_1" will match "field1_1", "field_11", "field_123", etc.
//lockstatus: "lock" - disable the fields; "unlock" - enable the fields.
function LockSelected(thisform, fieldprefixstr, lockstatus) {
	var fieldprefixarr = fieldprefixstr.split(",");
	for (m=0; m<fieldprefixarr.length; m++) {
		fieldprefix = Trim(fieldprefixarr[m]);
		for (n=0; n<thisform.elements.length; n++) {
		fieldname = thisform.elements[n].name;
		if (fieldname.indexOf(fieldprefix) == 0) {
			if (lockstatus == "lock") {
				ClearField(thisform.elements[n]);
				thisform.elements[n].disabled = true;
				}
			if (lockstatus == "unlock") {
				if (fieldname.indexOf("othertext") == -1 ) {
					thisform.elements[n].disabled = false;
					}
				}
			}
		}
	}
}
//######### LockSelected #########/////////////////////

//######### ClearSelected #########/////////////////////
//Will clear the value of multiple fields. 
//fieldprefixstr: a list of field prefixes that will be cleared
//excludefield: field to be excluded from clearing.
function ClearSelected(thisform, fieldprefixstr, excludefield) {
	var fieldprefixarr = fieldprefixstr.split(",");
	for (m=0; m<fieldprefixarr.length; m++) {
		fieldprefix = Trim(fieldprefixarr[m]);
		for (n=0; n<thisform.elements.length; n++) {
			fieldname = thisform.elements[n].name;
			if (fieldname.indexOf(fieldprefix) == 0 && fieldname != excludefield) {
				ClearField(thisform.elements[n]);
				if (fieldname.indexOf("othertext") != -1 ) {
					thisform.elements[n].disabled = true;
					}
			}
		}
	}
}

//######### ClearField #########/////////////////////
function ClearField(thisfield) {
	if (thisfield.type == "text") {
		thisfield.value = "";
	}
	if (thisfield.type == "textarea") {
		thisfield.value = "";
	}
	if (thisfield.type == "checkbox") {
		thisfield.checked = false;
	}
	if (thisfield.type == "radio") {
		thisfield.checked = false;
	}
}