
function getRandomImage(){
	//what is the id off the rotator image we're looking for?
	var randomImageID = "randomImg";
	
	//find that image in the document
	var theRandomImage = document.getElementById(randomImageID);
	
	//set the root location where the images are found
	var imageRoot = "/assets/";
	
	//create an array of images to be pulled from
	randomImages = new Array();
	randomImages[randomImages.length] = new Array(imageRoot + "DSC7573.jpg","Workers examining a blueprint.");
	randomImages[randomImages.length] = new Array(imageRoot + "DSC7760.jpg","A group of CFS employees.");
	randomImages[randomImages.length] = new Array(imageRoot + "DSC9958.jpg","An electrical engineer working on a breaker box.");
	randomImages[randomImages.length] = new Array(imageRoot + "DSC9995.jpg","A CFS employee taking a measurement.");
	
	//if an image with the correct id is found, swap out its src 
	//with a randomly selected one from the above array.
	if(theRandomImage){
		var rand=Math.round(Math.random()*(randomImages.length-1));
		theRandomImage.src = randomImages[rand][0];
		theRandomImage.alt = randomImages[rand][1];
	}
}
//run the random image function on every page load. 
//It only works if an image is found with the appropriate id.
window.onload = getRandomImage;

 /*-----------------------------------------------------------------------------------*/

// The following function is used to create mailto links in an effort to thwart 
//email harvesting spam-bots.
function generate_mailto_link( username, domain ) {
	var atsign = "&#64;";
	var addr = username + atsign + domain;
	document.write( 
		"<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" +
		addr +
		"<\/a>");
}

// function to encode mailto links
function safe_mailto(username,domain,text) {
	var atsign = "&#64;";
	var addr = username + atsign + domain;
	if (!text) {
		var text = addr;
	}
	document.write( 
		"<" + "a" + " " + "h" + "r" + "e" + "f" + "=" + "m" + "a" + "i" + "l" + "t" + "o" + ":" + addr + ">" +
		text +
		"<\/a>");
}

// used to snap window to image size
function PopupPic(sPicURL) {
     window.open( "/snaptoimage.html?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200");
} 


// open popup window
function openPopup(URL, name, ww, hh) {
	var xcoord, ycoord, popWidth, popHeight, popName;
	
	xcoord = 0;
	ycoord = 0;
	
	if(name != null) {
		popName = name;
	}
	else {
		popName = "popup";
	}
	
	if(ww != null) {
		popWidth = ww;
	}
	else {
		popWidth = 460;
	}
	
	if(hh != null) {
		popHeight = hh;
	}
	else {
		popHeight = 580;
	}
	
	if(document.getElementById) {
		xcoord = Math.round((screen.availWidth - popWidth) / 2);
		ycoord = Math.round((screen.availHeight - popHeight) / 2);
	}
	
  myPopup = window.open(URL,popName,'width=' + popWidth + ',height=' + popHeight + ',left=' + xcoord + ',top=' + ycoord + ',directories=no,menubar=yesn,status=no,resizable=1,scrollbars=yes');
  if (!myPopup.opener) {
		myPopup.opener = self;
	}
	
	myPopup.focus();
}


/*-- Begin vertical scroller code for homepage --------------------*/
/*-- http://www.devdude.com/tools/tool.pl -------------------------*/

//scroller width
var swidth=104;

//scroller height
var sheight=100;

//background color
var sbcolor='';

//scroller's speed
var sspeed=1;
/*
var msg=''

//Your messages go below:


msg +=

		'<ul><li><a href="http://www.erikscull.com" target="_blank" title="">Mon Jun 16,  2008</a></li>'+
		'<li>NUMBER 1</li>'+
		'<li> </li></ul>'+                     
		

'';

//End of your messages
*/

// Begin the ticker code

var resumesspeed=sspeed
function start() {
				//alert("started");
				if (document.all) iemarquee(ticker);
				else if (document.getElementById)
								ns6marquee(document.getElementById('ticker'));
}

function iemarquee(whichdiv){
				iediv=eval(whichdiv)
				//sheight += 50;
				iediv.style.pixelTop=sheight
				//iediv.innerHTML=msg 
				sizeup=iediv.offsetHeight
				ieslide()
}

function ieslide(){
				if (iediv.style.pixelTop>=sizeup*(-1)){
								iediv.style.pixelTop-=sspeed
								setTimeout("ieslide()",100)
				}
				else{
								iediv.style.pixelTop=sheight
								ieslide()
				}
}

function ns6marquee(whichdiv){
				ns6div=eval(whichdiv)
				//sheight += 50;
				ns6div.style.top=sheight + "px";
				//ns6div.innerHTML=msg
				sizeup=ns6div.offsetHeight
				ns6slide()
}
function ns6slide(){
				if (parseInt(ns6div.style.top)>=sizeup*(-1)){
								theTop = parseInt(ns6div.style.top)-sspeed
								ns6div.style.top = theTop + "px";
								setTimeout("ns6slide()",100)
				}
				else {
								ns6div.style.top = sheight + "px";
								ns6slide()
				}
}