	if(window.event + "" == "undefined") event = null;
 	function HM_f_PopUp(){return false};
 	function HM_f_PopDown(){return false};
 	popUp = HM_f_PopUp;
 	popDown = HM_f_PopDown;

// Trick to dynamically get the file name of the displayed page.
// Hence the "file" argument is not needed.
    var homepage = 0; // default to not the home page
	var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
	var filenm = location.href.substring(dir.length,location.href.length+1);
    ulname = "www.twistedpixel.com"
// Have to use a slightly different page when it's the homepage since the index.html file
// is not in the /html directory.
	
    if (filenm.substring(0,5) == "index" || filenm == "" || filenm == ulname) homepage = 1;
 	if (homepage) {
 	   imagedir = "images";
 	   htmldir = "html/";
 	}   
 	else {   
	   imagedir = "../images";
	   htmldir = "../html/";
	} 
// alert(imagedir);
if(document.images){
  	homeon 		= new Image(); homeon.src= imagedir + "/b-homeon.gif";
 	homeoff		= new Image(); homeoff.src= imagedir + "/b-homeoff.gif";	 	 	 	
  	abouton 	= new Image(); abouton.src= imagedir + "/b-abouton.gif";
 	aboutoff	= new Image(); aboutoff.src= imagedir + "/b-aboutoff.gif";	 	
  	servon 		= new Image(); servon.src= imagedir + "/b-servon.gif";
 	servoff		= new Image(); servoff.src= imagedir + "/b-servoff.gif";
  	porton 		= new Image(); porton.src= imagedir + "/b-porton.gif";
 	portoff		= new Image(); portoff.src= imagedir + "/b-portoff.gif";	 		
  	infoon 		= new Image(); infoon.src= imagedir + "/b-infoon.gif";
 	infooff		= new Image(); infooff.src= imagedir + "/b-infooff.gif"; 	
  	contacton 	= new Image(); contacton.src= imagedir + "/b-contacton.gif";
 	contactoff	= new Image(); contactoff.src= imagedir + "/b-contactoff.gif";
 	copyon 	= new Image(); copyon.src= imagedir + "/b-copyrighton.gif";
 	copyoff	= new Image(); copyoff.src= imagedir + "/b-copyrightoff.gif";
 }
 
function flipImg(imgNam,imgTyp,onoff){
  	if(document.images){ 	
 		document.images[imgNam].src=eval(imgTyp+onoff+'.src');
  	}
}

function showPic( fn, w, h ) {
//*******************************************************************************
//	Display a window with big pic
//******************************************************************************* 
//   alert(fn + w + h)

 	setCookie("picname", fn);
 	setCookie("picwidth", w);
 	setCookie("picheight", h);
     w = w + 60; h = h + 50;  // Increase border area

	window.open("showpic.html", "newwin", "width=" + w +  ",height=" + h + ",scrollbars=yes,status=yes,resizable=yes");
}
function adshow( adfn ) {
//*******************************************************************************
//	Display a window with big add pic
//*******************************************************************************
 
 	setCookie("ad", adfn);
	window.open("adshow.html", "newwin", "width=630,height=580,scrollbars=yes,status=yes,resizable=yes");
}

function copyright() {
//*******************************************************************************
//	Display a window with copyright info
//*******************************************************************************
 //   alert("homepage=" + homepage);
 	if (homepage) {
 	   cdir = "html/";
 	}   
 	else {   
	   cdir = "";
	} 
 
	window.open(cdir + "copyright.html", "newwin", "width=300,height=400,scrollbars=yes,status=yes,resizable=yes");
}

function copyright2() {
//*******************************************************************************
//	Display a window with copyright info from Homepage
//*******************************************************************************
	window.open("html/copyright.html", "newwin", "width=300,height=400,scrollbars=yes,status=yes,resizable=yes");
}

function gateKeeper() {
    var password = prompt("Password required:", "")
    var location= password + ".shtml";
	this.location.href = location;
} 
function upload() {
	var password = prompt("Password required:", "")
	var location= password + ".html";
	this.location.href = location;
}
    
function showSite(theURL)
//*******************************************************************************
//	Display the portfolio mirror site in a new window
//*******************************************************************************
{	
	theSite = "http://www.twistedpixel.com/" + theURL 	
	 window.open(theSite, "newwin");
}
//*******************************************************************************
//	Display Email link
//*******************************************************************************
function ShowAddress(part1, part2)
{
  var addr = part1 + "@" + part2;
  var result = ("<a href='" + "mail" + "to:" + addr + "'>" + addr + "</a>")
  return result;
} 
function setCookie(name, value, expires, path, domain, secure) {
//*******************************************************************************
// Generic rtn to set a cookie.
//*******************************************************************************
       var curCookie = name + "=" + escape(value) +
           ((expires) ? "; expires=" + expires.toGMTString() : "") +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           ((secure) ? "; secure" : "");
       document.cookie = curCookie;
}
function getCookie(name) {
       var dc = document.cookie;
       var prefix = name + "=";
       var begin = dc.indexOf("; " + prefix);
       if (begin == -1) {
         begin = dc.indexOf(prefix);
         if (begin != 0) return null;
       } else
         begin += 2;
       var end = document.cookie.indexOf(";", begin);
       if (end == -1)
         end = dc.length;
       return unescape(dc.substring(begin + prefix.length, end));
     }     
function makeArray(){
    this.length = makeArray.arguments.length 
        for (var i = 0; i < this.length; i++)
        this[i + 1] = makeArray.arguments[i]
}

function randNum (num) {
    var now = new Date();                                  
    var rand = Math.round(num * Math.cos(now.getTime()));  
    if (rand < 0) rand = - rand; if (rand == 0) rand++;        
    return rand;                                           
}
