function linkhome(){
	window.location.href = '/';
}

function getObjByName(name,doc) {
  var o = 0;
  if(!doc) doc = document;
  if(doc[name]) o=doc[name];
  if(document.all && doc.all[name]) o=doc.all[name];
  if(o) {
    if(!o.getElementsByTagName) o.getElementsByTagName = getElementsArray;
    return o;
  }
  if(document.layers) {
    for(var i=0;i < doc.layers.length;i++){
      var lyrdoc = doc.layers[i].document;
      if(lyrdoc[name]) return lyrdoc[name];
      if(lyrdoc.layers.length > 0) {
        var o = getObjByName(name,lyrdoc);
        if(o) return o;
      }
    }
  }
  return 0;
}
if(!document.getElementById) document.getElementById = getObjByName;

function getElementsArray(el) {
  if(document.layers) {
    var doc = (this == document) ? document : this.document;
    switch(el) {
      case 'img' : return doc.images;
      case 'a' : return doc.links;
      case 'div' : return doc.layers;
      case 'form' : return doc.forms;
      default : return 0;
    }
  }
  if(document.all) return this.all.tags(el);
  return 0;
}
if(!document.getElementsByTagName) document.getElementsByTagName = getElementsArray;
if(document.layers) Layer.prototype.getElementsByTagName = getElementsArray;

function show(div){
  if(document.all) window.document.all[div].style.visibility = 'visible';
  else if(document.layers) getObjByName(div).visibility = 'show';
  else document.getElementById(div).style.visibility = 'visible';
}
function hide(div){
  if(document.all) window.document.all[div].style.visibility = 'hidden';
  else if(document.layers) getObjByName(div).visibility = 'hide';
  else document.getElementById(div).style.visibility = 'hidden';
}

function swapImg() {
  if(!document.images) return;
  var args = swapImg.arguments;
  for(var i=0;i < args.length;i+=2) {
    var imgSrc = (args[i + 1].indexOf('[') != -1) ? eval(args[i + 1] + '.src') : args[i + 1];
    if(getObjByName(args[i])) getObjByName(args[i]).src = imgSrc;
  }
}


function FormSearch(t, dirn)
{	
	if (dirn == 1 && t.value == "search site...") t.value= "";
	if (dirn == 0 && t.value == "") t.value= "search site...";
}

function login_onclick(){
  	if (form1.password.value == ''){
   		alert('Password can not be blank.  Please enter a password to continue.');
   		form1.password.focus();
   		return false;
   	}
   	return true;
}

function displaymenu(whichone,state){
	var companydiv = document.getElementById('tabcompany');
	var productsdiv = document.getElementById('tabproducts');
	var servicesdiv = document.getElementById('tabservices');
	//var supportdiv = document.getElementById('tabsupport');
	
	switch(whichone){
		case 'company':
			companydiv.style.display = 'inline'; 
			break;
		case 'products':
			productsdiv.style.display = 'inline'; 
			break;
		case 'services':
			servicesdiv.style.display = 'inline'; 
			break;
		//case 'support':
		//	supportdiv.style.display = 'inline'; 
		//	break;
	}
}

function hidemenus(){
	var companydiv = document.getElementById('tabcompany');
	var productsdiv = document.getElementById('tabproducts');
	var servicesdiv = document.getElementById('tabservices');
	//var supportdiv = document.getElementById('tabsupport');
	
	companydiv.style.display = 'none';
	productsdiv.style.display = 'none';
	servicesdiv.style.display = 'none';
	//supportdiv.style.display = 'none';
}

function positionFooter(){
    if(!window.innerWidth){ //IE
        if(!(document.documentElement.clientWidth == 0)){
		    w = document.documentElement.clientWidth;
		    h = document.documentElement.clientHeight;
	    } else { //quirks mode
			w = document.body.clientWidth;
    		h = document.body.clientHeight;
	    }
    } else { // W3C
	    w = window.innerWidth;
	    h = window.innerHeight;
    }
	
	var body = document.getElementById('pageBody');
	var footer = document.getElementById('pageFooter');
	if(body.offsetHeight + 59 < h){
	    footer.style.position = 'absolute';
	    footer.style.top = String(h - 59) + 'px';
        footer.style.marginLeft = '1px';
	    body.style.height = String(h - 59) + 'px';
	    //alert('Body Height: ' + String(body.offsetHeight) + 'px\nWindow Height: ' + h + 'px');
	}
}

function setupnav(){
	//drop-down menu divs
	var companydiv = document.getElementById('tabcompany');
	var productsdiv = document.getElementById('tabproducts');
	var servicesdiv = document.getElementById('tabservices');
	//var supportdiv = document.getElementById('tabsupport');
	//navigation header link elements
	var linkhome = document.getElementById('linkhome');
	var linkcompany = document.getElementById('linkcompany');
	var linkproducts = document.getElementById('linkproducts');
	var linkservices = document.getElementById('linkservices');
	var linksupport = document.getElementById('linksupport');
	var linkcontact = document.getElementById('linkcontact');
	
	//quote box
	var quotebox = document.getElementById('quotebox');
	//nav positioning variables
	var tableW = 762;
	var windowW;
   	var marginW;
	
	//position the drop-down menus
	if (document.all){windowW = document.body.offsetWidth;} else {windowW = window.innerWidth;}
	marginW = parseFloat(((windowW - tableW) / 2));
	companydiv.style.left = parseFloat(marginW + 305) + 'px';
	productsdiv.style.left = parseFloat(marginW + 427) + 'px';
	servicesdiv.style.left = parseFloat(marginW + 504) + 'px';
	//supportdiv.style.left = parseFloat(marginW + 578) + 'px';
	
	//determine current section
	var spath = window.location.pathname; //get path name of current page
	if(spath == '/stage/'){spath = '/stage/index.asp';} //handle root path
	if(spath.lastIndexOf('/support/') == 8){
		linksupport.className = 'onLnk';
	} else {
		var filename = spath.substring(spath.lastIndexOf('/') + 1); //get the file name
		var supportflag = spath.lastIndexOf('support');
		
		var sectionfinal;
		// DT Bossle 06/11/2007 - trap for no filename in URL
		if (filename != ''){
			var tmp = filename.split('.');
			var section = tmp[0]; // get the file name without the extension
			var tmp2;
			if(section.indexOf('_') > 0){
				tmp2 = section.split('_');
				sectionfinal = tmp2[0];
			} else {
				sectionfinal = section;
			}
		} else { //homepage with no filename, ie. "http://www.selectsa.com/"
			sectionfinal = 'index';
		}
		
		// if we're in the support directory, change the header link style
		if(supportflag == 1){
			linksupport.className = 'onLnk';
		} else {
		// otherwise, determine which section we're on, and change the appropriate header link
			switch(sectionfinal){
				case 'index':
					linkhome.className = 'onLnk';
					break
				case 'company':
					linkcompany.className = 'onLnk';
					break
				case 'products':
					linkproducts.className = 'onLnk';
					break
				case 'services':
					linkservices.className = 'onLnk';
					break
				case 'contact':
					linkcontact.className = 'onLnk';
					break
			}
		}
				
		// if there is a quote box on the page, display a random quote
		//alert(sectionfinal);
		if (sectionfinal != 'index' && sectionfinal != 'contact' && sectionfinal != 'landingilta' && sectionfinal != 'promo' && supportflag != 1) {
			var quotes = new Array;
			quotes[1] = '"Ropes &amp\; Gray has significantly improved the quality of its receivables since purchasing the star*collect product. The product has allowed us to be more organized and productive in our communications with clients and lawyers, thus promoting a more efficient and professional approach."<br/><br/>Kim Spaner<br/><em>Senior Inventory Coordinator<br/>Ropes & Gray</em><br/>';
			quotes[2] = '"Select* Associates listens, they improve. They are customer oriented, they are dedicated to their product, and they provide excellent service."<br/><br/>Pierre Agnew<br/><em>Credit and Collection Manager<br/>Choate, Hall & Stewart LLP</em><br/>';
			quotes[3] = '"The staff is always very efficient with responding to any questions or problems. They\'ve got great personalities to deal with and an overall great attitude when asking for help. They\'re happy to take you step-by-step through a certain process to achieve your goal."<br/><br/>Sandy Blazejewski<br/><em>Senior Collections Coordinator<br/>White and Williams LLP<br/>';
	
			//get a random number between 1 and 3 and display that quote
			var randomquote = Math.floor(Math.random()*3) + 1;
			quotebox.innerHTML = quotes[randomquote];
		}
	}
}

