/* javascripts required globally */

/* mf - menu script based on and adapted from suckerfish script authored by Patrick Griffiths and Dan Webb */

sfnavHover = function() {
			var sfEls = document.getElementById("main-nav").getElementsByTagName("li");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfnavhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfnavhover\\b"), "");
				}
			}
		}
		if (window.attachEvent) window.attachEvent("onload", sfnavHover);
	
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgnavover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

/* mf - existing search check if form is empty */
	function checkform ( form )
	{
	 
	    // ** START **
	    if (form.words.value == "") {
	        alert( "Please enter search criteria." );
	        form.words.focus();
	        return false ;
	    }
	  
	    
	   // ** END **
		return true ;
	   }
	   
/* mf - existing script - resource centre - deadly exchanges */

function openWindow(arg1){
  window.open (arg1,"edit","status=no,toolbars=no,scrollbars=yes,width=410,height=400,resize=no")
}

/* mf - existing script */

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+400+',height='+300+',left='+left+', top='+top+',screenX='+392+',screenY='+184+'');
}

/* mf - script to open window for Grassy Narrows site */

function gnPopitup(url) {
    newwindow=window.open(url,'name','menubar=no,directories=no,location=no,status=no,toolbar=no,resizable=no,scrollbars=no,height=600,width=800,top=10,left=10');
    if (window.focus) {newwindow.focus()};
    return false;
}

function rightPopitup(url) {
    newwindow=window.open(url,'name','menubar=no,directories=no,location=no,status=no,toolbar=no,resizable=no,scrollbars=no,height=480,width=640,top=30,left=30');
    if (window.focus) {newwindow.focus()};
    return false;
}


/* mf - george's subscribe to script
Online Form HTML Source Code Generated By ThinData EMS      
Copyright (c) 2000-2005, All Rights Reserved                
http://www.thindata.com                                    
Javascript Section
Do not edit this section
*/

// This main function is responsible for parsing the query string 
// and populating matching fields in this online form. 

function preLoadData(strPassedFormName)   

{ 
  var strTemp; 
  var strFormType; 
  var qsName; 
  var qsValue; 
  var arrPassedString; 
  var intI, intJ; 
  var urlPassedString = location.search.substring(1); 
  var re = /[+]/gi; 
  var blnFoundValidItem = 0;  

  // Look for at least one item in the query string that corresponds to  
  // PIID, MLID, or MPID.  If we find at least one item with that designation,  
  // then continue the preloading of the form.  Otherwise, do not go into the  
  // preload script  

  arrPassedString = urlPassedString.split("&")  
  for (intI = 0; intI < arrPassedString.length; intI++) { 
    qsName = '';  
    qsName = arrPassedString[intI].substring(0, 4);  
    qsName = qsName.toUpperCase();  
    if (qsName == 'PIID' || qsName == 'MLID' || qsName == 'MPID') {  
      blnFoundValidItem = 1;  
    }  
  } 


  // parse our string of data into it's appropriate name and value pairs 

  if (urlPassedString.length != 0 && blnFoundValidItem == 1) 
  { 
    for (intJ = 0; intJ < window.document.forms[strPassedFormName].length; intJ++) {  
      varFormElement = window.document.forms[strPassedFormName][intJ];  
      strFormType    = varFormElement.type;  
      strFormType = strFormType.toUpperCase();  
      if (strFormType == "TEXT"  || strFormType == "HIDDEN") { 
        strTemp = varFormElement.name;  
        strTemp = strTemp.toUpperCase();  
        if (strTemp != "WEBFORMID" && strTemp != "PROCESSPAGE" && strTemp != "W" && strTemp != "CID" && strTemp != "I") { 
          varFormElement.value = ""; 
        } 
      } else if (strFormType == "CHECKBOX" || strFormType == "RADIO") {  
        varFormElement.checked = false;  
      } else if (strFormType == "SELECT-ONE") {  
        varFormElement.selectedIndex = -1;  
      } else if (strFormType == "TEXTAREA") {  
        varFormElement.value = "";  
      } 
    }  
    arrPassedString = urlPassedString.split("&") 
    for (intI = 0; intI < arrPassedString.length; intI++) { 
      qsValue = ''; 
      qsName = ''; 
      qsName = arrPassedString[intI].substring(0, arrPassedString[intI].indexOf("=",1)); 
      qsValue = arrPassedString[intI].substring(arrPassedString[intI].indexOf("=",1)+1) 
      if (qsValue.substring(0, 1) == "+") { 
        qsValue = qsValue.substring(1, qsValue.length) 
      } 
      qsValue = unescape(qsValue.replace(re, " ")); 
      qsName = unescape(qsName.replace(re, " ")); 
      if (window.document.forms[strPassedFormName][qsName]) { 

        // Determine wether the profile item has been listed on the form multiple 
        // times (in the case of a checkbox or radio button or select box with 
        // multiple options) or if it's just listed once (in the case of everything else) 

        if (window.document.forms[strPassedFormName][qsName].length) {          
          strFormType = window.document.forms[strPassedFormName][qsName].type; 
          if (strFormType) { 
            strFormType = strFormType.toUpperCase(); 
          } 
          if (strFormType == "TEXT"  || strFormType == "HIDDEN") { 
            window.document.forms[strPassedFormName][qsName].value = qsValue; 
          } else if (strFormType == "RADIO" || strFormType == "CHECKBOX") { 
            if (window.document.forms[strPassedFormName][qsName].value == qsValue) { 
              window.document.forms[strPassedFormName][qsName].checked = true; 
            }      
          } else if (strFormType == "SELECT-ONE") { 
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value; 
              if (strTemp == qsValue) { 
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ; 
              } 
            } 
          } else { 

            // We have a checkbox or radio button with multiple values. 
            // In each case we know that there will be a value attribute 

            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              if (window.document.forms[strPassedFormName][qsName][intJ].value == qsValue) { 
                window.document.forms[strPassedFormName][qsName][intJ].checked = true; 
              } 
            } 
          } 
        } else { 

          // We know that we either have a select box or we have something else. 
          // Test for the selectedIndex property to determine.

          strFormType = window.document.forms[strPassedFormName][qsName].type; 
          strFormType = strFormType.toUpperCase(); 
          if (strFormType == "SELECT-ONE") { 
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value; 
              if (strTemp == qsValue) { 
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ; 
              } 
            } 
          } else { 
            strFormType = window.document.forms[strPassedFormName][qsName].type; 
            strFormType = strFormType.toUpperCase(); 
            if (strFormType == 'RADIO' || strFormType == 'CHECKBOX') { 
              if (window.document.forms[strPassedFormName][qsName].value == qsValue) { 
                window.document.forms[strPassedFormName][qsName].checked = true; 
              }      
            } else { 
              window.document.forms[strPassedFormName][qsName].value = qsValue; 
            } 
          } 
        } 
      } 
 else {  qsName = qsName + '_0';       if (window.document.forms[strPassedFormName][qsName]) { 

        // Determine wether the profile item has been listed on the form multiple 
        // times (in the case of a checkbox or radio button or select box with 
        // multiple options) or if it's just listed once (in the case of everything else) 

        if (window.document.forms[strPassedFormName][qsName].length) {          
          strFormType = window.document.forms[strPassedFormName][qsName].type; 
          if (strFormType) { 
            strFormType = strFormType.toUpperCase(); 
          } 
          if (strFormType == "TEXT"  || strFormType == "HIDDEN") { 
            window.document.forms[strPassedFormName][qsName].value = qsValue; 
          } else if (strFormType == "RADIO" || strFormType == "CHECKBOX") { 
            if (window.document.forms[strPassedFormName][qsName].value == qsValue) { 
              window.document.forms[strPassedFormName][qsName].checked = true; 
            }      
          } else if (strFormType == "SELECT-ONE") { 
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value; 
              if (strTemp == qsValue) { 
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ; 
              } 
            } 
          } else { 

            // We have a checkbox or radio button with multiple values. 
            // In each case we know that there will be a value attribute 

            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              if (window.document.forms[strPassedFormName][qsName][intJ].value == qsValue) { 
                window.document.forms[strPassedFormName][qsName][intJ].checked = true; 
              } 
            } 
          } 
        } else { 

          // We know that we either have a select box or we have something else. 
          // Test for the selectedIndex property to determine.

          strFormType = window.document.forms[strPassedFormName][qsName].type; 
          strFormType = strFormType.toUpperCase(); 
          if (strFormType == "SELECT-ONE") { 
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) { 
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value; 
              if (strTemp == qsValue) { 
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ; 
              } 
            } 
          } else { 
            strFormType = window.document.forms[strPassedFormName][qsName].type; 
            strFormType = strFormType.toUpperCase(); 
            if (strFormType == 'RADIO' || strFormType == 'CHECKBOX') { 
              if (window.document.forms[strPassedFormName][qsName].value == qsValue) { 
                window.document.forms[strPassedFormName][qsName].checked = true; 
              }      
            } else { 
              window.document.forms[strPassedFormName][qsName].value = qsValue; 
            } 
          } 
        } 
      } 
    }     } 
  } 
} 

// Call the routine to do our replacement of text values 

preLoadData('testOnlineFormName') 

