// JavaScript Document

var w3c = document.getElementById ? true : false;
var iex = document.all ? true : false;
var ns4 = document.layers ? true : false;

function fixNetscape(){
	if(origWidth != window.innerWidth || origHeight != window.innerHeight){
		window.location.reload();
	}	
}
if(ns4){
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
	window.onresize = fixNetscape;
}
function newImage(src){
	img = new Image();
	img.src = src;
	return img;
}
function imageSwap(img,obj,div){
	if(ns4 && div != null){
		document.layers[div].document.images[img].src = obj.src;
	}else{
		document.images[img].src = obj.src;
	}
}
function getStyle(name, nest){
	nest = nest ? 'document.'+nest+'.' : '';
	return w3c ? document.getElementById(name).style : iex ? document.all[name].style : ns4 ? eval(nest+'document.'+name) : false;
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

Menus = new Object();
var curMenu = null;

MakeMenu = function(name,left,top,rollimg,rollout,rollover,rolldiv){
	this.name = name;
	this.left = left;
	this.top = top;
	this.timer = null;
	this.rollimg = rollimg;
	this.rollout = newImage(rollout);
	this.rollover = newImage(rollover);
	this.rolldiv = (rolldiv != null) ? rolldiv : null;
	this.obj = name+'Object';
	eval(this.obj+'=this');
}
MakeMenu.prototype.show = function(){
	clearTimeout(this.timer);
	getStyle(this.name).visibility = 'visible';
	imageSwap(this.rollimg,this.rollover,this.rolldiv);
	curMenu = this.name;
}
MakeMenu.prototype.hide = function(){
	this.timer = setTimeout(this.obj+'.hideIt()',500);
}
MakeMenu.prototype.hideIt = function(){
	getStyle(this.name).visibility = 'hidden';
	imageSwap(this.rollimg,this.rollout,this.rolldiv);
}
MakeMenu.prototype.startMenu = function(){
	var html;
	if(ns4){
		html = '<layer name="'+this.name+'" left="'+this.left+'" top="'+this.top+'" z-index="1000" visibility="hidden" ';
	}else{
		html = '<div id="'+this.name+'" style="position:absolute; left:'+this.left+'px; top:'+this.top+'px; z-index:1000; visibility:hidden" ';
	}
	html += 'onMouseOver="Menus.'+this.name+'.show()" onMouseOut="Menus.'+this.name+'.hide()">';
	return html;
}
hideCur = function(){
	if(curMenu != null){
		Menus[curMenu].hideIt();
		curMenu = null;
	}
}
endMenu = function(){
	 return ns4 ? '<\/layer>' : '<\/div>';
}
createMenu = function(name,left,top,rollimg,rollout,rollover,rolldiv){
	Menus[name] = new MakeMenu(name,left,top,rollimg,rollout,rollover,rolldiv);
}

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

// object name | left position | top position | rollover image name | normal image src | rollover image src | rollover div name (optional)

createMenu('submenu1', 20,  111, 'img_1', 'http://www.medfone.com/images_v3/main_r1_c1.gif', 'http://www.medfone.com/images_v3/main_r1_c1_f2.gif');
createMenu('submenu2', 146, 111, 'img_2', 'http://www.medfone.com/images_v3/main_r1_c2.gif', 'http://www.medfone.com/images_v3/main_r1_c2_f2.gif');
createMenu('submenu3', 271, 111, 'img_3', 'http://www.medfone.com/images_v3/main_r1_c3.gif', 'http://www.medfone.com/images_v3/main_r1_c3_f2.gif');
createMenu('submenu4', 398, 111, 'img_4', 'http://www.medfone.com/images_v3/main_r1_c4.gif', 'http://www.medfone.com/images_v3/main_r1_c4_f2.gif');
createMenu('submenu5', 522, 111, 'img_5', 'http://www.medfone.com/images_v3/main_r1_c5.gif', 'http://www.medfone.com/images_v3/main_r1_c5_f2.gif');
createMenu('submenu6', 647, 111, 'img_6', 'http://www.medfone.com/images_v3/main_r1_c6.gif', 'http://www.medfone.com/images_v3/main_r1_c6_f2.gif');

// ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

