/*
 * Copyright 2003-2004 by BMC
 * 
 * This is a collection of JavaScript functions
 * used in different places on a BMC web-site.
 * 
 */

function openWindow(url, myname, w, h, scroll, resize) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var props = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize;
	popupWin = window.open(url, myname, props);
	popupWin.focus();
}

/*** Reload the page ***/
function reloadPage() {
         if (innerWidth != origWidth || innerHeight != origHeight)
             location.reload();
             }
             

/*** This code will take care of fading link ***/
// add as many or as few messages as you would like
var msg=new Array()
//msg[0]="<CENTER>You can see more scripts like this one...</CENTER>";
//msg[1]="<CENTER>...when you visit the JavaScript Source.</CENTER>";
//msg[2]="<CENTER>Just type in \"<A href='http://javascript.internet.com/'>javascript.internet.com</A>\"</CENTER>";
msg[1]="<CENTER>Your computer can handle the rest.</CENTER>";

// set your first set of colors.  Use as many or as few as you wish.
var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff",
"8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222ff", "1111ff", "0000ff")

//set your second set of colors
// *** must have exactly the same number of colors as the array above ***
var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999",
"ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000")

//set the height of the display in pixels
high=60;

//set the width of the display in pixels
wide=350;

//set the pixel coordinates for the upper left hand corner of the display
Xpos=220;
Ypos=180;

// move the display away from the edges of the background
pad=15;

// set the background color of the display
bgcol="ffffff";

//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
//cellbg="faderbg.jpg";
cellbg="";

// set the font
fntFam="verdana,helvetica,arial";
fntSize=14;

// set how how many seconds you want the message to stay remain at totality.
pause=2.5;


// Do not edit these values below!!!

icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg="";
var cellcontent="";
pause=pause*1000;
if(cellbg.length>4){cellbg=" background="+cellbg}
else{cellbg="";}

function doPause(){
   totality=false; t=setTimeout("changecolor()",pause);
   }
function initiate(){
   getContentColor();
   getMsg();
   getCellContent();
   if(document.all){
   msgbg.innerHTML=cellcontent;
   msgfade.innerHTML=theMsg;
   msgbg.style.posLeft=Xpos;
   msgbg.style.posTop=Ypos;
   msgfade.style.posLeft=Xpos+pad;
   msgfade.style.posTop=Ypos+pad;
   t=setTimeout("changecolor()",50);}
   if(document.layers){
   document.msgbg.document.write(cellcontent);
   document.msgbg.document.close();
   document.msgfade.document.write(theMsg);
   document.msgfade.document.close();
   document.msgbg.left=Xpos;
   document.msgbg.top=Ypos;
   document.msgfade.left=Xpos+pad;
   document.msgfade.top=Ypos+pad;
   t=setTimeout("changecolor()",100);}
   }
function changecolor(){
   if(totality==true){doPause();}
   else{
   getMsg();
   getContentColor();
   if(document.all){
   msgfade.innerHTML=theMsg;
   t=setTimeout("changecolor()",50);}
   if(document.layers){
   document.msgfade.document.write(theMsg);
   document.msgfade.document.close();
   t=setTimeout("changecolor()",70);}
   }
   }
function getFadeColor(){
   icolor=icolor-1;
   if(mcolor==1){contentcolor=colors1[icolor];}
   else{contentcolor=colors2[icolor];}
   }
function getGlowColor(){
   icolor=icolor+1;
   if(mcolor==1){contentcolor=colors1[icolor];}
   else{contentcolor=colors2[icolor];}
   }
function changemsg(){
   if(imsg==msg.length-1){imsg=0; mcolor=1;}
   else if(imsg != msg.lenght-1 && mcolor==1){imsg=imsg+1; mcolor=0;}
   else{imsg=imsg+1; mcolor=1;}
   }
function getContentColor(){
   if(icolor==colors1.length-1 && glowing==true){
   getFadeColor(); glowing=false; totality=true;}
   else if(icolor < colors1.length && glowing==true){
   getGlowColor();}
   else if(icolor < 1 && glowing==false){changemsg(); getGlowColor(); glowing=true;}
   else{getFadeColor();}
   }
function getMsg() {
   theMsg="<span style='font-size:"+fntSize+"pt; font-family:"+fntFam+"; width:"+spWidth+";'>"
   theMsg+="<B><font color="+contentcolor+">"+msg[imsg]+"</font></B> "
   theMsg+="</span>"
   }
function getCellContent(){
   cellcontent="<TABLE height="+high+
   " width="+wide+" bgcolor="+bgcol+" cellpadding=0 cellspacing=0><TR><TD"+cellbg+"> </TD></TR></TABLE>"}
/***********************************************************************************************?

/*** This will take care of openning a hypertext description ***/
function findLivePageWidth() {
	if (window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth;
	return (null);
}


function popUp(evt,objectID){
	if (isDHTML) { // Makes sure this is a DHTML browser
		var livePageWidth = findLivePageWidth();
		//alert(livePageWidth);
		domStyle = findDOM(objectID,1);
		dom = findDOM(objectID,0);
		state = domStyle.visibility;
		if (dom.offsetWidth) elemWidth = dom.offsetWidth;
		else { if (dom.clip.width)	elemWidth = dom.clip.width; }
		if (state == "visible" || state == "show")  { domStyle.visibility = "hidden"; }
		else {
			if (evt.pageY) { //Calculates the position for Navigator 4 
				topVal = evt.pageY + 4;
				leftVal = evt.pageX - (elemWidth / 2); 
			}
			else { 
				if (evt.y) { // Calculates the position for IE4
					topVal = evt.y + 4 + document.body.scrollTop;
					leftVal = evt.x - (elemWidth / 2) + document.body.scrollLeft;
				}
			}
		/*If the element goes off the page to the left, this moves it back */
			if(leftVal < 2) { leftVal = 2; }
			else { 
				if ((leftVal + elemWidth) > livePageWidth) { leftVal = leftVal - (elemWidth / 2); }
			}
			domStyle.top = topVal; // Positions the element from the top
			domStyle.left = leftVal; // Positions the element from the left
			domStyle.visibility = "visible"; // Makes the element visible 
		}
	}
}

//*** Will select a checkbox if user clicks on a text next to it ***/
function changeBox(cbox) {
box = eval(cbox);
box.checked = !box.checked;
}

/****** This is to make application form textfield required ***/
function checkFilled(textfield) {
     if (textfield.value.length == 0) {
        alert("The field \"" + textfield.name + "\" is required. Please provide information.");
        textfield.focus();
        textfield.select();
        return false;
     }
     return true;
  }

function validateForm(theForm) {

        if (theForm.realname.value.length == 0){
        alert("The field \"" + realname + "\" is required. Please provide information.");
        theForm.realname.focus();
        theForm.realname.select();
	event.returnValue=false;
	}else{ return true;}
	
	if (theForm.email.value.length == 0){
	        alert("The field \"" + email + "\" is required. Please provide information.");
	        theForm.email.focus();
	        theForm.email.select();
		event.returnValue=false;
	}else{ return true;}
	
	if (theForm.address.value.length == 0){
	        alert("The field \"" + address + "\" is required. Please provide information.");
	        theForm.address.focus();
	        theForm.address.select();
		event.returnValue=false;
	}else{ return true;}
	
	if (theForm.city.value.length == 0){
	        alert("The field \"" + city + "\" is required. Please provide information.");
	        theForm.city.focus();
	        theForm.city.select();
		event.returnValue=false;
	}else{ return true;}
	
	if (theForm.zip.value.length == 0){
	        alert("The field \"" + realname + "\" is required. Please provide information.");
	        theForm.zip.focus();
	        theForm.zip.select();
		event.returnValue=false;
	}else{ return true;}







	if (
	theForm.CHECKBOX_1.checked == false &&
	theForm.CHECKBOX_2.checked == false &&
	theForm.CHECKBOX_3.checked == false) 
	{
		alert ('You didn\'t choose any of the checkboxes!');
		return false;
	} else { 	
		return true;
	}
}
