// 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.infrasave.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 = "en/";
 	   homedir = "";
 	}   
 	else {   
	   imagedir = "../images";
	   htmldir = "../en/";
	   htmldir = "";
	   homedir = "../";
	} 
// alert(imagedir);

if(document.images){
 	copyon 		= new Image(); copyon.src= imagedir + "/b-copyon.gif";
 	copyoff		= new Image(); copyoff.src= imagedir + "/b-copyoff.gif";

  	loginon 	= new Image(); loginon.src= imagedir + "/b-loginon.gif";
 	loginoff	= new Image(); loginoff.src= imagedir + "/b-loginoff.gif";
 	
 }
 
function flipImg(imgNam,imgTyp,onoff){
  	if(document.images){ 	
 		document.images[imgNam].src=eval(imgTyp+onoff+'.src');
  	}
}

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 = "en/";
 	}   
 	else {   
	   cdir = "en/";
	} 
 
	window.open("copyright.asp", "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;
}    
//*******************************************************************************
//	Display Email link
//*******************************************************************************
function ShowAddress(part1, part2)
{
  var addr = part1 + "@" + part2;
  var result = ("<a href='" + "mail" + "to:" + addr + "'>" + addr + "</a>")
  return result;
} 

function showAddr(part1, part2){
//*******************************************************************************
//	Display mailto link, hide from spam miners.
//*******************************************************************************
  if (part2 == undefined) part2 = "infrasave.com";	
  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;                                           
}
