<!--
//-----------------------------------------------
//Title : Common.js 
//Desc  : Javascript code used 
//        throughout the DPC 
//        Internet site 
//        (Domino hosted)
//-----------------------------------------------



//-----------------------------------------------
//Globals
//-----------------------------------------------

String.prototype.trim = function() {
return this.replace(/^\s*/,"").replace(/\s*$/,"");
}


//-----------------------------------------------
//END Globals
//-----------------------------------------------



//----------------------------------
//Title  : modClass
//Date   : 1/8/03
//Author : Fletcher Davidson(DTF)
//Desc   : Modify a class value for a
//         given elements id
//----------------------------------

curid ="";
function modClass(objId){

         if (document.getElementById) {

            if (curid != objId ){
               //turn off the last element that was turned on
               if (curid !=""){
                  obj = document.getElementById(curid);
               //classSwap(obj, "tbnavitembar","tbnavitembaron");
               classChange(obj, "tbnavitembar");
            }
            }

            //turn on this element
            obj = document.getElementById(objId);

         //classSwap(obj, "tbnavitembar","tbnavitembaron");
         classChange(obj, "tbnavitembaron");

         curid = objId;
      }else{
         window.status ="dHTML incapable browser";
      }
}

function classChange(obj,newClass){
   obj.className = newClass
}

function classSwitch(obj,class0,class1){
   if (obj.className == class0){
      obj.className = class1;
   }else{
      obj.className = class0;
   }
}
//------------
//End modClass
//------------


//------------------------------------------------------
//Title  : simpleSearch
//Date   : x/9/03
//Author : Fletcher Davidson(DTF)
//Desc   : Assist the simple search function in main nav
//------------------------------------------------------

function simpleSearch(searchText,db){
   
   
   if(searchText.length>0 && searchText != "Keyword Search"){   
      searchVal = SearchConvertString(searchText);;
      proto = window.location.protocol;
      host = window.location.hostname;
      url = proto+"//"+host+"/"+db+"/SearchView!SearchView&1=~&2=~&3=~&stype=~&Query="+searchVal+"&Start=1&Count=20&SearchOrder=1&SearchWV=TRUE&SearchMax=0&SearchThesaurus=FALSE&SearchType=FullText"
      window.location = url;
   }else{
      window.status = "No text entered for search";
   }
}
//----------------
//End simpleSearch
//----------------



//------------------------------------------------
//Title  : printLinks
//Date   : x/9/03
//Author : Fletcher Davidson(DTF)
//Desc   : Print the links on 
//         document listings in WebInterprise.
//
//         override_l3 is used when the listing 
//         document is a internal link, published 
//         to a listing it forces the breadcrumbs 
//         to display the correct values.
//------------------------------------------------
function printLinks(pre,url,post, override_l3){
   
   if (override_l3.length == 0){
      
      l3_link = document.forms.bcVals.l3.value;
   }else{
      l3_link = override_l3;
   }
   
   pre = pre.replace(/\{/g, "\'");
   pre = pre.replace(/\}/g, "\'");
   pre = pre.replace(/\|/g, "\"");
   
   //alert("{"+pre +" }   { "+url+" }   { "+post+" }   { "+override_l3+"} therefore: {"+l3_link+"}");
   sRtn  = url+"&1="+document.forms.bcVals.l1.value;
   sRtn  += "~&2="+document.forms.bcVals.l2.value;
   sRtn  += "~&3="+l3_link+"~";   
   
   return pre+"'"+sRtn+"'"+post;
   
   
}

function evenOrOdd(num){
   return num % 2;
}
//--------------
//End printLinks
//--------------


//----------------------------------
//Title  : writeLink
//Date   : 1/8/03
//Author : Fletcher Davidson(DTF)
//Desc   : Write the current url with 
//         additional qs values
//         (Printer Friendly/Top)
//----------------------------------
function writeLink(qs,append,attribs){
   proto=window.location.protocol;
   host=window.location.hostname;
   path=window.location.pathname;
   prehtml = "<a href=\"";
   posthtml = "\" "+attribs+">";

   return prehtml+proto+"//"+host+path+qs+append+posthtml;
}
//--------------------
//End writeLink
//--------------------


//----------------------------------
//Title  : rnd
//Date   : Unknown
//Author : MG(sourced)
//Desc   : Return a random img name
//----------------------------------
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
}

function randImg(number, ImgName) {
        randVal = Math.ceil(rnd()*number);
        return ImgName + randVal + '.gif';
}
//----------------
//End rnd 
//----------------



//----------------------------------
//Title  : evenOrOdd
//Date   : 2/8/03
//Author : FLD
//Desc   : Returns even or odd - used for alternating colours in views
//----------------------------------
function evenOrOdd(num){
	return num % 2;
}
//----------------
//End evenOrOdd
//----------------

//------------------------------------------------
//Title  : SearchConvertString
//Date   : 9/10/03
//Author : Fletcher Davidson(DTF)
//Desc   : Format the search string to include AND
//         when AND isn't specified
//------------------------------------------------
function SearchConvertString(strIn){
	var str = new String();
	str = strIn

	if (str.toLowerCase().indexOf(" and ")==-1) {
	   	if (str.toLowerCase().indexOf(" or ")==-1) {
			str = str.trim();
	   		str = str.replace(/\s+/," "); 		//multiple spaces
	   		str = str.replace(/not/g, "NOT"); 	//force lcase(not) = ucase(not)

			str = str.replace(/ /g, " AND ");
			str = str.replace(/AND NOT AND/g, " AND NOT ");
	   	}
	}
return str;
}
//------------------------------------------------
//END SearchConvertString
//------------------------------------------------

//-->

function LaunchWindow(url,id,x,y,rs,mn,sc,tb,loc,dir,st,ch) { 
	var newwind = window.open(url,id, config='height='+y+',width='+x+',toolbar='+tb+',menubar='+mn+',scrollbars='+sc+',resizable='+rs+',location='+loc+',directories='+dir+',status='+st); 
	}
