function doLogin() {
s = document.location.search;
if (s.toLowerCase().indexOf("&login") ==
-1 ) {
a = (s=="") ? "?Open&Login" : "&Login";
document.location.href += a;
}
}
function ApplyWindow(){
	theWindow = window.open('/clipper/clipperjob.nsf/Application?OpenForm','Job', 'width=550,height=650, scrollbars=Yes') 
}
function doSearch (t, s ) {
//alert(t);
var regExp1 = /\bfield\b/;
var regExp2 = /[(,),<,>,\[,\]]/;
//var searchtype = t.value;
//alert(searchtype);
var str = s.value; if ( str == "" ){ 
alert("Please be sure to enter something to search for.");
s.focus();
} else { 
if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
if ( regExp1.test( str ) || regExp2.test( str ) ){
var alrt = "Please note that you can not include:"; 
alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
alrt += "\n\nin your search query!\n\nIf you are confident that you know";
alrt += "\nwhat you are doing, then you can\nmanually produce the URL required."
s.focus();
return alert( alrt );
}
openDbRelativeURL("content/Search?OpenDocument&SearchType=" + t +"&SearchQuery=" + escape( str ));

}
}
function doAdvancedSearch (t, Country, City,CompanyName, Department, FirstName, LastName) {

openDbRelativeURL("content/Search?OpenDocument&SearchType=" + t +"&Country=" + Country + "&City=" + City + "&CompanyName=" + CompanyName + "&Department=" + Department + "&FirstName=" + FirstName + "&LastName=" + LastName);

}

//W_clock.city.options[W_clock.city.selectedIndex].value

function returnFalse(s){
//guess the field if not supplied
s = (s == null) ? document.forms[0].Query : s;

//if you want to do the search, use this line
doSearch("all", s);

//if you want to alert the user, use this line
//alert('Please use the \'Go!!\' button to do a search');

//this line should always be here!!
return false;
}

function openDbRelativeURL( url, target ){
//Check we have a target window;
target = (target == null ) ? window : target;
//Work out the path of the database;
path = location.pathname.split('.nsf')[0] + '.nsf/';
target.location.href = path + url;
}
var pathName = leftOf('/',location.pathname);
function ReplaceViewTwisties() {
  for (var i=0; i<document.images.length; i++) {
     if ((document.images[i].src.substring(document.images[i].src.length-18,document.images[i].src.length)=='/icons/ecblank.gif') ) {
    } else
    if (document.images[i].src.substring(document.images[i].src.length-19,document.images[i].src.length)=='/icons/collapse.gif') {
      document.images[i].src=pathName+'minus.gif';
      document.images[i].alt='click to collapse';
    } else
    if (document.images[i].src.substring(document.images[i].src.length-17,document.images[i].src.length)=='/icons/expand.gif') {
      document.images[i].src=pathName+'plus.gif';
      document.images[i].alt='click to expand';
    }
  } 
}
function getCookieVal (offset) {
// Reads the value of the cookie (until a ";" or EOL)
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) endstr = document.cookie.length;
  return document.cookie.substring(offset, endstr);
}
function GetCookie (name) {
// Returns the value of the cookie "name"
  var arg = name + '=';
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
       return getCookieVal (j);
    i = document.cookie.indexOf(' ', i) + 1;
    if (i == 0) break;
  }
  return false;
}
function SetCookie (name, useExpireDate, path, domain, value) {
// Deletes existing cookie
DeleteCookie(name,path,domain);
// Sets the value of the cookie "name" to value
  var expiresDate = '';
  document.cookie = name + '=' + value +
  ((useExpireDate) ? '; expires=' + expiresDate : '') +
  ((path) ? '; path=' + path : '') +
  ((domain) ? '; domain=' + domain : '');
  return GetCookie (name)
}
function DeleteCookie(name, path, domain) {
  if (GetCookie(name)!='') {
    document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
  }
}
function leftOf(smstring,lrgstring) {
//Returns leftmost characters of lrgstring up to smstring.
//If user passes an empty string, change that to a space.
  if (smstring == ""){
    smstring = " "
  }
  strlen1 = smstring.length
  strlen2 = lrgstring.length
  foundat = 0
  for (i=0;i<=strlen2;i++) {
    comp=lrgstring.substring(i-1,strlen2)
    comp = comp.substring(0,strlen1)		
    if (comp == smstring) {
      foundat = i
      break
    }
  }
  return lrgstring.substring(0,(foundat-1))
}
function rightOf(smstring,lrgstring) {
//returns the rightmost characters of lrgstring back to smstring.
//If user passes an empty string, change that to a space.
  if (smstring == ""){smstring = " "}
  strlen1 = smstring.length
  strlen2 = lrgstring.length
  foundat = 0
  for (i=strlen2;i>=0;i--) {
    comp=lrgstring.substring(i-1,strlen2)
    comp = comp.substring(0,strlen1)		
    if (comp == smstring) {
      foundat = i
      break
    }
  }
  return lrgstring.substring(foundat,255)
}
function imgSkift(imgDocID,imgObjName){
  document.images[imgDocID].src = imgObjName;
}
function popupList(type,field,openURL){
  ReturnTo(type,field);
  window.open(openURL);
}
function windowOpener(target, width, height){
controlWindow=window.open(target,"","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + "");
}
function popupImages(openURL){
  windowOpener(openURL,'800','600');
}
function ReturnTo(returnType,returnName){
  SetCookie ('ReturnTo', '', '/' ,'', returnType+'|'+returnName);
}
function rightlinksPopup(mylink, windowname)
{
	if (! window.focus)return true;
		var href;
	if (typeof(mylink) == 'string')
   		href=mylink;
	else
   		href=mylink.href;
		window.open(href, windowname, 'width=600,height=400, scrollbars=no');
return false;
}
