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.01
  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 && d.getElementById) x=d.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 isPositive(n) {
	return (n > 0);
	}

function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}

FORM_DATA = createRequestObject();

function windowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.outerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
return myWidth;
}
function windowHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.outerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
return myHeight;
}

function windowInnerHeight() {
var browserName = navigator.appName;
if (browserName != 'Netscape')
	iH = document.body.clientHeight;
else
	iH = window.innerHeight;
return iH;
}

function windowInnerWidth() {
var browserName = navigator.appName;
if (browserName != 'Netscape')
	iW = document.body.clientWidth;
else
	iW = window.innerWidth;
return iW;
}

function borderVertical() {
hB=parseInt(FORM_DATA['height']) + parseInt(windowHeight()) - parseInt(windowInnerHeight());
return hB;
}

function borderHorizontal() {
// alert(parseInt(windowWidth()) - parseInt(windowInnerWidth()));
vB=parseInt(FORM_DATA['width']) + parseInt(windowWidth()) - parseInt(windowInnerWidth());
return vB;
}

function resizePictureWindow() {
var browserName = navigator.appName;
if (browserName == 'Netscape')
window.resizeTo(borderHorizontal(),borderVertical());
else {
window.resizeTo(FORM_DATA['width'],FORM_DATA['height']);
h=parseInt(FORM_DATA['height']) + parseInt(FORM_DATA['height']) -  parseInt(windowHeight());
w=parseInt(FORM_DATA['width']) + parseInt(FORM_DATA['width']) -  parseInt(windowWidth());
// alert("border vertical="+eval(parseInt(FORM_DATA['height']) - parseInt(windowHeight())));
// alert("window height="+parseInt(windowHeight()));
//alert("border vertical="+borderVertical());
// document.body.clientHeight = parseInt(FORM_DATA['height']);
// document.body.clientWidth = parseInt(FORM_DATA['width']);
if (parseInt(FORM_DATA['height']) - parseInt(windowHeight()) > 0) 
	window.resizeTo(w,h);
// location=document.location=
//alert(document.documentElement.clientWidth);
//document.documentElement.clientWidth = ;
// document.body.clientHeight=FORM_DATA['height'];
}
}



// toggle visibility 

function toggle( targetId ){ 
  if (document.getElementById){ 
        target = document.getElementById( targetId ); 
           if (target.style.display == "none"){ 
              target.style.display = ""; 
           } else { 
              target.style.display = "none"; 
           } 
     } 
} 



	function cleanText (str) {
		while (str.indexOf(String.fromCharCode(8221)) >= 0)
			str=str.replace(String.fromCharCode(8221),"\"");
		while (str.indexOf(String.fromCharCode(8220)) >= 0)
			str=str.replace(String.fromCharCode(8220),"\"");
		while (str.indexOf(String.fromCharCode(8216)) >= 0)
		str=str.replace(String.fromCharCode(8216),"'");
		while (str.indexOf(String.fromCharCode(8217)) >= 0)
			str=str.replace(String.fromCharCode(8217),"'");
		while (str.indexOf(String.fromCharCode(8211)) >= 0)
			str=str.replace(String.fromCharCode(8211),"&#150;");
		while (str.indexOf(String.fromCharCode(8212)) >= 0)
			str=str.replace(String.fromCharCode(8212),"&#151;");
		while (str.indexOf(String.fromCharCode(8230)) >= 0)
			str=str.replace(String.fromCharCode(8230),"...");
		return str;
	}

function selectLink (linkTarget) {
for (i=0; i<document.links.length; i++)
if(document.links[i].name)
if(document.links[i].name == linkTarget)
document.links[i].focus();
}


 function implode( delim, arr ) {
    var str ="";
    for ( var i = 0; i < arr.length; i++ ) {
      str += arr[i];
      if ( (i+1) < arr.length ) str += delim;
    }
    
    return str;
  }

/*function isdefined(variable) 
{ 
return (typeof(window[variable]) == "undefined")? false: true; 
} 
*/

function isdefined(ckVar)


    {
    	var DEFINED_V=true;
    	


        	function handleError() {
        	DEFINED_V=false;
        	return true;
        	}
        	var oldOnError=window.onerror;
        	window.onerror=handleError;
        	try { 
        		eval(ckVar);
        	}catch (e) 
        	{ DEFINED_V=false;
        	}
        	window.onerror=oldOnError;
        	return DEFINED_V;
    }


function listappend ( list, newValue, delimiter )
 	{
	if (listappend.arguments.length < 3)
		delimiter=",";
	if (list.length > 0)
		list += delimiter;
	list += newValue;
	return list;
	}
	
function listgetat ( list, position, delimiter )
 	{
	if (listgetat.arguments.length < 3)
		delimiter=",";
	listarr = list.split(delimiter);
	return listarr [ position - 1 ];
	}

function listlength ( list, delimiter )
 	{
	if (listlength.arguments.length < 2)
		delimiter=",";
	listarr = list.split(delimiter);
	return listarr.length;
	}

function listsetat ( list, position, value, delimiter )
 	{
	if (listsetat.arguments.length < 4)
		delimiter=",";
	listarr = list.split(delimiter);
	listarr[position - 1] = value;
	newlist = implode (delimiter, listarr);
	return newlist;
	}

function submitForm (formObx) {
//	checkForm(formObx);
	//	alert("x"+ " " + formObx.elements.length +formObx.elements[2].onblur);
	formValidated=1;
	
	for (u=0; u < formObx.elements.length; u++)	{
		testBlur=""+formObx.elements[u].onblur;
		if (testBlur.indexOf("checkTextBox") > 0)
			if (!checkTextBox(formObx.elements[u].value)) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkSoc") > 0)
			if (!checkSoc(formObx.elements[formObx.elements[u].name])) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkPhone") > 0)
			if (!checkPhone(formObx.elements[formObx.elements[u].name])) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkEmail") > 0)
			if (!checkEmail(formObx.elements[u].value)) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkMultipleChoice") > 0)
			if (!checkMultipleChoice(formObx.elements[formObx.elements[u].name])) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkCheckBox") > 0)
			if (!checkMultipleChoice(formObx.elements[formObx.elements[u].name])) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		if (testBlur.indexOf("checkSelect") > 0)
			if (!checkSelect(formObx.elements[u])) {
				formValidated=0;
				formObx.elements[u].focus();
				break;
				}
		}
//		alert(formValidated);
	if (formValidated)
		formObx.submit();
	else
		alert("Please Complete all required fields");
}

function hideSelects (formObj) {
	for (y=0; y < formObj.elements.length; y++)
		if (formObj.elements[y].type.indexOf("select") >= 0)
			formObj.elements[y].style.visibility='hidden';
	}
function showSelects (formObj) {
	for (y=0; y < formObj.elements.length; y++)
		if (formObj.elements[y].type.indexOf("select") >= 0)
			formObj.elements[y].style.visibility='visible';
	}
function checkForm (formObj)
	{
	for (y=0; y < formObj.elements.length; y++)	{
//	alert(typeof(formObj.elements[x].onblur));
// x=0;
// alert(formObj.elements.length + " " +y);
		if (typeof(formObj.elements[y].onblur) == 'function') {
			formObj.elements[y].focus();
			formObj.elements[y].blur();
			}
		}
//		alert('x'+formValidated);
	formObj.elements[0].focus();
	}

function checkTextBox (s) {
	if (s.length > 0)
	return true
	else{
		return false;
		}
}

function checkSoc (check) {
	isDone = isSSN(stripCharsNotInBag(check.value,'0123456789'));
	return isDone;
}

function checkPhone (check) {
	isDone = isUSPhoneNumber(stripCharsNotInBag(check.value,'0123456789'));
	return isDone;
}

function checkEmail(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		   return false
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		   return false
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		    return false
		 if (str.indexOf(at,(lat+1))!=-1)
		    return false
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		    return false
		 if (str.indexOf(dot,(lat+2))==-1)
		    return false
		 if (str.indexOf(" ")!=-1)
		    return false
 		 return true					
	}


function checkPassword (pass1, pass2) {
	if (pass1.length < 5)
		return false;
	if (pass1==pass2)
		return true;
	else
		return false;
	}

	
function checkCheckBox (check) {
	if (check.checked)
		return true;
	else
		return false;
	}

function checkMultipleChoice (check) {
	var isDone=false;
	for (x=0; x < check.length; x++)
		if (check[x].checked)
			isDone=true;
			//alert(isDone);
		return isDone;
	}

function checkSelect (check) {
	var isDone=false;
	if (check.options.selectedIndex >= 0)
		if (check.options[check.options.selectedIndex].value != '')
			isDone=true;
		return isDone;
	}

function openWin (loc,width,height,left,top) {
msg=window.open(loc,"msg","height="+height+",width="+width+",left="+left+",top="+top+",statusbar=1");
msg.topmargin = 0;
msg.leftmargin = 0;
msg.marginwidth = 0;
msg.marginheight = 0;
msg.window.focus();
}
function openWinSimple (loc) {
msg=window.open(loc,"msg","statusbar=0");
msg.topmargin = 0;
msg.leftmargin = 0;
msg.marginwidth = 0;
msg.marginheight = 0;
msg.window.focus();
}

function openPic (loc) {
msg=window.open(relpath+'viewPic.php?pic='+loc,"msg","statusbar=0");
msg.topmargin = 0;
msg.leftmargin = 0;
msg.marginwidth = 0;
msg.marginheight = 0;
msg.window.focus();
}

function tocItem (name, ext) {
this.on = new Image();
this.on.src = imgRoot + name + "_on." + ext
this.off = new Image();
this.off.src = imgRoot + name + "." + ext
}
function sideDot () {
this.red = new Image();
this.red.src = relroot+"/images/dot_red.gif"
this.green = new Image();
this.green.src = relroot+"/images/dot_green.gif"
this.orange = new Image();
this.orange.src = relroot+"/images/dot_orange.gif"
}
function toc_new (name, ext) {
if (toc_new.arguments.length < 2)
		ext="gif";
tocItem[name] = new tocItem(name, ext);
}

function img_act (imgName)
// Show Image
{
if (document.images)
	document[imgName].src = tocItem[imgName].on.src;
}

function img_inact (imgName)
// Hide Image
{
if (document.images)
    document[imgName].src = tocItem[imgName].off.src;
}


function form_done (imgName)
// Show Image
{
if (document.images)
	document[imgName].src = dot.green.src;
}

function form_inprogress (imgName)
// Hide Image
{
if (document.images)
    document[imgName].src = dot.orange.src;
}

function form_undone (imgName)
// Hide Image
{
if (document.images)
    document[imgName].src = dot.red.src;
}

if (document.images != null) {
dot = new sideDot();
}

var browserName = navigator.appName;
var browserVersion = parseInt(navigator.appVersion);
var browser;
// Style Sheet Additions
/*if (browserName == "Netscape" && browserVersion < 5)
document.writeln("<link rel=\"stylesheet\" href=\""+relroot+"/includes/netscape.css\" type=\"text/css\">")
else if (browserName == "Netscape" && browserVersion >= 5)
document.writeln("<link rel=\"stylesheet\" href=\""+relroot+"/includes/netscape6.css\" type=\"text/css\">")
*/

function checkAll(field)
{
	if ('' + field.length != 'undefined')
		for (i = 0; i < field.length; i++)
			field[i].checked = true;
		else
			field.checked = true;
}

function getCheckBoxes(field) {
	fields="";
	if ('' + field.length != 'undefined') {
		for (i = 0; i < field.length; i++)
			if (field[i].checked)
				fields = listappend(fields,field[i].value);
		}
	else
		fields = field.value;
	return fields;
	}

function uncheckAll(field)
{
	if ('' + field.length != 'undefined')
		for (i = 0; i < field.length; i++)
			field[i].checked = false;
	else
		field.checked=false;
}

//<!--[if lte IE 7.0000]>
//<script language="JavaScript">
function correctPNG() // correctly handle PNG transparency in versions of Win IE lower than 7.
   {
   for(var i=0; i<document.images.length; i++)
      {
          var img = document.images[i]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
             {
                 var imgID = (img.id) ? "id='" + img.id + "' " : ""
                 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                 var imgStyle = "display:inline-block;" + img.style.cssText 
                 if (img.align == "left") imgStyle = "float:left;" + imgStyle
                 if (img.align == "right") imgStyle = "float:right;" + imgStyle
                 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle              
                 var strNewHTML = "<span " + imgID + imgClass + imgTitle
                 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                 + "(src='" + img.src + "', sizingMethod='scale');\"></span>" 
                 img.outerHTML = strNewHTML
                 i = i-1
             }
      }
   }
//window.attachEvent("onload", correctPNG);
//</script>
//<![endif]-->