﻿// JScript File
var imagePath = '/images/';

var imgwhitedot = new Image();
imgwhitedot.src = "/images/wht_dot.gif";

var imgbrowndot = new Image();
imgbrowndot.src = "/images/brn_dot.gif";


/////////////////////////////////////////////////////////////
//does image swap for onmouseover and onmouseout event
/////////////////////////////////////////////////////////////
function SwapImage(obj, img)
{
    obj.src = img
    //alert(obj.src);
    //obj.src = imagePath + img
}

/////////////////////////////////////////////////////////////
//Global Variables For Use With Dynamic FlyOut Menus
/////////////////////////////////////////////////////////////
var timerID = null;
var timerOn = false;
var timecount = 400;

/////////////////////////////////////////////////////////////
//Shows Dynamic Sub Menu, Need The TD ID To Get The Correct X,Y Lccation Of TD Tag
//So We Can Place The Dynamic Sub Menu Div Element In The Correct Position
/////////////////////////////////////////////////////////////
function ShowDynamicMenu(obj, div) {
    var offsetTrail = document.getElementById(obj);
    var offsetLeft = 0;
    var offsetTop = 0;

    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    //Set Position/Visibility Of Dynamic Menu
	document.getElementById(div).style.visibility = "visible";
	document.getElementById(div).style.display = 'block';
    document.getElementById(div).style.position = 'absolute';
	document.getElementById(div).style.left = offsetLeft + 'px';	
	document.getElementById(div).style.top = offsetTop + 20 + 'px';
}

/////////////////////////////////////////////////////////////
//Set The CSS Style Of The Static MousedOver TD Cell
/////////////////////////////////////////////////////////////
function StopTime(tdCell) {
	document.getElementById(tdCell).style.cursor = "pointer";
	document.getElementById(tdCell).style.backgroundColor = "#4E6A77";
	document.getElementById(tdCell).style.color = "#FFFFFF";

	if (timerOn) {
    	clearTimeout(timerID);
        timerID = null;
        timerOn = false;
	}
}

/////////////////////////////////////////////////////////////
//Sets Dynamic MenuItems Style When MousedOver
/////////////////////////////////////////////////////////////
function DynamicMenuItemStyleHover(tdCell, img) {
	tdCell.style.cursor = "pointer";
    tdCell.style.backgroundColor = "#663300";
    tdCell.style.color = "#FFFFFF";
    //alert(img);
	document.getElementById(img).src = imgbrowndot.src;
	//document.getElementById(img).src = imagePath + 'brn_dot.gif';;
}

/////////////////////////////////////////////////////////////
//Sets Dynamic MenuItems Style When MousedOut
/////////////////////////////////////////////////////////////
function DynamicMenuItemStyle(tdCell, img) {
    tdCell.style.backgroundColor = "#e1f0b2";
    tdCell.style.color = "#663300";
   // alert(img);

	document.getElementById(img).src = imgwhitedot.src;

	//document.getElementById(img).src = imagePath + 'wht_dot.gif';
}

/////////////////////////////////////////////////////////////
//Set The CSS Style Of The Static MousedOut TD Cell
/////////////////////////////////////////////////////////////
function StartTime(tdCell) {
	document.getElementById(tdCell).style.backgroundColor = "#FFFFFF";
	document.getElementById(tdCell).style.color = "#4E6A77";
	
	if (timerOn == false) {
         timerID=setTimeout( "HideAllDynamicMenus()" , timecount);
         timerOn = true;
	}
}

/////////////////////////////////////////////////////////////
//Set The CSS Style Of The Static MousedOut TD Cell
/////////////////////////////////////////////////////////////
function StartTimeSub(tdCell, img) {
	//document.getElementById(tdCell).style.backgroundColor = "#FFFFFF";
	//document.getElementById(tdCell).style.color = "#4E6A77";
	
	if (timerOn == false) {
         timerID=setTimeout( "HideAllDynamicMenus()" , timecount);
         timerOn = true;
	}
}


/////////////////////////////////////////////////////////////
// Navigates To Supplied URL
/////////////////////////////////////////////////////////////
function NavigateURL(URL) {
	window.location = URL;
}

/////////////////////////////////////////////////////////////
//Hides All Dynamic Menus
/////////////////////////////////////////////////////////////
function HideAllDynamicMenus() {
	HideDynamicMenu('divOurBooks');
    HideDynamicMenu('divMemberLogin');
    document.getElementById('imgOurBooks').src = imagePath + 'butts_new_04.gif';
    document.getElementById('imgMemberLogin').src = imagePath + 'butts_new_07.gif';
}

/////////////////////////////////////////////////////////////
//Hides Single Dynamic Menu, Used By Function HideAllDynamicMenus()
/////////////////////////////////////////////////////////////
function HideDynamicMenu(divDynamicMenu) {
    if (document.getElementById(divDynamicMenu).style.display != "none")
    {
        document.getElementById(divDynamicMenu).style.display = "none"
    }
}

//Adds Hand Pointer To Moused Over Images
function MakePointer(obj) {
	obj.style.cursor = "pointer";
}
