// functions.js -OMEGA WEBSITE ONLY !!!

var NS=false;
if (navigator.appName=="Netscape")NS=true;

function do_NSmsg(){
 version = parseFloat(navigator.appVersion);
 if (navigator.userAgent.indexOf("Netscape6") > 0){
 alert("Sorry .. this function only works with IE 5+\n   You are running Netscape 6");
}
else{
 alert("Sorry .. this function only works with IE 5+\n   You are running Netscape ver."+version);
}
}

//function playSound(){
   // do nothing for now;
//}

var aysounds = new Array();
aysounds[0] = "media/click-1.au";
aysounds[1] = "media/mini.wav";
aysounds[2] = "media/boing.au";
aysounds[3] = "media/radar.au";
aysounds[7] = "media/phaser.wav";
aysounds[5] = "media/tunein.wav";
aysounds[6] = "media/bark.au";
aysounds[4] = "media/infobar.wav";
aysounds[8] = "media/beep.wav";

var cookieVal;  
function getSoundcookie(){  
  cookieVal = getCookie("UserSound");
  if (cookieVal == null) {
    cookieVal="OFF";
	delCookie("UserSound");
    setCookie("UserSound",cookieVal);
  }
}

function playSound(s) {
if (!document.all)return;
 var cookieVal = getCookie("UserSound");

     if(cookieVal == "OFF")return;

 soundfil=aysounds[s];

 document.all.mysound.src = soundfil;
}



function closeWin() {
  window.close();
}
// add this in <HEAD> of document...
//if (window.Event) document.captureEvents(Event.ONCLICK);
//document.onclick = closeWin;
//<font FACE="arial" color="red" size="1">[Click and blank spot on this page to close Window]</font>
// or paste this whole part into document

function  show_loading_time(pgTmp) {
var to_time = new Date();
to_time = to_time.getTime();
var secs = (to_time - from_time) /1000;
window.status="Omega Chemical Company -- "+ pgTmp + ":    Total loading time "+secs + " seconds"; 
}

function on_page_loaded(pgName) {
 show_loading_time(pgName);
}

function create_bookmark(){
 if(NS){alert ("In Netscape please press Ctrl-B for bookmarks");
        return;
		}
  var url="http://http://216.253.104.213/";
  var title="Omega Chemical Co. web site";
  window.external.AddFavorite(url,title);
}

function changeto(form) {
   var myindex=form.select1.selectedIndex;
   if (form.select1.options[myindex].value != 0) {
   location=form.select1.options[myindex].value;}
}

function LmOver(elem, bfilename)
   {elem.background = "img/buttons/"+bfilename;
    elem.children.tags('A')[0].style.color = "#FFFFFF";}

function LmOut(elem, bfilename)
   {elem.background = "img/buttons/"+bfilename;
    elem.children.tags('A')[0].style.color = "#FFFFFF";}

function surfto(form) {
        var pageindex=form.dest.selectedIndex;
        window.open(form.dest.options[pageindex].value, target="_self");  
}


function resize_window(){
  if(NS)do_NSmsg();return;
  var  newLeft = 0;
  var newTop = 0;
  var newWidth =  800;
  var newHeight = 800;
    
 if (screen.width >= 800){
   newWidth = 800;
   newLeft = (screen.Width  - 800)/2;
   }
  else {
   newWidth = screen.Width;
   newLeft=0;
  }

if (screen.height >= 800){
   newHeight = 800;
   newTop = (screen.Height -800)/2;
   document.body.topMargin = 12;
   }
  else {
   newHeight = screen.Height;
   newTop=0;
  }
  self.resizeTo (newWidth,newHeight); 
  self.moveTo(newLeft,newTop);

  alert ("Your browser has been resized to " + newWidth + " x " + newHeight + " and \n\ncentered to fit your screen resolution of " + screen.Width + " x " + screen.Height +".");
}


function jumpMenu(){
location=document.jump.menu.options[document.jump.menu.selectedIndex].value;
}


function scroll_banner(msg,ctrlwidth) {
   // Pad message and bring to width of textbox.
   for (i=0;i<=ctrlwidth;i++){msg=" "+msg}
   // Set up the form and form field.
  
   rollmsg() //Get the banner rolling
 // REMOVED [weather] rollmsg1() //Get the banner rolling
}

//This function makes the message scroll through the text box.
function rollmsg() {
   nowMsg=document.scrollbanner.scrollBox.value
   nowMsg=nowMsg.substring(1,nowMsg.length)+nowMsg.substring(0,1)
   document.scrollbanner.scrollBox.value=nowMsg
   myTimer=setTimeout("rollmsg()",50) 
}
function rollmsg1() {
   nowMsg=document.scrollbanner.scrollBox1.value
   nowMsg=nowMsg.substring(1,nowMsg.length)+nowMsg.substring(0,1)
   document.scrollbanner.scrollBox1.value=nowMsg
   myTimer1=setTimeout("rollmsg1()",175) 
}



function delCookie (name) {
var expireNow = new Date();
document.cookie = name + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

function showCookie(){
 var tcookie=document.cookie;
 alert("Cookie= "+tcookie);
}

// Heinle's function for retrieving a cookie.
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;    
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}



  function setCookie(name, value) { // use: setCookie("name", value);
	var today = new Date();
    var expiry = new Date(today.getTime() + 90 * 24 * 60 * 60 * 1000); // plus 90 days
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString()
   
  }
  
  function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}


  
  


// Last Modified date
function lastModified(){
var months = new Array(13);
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";

var dateObj = new Date(document.lastModified)
var lmonth = months[dateObj.getMonth() + 1]
var fyear = dateObj.getYear()
var date = dateObj.getDate()

if (fyear<=99)
  fyear= "19"+fyear;

if ((fyear>99) && (fyear<2000))
 fyear+=1900;

    document.write("Last updated on:" + " &nbsp;" + lmonth + " " + date + ", " + fyear)
}


var NS4=false;
if(navigator.appName == "Netscape")NS4 = true;

function getImageXfromLeft(imgID) {
  if (NS4) return eval(imgID).x
  else return getRealLeft(imgID);
}

function getImageYfromTop(imgID) {
  if (NS4) return eval(imgID).y
  else return getRealTop(imgID);
}
function getRealLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;


  	while (tempEl != null) {

  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
		
  	}
	return xPos;
}

function getRealTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}
function doBrowserName(){
var userAgent=navigator.userAgent+"\n";
var appName=navigator.appName+"\n";
var appVersion=navigator.appVersion
alert("navigator.userAgent = "+userAgent+"navigator.appName = "+appName+"Version = "+appVersion)
}

function clock(){
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";

if (nhours>=12) AorP="PM"; 
 else  AorP="AM";
if (nhours>=13) nhours-=12;
if (nhours==0)  nhours=12;
if (nsecn<10) nsecn="0"+nsecn;
if (nmins<10) nmins="0"+nmins;
if (nhours<10) nhours="0"+nhours;
document.clockform.timebox.value=nhours+": "+nmins+": "+nsecn+" "+AorP;
setTimeout('clock()',1000);
} 

function scroll_banner(msg,ctrlwidth) {
   // Pad message and bring to width of textbox.
   for (i=0;i<=ctrlwidth;i++){msg=" "+msg}
   // Set up the form and form field.
  
   rollmsg() //Get the banner rolling
 // REMOVED [weather] rollmsg1() //Get the banner rolling
}

//This function makes the message scroll through the text box.
function rollmsg() {
   nowMsg=document.scrollbanner.scrollBox.value
   nowMsg=nowMsg.substring(1,nowMsg.length)+nowMsg.substring(0,1)
   document.scrollbanner.scrollBox.value=nowMsg
   myTimer=setTimeout("rollmsg()",50) 
}
function rollmsg1() {
   nowMsg=document.scrollbanner.scrollBox1.value
   nowMsg=nowMsg.substring(1,nowMsg.length)+nowMsg.substring(0,1)
   document.scrollbanner.scrollBox1.value=nowMsg
   myTimer1=setTimeout("rollmsg1()",175) 
}
