$(document).ready( function() { $('.lightbox').lightbox(); } );
function triggerThumbClick(o) { $("#more-image").children().eq(0).click(); }

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 () {
		$('#rsp_subs_div').slideUp();
        dynamItLoad(dURL+'catalog.sub_search&rsp='+$("#rsp").val(), 'rsp_subs', '', '', function () {
            var manID = $("#rsm").val();
            if ($('#rsp_subs option').length > 1) $('#rsp_subs_div').slideDown();
            dynamItLoad(dURL+'catalog.ajax_rsm&rsm='+manID+"&rsp="+$("#rsp").val(), 'rsm', '', '', '');
        });
    });
    $("#rsp_subs").change(function () {
		dynamItLoad(dURL+'catalog.ajax_rsm&rsm='+$("#rsm").val()+"&rsp="+$("#rsp").val()+"&rsp_subs="+$("#rsp_subs").val(), 'rsm', '', '', '');
    });
    $("#rsm").change(function () {
        dynamItLoad(dURL+'catalog.ajax_rsp&rsm='+$("#rsm").val()+"&rsp="+$("#rsp").val(), 'rsp', '', '', '');
        dynamItLoad(dURL+'catalog.sub_search&rsm='+$("#rsm").val()+'&rsp='+$("#rsp").val(), 'rsp_subs', '', '', '');
    });
    $("#produ select").keyup(function (evt) {if (evt.keyCode == 13) $("#produ").submit();});
});

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) {

		$("#territoryMap").find('a').css('color', '#29599C');
		if( p != 'office1' && p != 'office2' && p != 'office3' && p != 'office4' && p != 'office5' && p != 'hq') {
				$("#territoryMAP").attr('src', '/img/territory-map-' + p + '.jpg');
				$("#" + p + " a").css('color', 'white');
		}
		$('#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 == 'curren') {
		$('#bubble #name').html("Jason Curren");
		$('#bubble #email').html("jcurren@rodem.com");
		$('#bubble #office').html("");
		$('#bubble #cell').html("c: 717-480-6060");
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Jason Curren" />');
	}


	if(p == 'goebel') {
		$('#bubble #name').html("Greg Goebel");
		$('#bubble #email').html("ggoebel@rodem.com");
		$('#bubble #office').html("&nbsp;");
		$('#bubble #cell').html("c: 812-456-1396");
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Greg Goebel" />');
	}

	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 == 'grunenwald') {
		$('#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("Brett Deemer");
		$('#bubble #email').html("bdeemer@rodem.com");
		$('#bubble #office').html("o: 800.543-7312 Ext. 159");
		$('#bubble #cell').html("c: 484.667.0746");
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Brett Deemer" />');
	}

	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 == 'trischler') {
		$('#bubble #name').html("Bill Trischler");
		$('#bubble #email').html("btrischler@rodem.com ");
		$('#bubble #office').html("o: 513-922-6140");
		$('#bubble #cell').html("c: 513-260-8179");
		$('#bubble').append('<img class="salesmen-thumb" src="../img/salesmen-thumbs/placeholder.jpg" alt="Bill Trischler" />');
	}

	if(p == 'falconbury' || p == 'falconbury2') {
		$('#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("5641 Merchants Center Drive Suite 102<br/>Knoxville, TN 37912<br/>(800) 778-0023 (Toll Free)<br/>(865) 312-7280<br/>(865) 687-7288 (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 == 'office5') {
		$('#bubble #name').html("Atlanta Office");
		$('#bubble #full').html("4420 South Lee St. Suite 114<br/>Buford, GA 30518<br/>(800) 928-8848 (Toll Free)<br/>(678) 804-7147<br/>(678) 889-4190 (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() {
	$("#territoryMap").find('a').css('color', '#29599C');
	$("#territoryMAP").attr('src', '/img/territory-map.jpg');
	$("#bubble").hide();
}



function addToCart(model, product) {
	dynamItSend( dURL + 'cart.quantity&f=add&quantity=1&subtypeID=' + product );
}

function requestQuote(product) {
	dynamItLoad( dURL + 'cart.quote_req_dialog&p=' + product, '', 397, 400, '');
}
