function mainmenu(){
$("#nav ul").css({display: "none"}); // Opera Fix
$("#nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(400);
		},function(){
		$(this).find('ul:first').slideUp(400);//css({visibility: "hidden"});
		});
}

 $(document).ready(function(){
	mainmenu();
});

$(document).ready(function() {
	var adjustheight = 92;
	$("#adjust").toggle(function() {
			$('#mytext').css('height', 'auto').css('overflow', 'visible');
			$(this).text("<< Less");
		}, function() {
			$('#mytext').css('height', adjustheight).css('overflow', 'hidden');
			$(this).text("More >>");
	});
});

function detailSwitch(id, tab) {
	$(".contents").slideUp('slow');
	$(".tabLink").removeClass("on");
	$("#" + tab).addClass("on");
	$("#" + id).delay(500).slideDown('slow');
	return false;
}

function showProductReviewPopup(id) {
	var productId = escape(id);
	var formurl = "https://forms.netsuite.com/app/site/crm/externalcustrecordpage.nl?compid=606684&formid=1&h=d96f3136b1d0e66acb5e";
	window.open(formurl + "&productId=" + productId, "productReview", "toolbar=0, status=1, menubar=0, location=0, scrollbars=1, resizable=1,width=600,height=400");
	return false;
}

function scaleSize(maxW, maxH, currW, currH){
	var ratio = currH / currW;
	if(currW >= maxW && ratio <= 1){
		currW = maxW;
		currH = currW * ratio;
	} else if(currH >= maxH){
		currH = maxH;
		currW = currH / ratio;
	}
	return [currW, currH];
}


/* ############ 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;
}
