var timeout	= 300;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id){	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose(){
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime(){
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime(){
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 




/* ############ BEGIN AUTOMATED HOMEPAGE BANNER ROTATOR ############## */

// Next Button functionality
function nextAd() {
	if (loc == adNum - 1) {
		newLoc = 0;
	} else {
		newLoc = parseInt(loc) + 1;
	}
	pos = newLoc * wide * -1;
	$("#mainWindow .adContent").animate({'marginLeft': pos + 'px'}, 500);
	loc = newLoc;
	setLinks();
	clearInterval(rotateTimer);
	rotateTimer = setInterval("nextAd()", 8000);
}

// Previous Button functionality
function prevAd() {
	if (loc == 0) {
		newLoc = adNum - 1;
	} else {
		newLoc = parseInt(loc) - 1;
	}
	pos = newLoc * wide * -1;
	$("#mainWindow .adContent").animate({'marginLeft': pos + 'px'}, 500);
	loc = newLoc;
	setLinks();
	clearInterval(rotateTimer);
	rotateTimer = setInterval("nextAd()", 8000);
}

// Direct link functionality
function indexGo(link) {
	var me = $(link).attr('rel');
	pos = me * wide * -1;
	$("#mainWindow .adContent").animate({'marginLeft': pos + 'px'}, 500);
	loc = me;
	clearInterval(rotateTimer);
	rotateTimer = setInterval("nextAd()", 8000);
}

// Change the links to show which is active
function setLinks() {
	$("#banControls a").removeClass("on");
	$("#banControls a[rel=" + loc + "]").addClass("on");
}

/* ############ END AUTOMATED HOMEPAGE BANNER ROTATOR ############## */


function getValue(num)
{
    var noJunk = ""
    var withDollar = ""
    var foundDecimal = 0
    var foundAlphaChar = 0
    num += "";

    if (num == "") { return(0); }
    for (i=0; i <= num.length; i++)
    {
        var thisChar = num.substring(i, i+1);
        if (thisChar == ".")
        {
          foundDecimal = 1;
          noJunk = noJunk + thisChar;
        }
        if ((thisChar < "0") || (thisChar > "9"))
        {
          if ((thisChar != "$") && (thisChar !=".") && (thisChar != ",") && (thisChar != " ") && (thisChar !="")) foundAlphaChar = 1;
        }
        else 
 {
    withDollar = withDollar + thisChar
    noJunk = noJunk + thisChar
 }

 if ((thisChar == "$") || (thisChar == ".") || (thisChar == ","))
 {
   withDollar = withDollar + thisChar
 }
  }
     if (foundDecimal) { return parseFloat(noJunk); }
     else if (noJunk.length > 0) { return parseFloat(noJunk); }
     else return 0;
}
