//-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o//
//
//			DROP DOWN MENUS
//
//-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o//


// New library object for dynamic layers 
// Global document object
d = window.document;
active = 0;
delay=1000;
timer = null;
loaded=false;

menuAr = new Array();
menuAr[0] = 'navAbout';
menuAr[1] = 'navService';
menuAr[2] = 'navRates';
menuAr[3] = 'navContact';


// MENU ROLLOVERS

function MROLoad(){
	MROAr = new Array();
	for (var i=0;i<menuAr.length;i++){
		MROAr[menuAr[i]] = new Array();
		MROAr[menuAr[i]]['off']=new Image();
		MROAr[menuAr[i]]['on']=new Image();
		MROAr[menuAr[i]]['off'].src="images/"+menuAr[i]+".gif";
		MROAr[menuAr[i]]['on'].src="images/"+menuAr[i]+"-on.gif";
	}
}

MROLoad();

function MRollover(which){
	document.images[which].src = MROAr[which]['on'].src;
}

function MRollout(which){
	document.images[which].src = MROAr[which]['off'].src;
}



// MENU FUNCTIONS 


if(d.layers){
	origWidth=innerWidth;
	origHeight=innerHeight;
}
// Browser detection object
function lib_bwCheck(){
	this.ver = navigator.appVersion;
	this.agent = navigator.userAgent;
	this.dom = document.getElementById?1:0;
	this.opera5 = this.agent.indexOf("Opera 5")>-1;
	this.ie5 = (this.agent.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6 = (this.agent.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0;
	this.ie = this.ie4||this.ie5||this.ie6;
	this.mac = this.agent.indexOf("Mac")>-1;
	this.ns6 = (this.dom && parseInt(this.ver)>=5)?1:0;
	this.ns4 = (document.layers && !this.dom)?1:0;
	this.bw = (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
	return this;
}
bw = new lib_bwCheck(); // Browser object

function lib_obj(obj){
	this.el = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval('document.' + obj):0;
	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
	this.moveIt = lib_moveIt;
	return this;
}

function lib_moveIt(x,y){
	this.x=x;this.y=y;this.css.left = x;this.css.top = y;
}

lib_obj.prototype.hideIt = function(){this.css.visibility = "hidden"};
lib_obj.prototype.showIt = function(){this.css.visibility = "visible"};

function changeActive(num){
	if (loaded){
		clearTimeout(timer);
		oDiv[active].hideIt();
		MRollout(menuAr[active]);
		active=num;
		oDiv[active].showIt();
		MRollover(menuAr[active]);
	}
}

function killIt(){
	if (loaded){
		oDiv[active].hideIt();
		MRollout(menuAr[active]);
	}
}

function killMenu(){
	if (loaded){
		if (arguments.length > 0) timer = setTimeout("changeActive("+arguments[0]+")",delay);
		else timer = setTimeout("killIt()",delay);
	}
}

function sleep(){
	if (loaded){
		clearTimeout(timer);
	}
}

// DHTML fix detection for Netscape browser resize
if (d.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=DHTMLfix;
}
		
// DHTML fix for Netscape browser resize
function DHTMLfix() {
	if (origWidth != innerWidth || origHeight != innerHeight) {
		location.reload();
	}
}

function fixNav(){
	if(d.all)history.go(0);
	if (d.layers) {
		DHTMLfix();
	}
}
/*
function get_xPos(){
	if(d.layers && !d.dom){
		xPos = d.layers['aObj'].pageX
	} else {
		xPos = d.all['aObj'].offsetLeft;
		tempEl = d.all['aObj'].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	return xPos
}
*/
function get_xPos(n){
	if(d.layers && !d.dom){
		xPos = d.images[lnkArr[n].name].x;
	} else {
		xPos = d.images[lnkArr[n].name].offsetLeft;
		tempEl = d.images[lnkArr[n].name].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	xPos = xPos+95;
	return xPos;
}


function get_yPos(n){
	if(d.layers && !d.dom){
		yPos = d.images[lnkArr[n].name].y;
	} else {
		yPos = d.images[lnkArr[n].name].offsetTop;
		tempEl = d.images[lnkArr[n].name].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	return yPos
}

function init(){
	bw = new lib_bwCheck(); // Browser object
	oDiv = new Array();
	for (var i=0;i<menuAr.length;i++){
		oDiv[i] = new lib_obj('sub'+i);
	}
//	for(n=0; n<oDiv.length; n++){
//		oDiv[n].moveIt(get_xPos(n),get_yPos(n))
//	}
	loaded=true;
}



//-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o//
//
//			NETSCAPE RESIZE BUG
//
//-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o//


function resizefix() {
  if (document.d.resizefix.initWindowWidth != window.innerWidth || document.d.resizefix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function resizefixCheck() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.d == 'undefined'){
      document.d = new Object;
    }
    if (typeof document.d.d_scaleFont == 'undefined') {
      document.d.resizefix = new Object;
      document.d.resizefix.initWindowWidth = window.innerWidth;
      document.d.resizefix.initWindowHeight = window.innerHeight;
    }
    window.onresize = resizefix;
  }
}

resizefixCheck();



