function portfolioScroll (strDirection) {
    if ((strDirection == 'left') && (intPortfolioMargin != 0)) {
        intPortfolioMargin += intShift;
        $('#ar').fadeTo('fast', 1);
        if (intPortfolioMargin == 0) {
            $('#al').fadeTo('fast', .25);
        }
    }
    if ((strDirection == 'right') && (intPortfolioMargin > -1*((intNumPortfolioItems - intNumVisibleItems) * intShift))) {
        intPortfolioMargin -= intShift;
        $('#al').fadeTo('fast', 1);
        if (intPortfolioMargin == -1*((intNumPortfolioItems - intNumVisibleItems) * intShift)) $('#ar').fadeTo('fast', .25);
    }
    if (strDirection == 'reset') {
        $('#al').fadeTo('fast', .25);
        $('#ar').fadeTo('fast', 1);
        intPortfolioMargin = 0;
        $('#slides').animate({marginLeft: intPortfolioMargin+'px'}, 'fast', 'swing');
        return;
    }
    $('#slides').animate({marginLeft: intPortfolioMargin+'px'}, 'slow', 'swing');
}

function autoPortfolioScroll () {
    if ((intPortfolioMargin > -1*((intNumPortfolioItems - intNumVisibleItems) * intShift))) {
        portfolioScroll("right");
    } else {
        portfolioScroll("reset");
    }
    animation_scroll  = setTimeout("autoPortfolioScroll()",7000);
}

function loadVideo (intAssetID) {
    dynamItLoad(dURL+'catalog.ajaxVideo&v='+intAssetID, '', 579, 429, '');
}

function doLogin() {
    dynamItCloseDialog();
    $("#user").text("My Account").attrib("href", dURL+"account.history");
}

function cart_q_update (intItemNumber, sType) {
	dynamItLoad(dURL+'cart.q_ajax&m='+intItemNumber+'&q='+$('#qty'+intItemNumber).val()+'&qtype='+sType,'c-foot', null, null, null);
}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}

$(document).ready( function () {

    $('#al').fadeTo('fast', .25);
    $("#rsp").change(function () {
        dynamItLoad(dURL+'catalog.ajax_rsm&rsm='+$("#rsm").val()+"&rsp="+$("#rsp").val(), 'rsm', '', '', '');
    });
    $("#rsm").change(function () {
        dynamItLoad(dURL+'catalog.ajax_rsp&rsm='+$("#rsm").val()+"&rsp="+$("#rsp").val(), 'rsp', '', '', '');
    });
});

var manufacturersOn = false;
var categoriesOn = false;


function allManufacturersToggle() {
	if(manufacturersOn == false) {
		$("#manufacturers input:checkbox").attr("checked", "on");
		manufacturersOn = true;
	} else {
		$("#manufacturers input:checkbox").attr("checked", "");
		manufacturersOn = false;
	}
}

function allCategoriesToggle() {
	if(categoriesOn == false) {
		$("#categories input:checkbox").attr("checked", "on");
		categoriesOn = true;
	} else {
		$("#categories input:checkbox").attr("checked", "");
		categoriesOn = false;
	}
}

function showSubnav(x) {
	hideAllSubnav(x);

	if(!$('#' + x + '_a').hasClass("open")) {
		$('#' + x + '_sub').slideToggle();
		$('#' + x + '_a').addClass("open");
		if($('#' + x + '_img').attr("src") == "img/orb-nav-closed.png")
			$('#' + x + '_img').attr("src", "img/orb-nav-open.png");
		else
			$('#' + x + '_img').attr("src", "img/orb-nav-closed.png");
	}

}

function hideAllSubnav(x) {

	if(!$('#' + x + '_a').hasClass("open")) {
		$('.lh-subnav').slideUp();
		$('.open').removeClass("open");
	}
}

function subnavAppear(x) {
	$('#' + x + '_sub').show();
	$('#' + x + '_a').addClass("open");
	$('#' + x + '_img').attr("src", "img/orb-nav-open.png");
}



function moveMap(p) {

		$('#name').html("");
		$('#bubble #email').html(""); 
		$('#bubble #office').html(""); 
		$('#bubble #cell').html(""); 
		$('#bubble #full').html(""); 
		$('#bubble .salesmen-thumb').remove();

	if(p == 'reinhart') {
		$('#name').html("Chuck Reinhart");
		$('#bubble #email').html("creinhart@rodem.com"); 
		$('#bubble #office').html("o: 248-538-7143"); 
		$('#bubble #cell').html("c: 248-760-0442"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/reinhart.jpg" alt="Chuck Reinhart" />'); 
	}

	if(p == 'henline') {
		$('#name').html("Ryan Henline");
		$('#bubble #email').html("rhenline@rodem.com"); 
		$('#bubble #office').html("o: 800-996-4574"); 
		$('#bubble #cell').html("c: 419-467-8988"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Ryan Henline" />'); 
	}

	if(p == 'pritchard') {
		$('#name').html("John Pritchard");
		$('#bubble #email').html("jpritchard@rodem.com"); 
		$('#bubble #office').html("o: 800-527-7151"); 
		$('#bubble #cell').html("c: 317-417-4030"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/pritchard.jpg" alt="John Pritchard" />'); 
	}

	if(p == 'crull') {
		$('#bubble #name').html("Darrin Crull");
		$('#bubble #email').html("dcrull@rodem.com"); 
		$('#bubble #office').html("o: 800-996-4574"); 
		$('#bubble #cell').html("c: 419-973-7982"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Darrin Crull" />'); 
	}

	if(p == 'merilatt') {
		$('#bubble #name').html("Dwayne Merilatt");
		$('#bubble #email').html("dmerilatt@rodem.com"); 
		$('#bubble #office').html("o: 502-718-0575"); 
		$('#bubble #cell').html("c: 502-718-0575"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Darrin Crull" />'); 
	}

	if(p == 'zimmerman') {
		$('#bubble #name').html("John Zimmerman");
		$('#bubble #email').html("jzimmerman@rodem.com"); 
		$('#bubble #office').html("o: 800-527-7151"); 
		$('#bubble #cell').html("c: 317-445-0804"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/zimmerman.jpg" alt="John Zimmerman" />'); 
	}

	if(p == 'watkins') {
		$('#bubble #name').html("Greg Watkins");
		$('#bubble #email').html("gwatkins@rodem.com"); 
		$('#bubble #office').html("o: 330-494-2708"); 
		$('#bubble #cell').html("c: 330-730-0003"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Greg Watkins" />'); 
	}

	if(p == 'gruenwald') {
		$('#bubble #name').html("Bill Grunenwald");
		$('#bubble #email').html("bgrunenwald@rodem.com"); 
		$('#bubble #office').html("o: 412-856-4140"); 
		$('#bubble #cell').html("c: 412-292-2989"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/gruenwald.jpg" alt="Bill Gruenwald" />'); 
	}

	if(p == 'taylor') {
		$('#bubble #name').html("Ray Taylor");
		$('#bubble #email').html("rtaylor@rodem.com"); 
		$('#bubble #office').html("o: 610-530-0111"); 
		$('#bubble #cell').html("c: 610-751-0391"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/taylor.jpg" alt="Ray Taylor" />'); 
	}

	if(p == 'coffman') {
		$('#bubble #name').html("Russ Coffman");
		$('#bubble #email').html("rcoffman@rodem.com"); 
		$('#bubble #office').html("o: "); 
		$('#bubble #cell').html("c: 614-915-1901"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/coffman.jpg" alt="Russ Coffman" />'); 

	}

	if(p == 'glenn') {
		$('#bubble #name').html("Dan Glenn");
		$('#bubble #email').html("dglenn@rodem.com "); 
		$('#bubble #office').html("o: 800-543-7312"); 
		$('#bubble #cell').html("c: 513-617-8239"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/glenn.jpg" alt="Dan Glenn" />'); 
	}

	if(p == 'falconbury') {
		$('#bubble #name').html("Paul Falconbury");
		$('#bubble #email').html("pfalconbury@rodem.com"); 
		$('#bubble #office').html("o: 800-527-7151"); 
		$('#bubble #cell').html("c: 317-443-9338"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/falconbury.jpg" alt="Paul Falconbury" />'); 
	}

	if(p == 'frey' || p == 'frey2') {
		$('#bubble #name').html("Jim Frey");
		$('#bubble #email').html("jfrey@rodem.com"); 
		$('#bubble #office').html("o: 800-543-7312"); 
		$('#bubble #cell').html("c: 513-266-4618"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Jim Frey" />'); 
	}

	if(p == 'barnett') {
		$('#bubble #name').html("Tim Barnett");
		$('#bubble #email').html("tbarnett@rodem.com"); 
		$('#bubble #office').html("o: 800-543-7312"); 
		$('#bubble #cell').html("c: 513-266-7809"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/barnett.jpg" alt="Tim Barnett" />'); 
	}

	if(p == 'davis') {
		$('#bubble #name').html("Vic Davis");
		$('#bubble #email').html("vdavis@rodem.com "); 
		$('#bubble #office').html("o: 800-362-7339"); 
		$('#bubble #cell').html("c: 615-972-0381"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/davis.jpg" alt="Vic Davis" />'); 
	}

	if(p == 'baines') {
		$('#bubble #name').html("Donald Baines");
		$('#bubble #email').html("dbaines@rodem.com "); 
		$('#bubble #office').html("o: 731-668-5227"); 
		$('#bubble #cell').html("c: 731-267-9672"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/baines.jpg" alt="Donald Baines" />'); 
	}

	if(p == 'stumm') {
		$('#bubble #name').html("George Stumm");
		$('#bubble #email').html("gstumm@rodem.com"); 
		$('#bubble #office').html("o: 800-362-7339"); 
		$('#bubble #cell').html("c: 615-414-8762"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Stumm" />'); 
	}

	if(p == 'lawson') {
		$('#bubble #name').html("Ed Lawson");
		$('#bubble #email').html("elawson@rodem.com"); 
		$('#bubble #office').html("o: 423-338-8266"); 
		$('#bubble #cell').html("c: 423-584-1266"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/lawson.jpg" alt="Ed Lawson" />'); 
	}

	if(p == 'korte') {
		$('#bubble #name').html("Tom Korte");
		$('#bubble #email').html("tkorte@rodem.com"); 
		$('#bubble #office').html("o: 800-543-7312"); 
		$('#bubble #cell').html("c: 513-608-3832"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Tom Korte" />'); 
	}

	if(p == 'mason') {
		$('#bubble #name').html("Dan Mason");
		$('#bubble #email').html("dmason@rodem.com"); 
		$('#bubble #office').html("o: 800-778-0023"); 
		$('#bubble #cell').html("c: 865-257-6748"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/mason.jpg" alt="Dan Mason" />'); 
	}

	if(p == 'sommers') {
		$('#bubble #name').html("Rob Sommers");
		$('#bubble #email').html("rsommers@rodem.com"); 
		$('#bubble #office').html("o: 770-365-0193"); 
		$('#bubble #cell').html("c: 770-365-0193"); 
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/sommers.jpg" alt="Rob Sommers" />'); 
	}

	if(p == 'office1') {
		$('#bubble #name').html("Toledo Office");
		$('#bubble #full').html("12323 Williams Road<br/>Perrysburg, OH 43551<br/>(800) 996-4574 (Toll Free) (419) 873-9172<br/>(419) 873-9184 (Fax)");
	}

	if(p == 'office2') {
		$('#bubble #name').html("Indianapolis Office");
		$('#bubble #full').html("5880 West 71st Street<br/>Indianapolis, IN 46278<br/>(800) 527-7151 (Toll Free)<br/>(317) 297-0438<br/>(317) 293-8253 (Fax)");
	}

	if(p == 'office3') {
		$('#bubble #name').html("Knoxville Office");
		$('#bubble #full').html("519 Lovell Road<br/>Knoxville, TN 37932<br/>(800) 778-0023 (Toll Free)<br/>(865) 777-3620<br/>(865) 777-3624 (Fax)");
	}

	if(p == 'office4') {
		$('#bubble #name').html("Nashville Office");
		$('#bubble #full').html("136 Commerce Drive<br/>Hendersonville, TN 37075<br/>(800) 362-7339 (Toll Free)<br/>(615) 824-8812<br/>(615) 824-8835 (Fax)");
	}

	if(p == 'hq') {
		$('#bubble #name').html("Rodem Headquarters");
		$('#bubble #full').html("5095 Crookshank Road<br/>Cincinnati, OH 45238<br/>(800) 543-7312 (Toll Free)<br/>(513) 922-6140<br/>(513) 922-1680 (Fax)");
	}

	var e = dynamItMouse();
	$("#bubble").css({ left: e.pageX-18 + 'px', top: e.pageY + 'px' }).show();
}

function hideBubble() {
	$("#bubble").hide();
}
