// JavaScript Document

function quickFind(){
	 
  var xmlJobAZ;
  var xmlJobDetail;
  var req;
  var itemPerPage=50;
  var i=0;
  var scrollbar_col1;
  var scrollbar_col2;
  var scrollbar_col3;
  var scrollbar_col4;
  var letter = '';
  var range = '';
  var jobId = '';
  var jobTitle = '';
  var propagate = false; /* used if cookies data are present, to populate columns with data*/

  this.scrollUp = function(fromColumn) {
    switch (fromColumn) {
      case 'col1':scrollbar_col1.scrollBy(-10);break;
      case 'col2':scrollbar_col2.scrollBy(-10);break;
      case 'col3':scrollbar_col3.scrollBy(-10);break;
      case 'col4':scrollbar_col4.scrollBy(-10);break;
    }
  }
  
  this.scrollDown = function(fromColumn) {
    switch (fromColumn) {
      case 'col1':scrollbar_col1.scrollBy(10);break;
      case 'col2':scrollbar_col2.scrollBy(10);break;
      case 'col3':scrollbar_col3.scrollBy(10);break;
      case 'col4':scrollbar_col4.scrollBy(10);break;
    }
  }
  resetClass = function(id){
	  
    if ($(id).firstDescendant()!= null) {
      if ($(id).firstDescendant().getAttribute('name') == 'jsResult') id = $(id).firstDescendant();
    }
    
    for (index=0;index<$(id).immediateDescendants().length; index++){
      //alert($(id).immediateDescendants()[index].getAttribute('class'));
      if ($(id).immediateDescendants()[index].tagName == 'A') $(id).immediateDescendants()[index].className = '';
    }
  }
  
  update = function(id,fromColumn, item, title, propagation) {
	 
    propagate = (propagation == true) ? true : false;
    id = unescape(id);
    title = unescape(title);
    switch (fromColumn) {
      case 'col1':
        clearHTML('qf-col2-content');
        clearHTML('qf-col3-content');
        clearHTML('qf-col4-jobSummary');
        clearHTML('qf-col4-relatedCourses');
        clearHTML('qf-col4-relatedIndustry');
        createCookie('letter', item, 0);
        eraseCookie('range');eraseCookie('jobId');eraseCookie('jobTitle');
        resetClass('qf-col1-content');
        resetClass('qf-col2-content');
        resetClass('qf-col3-content');
        try {$(id).className = 'current';} catch(error) {}
        ajaxRequest(fromColumn, item);
        break;       
      case 'col2':
        clearHTML('qf-col3-content');
        clearHTML('qf-col4-jobSummary');
        clearHTML('qf-col4-relatedCourses');
        clearHTML('qf-col4-relatedIndustry');
        populate('col3',generate('col3',item));
        populate('col4',generate('col4','leftArrow'),'qf-col4-jobSummary');
        resetClass('qf-col2-content');
        resetClass('qf-col3-content');
        try {$(id).className = 'current';} catch(error) {}
        createCookie('range', item, 0);
        eraseCookie('jobId');eraseCookie('jobTitle');
        if ((propagate == true) && (jobTitle != '')) {
          try {$(jobTitle).className = 'current';} catch(error) {}
          this.update(jobTitle, 'col3', jobId, jobTitle, true);
        } else propagate = false;
        break;
      case 'col3':
        clearHTML('qf-col4-jobSummary');
        clearHTML('qf-col4-relatedCourses');
        clearHTML('qf-col4-relatedIndustry');
        resetClass('qf-col3-content');
        try {$(id).className = 'current';} catch(error) {}
        createCookie('jobId', item, 0);
        if ((title != null) && (title != '')) {
          jobTitle = title;
          createCookie('jobTitle', jobTitle, 0);
        }
        ajaxRequest(fromColumn, item, '103');
        break;
    }
  }
  this.update = update;
    
  clearHTML = function(element){
	  
  	if(!document.getElementById(element)){return;}
  	if (document.getElementById(element).hasChildNodes() )
  	{
      	while (document.getElementById(element).childNodes.length >= 1 )
      	{
          	document.getElementById(element).removeChild(document.getElementById(element).firstChild );       
      	} 
  	}
  }
  
  makeLink = function(text,onClickAttrib,href,id){
	  
    link=document.createElement('a');
    if ((onClickAttrib != '') && (onClickAttrib != null)){
      link.setAttribute('onclick',onClickAttrib);
      /*@cc_on @*/ /*@if (@_jscript_version >= 4) link.onclick = function(){eval(onClickAttrib)};/*@end @*/
    }
    if ((href != '') && (href != null)){
      link.setAttribute('href',href);
    }
    if ((id != '') && (id != null)){
      link.setAttribute('id',id);
    }
    link.setAttribute('onmouseover','onHover(this);');
    /*@cc_on @*/ /*@if (@_jscript_version >= 4) link.onmouseover = function(){eval('onHover(this);')};/*@end @*/
    link.setAttribute('onmouseout','onOut(this);');
    /*@cc_on @*/ /*@if (@_jscript_version >= 4) link.onmouseout = function(){eval('onOut(this);')};/*@end @*/
    //linkText=document.createTextNode(text);
    link.innerHTML = text;
    //link.appendChild(linkText);
    return link;
  }
  
  makeImg = function(src,href){  
  
    img=document.createElement('img');
    img.setAttribute('src',src);
    if ((href != '') && (href != null)){
      link=document.createElement('a');
      link.setAttribute('href',href);
      link.appendChild(img);
      return link;
    }
    return img;
  }
  
  makeJobTitle = function(data){
    jobTitleTag=document.createElement('p');
    i=0;
    while (data[i].attributes.getNamedItem("type").value != 'N') {
      i = i+1;
    }
    if (jobTitle != data[i].attributes.getNamedItem("name").value)
      jobTitleTagText=jobTitle+' aka '+data[i].attributes.getNamedItem("name").value;
    else
      jobTitleTagText=data[i].attributes.getNamedItem("name").value;
    jobTitleTag.setAttribute('id','title');
    jobTitleTag.innerHTML = jobTitleTagText;
    return jobTitleTag;
  }
  
  makeJobDescription = function(data){
    jobDescription=document.createElement('p');
    i=0;
    while (data[i].attributes.getNamedItem("Name").value != 'Description') {
      i = i+1;
    }
    shortDescArray = data[i].attributes.getNamedItem("text").value.split(" ");
    numWords = 10;
    shortDesc = '';
    for (j=0;j<numWords;j++) { 
      shortDesc = shortDesc + shortDescArray[j];
      if (j<numWords-1) shortDesc = shortDesc + " ";
    }
    shortDesc = shortDesc + "...";
    jobDescription.setAttribute('id','desc');
    jobDescription.innerHTML = shortDesc;
    return jobDescription;
  }
  
  makeParagraph = function(text){
    paragraph=document.createElement('p');
    paragraphText=document.createTextNode(text);
    paragraph.appendChild(paragraphText);
    return paragraph;
  }
  
  makeRuler = function(){
    ruler=document.createElement('hr');
    return ruler;
  }
  
  makeSpacer = function(){
    spacer=document.createElement('div');
    spacer.setAttribute('class','clear');
    return spacer;
  }
  
  makeLeftArrow = function(){
    img=document.createElement('img');
    img.setAttribute('id','choose-arrow');
    img.setAttribute('src','fileadmin/images/gui/qf-choose-left.gif');
    return img;
  }
  
  makeRightArrow = function(){
	  
    img=document.createElement('img');
    img.setAttribute('id','choose-arrow');
    img.setAttribute('src','fileadmin/images/gui/qf-choose-right.gif');
    return img;
  }
  
  generate = function(toColumn, item, pageId) {
	 
    result = document.createElement('div');
    result.setAttribute('name','jsResult');
    // col2 can contain a list of letter ranges if there is a lot of result, or a tip for helping the end user
    if (toColumn == 'col2'){
      // here we want to generate the letter ranges
      if ((item != 'leftArrow') && (item!= 'rightArrow')){
        index = -1;
        nbPage = 0;
        while (index<data.length-1){
          indexStart = index+1;
          indexEnd = ((indexStart+itemPerPage)>(data.length-1)) ? data.length-1 : indexStart+itemPerPage;
          // Test if the first two letters of the last result are similar to the ones at the end of the current set, so we skip the refinement
          if (data[indexEnd].attributes.getNamedItem("name").value.substring(0,2).toLowerCase() == data[data.length-1].attributes.getNamedItem("name").value.substring(0,2).toLowerCase()){
            indexEnd = data.length-1;
          }
          if (indexEnd<(data.length-1)){
            // Test if the first two letters of the current set bounds are similar. In this case we parse the list until we find the next end boundary, defined by a changing second letter 
            if (data[indexStart].attributes.getNamedItem("name").value.substring(0,2).toLowerCase() == data[indexEnd].attributes.getNamedItem("name").value.substring(0,2).toLowerCase()){
              while (data[indexStart].attributes.getNamedItem("name").value.substring(0,2).toLowerCase() == data[indexEnd].attributes.getNamedItem("name").value.substring(0,2).toLowerCase()){
                indexEnd = indexEnd+1;
              }
            } else {
              // Test failed, so we must find the end boundary, defined by a changing second letter
              currentEnd = indexEnd;
              while ((data[indexEnd].attributes.getNamedItem("name").value.substring(0,2).toLowerCase() == data[currentEnd].attributes.getNamedItem("name").value.substring(0,2).toLowerCase()) && (indexEnd<data.length-1)){
                indexEnd = indexEnd+1;
              }              
            }
            indexEnd = indexEnd-1;
          }
          itemStart = data[indexStart].attributes.getNamedItem("name").value.substring(0,2);
          itemEnd = data[indexEnd].attributes.getNamedItem("name").value.substring(0,2);
          // Here we detect a unicode sequence and build up the appropriate string
          itemStartText = (itemStart.substring(1,2) == '&') ? data[indexStart].attributes.getNamedItem("name").value.substring(0,6) : itemStart;
          itemEndText = (itemEnd.substring(1,2) == '&') ? data[indexEnd].attributes.getNamedItem("name").value.substring(0,6) : itemEnd;          
          result.appendChild(makeLink(itemStartText+' - '+itemEndText, 'qf.update(\'range'+itemStart+itemEnd+'\',\'col2\',\''+itemStart.toLowerCase()+'-'+itemEnd.toLowerCase()+'\');','','range'+itemStart+itemEnd));
          index = indexEnd; 
          nbPage = nbPage + 1;           
        }
        // Finally it happens sometimes that even if the number of result is greater than the number of item per page, one page is enough
        // for example we have 53 jobs, and itemPerPage=50, with two ranges like "Ba-Bu" and "Bu-Bu" (with 3 jobs), it would be better to handle all of them as a single set
        // so we return null. Typically in this case we would populate col3 with the job titles
        if (nbPage == 1) {
          result = null;
        }
      } 
      if (item == 'leftArrow') result.appendChild(makeLeftArrow());
      if (item == 'rightArrow') result.appendChild(makeRightArrow());
    }
    if (toColumn == 'col3'){
      if ((item != 'leftArrow') && (item != 'rightArrow')){
        startBound = item.charCodeAt(1);
        endBound = item.charCodeAt(4);
        for (index=0;index<data.length;index++){
          job2ndLetterCode = data[index].attributes.getNamedItem("name").value.toLowerCase().charCodeAt(1);
          if ((job2ndLetterCode >= startBound) && (job2ndLetterCode <= endBound)) {
            result.appendChild(makeLink(data[index].attributes.getNamedItem("name").value, 'qf.update(\''+escape(data[index].attributes.getNamedItem("name").value)+'\',\'col3\',\''+data[index].attributes.getNamedItem("id").value+'\',\''+escape(data[index].attributes.getNamedItem("name").value)+'\');','',data[index].attributes.getNamedItem("name").value));
          }
        }
      }
      if (item == 'leftArrow') result.appendChild(makeLeftArrow());
      if (item == 'rightArrow') result.appendChild(makeRightArrow());
    }
    if (toColumn == 'col4'){
      if ((item != 'leftArrow') && (item!= 'rightArrow')){
        switch (pageId){
          case '103':
            dataJobDetail = xmlJobDetail.getElementsByTagName('jobname');  
            if (dataJobDetail.length != 0) result.appendChild(makeJobTitle(dataJobDetail));
            dataJobDetail = xmlJobDetail.getElementsByTagName('OccupationSalaryImage');
            if (dataJobDetail.length != 0) result.appendChild(makeImg('http://www.careers.govt.nz/image/data/'+dataJobDetail[0].attributes.getNamedItem("file").value));
            
            jobLinks = document.createElement('div');
            jobLinks.setAttribute('id','jobLinks');
            //jobLinks.setAttribute('href','http://www.careers.govt.nz/default.aspx?id0=103&id1='+item)
            
            dataJobDetail = xmlJobDetail.getElementsByTagName('content');  
            if (dataJobDetail.length != 0) jobLinks.appendChild(makeJobDescription(dataJobDetail));
            jobLinks.appendChild(makeImg('fileadmin/images/gui/btn_ReadJobInfo.png',dms_url+'default.aspx?id0=103&id1='+item));
            jobLinks.appendChild(makeSpacer());
            jobLinks.appendChild(makeLink('Related courses','',dms_url+'default.aspx?id0=30103&id1='+item,'relatedCourses'));
            result.appendChild(jobLinks);
            ajaxRequest('col3', item, '80103');
            break;
          case '80103':
            dataJobDetail = xmlJobDetail.getElementsByTagName('related-industry');
            code='';
            if (dataJobDetail.length != 0) {
              for (i=0; i<dataJobDetail.length; i++)
                if (dataJobDetail[i].attributes.getNamedItem("isPrimary").value == 1) {
                  code = dataJobDetail[i].attributes.getNamedItem("code").value;
                  name = dataJobDetail[i].attributes.getNamedItem("name").value;
                }
              jobLinks.appendChild(makeSpacer());
              $('jobLinks').appendChild(makeLink(name,'',dms_url+'default.aspx?id0=104&id1='+code,'relatedIndustry'));
              result.appendChild(jobLinks);
            }
            break;
        }
      }
      if (item == 'leftArrow') result.appendChild(makeLeftArrow());
      if (item == 'rightArrow') result.appendChild(makeRightArrow());
    }
    return result;
  }
  
  populate = function(toColumn,HTMLCode,parentTag){
 
    switch (toColumn){
      case 'col2':$('qf-col2-content').appendChild(HTMLCode);delayedScrollBarRefresh(false, true, false, false);break;
      case 'col3':$('qf-col3-content').appendChild(HTMLCode);delayedScrollBarRefresh(false, false, true, false);break;
      case 'col4':$(parentTag).appendChild(HTMLCode);delayedScrollBarRefresh(false, false, false, true);break;
    }
  }
  
  newDocument = function() {
      if (document.implementation && document.implementation.createDocument) {
          // W3C standard way 
          return document.implementation.createDocument("","", null);
      }
      else { //IE wat
          var doc = new ActiveXObject("MSXML2.DOMDocument");
          return doc;
      }
  }
  
  
  loadAsync = function(url,fromColumn,item,pageId) {	      
      switch (pageId) {
        case '103':
        case '80103':xmlJobDetail = newDocument();break;
        default:xmlJobAZ = newDocument();break;
      }
      // If we created the XML document using createDocument, use
      // onload to determine when it is loaded
      req = false;
      // branch for native XMLHttpRequest object
      if(window.XMLHttpRequest && !(window.ActiveXObject)) {
        try {
          req = new XMLHttpRequest();
        } catch(e) {
          req = false;
        }
      // Otherwise, use onreadystatechange as with XMLHttpRequest
      } else if(window.ActiveXObject) {
        switch (pageId) {
          case '103':
          case '80103':xmlJobDetail.onreadystatechange = function() {if (xmlJobDetail.readyState == 4) {handleAjaxResult(fromColumn,item,pageId);};};xmlJobDetail.load(url);break;
          default:xmlJobAZ.onreadystatechange = function() {if (xmlJobAZ.readyState == 4) {handleAjaxResult(fromColumn,item,pageId);};};xmlJobAZ.load(url);break;
        }
      }
      if(req) {
          req.onreadystatechange = function() {
          if (req.readyState == 4) {  
            // only if "OK"
            if (req.status == 200) {
              switch (pageId) {
                case '103':
                case '80103':xmlJobDetail = req.responseXML;handleAjaxResult(fromColumn,item,pageId);break;
                default:xmlJobAZ = req.responseXML;handleAjaxResult(fromColumn,item,pageId);break;
              }
            } else alert("There was a problem retrieving the XML data:\n" + req.statusText);
          }
        }
  		  req.open("GET", url, true);
  		  req.send(null);
      }
  } 
  
  ajaxRequest = function(fromColumn, item, pageId){
    var id0='';
    var id1='';
    var id3='';
    if (fromColumn=='col1') {
      id0='id0=03';
      id1='&id1='+item;
    }
    if (fromColumn=='col3') {
      id0='id0='+pageId;
      id1='&id1='+item;
    }
    url = 'http://www2.careers.govt.nz/fileadmin/scripts/getXML.php?'+id0+id1+id3;
    if (window.location.hostname =='www.careers.govt.nz') {
  	 url = 'http://www.careers.govt.nz/default.aspx?'+id0+id1+'&xml=1';
  	}
  	loadAsync(url,fromColumn,item,pageId);
  }
  
  
  handleAjaxResult = function(fromColumn, item, pageId) {
    switch (fromColumn) {
      case 'col1':
        data=xmlJobAZ.getElementsByTagName('job');
        // If the number of result is greater than the number of item per page, we will probably need a list of ranges in col2
        if (data.length>itemPerPage) {          
          // "generate" returns null for col2 when there is just a single page, so we populate col3 with the jobs without populating col2
          if (generate('col2',item) != null) {
            populate('col2',generate('col2',item));
            populate('col3',generate('col3','leftArrow'));
            if ((propagate == true) && (range != '')) {
              idRange = 'range'+range.toUpperCase().substring(0,1)+range.substring(1,2)+range.toUpperCase().substring(3,4)+range.substring(4,5);
              this.update(idRange, 'col2', range, jobTitle, true);
            } else propagate = false;
          } else {
            populate('col2',generate('col2','rightArrow'));
            populate('col3',generate('col3',item+'-!'+item+'~'));
            if ((propagate == true) && (jobTitle != '')) {
              this.update(jobTitle, 'col3', jobId, jobTitle, true);
            } else propagate = false;
          }
        } else {
          // Here there is not enough result to create ranges of letters so we populate col3 with job titles
          populate('col2',generate('col2','rightArrow'));
          populate('col3',generate('col3',item+'-!'+item+'~'));
          if ((propagate == true) && (jobTitle != '')) {
              this.update(jobTitle, 'col3', jobId, jobTitle, true);
            } else propagate = false;
        }
        break;
      case 'col3':
        switch (pageId) {
          case '103':populate('col4',generate('col4',item, pageId),'qf-col4-jobSummary');break;
          case '30103':populate('col4',generate('col4',item, pageId),'qf-col4-relatedCourses');break;
          case '80103':populate('col4',generate('col4',item, pageId),'qf-col4-relatedIndustry');break;
        }
        break;
    }
  }
  
  
  createCookie = function(name,value,days) {
  	if (days) {
  		var date = new Date();
  		date.setTime(date.getTime()+(days*24*60*60*1000));
  		var expires = "; expires="+date.toGMTString();
  	}
  	else var expires = "";
  	document.cookie = name+"="+escape(value)+expires+"; path=/";
  }
  
  readCookie = function(name) {
  	var nameEQ = name + "=";
  	var ca = document.cookie.split(';');
  	for(var i=0;i < ca.length;i++) {
  		var c = ca[i];
  		while (c.charAt(0)==' ') c = c.substring(1,c.length);
  		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
  	}
  	return null;
  }
  
  eraseCookie = function(name) {
  	createCookie(name,"",-1);
  }
  
  getUrlParam = function(name) {
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec(window.location.href);
    if( results == null )
      return "";
    else
      return unescape(results[1]);
  }
  
  
  scrollBarRefresh = function(col1,col2,col3,col4) {
    if (col1 == true) scrollbar_col1.recalculateLayout();
    //if (col2 == true) scrollbar_col2.recalculateLayout();   
    if (col3 == true) {scrollbar_col3.recalculateLayout();scrollbar_col3.scrollTo(0);}
    //if (col4 == true) {scrollbar_col4.recalculateLayout();scrollbar_col4.scrollTo(0);}
  }
  
  delayedScrollBarRefresh = function(col1,col2,col3,col4){
    setTimeout('scrollBarRefresh('+col1+','+col2+','+col3+','+col4+')',0);
  }
  
  if (getUrlParam('qf') == 'on') {
    if (getUrlParam('col1') != "") createCookie('letter',getUrlParam('col1'));
    if (getUrlParam('col2') != "") createCookie('range',getUrlParam('col2'));
    if (getUrlParam('col3') != "") createCookie('jobId',getUrlParam('col3'));
    if (getUrlParam('jobTitle') != "") createCookie('jobTitle',getUrlParam('jobTitle').replace(/\+/," "));
  }  
  letter=readCookie('letter') != null ? readCookie('letter'):'';
  range=readCookie('range') != null ? readCookie('range'):'';
  jobId=readCookie('jobId') != null ? readCookie('jobId'):'';
  jobTitle=readCookie('jobTitle') != null ? readCookie('jobTitle'):'';
  
  if (letter != '') {
    propagate = true;
    this.update('qf-letter'+letter,'col1', letter, jobTitle, true);
  }
  scrollbar_col1 = new Control.ScrollBar('qf-col1-content','scrollbar_track_col1');
  scrollbar_col1.scrollTo(0);
  scrollbar_col2 = new Control.ScrollBar('qf-col2-content','scrollbar_track_col2');
  scrollbar_col2.scrollTo(0);
  scrollbar_col3 = new Control.ScrollBar('qf-col3-content','scrollbar_track_col3');
  scrollbar_col3.scrollTo(0);
   
}

var periodicalId;

function periodicalExecuter(object,target,delta){
  currentWidth = parseInt($(object).style.width.substring(0,$(object).style.width.length-2));
  nextWidth = currentWidth + delta;
  if (delta>0) {
    if (nextWidth>=target) {
      nextWidth=target;
      stopExecuter();
      $('qf-panel').style.display = 'none';
    }
  } else if (nextWidth<=target) {
      nextWidth=target;
      stopExecuter();
  }
  $('realpeople').style.width = (916-22-nextWidth >= 0) ? 916-22-nextWidth+'px' : '0px';
  try {$('rl_object').style.width = (916-22-nextWidth >= 0) ? 916-22-nextWidth+'px' : '0px';} catch(error) {}
  try {$('rl_embed').style.width = (916-22-nextWidth >= 0) ? 916-22-nextWidth+'px' : '0px';} catch(error) {}
  $('qf-container').style.width = nextWidth+'px';
  $('qf-wrapper').style.width = nextWidth+'px';
  $('qf-panel').style.opacity = (nextWidth*-1/662)+(1+232/662); 
  $('qf-panel').style.filter = 'alpha(opacity='+ (((nextWidth*-1/662)+(1+232/662))*100) + ')';  
  
}

function stopExecuter(){
  clearInterval(periodicalId);
}

function moveTo(numCol) {
  var interval = 25;
  if(!$('qf-box')){return;}
  switch (numCol){
    case 0:newWidth = 916;break;
    case 1:newWidth = 232;$('qf-panel').style.display = 'inline';break;
  }
  currentWidth = parseInt($('qf-container').style.width.substring(0,$('qf-container').style.width.length-2));
  (newWidth < currentWidth) ? delta=-60 : delta=60;
  periodicalId = setInterval("periodicalExecuter('qf-container',newWidth,delta);",interval);
}

function onHover(object) {
  object.className = object.className==''? 'over':'current';
}

function onOut(object) {
  object.className = object.className=='over'? '':'current';
}

function readStatus() {
	var nameEQ = "status=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function forceReveal(){
  try {$('realpeople').style.width = '0px';} catch(error) {}
  try {$('rl_object').style.width = '0px';} catch(error) {}
  try {$('rl_embed').style.width = '0px';} catch(error) {}
  $('qf-container').style.width = '916px';
  $('qf-wrapper').style.width = '916px';
  $('qf-panel').style.display = 'none'; 
}

function onLoaded(revealed) {  
  //Uncomment the following lines to get qf to open automatically when ones gets back to the page and left qf open.
  /*if ((readStatus() == 'on') && (revealed == 0)) {
    moveTo(0);
    setTimeout("if (typeof(qf) == 'undefined') qf=new quickFind();",1000);
  }*/
  if (revealed == 1) { 
    forceReveal();
    qf=new quickFind();
  }
}

function setStatusOn() {
  	expires = "";
  	document.cookie = "status=on"+expires+"; path=/";
}

function setStatusOff() {
  	expires = "";
  	document.cookie = "status=off"+expires+"; path=/";
}
