
var AgntUsr = navigator.userAgent.toLowerCase();
var DomYes = (document.getElementById)?1:0;
var NavYes = (AgntUsr.indexOf('mozilla') != -1 && AgntUsr.indexOf('compatible') == -1)?1:0;
var ExpYes = (AgntUsr.indexOf('msie') != -1)?1:0;
var Opr5 = (AgntUsr.indexOf('opera 5')!= -1 || AgntUsr.indexOf('opera/5') != -1)?1:0;
var DomNav = (DomYes && NavYes)?1:0;
var DomExp = (DomYes && ExpYes)?1:0;
var Nav4 = (NavYes && !DomYes && document.layers)?1:0;
var Exp4 = (ExpYes && !DomYes && document.all)?1:0;

var randomnumber = Math.round(Math.random() * 100000);
var contentblock = 0;

//-----------------------------------------------------------------------------
//code for search function in masthead
function checkform (form) {
  if (form.ss.value == "") {
    alert( "Please enter a term in the search box." );
    form.ss.focus();
    return false ;
  }
	return true ;
}

//-----------------------------------------------------------------------------
//code to pop-up a window
function openWin(theURL, winName, features) {
  window.open(theURL, winName, features);
}

//-----------------------------------------------------------------------------
//code for email pop-up window
var myrl = location.href;
var daurl = ("http://costest.construction.com/cest/emailus/form2.asp?rd="+myrl);
function maillink(p) {
	window.open(p,'mail','width=617,height=561,scrollbars=yes,toolbar');
}

//-----------------------------------------------------------------------------
function jumpMenu (target,selObj,restore) {
  if (selObj.selectedIndex > 0 && selObj.options[selObj.selectedIndex].value != '') {
    window.open(selObj.options[selObj.selectedIndex].value,target);
  }
  else if (selObj.options[selObj.selectedIndex].value == '') {
    selObj.selectedIndex = 0;
  }
  if (restore)
    selObj.selectedIndex = 0;
}

//-----------------------------------------------------------------------------
function skipTo (obj) {
  location.href = "#" + obj[obj.selectedIndex].value;
  return false;
}

//-------------------------------------------------------
function navimage (environment, strurl) {
	var site = "";
	if (environment > ""){
	  site = environment;
	}
	if (strurl.indexOf("news") > -1) {
	  document.imgnews.src = site + "/images/topnav_news_on.gif";
	}
	else if (strurl.indexOf("features") > -1) {
	  document.imgfeatures.src = site + "/images/topnav_features_on.gif";
	}
	else if (strurl.indexOf("projects") > -1) {
	  document.imgprojects.src = site + "/images/topnav_projects_on.gif";
	}
	else if (strurl.indexOf("products") > -1) {
	  document.imgproducts.src = site + "/images/topnav_products_on.gif";
	}
	else if (strurl.indexOf("people") > -1) {
	  document.imgpeople.src = site + "/images/topnav_people_on.gif";
	}
	else if (strurl.indexOf("opinions") > -1) {
	  document.imgopinions.src = site + "/images/topnav_opinions_on.gif";
	}
	else if (strurl.indexOf("resources") > -1) {
	  document.imgresources.src = site + "/images/topnav_resources_on.gif";
	}
	else {
	  document.imghome.src = site + "/images/topnav_home_on.gif";
	}
}

//-------------------------------------------------------
function ad(p, r) {
  var num = Math.round(Math.random() * 10000000);
  var ord = "<a href='http://" + p + "jump" +  r + "ord=" + num + "?'><img src='http://" + p + "ad" + r + "ord=" + num + "?' border='0'></a>";
  return ord;
} 

//-------------------------------------------------------
function openprintable(page) {
 OpenWin = window.open(page, "CtrlWindow", "resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no ,height=500,width=657");
}


//-------------------------------------------------------
//Pop-up window code, see prod docs for instructions


var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 200  // default, pixels from screen left to window left
var d_winTop = 200   // default, pixels from screen top to window top
winName = "popWin" + winCount++ //unique name for each pop-up window
closePopWin()           // close any previously opened pop-up window
if (openPopWin.arguments.length >= 4)  // any additional features? 
winFeatures = "," + winFeatures
else 
winFeatures = "" 
if (openPopWin.arguments.length == 6)  // location specified
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth 
       + ",height=" + winHeight + winFeatures)
}

// close pop-up window if it is open 
function closePopWin(){    
if (navigator.appName != "Microsoft Internet Explorer" 
  || parseInt(navigator.appVersion) >=4) //do not close if early IE
if(popWin != null) if(!popWin.closed) popWin.close() 
}

//optional code below is for old browsers

function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}

function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation =  ",screenX=" + winLeft + ",left=" + winLeft	
            + ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
