function addToCart(drid) {
	var quantity = $("#quantity" + drid).val();
	document.location = DR_addToCart_URL + '/productID.' + drid + '/quantity.' + quantity;
}
// Fix background image flickering in IE
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) { }

var DD_belatedPNG;

/* Special search behavior */
var Search = {
  prompt: "Search", // default value - should get real value from markup
  init: function() { this.prompt = jQuery('#search').focus(this.focus).blur(this.blur).val(); },
  focus: function() { if (this.value == Search.prompt) { this.value = ''; } },
  blur: function() { if (this.value.length == 0) { this.value = Search.prompt; } }
};

jQuery(function() {
  Search.init();
});

// Convert on-tabbed display into tabbed display and activate tabs
$(document).ready(function() {
	if ($('body').printPageOn())
		return;
	var $tabs = $('div.tabs');
	var $tabnav = $tabs.find('ul.tabNav');
	if ($tabs.length > 0 && $tabnav.length == 0) {
		$tabnav = $tabs.prepend('<ul class="tabNav selfClear"></li>').find('> ul');

		// top link breaks tabs
		$('p.topLink').hide();
		
		$tabs	.find('> div')
			.each( function(i) {
				var id = this.id;
				var $h2 = $(this).find('h2:first');
				var title = $h2.attr('title') || $h2.html();
				$tabnav.append('<li><a href="#' + id + '" class="noPopup"><span><em>' + title + '</em></span></a></li>');
				$h2.remove();
			});
		// Need delay for browsers to get their DOM in order
		setTimeout(function() {
			$tabs.tabs();
			$('a.tabLink').click(function() { // bind click event to link
				$tabs.tabs('select', this.hash);
				return false;
			});

 		}, 500);
	}
});

$(document).ready(function() {
	$('a.glossary')	.wrap('<span class="glossary"></span>')
									.parent()
									.append('<img src="/images/common/glossary-icon.gif" alt="Glossary Term" width="16" height="13" />')
									.end()
									.filter(function() { return $('body.popup').length == 0; } )
									.popupwindow( {height: 400, width: 680, menubar: 0, toolbar: 0, 'location': 0} );
});

$(document).ready(function() {
	$('table.resources').find('span.html').each(function(i){
		$(this).parent().next().find('span').text('View Now');
	});
	$('table.resources').find('a.html').each(function(i){
		$(this).find('span').text('Go There');
	});
	if ($('#MainChannel').height() < 1000)
		$('p.topLink').hide();
});

$(document).ready(function() {
	$("a[href*='#todo']").addClass('todoLink');
});

$(function() {
	// open new window for external links and pdfs
	$('a[href^=http://]')
		.not($('a.dl'))
		.not($('ul.tabNav a'))
		.not($('#SearchResults a'))
		.filter(function() { return $(this).parents('#FooterWrapper').length == 0; } )
		.filter(function() { return $(this).parents('#SiteTools').length == 0; } )
		.after('<img src="/images/common/external-icon.gif" alt="Off-site Link" width="16" height="13" />')
		.end()
		.not($('a.noPopup'))
		.popupwindow(); // Fully qualified links
	$('a[href^=https://]')
		.not($('a.dl'))
		.not($('ul.tabNav a'))
		.after('<img src="/images/common/external-icon.gif" width="16" height="13" />')
		.end()
		.not($('a.noPopup'))
		.popupwindow(); // Secure HTTP connection links
	$('a[href$=.pdf]').popupwindow(); // PDFs by URL
	$('a.popup').popupwindow(); // specific links
	$('a#PrintPage').popupwindow( { menubar: 0, toolbar: 0 } );
	$('#Content a')	.not($('div.eventList a, div.eventCalendar a, #Breadcrumbs a, p.topLink a, a.tabLink'))
									.printPage( { postPrintHandler: function() { $('html').addClass('print'); window.print(); }});
	// Fix site logo PNG 
	if (DD_belatedPNG)
		DD_belatedPNG.fix('#SiteId img');
	
	$('.processInfographic').hover(function() { $(this).find('img.large').show(); }, function() { $(this).find('img.large').hide(); });
});

/* Clients map */
function initialize_map() {
	var latlng = new google.maps.LatLng(47.87214396888731,-108.984375);
	var myOptions = {
		zoom: 3, 
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
	setMarkers(map, offices); 
}

var offices = [  
	['Anchorage', 61.2180556, -149.9002778, 1],
	['Birmingham', 33.5206608, -86.80249, 2],
	['Huntsville', 34.7303688, -86.5861037, 3],
	['Mobile', 30.6943566, -88.0430541, 4],
	['Montgomery', 32.3668052, -86.2999689, 5],
	['Chandler', 33.3061605, -111.8412502, 6],
	['Mesa', 33.4222685, -111.8226402, 7],
	['Phoenix', 33.4483771, -112.0740373, 8],
	['Scottsdale', 33.5092103, -111.8990327, 9],
	['Tempe', 33.414768, -111.9093095, 10],
	['Tucson', 32.2217429, -110.926479, 11],
	['Aliso Viejo', 33.6083566, -117.7453312, 12],
	['Antelope', 38.708236,-121.329951, 13],
	['Atwater', 37.3477174, -120.609084, 14],
	['Auburn', 38.8965654, -121.0768901, 15],
	['Berkeley', 37.8715926, -122.272747, 16],
	['Brisbane', 37.6807661, -122.3999715, 17],
	['Burbank', 34.1808392, -118.3089661, 18],
	['Calabasas', 34.1577833, -118.6384203, 19],
	['Camarillo', 34.2163937, -119.0376023, 20],
	['Campbell', 37.2871651, -121.9499568, 21],
	['Commerce', 34.0005691, -118.1597929, 22],
	['Concord', 37.9779777, -122.0310733, 23],
	['Covina', 34.0900091, -117.8903397, 24],
	['Cupertino', 37.3229978, -122.0321823, 25],
	['Cypress', 33.8169599, -118.0372852, 26],
	['Diamond Springs', 38.6946259, -120.8149355, 27],
	['Dominguez Hills', 33.864722,-118.256111, 28],
	['El Segundo', 33.9191799, -118.4164652, 29],
	['Emeryville', 37.831316, -122.2852473, 30],
	['Fairfield', 38.2493581, -122.0399663, 31],
	['Foothill Ranch', 33.6864093, -117.6608836, 32],
	['Foster City', 37.5585465, -122.2710788, 33],
	['Fremont', 37.5482697, -121.9885719, 34],
	['Fresno', 36.7477272, -119.7723661, 35],
	['Gold River', 38.6262937, -121.2466156, 36],
	['Hayward', 37.6688205, -122.0807964, 37],
	['Hercules', 38.0171441, -122.2885808, 38],
	['Herndon', 38.9695545, -77.3860976, 39],
	['Hillsboro', 39.1611586, -89.4936989, 40],
	['Irvine', 33.6694649, -117.8231107, 41],
	['Lake Forest', 33.6469661, -117.689218, 42],
	['Long Beach', 33.7669623, -118.1892348, 43],
	['Los Angeles', 34.0522342, -118.2436849, 44],
	['Menlo Park', 37.4538274, -122.1821871, 45],
	['Milpitas', 37.4282724, -121.9066238, 46],
	['Monterey', 36.6002378, -121.8946761, 47],
	['Mountain View', 38.0088105, -122.1174648, 48],
	['Oakland', 37.8043722, -122.2708026, 49],
	['Oceanside', 33.1958696, -117.3794834, 50],
	['Palo Alto', 37.4418834, -122.1430195, 51],
	['Pasadena', 34.1477849, -118.1445155, 52],
	['Petaluma', 38.232417, -122.6366524, 53],
	['Pleasant Hill', 37.9479786, -122.0607963, 54],
	['Pleasanton', 37.6624312, -121.8746789, 55],
	['Rancho Cordova', 38.5890723, -121.302728, 56],
	['Redwood City', 37.4852152, -122.2363548, 57],
	['Redwood Shores', 37.53188,-122.248022, 58],
	['Richmond', 37.9357576, -122.3477486, 59],
	['Riverside', 33.9533487, -117.3961564, 60],
	['Sacramento', 38.5815719, -121.4943996, 61],
	['San Bruno', 37.6304904, -122.4110835, 62],
	['San Diego', 32.7153292, -117.1572551, 63],
	['San Francisco', 37.7749295, -122.4194155, 64],
	['San Jose', 37.3393857, -121.8949555, 65],
	['San Mateo', 37.5629917, -122.3255254, 66],
	['San Rafael', 37.9735346, -122.5310874, 67],
	['San Ramon', 37.7799273, -121.9780153, 68],
	['Santa Ana', 33.7455731, -117.8678338, 69],
	['Santa Barbara', 34.4208305, -119.6981901, 70],
	['Santa Clara', 37.354108, -121.9552356, 71],
	['Santa Cruz', 36.9741171, -122.0307963, 72],
	['Santa Rosa', 38.4404675, -122.7144314, 73],
	['South San Francisco', 37.654656, -122.4077498, 74],
	['Sunnyvale', 37.3688301, -122.0363496, 75],
	['Temecula', 33.4936391, -117.1483648, 76],
	['Terminal Island', 33.756963,-118.248126, 77],
	['Tustin', 33.7458511, -117.826166, 78],
	['Union City', 37.5963232, -122.0816297, 79],
	['Vacaville', 38.3565773, -121.9877444, 80],
	['Vista', 33.2000368, -117.2425355, 81],
	['Walnut Creek', 37.9063131, -122.064963, 82],
	['Westlake Village', 34.1458389, -118.8056474, 83],
	['Woodland Hills', 40.0130106, -111.6760364, 84],
	['Bloomfield', 39.0269903, -86.9375068, 85],
	['Boulder', 40.0149856, -105.2705456, 86],
	['Colorado Springs', 38.8338816, -104.8213634, 87],
	['Denver', 39.7391536, -104.9847034, 88],
	['Englewood', 39.6477653, -104.9877597, 89],
	['Fort Collins', 40.5852602, -105.084423, 90],
	['Greenwood Village', 39.6172101, -104.9508141, 91],
	['Longmont', 40.1672069, -105.1019275, 92],
	['Bloomfield', 39.0269903, -86.9375068, 93],
	['Norwalk', 41.1175966, -73.4078968, 94],
	['Rocky Hill', 41.664822,-72.639259, 95],
	['Washington', 38.8951118, -77.0363658, 96],
	['Wilmington', 39.7459467, -75.5465889, 97],
	['Boca Raton', 26.3586885, -80.0830984, 98],
	['Clearwater', 27.9658533, -82.8001026, 99],
	['Coral Gables', 25.72149, -80.2683838, 100],
	['Fort Lauderdale', 26.1223084, -80.1433786, 101],
	['Jacksonville', 30.3321838, -81.655651, 102],
	['Lake Mary', 28.7588833, -81.3178446, 103],
	['Miami', 25.7742658, -80.1936589, 104],
	['Milbourne', 28.083627,-80.608109, 105],
	['Orlando', 28.5383355, -81.3792365, 106],
	['St. Petersburg', 27.7708606, -82.6792661, 107],
	['Tallahassee', 30.4382559, -84.2807329, 108],
	['Tampa', 27.9475216, -82.4584279, 109],
	['West Palm Beach', 26.7153425, -80.0533746, 110],
	['Alpharetta', 34.0753762, -84.2940899, 111],
	['Athens', 33.960948, -83.3779358, 112],
	['Atlanta', 33.7489954, -84.3879824, 113],
	['Duluth', 34.0028787, -84.1446376, 114],
	['Fairburn', 33.5670562, -84.5810418, 115],
	['Newnan', 33.3806716, -84.7996573, 116],
	['Norcross', 33.9412127, -84.2135309, 117],
	['Honolulu', 21.3069444, -157.8583333, 118],
	['Waterloo', 42.4927641, -92.3429631, 119],
	['Boise', 43.6135002, -116.2034505, 120],
	['Batavia', 41.8500284, -88.3125738, 121],
	['Buffalo Grove', 42.1514146, -87.959794, 122],
	['Champaign', 40.1164205, -88.2433829, 123],
	['Chicago', 41.850033, -87.6500523, 124],
	['Evanston', 42.0411414, -87.6900587, 125],
	['Itasca', 41.9750288, -88.0072909, 126],
	['Naperville', 41.7858629, -88.1472893, 127],
	['Northbrook', 42.1275267, -87.8289548, 128],
	['Oakbrook Terrace', 41.8500302, -87.9645077, 129],
	['Rolling Meadows', 42.0841936, -88.0131275, 130],
	['Schaumburg', 42.0333608, -88.0834059, 131],
	['Warren', 42.4963957, -89.9895681, 132],
	['Carmel', 39.9783711, -86.1180435, 133],
	['Indianapolis', 39.7683765, -86.1580423, 134],
	['South Bend', 41.6833813, -86.2500066, 135],
	['Leawood', 38.966673, -94.6169012, 136],
	['Overland Park', 38.9822282, -94.6707917, 137],
	['Lexington', 37.9886892, -84.4777153, 138],
	['Louisville', 38.2542376, -85.759407, 139],
	['Avery Island', 29.903539,-91.910398, 140],
	['Baton Rouge', 30.4507462, -91.154551, 141],
	['Covington', 30.4754702, -90.1009108, 142],
	['Metairie', 29.9840922, -90.1528519, 143],
	['New Orleans', 29.9546482, -90.075072, 144],
	['Boston', 42.3584308, -71.0597732, 145],
	['Boxborough', 42.495533,-71.513044, 146],
	['Burlington', 42.5048167, -71.1956111, 147],
	['Cambridge', 42.375097, -71.1056079, 148],
	['Farmingham', 42.291762,-71.425894, 149],
	['Lexington', 42.4473175, -71.2245003, 150],
	['Marlborough', 42.3490930324696, -71.5454578399658, 151],
	['Shrewsbury', 42.2959267, -71.7128471, 152],
	['Springfield', 42.1014831, -72.589811, 153],
	['St. Louis', 38.6272733, -90.1978889, 154],
	['Summerville', 34.480642, -85.3477343, 155],
	['Waltham', 42.3764852, -71.2356113, 156],
	['Westborough', 42.2695387, -71.6161777, 157],
	['Westford', 42.5792583, -71.4378411, 158],
	['Westwood', 42.2139873, -71.2244987, 159],
	['Baltimore', 39.2903848, -76.6121893, 160],
	['Columbia', 39.2403841, -76.8394184, 161],
	['Frederick', 39.4142688, -77.4105409, 162],
	['Gaithersburg', 39.1434406, -77.2013705, 163],
	['Hunt Valley', 39.481217,-76.64386, 164],
	['Rockville', 39.0839973, -77.1527578, 165],
	['Dearborn', 42.3222599, -83.1763145, 166],
	['Detroit', 42.331427, -83.0457538, 167],
	['Grand Rapids', 42.9633599, -85.6680863, 168],
	['Novi', 42.48059, -83.4754913, 169],
	['Southfield', 42.4733689, -83.2218731, 170],
	['Troy', 42.6055893, -83.1499304, 171],
	['Bloomington', 44.840798, -93.2982799, 172],
	['Egan', 44.804132,-93.166886, 173],
	['Minneapolis', 44.9799654, -93.2638361, 174],
	['Minnetonka', 44.9132965, -93.5032877, 175],
	['St Paul', 44.94441,-93.093274, 176],
	['Chesterfield', 38.6631083, -90.5770675, 177],
	['Kansas City', 39.0997266, -94.5785667, 178],
	['Lee\'s Summit', 38.916343,-94.383516, 179],
	['St. Louis', 38.6272733, -90.1978889, 180],
	['Ashville', 39.7156186, -82.9529584, 181],
	['Cary', 35.79154, -78.7811169, 182],
	['Charlotte', 35.2270869, -80.8431268, 183],
	['Durham', 35.9940329, -78.898619, 184],
	['Raleigh', 35.772096, -78.6386145, 185],
	['Research Triangle Park', 35.901627,-78.866573, 186],
	['Lincoln', 40.8000011, -96.6669599, 187],
	['Omaha', 41.2586096, -95.937792, 188],
	['Manchester', 42.9956397, -71.4547891, 189],
	['Portsmouth', 43.0717552, -70.7625532, 190],
	['Bloomfield', 40.806767, -74.1854226, 191],
	['Carlstadt', 40.8403778, -74.0906974, 192],
	['Chatham', 40.7409341, -74.3837624, 193],
	['East Hanover', 40.8200998, -74.3648731, 194],
	['Edison', 40.5187154, -74.4120953, 195],
	['Elmwood', 29.9565932, -90.1897975, 196],
	['Iselin', 40.5753817, -74.3223703, 197],
	['Jersey City', 40.7281575, -74.0776417, 198],
	['Montvale', 41.0467635, -74.0229173, 199],
	['Moorestown', 39.967057,-74.942668, 200],
	['Paramus', 40.9445428, -74.0754189, 201],
	['Princeton', 40.3487181, -74.6590472, 202],
	['Roselle', 40.6642692, -74.2632022, 203],
	['South Plainfield', 40.5792701, -74.4115401, 204],
	['Wall Township', 40.164221,-74.088758, 205],
	['Wayne', 40.9253763, -74.2765368, 206],
	['Albuquerque', 35.0844909, -106.6511367, 207],
	['Las Vegas', 36.1749705, -115.137223, 208],
	['Reno', 39.5296329, -119.8138027, 209],
	['Athens', 42.2603648, -73.8095707, 210],
	['Buffalo', 42.8864468, -78.8783689, 211],
	['Garden City', 40.7267682, -73.6342955, 212],
	['Grand Island', 40.9250123, -98.3420068, 213],
	['Hopewell Junction', 41.5839824, -73.8087442, 214],
	['New York', 40.7142691, -74.0059729, 215],
	['Pearl River', 41.0589855, -74.0218063, 216],
	['Rochester', 43.1547845, -77.6155568, 217],
	['Williamsville', 42.963947, -78.7378091, 218],
	['Akron', 41.0814447, -81.5190053, 219],
	['Cincinnati', 39.1620036, -84.4568863, 220],
	['Cleveland', 41.4994954, -81.6954088, 221],
	['Columbus', 39.9611755, -82.9987942, 222],
	['Dublin', 40.0992294, -83.1140771, 223],
	['Eaton', 39.7439405, -84.6366201, 224],
	['Highland Hills', 41.4483869, -81.51901, 225],
	['Richfield', 41.2397772, -81.6381785, 226],
	['Toledo', 41.6639383, -83.555212, 227],
	['Twinsburg', 41.3125552, -81.4401129, 228],
	['Westerville', 40.1261743, -82.9290696, 229],
	['Oklahoma City', 35.4675602, -97.5164276, 230],
	['Richfield', 44.8832982, -93.2830021, 231],
	['Tulsa', 36.1539816, -95.992775, 232],
	['Beaverton', 45.487062, -122.8037102, 233],
	['Eugene', 44.0520691, -123.0867536, 234],
	['Hillsboro', 45.5228939, -122.989827, 235],
	['Lake Oswego', 45.4206749, -122.6706498, 236],
	['Portland', 45.5234515, -122.6762071, 237],
	['Tualatin', 45.3840077, -122.7639851, 238],
	['Wilsonville', 45.2998418, -122.7737062, 239],
	['Chadds Ford', 39.871777,-75.591318, 240],
	['Cranberry Township', 40.71645,-80.120526, 241],
	['Fort Washington', 40.1417761, -75.209065, 242],
	['Glen Mills', 39.919277,-75.49159, 243],
	['King of Prussia', 40.0892746, -75.3960211, 244],
	['Malford', 41.322316,-74.802388, 245],
	['Malvern', 40.0362185, -75.5138118, 246],
	['Philadelphia', 39.952335, -75.163789, 247],
	['Pittsburgh', 40.4406248, -79.9958864, 248],
	['Yardley', 40.245664, -74.8459972, 249],
	['San Juan', 26.1892409, -98.1552872, 250],
	['Columbia', 34.0007104, -81.0348144, 251],
	['Brentwood', 36.0331164, -86.7827772, 252],
	['Donelson', 36.162557,-86.669997, 253],
	['Knoxville', 35.9606384, -83.9207392, 254],
	['Memphis', 35.1495343, -90.0489801, 255],
	['Nashville', 36.1658899, -86.7844432, 256],
	['Oak Ridge', 36.0103561, -84.2696449, 257],
	['Willis', 30.4249276, -95.4799418, 258],
	['Addison', 32.96179, -96.8291685, 259],
	['Austin', 30.267153, -97.7430608, 260],
	['Coppel', 32.954569,-97.015008, 261],
	['Dallas', 32.7830556, -96.8066667, 262],
	['El Paso', 31.7587198, -106.4869314, 263],
	['Fort Worth', 32.725409, -97.3208496, 264],
	['Freeport', 28.9541368, -95.3596617, 265],
	['Frisco', 33.1506744, -96.8236116, 266],
	['Grand Prairie', 32.7459645, -96.9977846, 267],
	['Houston', 29.7632836, -95.3632715, 268],
	['Irving', 32.8140177, -96.9488945, 269],
	['Plano', 33.0198431, -96.6988856, 270],
	['Richardson', 32.9481789, -96.7297206, 271],
	['San Antonio', 29.4241219, -98.4936282, 272],
	['Waco', 31.549333, -97.1466695, 273],
	['Provo', 40.2338438, -111.6585337, 274],
	['Salt Lake City', 40.7607794, -111.8910474, 275],
	['Arlington', 38.8810112826588, -77.1042823791504, 276],
	['Dulles', 38.961746,-77.539013, 277],
	['Fairfax', 38.8462236, -77.3063733, 278],
	['Fredericksburg', 38.3031837, -77.4605399, 279],
	['Glen Allen', 37.665978, -77.5063739, 280],
	['Herndon', 38.9695545, -77.3860976, 281],
	['Manassas', 38.7509488, -77.4752667, 282],
	['McLean', 38.9342776, -77.1774801, 283],
	['Richmond', 37.5537575, -77.4602617, 284],
	['Vienna', 38.9012225, -77.2652604, 285],
	['Virginia Beach', 36.8529263, -75.977985, 286],
	['Bellevue', 47.610377, -122.2006786, 287],
	['Redmond', 47.6739882, -122.121512, 288],
	['Seattle', 47.6062095, -122.3320708, 289],
	['Spokane', 47.6587803, -117.4260466, 290],
	['Tacoma', 47.2528769, -122.4442906, 291],
	['Brown Deer', 43.1633426, -87.9645322, 292],
	['Chippewa Falls', 44.9369054, -91.3929348, 293],
	['Madison', 43.0730517, -89.4012302, 294],
	['Mequon', 43.2363956, -87.9845335, 295],
	['Milwaukee', 43.0389025, -87.9064736, 296]
];

function setMarkers(map, locations) {
	for (var i = 0; i < locations.length; i++) {
		var office = locations[i];
		var myLatLng = new google.maps.LatLng(office[1], office[2]);
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			title: office[0],
			zIndex: office[3]
		});  
	}
}

/* Initialize the Google Map */
$(document).ready(function(){
	if ($('#map_canvas:visible').length > 0)
		initialize_map();
});

var swfobject;
$(document).ready(function() {
	var $$ = $('#ServeMap');
	if ($$.length > 0 && swfobject) {
		var flashvars = { };
		var params = {
			allowFullScreen: "false",
			scale: "noscale",
			menu: "false",
			wmode: "transparent"
		};
		swfobject.embedSWF("/images/home/serve-map.swf", 'ServeMap', 126, 83, '8.0.0.0', null, flashvars, params);
	}
});

// Remove loading class that provides alternate loading color
$(window).load(function() {
	setTimeout(function() {
		$('html,body').removeClass('loading');
	}, 2000);
});