AK="Alaska";
AL="Alabama";
AR="Arkansas";
AZ="Arizona";
CA="California";
CO="Colorado";
CT="Connecticut";
DE="Delaware";
FL="Florida";
GA="Georgia";
HI="Hawaii";
IA="Iowa";
ID="Idaho";
IL="Illinois";
IN="Indiana";
KS="Kansas";
KY="Kentucky";
LA="Louisiana";
MA="Massachusetts";
MD="Maryland";
ME="Maine";
MI="Michigan";
MN="Minnesota";
MO="Missouri";
MS="Mississippi";
MT="Montana";
NC="North Carolina";
ND="North Dakota";
NE="Nebraska";
NH="New Hampshire";
NJ="New Jersey";
NM="New Mexico";
NV="Nevada";
NY="New York";
OH="Ohio";
OK="Oklahoma";
OR="Oregon";
PA="Pennsylvania";
RI="Rhode Island";
SC="South Carolina";
SD="South Dakota";
TN="Tennessee";
TX="Texas";
UT="Utah";
VA="Virginia";
VT="Vermont";
WA="Washington";
WI="Wisconsin";
WV="West Virginia";
WY="Wyoming";
AB="Alberta";
BC="British Columbia";
MB="Manitoba";
NB="New Brunswick";
NL="Newfoundland and Labrador";
NS="Nova Scotia";
NT="Northwest Territories";
NU="Nunavut";
ON="Ontario";
PE="Prince Edward Island";
QC="Quebec";
SK="Saskatchewan";
YT="Yukon";
PR="Puerto Rico";


//title 0|streetAddress 1|l 2|st 3|zip 4|mainTollFreeNumber 5|telephoneNumber 6|facsimileTelephoneNumber 7|c 8

//LDAP (LDAP Browser) Search Settings:

//Search DN:ou=Locations,o=WORLDPAC,c=US
//Filter: c=CA
//Attributes: title,postalAddress,l,st,zip,mainTollFreeNumber,telephoneNumber,facsimileTelephoneNumber,c

//Gogle map Generation
//http://maps.google.com/maps?q=2370+Walkley+Road,+Ottawa,+ON,+L5T 2G9

allData =  new Array();
locations = new Array();
locationsSorted = new Array();
var j = 0;
locations[j++] = '-|8701 Research Blvd|Austin|TX|78758||||US';
locations[j++] = '-|902 4th Street SW, STE D|Auburn|WA|98001-5205|800 892-9982|253 735-4172|253 735-4190|US';
locations[j++] = '-|1511 Adrian Road|Burlingame|CA|94010-2102|800 888-9982|510 742-8900|650 259-7945|US';
locations[j++] = '-|7008-D 5th Street SE|Calgary|AB|T2H 2G3||403 640-7386|403 252-7871|CA';
//locations[j++] = '-|3168 Airway Avenue|Costa Mesa|CA|92626|800 733-2277|310 532-9752|714 662-7551|US';
locations[j++] = '-|3123 West Alpine Street|Santa Ana|CA|92704|800 733-2277|310 532-9752|714 662-7551|US';
locations[j++] = '-|8510 Warner Avenue|Culver City|CA|90232|800 733-2277|310 532-9752|310 836-1502|US';
locations[j++] = '-|155 Raritan Center PKWY|Edison|NJ|08837-3614||732 225-7500||US';
//// 2010-03-12 - Added zero in front of zip code for google maps - John Sanders
locations[j++] = '(DC)|300 Herrod BLVD|Dayton|NJ|08810|800 631-5544|732 230-5000|732 438-9358|US';
locations[j++] = '-|3200 South Platte River Drive|Englewood|CO|80110|800 892-9982|303 792-2798|303 761-8120|US';
locations[j++] = '-|8304 A-B Merrifield Avenue|Fairfax|VA|22031|800 892-9982|703 573-4950|703 573-0398|US';
locations[j++] = '-|4525 McEwen|Farmers Branch|TX|75244|888 805-9982|972 866-8299|972 866-6612|US'; //chg to Dallas from Farmers Branch
locations[j++] = '-|6501 NW 12th Avenue|Fort Lauderdale|FL|33309|800 765-0000|954 979-5660|954 979-0159|US';
locations[j++] = '-|3930 Dunvale Road|Houston|TX|77063|800 892-9982|713 780-0192|713 780-0361|US';
locations[j++] = '(DC)|6801 Columbus Road|Mississauga|ON|L5T 2G9||905 238-9850|905 238-9387|CA';
locations[j++] = '-|20917 63rd Avenue West|Lynnwood|WA|98036-8530|800 688-9982|425 245-4975|425 774-3887|US';
locations[j++] = '(DC)|37137 Hickory Street|Newark|CA|94560-5522|800 888-9982|510 742-8900|510 742-1993|US';
//// 2010-03-12 - Added zero in front of zip code for google maps - John Sanders
locations[j++] = '-|88 Rowe Street|Newton|MA|02466|800 892-9982|617 527-8891|617 527-7886|US';
locations[j++] = '-|3035 Kingston Court|Norcross|GA|30360|800 892-9982|770 416-9944|770 416-9004|US';
locations[j++] = '-|640 85th Avenue|Oakland|CA|94621|800 892-9982|510 632-1964|510 632-1049|US';
locations[j++] = '-|4653 lb McLeod Rd|Orlando|FL|32811|800 892-9982|407 648-9197|407 648-8769|US';
//// 2010-03-12 - Added zero in front of zip code for google maps - John Sanders
locations[j++] = '-|53 W. Century Rd Suite 200|Paramus|NJ|07652|800 892-9982|201 261-7899|201 261-5818|US';
locations[j++] = '-|2821 Pomona Boulevard|Pomona|CA|91766|800 733-2277|310 532-9752|909 598-9159|US';
locations[j++] = '-|636 SE 10th Avenue|Portland|OR|97214|800 892-9982|503 234-8855|503 234-1875|US';
locations[j++] = '-|2708 Discovery Drive|Raleigh|NC|27616-1850|800 892-9982|919 876-3101|919 876-4102|US';
locations[j++] = '(DC)|140-13480 Crestwood Pl|Richmond|BC|V6V 2K1|800 644-9129|604 248-1059||CA';
locations[j++] = '-|233 Derwood Circle|Rockville|MD|20850||301 309-6615|301 309-9053|US';
locations[j++] = '-|310 Commerce Circle|Sacramento|CA|95815|800 825-9982|510 742-8900|916 614-0123|US';
locations[j++] = '-|9586 Distribution Avenue|San Diego|CA|92121|800 892-9982|858 695-2663|858 695-6841|US';
locations[j++] = '-|1705 Junction Court, STE 100|San Jose|CA|95112-1023|800 888-9982|510 742-8900|408 437-9018|US';
locations[j++] = '-|160 Paul Drive|San Rafael|CA|94903|800 892-9982|415 479-8793|415 479-8797|US';
//// 2010-03-12 - Added zero in front of zip code for google maps - John Sanders
locations[j++] = '-|69 Harbor View Avenue|Stamford|CT|06902|800 892-9982|203 359-2110|203 359-8449|US';
locations[j++] = '(Syosset)|200 Robbins Lane Suite D-6|Jericho|NY|11791|800 648-8991|732 225-7500|516 681-3323|US';
locations[j++] = '-|5440 Pioneer Park Boulevard|Tampa|FL|33634|800 892-9982|813 290-9560|813 249-2472|US';
locations[j++] = '(DC)|19688 Van Ness Ave|Torrance|CA|90501|800 733-2277|800 733-2277|714 995-5776|US';
//locations[j++] = '-|19630 Pacific Gateway Drive|Torrance|CA|90502|800 733-2277|310 532-9752|310 515-5319|US';
locations[j++] = '-|7821 Hayvenhurst Ave|Van Nuys|CA|91406|800 892-9982|818 786-0960|818 786-0863|US';
locations[j++] = '-|4855 chemin Bois Franc|St-Laurent|QC|||514 956-8222||CA'; //CHK province
locations[j++] = '-|9 Portland Road|West Conshohocken|PA|19428|800 892-9982|610 832-2522|610 832-2525|US';
locations[j++] = 'Sales Office|95 Darcy Parkway|Lathrop|CA|95330|800 888-9982|510 742-8900|209 832-4769|US';
locations[j++] = '-|12939 Alcosta Blvd|San Ramon|CA|94583||510 742-8900|925 866-0154|US';
//locations[j++] = 'Costing Location|37137 Hickory Street|Newark|CA|94560-5522||||US'; //Remove Costing location, 
locations[j++] = '-|2250 Midland Ave STE 17|Scarborough|ON|M1P 4R9||416 321-2903|416 321-0932|CA';
locations[j++] = '-|4115 Thunderbird Lane|Fairfield|OH|45014-2233||513 942-4980|513 874-1075|US';
locations[j++] = '-|4701 Cameron St|Las Vegas|NV|89103||702 871-5664|702 221-1679|US'; //Remove " S " & " STE I" in address field
locations[j++] = '-|2370 Broadway Ave|Hermitage|PA|16148||330 468-1312|724 981-2252|US';
locations[j++] = '-|23151 Alcalde Drive, STE A|Laguna Hills|CA|92653||949 470-4749||US';
locations[j++] = '-|11761 Rock Landing Drive|Newport News|VA|23606|800 892-9982|757 599-0516||US';
locations[j++] = '-|1100 New Brighton Blvd|Minneapolis|MN|55413||612 379-0940|612 623-1827|US';
locations[j++] = '-|6605 West Montrose Avenue|Chicago|IL|60634|800 892-9982|773 545-2486||US';
locations[j++] = '-|1858 E Encanto Dr Ste 103|Tempe|AZ|85281|800 892-9982|480 377-9108||US';
locations[j++] = '-|133 Mata Way, STE 104-106|San Marcos|CA|92069||760 471-1725|760 471-8539|US';
locations[j++] = '-|8500 NW 17th Street, STE 110|Miami|FL|33126|800 765-0000|954 979-5660|786 845-8036|US';
locations[j++] = '-|2370 Walkley Road|Ottawa|ON|K1G 4H9||613 216-0944|613 216-0949|CA';
locations[j++] = '-|16440 Air Center Blvd|Houston|TX|77032||281 209-2291||US';
locations[j++] = '-|1727 Whitehead Road|Woodlawn|MD|21207|800 892-9982|410 277-9750|410 277-9751|US';
locations[j++] = '-|9511 28 Ave|Edmonton|AB|T6N 1N6||780 466-0314||CA';
locations[j++] = '-|7751 Nieman Road|Shawnee|KS|66214|800 955-9982|303 792-2784|303 761-8120|US';
locations[j++] = '-|3400 Boulevard Losch|ST-Hubert|QC|J3Y 5T6||450 462-9186|450 462-3195|CA'; //CHK province
locations[j++] = '-|550 Père-Lelièvre, Vanier|Quebec City|QC|G1M 3R2||||CA'; //
locations[j++] = '-|6670 Butler Crescent|Saanichton|BC|V8M 2G8||||CA'; //
locations[j++] = '-|105-5712 192nd Street|Surrey|BC|V3S 2V7||||CA';
locations[j++] = '-|485 Commerce Park Drive SE|Marietta|GA|30060|800 892-9982|650 654-3611|650 965-4289|US';
locations[j++] = '-|2100 Handley Ederville Rd|Ft. Worth|TX|76118|800 892-9982||847 222-9475|US';
locations[j++] = '-|3134 S East Avenue|Fresno|CA|93725|800 892-9982|703 924-5903|703 924-5909|US';
locations[j++] = '-|14930 NE 95th Street|Redmond|WA|98052|800 999-9982|800 999-9982||US';
locations[j++] = '-|55-55 58th Street|Queens|NY|11378||||US';
locations[j++] = '-|7477 Dry Creek Parkway|Longmont|CO|80503||||US';
locations[j++] = '-|3424 San Fernando Avenue|Los Angeles|CA|90065||323 259-8492|323 259-6497|US';// change LA 
locations[j++] = '-|1 Aegean Drive|Methuen|MA|01844||||US';
locations[j++] = '-|9240 Langelier Blvd|St Leonard|QC|H1P 2E1||||CA';
locations[j++] = '-|45B West Wilmot St.|Richmond Hill|ON|L4B 2P3||||CA';
locations[j++] = '-|120-117 King Edward Street E.|Winnipeg|MB|R2H-0Y3||||CA';
locations[j++] = '-|170-3100 Production Way|Burnaby|BC|V5A 4R4||||CA';
locations[j++] = '-|2240 South 300 East|Salt Lake City|UT|84115||||US';
locations[j++] = '-|2821 E. Philadelphia St. Suite C|Ontario|CA|91761|800 888-9982|800 888-9982|909 930-9727|US';
locations[j++] = '-|2001 N. Congress Ave.|West Palm Beach|FL|33404||561 845-8063|561 845-8071|US';
locations[j++] = '-|2010 Southern Drive|Columbia|SC|29201|800 999-9982||803 758-5141|'; // No Country - special processing - no map location yet
locations[j++] = '-|710 East State Parkway|Schaumburg|IL|60173|800 999-9982|919 424-8847|847 884-3945|US';
locations[j++] = '-|105 Clark Drive|East Berlin|CT|06023||919 424-8864|860 828-3084|US';
locations[j++] = '-|209 Constitution Drive|Menlo Park|CA|94025||||US';
locations[j++] = '-|10230 Page Industrial Blvd, Bldg. B, |St. Louis|MO|63132|800 888-9982 Ext. 7631||314 426-2024|US';
locations[j++] = '-|4216 Stuart Andrew Boulevard|Charlotte|NC|2028217||||US';
locations[j++] = '-|417 Brick Church Park Drive|Nashville|TN|37207||||US';
locations[j++] = '-|1500 Dell Avenue|Campbell|CA|95008||||US';
locations[j++] = '-|4902 Perrin Creek Unit 750|San Antonio|TX|78217||||US';
locations[j++] = '-|Luchetti Industrial Park Calle B|Bayamon|PR|00956||||PR';
locations[j++] = '-|7831-7833 Bayberry Road|Jacksonville|FL|32256||||US';
locations[j++] = '-|5007 Clark Howell Highway|Atlanta|GA|30349||||US';
locations[j++] = '-|31 Heller Rd|Bellmawr|NJ|08031||||US';
locations[j++] = '||||||||'; // must remain as the last line 
// http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=31+Heller+Rd+Bellmawr,+NJ+08031&sll=37.0625,-95.677068&sspn=48.956293,77.695313&ie=UTF8&hq=&hnear=31+Heller+Rd,+Bellmawr,+Camden,+New+Jersey+08031&ll=39.86352,-75.089085&spn=0.012155,0.018969&z=16
// Not sure why, but this line below was sitting here uncommented.
//  I've commented it out on 3/11/2010 - John Sanders
//
// http://maps.google.com/maps?q=4216%20Stuart%20Andrew%20Boulevard%20Charlotte,%20NC%2028217
//
for (var i=0; i<locations.length - 1; i++)
{allData[i] = locations[i];}


/*for (var z in allData) {
document.write (allData[z] + "<br />");}
*/

// REMOVE DUPE States
for (var i=0; i<locations.length - 1; i++)
{
  for (var j=i+1; j<locations.length; j++)
  {
   var itema = locations[i].split('|');
   var itemb = locations[j].split('|');
	if (itema[3] == itemb[3])
	  {locations[j] = '';}
  }
}


// REMOVE EMPTY RECORDS
k = 0;
for (var i in locations) {

	if (locations[i] != ''){
	locationsSorted[k] = locations[i];
	k++}
}


function sortByState(a, b) {
    var x = a.split('|');
    var y = b.split('|');
	  if (x[3]<y[3]) return -1;
	  if (x[3]>y[3]) return 1;
//    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

//SORT ARRAY

locationsSorted.sort(sortByState);

function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}

function removeAllOptions(from) { 
	if (!hasOptions(from)) { return; }
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	} 

countrydata = new Array();

function addOption(obj,value) {
	cTitle = value;
	removeAllOptions(obj);
	removeAllOptions(document.form1.loc);
	if (value == "CA") {obj.options[obj.options.length] = new Option("Choose a Province:", "", false);}else{obj.options[obj.options.length] = new Option("Choose a State:", "", false);}
	var z = 0;
	for (var i=0; i<locationsSorted.length; i++){
		
		var item = locationsSorted[i].split('|');
		var country = item[8];
		var st_prov = item[3];
		//alert(item[8]);
		if (country.match(cTitle))
	  		{
			var text = eval(st_prov);
			//alert (text);
			obj.options[obj.options.length] = new Option(text, st_prov, false);
			countrydata[z] = (allData[i]); 
			z++;
			}
	}

//alert(coursedata.length);
//for (var z in document.links) {document.write (document.links[z] + "<br />");}

}

locdata = new Array();

function addMapValue(value) {
	cTitle = value;
//	alert("input = " + cTitle);
//	removeAllOptions(obj);
//	obj.options[obj.options.length] = new Option("Choose a Location:", "", false);
	var z = 0;
//	var linky = '<span class="normalBold" style="float:left;"><br>Click to view location:<br /></span><img src="http://www.worldpac.com/images/div_blue_dot.gif" width="200" height="1" hspace="0" vspace="0" align="left"/><br><div align="left" style="overflow:auto; background-color:#F1F1F1"><ul>';
//	var linky = '<span class="normalBold" style="float:left;"><br>Click to view location:<br /></span><img src="http://www.worldpac.com/images/div_blue_dot.gif" width="200" height="1" hspace="0" vspace="0" align="left"/><br><div id="link_contents"><ul>';
	var linky = '<span class="normalBold" style="float:left;"><br /><p align="left">Click to view location:</p><img src="http://www.worldpac.com/images/div_blue_dot.gif" width="250" height="1" hspace="0" vspace="0" align="left" /></span><div id="link_contents">';

	for (var i=0; i<allData.length; i++){
//		902 4th Street SW, STE D|Auburn|WA|98001-5205
		var item = allData[i].split('|');
		var addr = item[1];
		var zc = item[4];
		var desc = item[0];
		var country = item[8];
		var st_prov = item[3];
		var loc = item[2]; 
		//alert(item[3]);
		if (st_prov.match(cTitle))
	  		{
			var text = desc + " - " + loc +"," + st_prov;
			//var text = eval(st_prov);
//			alert ("a match = " + text);

			if (country=="CA"){
				//addr=2250+Midland+Ave+STE+17&csz=Scarborough%2C+ON&.intl=ca
				var mLink = "addr=" + addr + "&csz=" + loc + ", " + st_prov + " " + zc + "&.intl=ca";
				var mapLink = "map_ca('" + mLink + "')";
			}else if(country==""){
				var mLink = "http://www.worldpac.com/images/columbia.gif";
				var mapLink = "maploc('" + mLink + "')";
				
			}else{
				var mLink = addr + " " + loc + ", " + st_prov + "," + zc;
//			mLink = escape(mLink);
				var mapLink = "mapit('" + mLink + "')";
			}




//			var mLink = addr + " " + loc + ", " + st_prov;
//			mLink = escape(mLink);
//			var mapLink = "mapit('" + mLink + "')";
//			alert (mLink);
//			linky += '<li style="list-style-image:none; list-style-type:none; margin-bottom:5px; float:left;"><img src="http://www.worldpac.com/images/dotted_arrow.gif" align="left"/>&nbsp;&nbsp;' + text + "</li>";
			linky += '<span class="small" style="float:left;"><a href="javascript:void(0)" onClick="' + mapLink + '">' + text + "</a></span><br />";
//			obj.options[obj.options.length] = new Option(text, mapLink, false);
			locdata[z] = (allData[i]); 
			z++;
			}
	}

linky += "</ul></div>";
return linky;

}



function mapit(raw,zip) {
  //var u = 'http://maps.google.com/maps?q=' + raw + '%2C+' + zip;
  var u = 'http://maps.google.com/maps?q=' + raw;
  if (zip) u = u + '%2C+' + zip;
  window.open(u,'MapIT')
}

function map_ca(raw,zip) {
//	alert('map_ca');
  var u = 'http://ca.maps.yahoo.com/maps_result?' + raw;
//  if (zip) u = u + '%2C+' + zip;
  window.open(u,'MapIT')
//http://ca.maps.yahoo.com/maps_result?addr=2250+Midland+Ave+STE+17&csz=Scarborough%2C+ON&.intl=ca
}


locdata = new Array();

function addStOption(obj,value) {
	cTitle = value;
	//alert("input = " + cTitle);
	removeAllOptions(obj);
	obj.options[obj.options.length] = new Option("Choose a Location:", "", false);
	var z = 0;
	for (var i=0; i<allData.length; i++){
//		902 4th Street SW, STE D|Auburn|WA|98001-5205
		var item = allData[i].split('|');
		var addr = item[1];
		var zc = item[4];
		var desc = item[0];
		var country = item[8];
		var st_prov = item[3];
		var loc = item[2];
		//alert(item[3]);
		if (st_prov.match(cTitle))
	  		{
			var text = desc + " - " + loc +"," + st_prov;
			//var text = eval(st_prov);
			//alert ("a match = " + text);
			if (country=="CA"){
				//addr=2250+Midland+Ave+STE+17&csz=Scarborough%2C+ON&.intl=ca
				var mLink = "addr=" + addr + "&csz=" + loc + ", " + st_prov + " " + zc + "&.intl=ca";
				var mapLink = "map_ca('" + mLink + "')";
			}else{
				var mLink = addr + " " + loc + ", " + st_prov;
				var mapLink = "mapit('" + mLink + "')";
			}
			obj.options[obj.options.length] = new Option(text, mapLink, false);
			locdata[z] = (allData[i]); 
			z++;
			}
	}

//alert(coursedata.length);
//for (var z in document.links) {document.write (document.links[z] + "<br />");}

}



function pData(value) {
var	detailsLink = "";
var	cDate = value;
//alert ("data passed = " + cDate);
//alert ("courses = " + coursedata);
var finaltext = "";
for (var i=0; i<coursedata.length; i++){
		var item = coursedata[i].split(',');
		var courseID = item[0];
		var courseTitle = item[8];
		var courseDate = item[1];
		var courseCity = item[3];
		var courseState = item[4];
		var courseCost = item[7];
		var text = courseCity + ',' + courseState + ' - ' + courseDate;
		//alert(courseID+"\n\n"+cDate)
		
		if (courseID == cDate)
	  		{//alert(courseTitle);
			finaltext = courseCity + ',' + courseState + ' - ' + courseDate;
			replaceText("tTitle", courseTitle)
			replaceText("tDate", courseDate)
			replaceText("tLocation", courseCity + ", " + courseState)
			courseCost = "$" + courseCost + " (per person)";
			replaceText("tCost", courseCost)
//			alert("pic href before = " + document.getElementById('detailImage').href);
			document.getElementById('detailButton').href = courseID;
			document.getElementById('detailImage').href = courseID;
			if (courseTitle.match("MBZ")){document.getElementById('tImage').src = "images/training_mcb_inset.gif";}
			if (courseTitle.match("BMW")){document.getElementById('tImage').src = "images/training_bmw_inset.gif";}
			if (courseTitle.match("Volvo")){document.getElementById('tImage').src = "images/training_volvo_inset.gif";}
			if (courseTitle.match("Toyota")){document.getElementById('tImage').src = "images/training_toyota_inset.gif";}
			
//			alert("button href = " + document.getElementById('detailButton').href);
//			alert("pic href after = " + document.getElementById('detailImage').href);
			hidepre('bArea');
			showhidepre('aArea');
			//ToggleDiv(aArea)
			break;
			}	
}

/*	if (obj!=null && obj.options!=null) {
		obj.options[obj.options.length] = new Option(text, courseID, false, selected);
		}
*/
//alert("finaltext = " + finaltext);
//alert("courseTitle = " + courseTitle);
}

function rolloverFunc(rolloverButID){
	//alert("in func");
if (rolloverButID != "roll_bmw") {document.getElementById('roll_bmw').src = 'images/roll_bmw_off.gif';}else{document.getElementById('main').src = 'images/roll_bmw_text.gif';}
if (rolloverButID != "roll_vw") {document.getElementById('roll_vw').src = 'images/roll_vw_off.gif';}else{document.getElementById('main').src = 'images/roll_vw_text.gif';}
if (rolloverButID != "roll_honda") {document.getElementById('roll_honda').src = 'images/roll_honda_off.gif';}else{document.getElementById('main').src = 'images/roll_honda_text.gif';}
if (rolloverButID != "roll_nissan") {document.getElementById('roll_nissan').src = 'images/roll_nissan_off.gif';}else{document.getElementById('main').src = 'images/roll_nissan_text.gif';}
if (rolloverButID != "roll_toyota") {document.getElementById('roll_toyota').src = 'images/roll_toyota_off.gif';}else{document.getElementById('main').src = 'images/roll_toyota_text.gif';}
if (rolloverButID != "roll_mbz") {document.getElementById('roll_mbz').src = 'images/roll_mbz_off.gif';}else{document.getElementById('main').src = 'images/roll_mbz_text.gif';}
if (rolloverButID != "roll_volvo") {document.getElementById('roll_volvo').src = 'images/roll_volvo_off.gif';}else{document.getElementById('main').src = 'images/roll_volvo_text.gif';}
	
}

function ToggleDiv(div_in) {
var mydiv;
mydiv = document.getElementById(div_in);
if (mydiv.style.visibility == "hidden")
mydiv.style.visibility = "visible";
else
mydiv.style.visibility = "hidden";
}

function showhidepre (subcode) {
	
    if (document.getElementById(subcode).style.display == 'none') {
        document.getElementById(subcode).style.display='block';
    }
	//else 
	//{
//        document.getElementById(subcode).style.display='none';
//    }
}

function hidepre (subcode) {
	
    if (document.getElementById(subcode).style.display == 'block') {
        document.getElementById(subcode).style.display='none';
    }
	//else 
	//{
//        document.getElementById(subcode).style.display='none';
//    }
}

function writeDateSelector(){
	document.writeln ('<SELECT name="courseDates" id="courseDates" class="small" ONCHANGE="pData(this.options[this.selectedIndex].value)" style="width:180px">');
//	document.write ('<OPTION VALUE="" SELECTED></OPTION>');
	document.writeln ('</SELECT>');
}



function replaceText(buttonId, text)
{//alert (text);
  if (document.getElementById)
  {
    var button=document.getElementById(buttonId);
    if (button)
    {
      if (button.childNodes[0])
      {
        button.childNodes[0].nodeValue=text;
      }
      else if (button.value)
      {
        button.value=text;
      }
      else //if (button.innerHTML)
      {
        button.innerHTML=text;
      }
    }
  }
}





function dmyOrdA(a, b){
a = a.replace(dateRE,"$3$2$1");
b = b.replace(dateRE,"$3$2$1");
if (a>b) return 1;
if (a <b) return -1;
return 0; }

function dmyOrdDx(a, b){
a = a.replace(dateRE,"$3$2$1");
b = b.replace(dateRE,"$3$2$1");
if (a>b) return -1;
if (a <b) return 1;
return 0; }

function mdyOrdA(a, b){
a = a.replace(dateRE,"$3$1$2");
b = b.replace(dateRE,"$3$1$2");
if (a>b) return 1;
if (a <b) return -1;
return 0; }

function mdyOrdDx(a, b){
a = a.replace(dateRE,"$3$1$2");
b = b.replace(dateRE,"$3$1$2");
if (a>b) return -1;
if (a <b) return 1;
return 0; }




var dat = new Array();

var t = 0;
dat[t++]="SEM193,3/31/2008,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM193,3/22/2002,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM193,3/12/2005,,Reno,NV,Canceled,,285,Introduction to Volvo";
dat[t++]="SEM175,5/2/2006 ,,San Diego,CA,,,275,Volkswagen Common Problems & Driveability";
dat[t++]="SEM176,8/1/2006 ,,Las Vegas,NV,,Sold Out,280,Mercedes Can & Body Systems";
dat[t++]="SEM177,7/19/2004,,Orlando,FL,,,275,Volkswagen Common Problems & Driveability";
dat[t++]="SEM178,06/9/2005,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/05/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,6/13/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/03/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,06/14/2007,,Newport News,VA,,,285,Introduction to Volvo";
dat[t++]="SEM178,6/01/2007,,Newport News,VA,,,285,Introduction to Volvo";

var dateRE = /^(\d{1,2})[\/\- ](\d{1,2})[\/\- ](\d{4})/;

function dmyOrdD(a, b){

	var x = a.split(',');
	var y = b.split(',');
	
//	var o = x[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//	var p = y[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
	var o = x[1].replace(dateRE,"$3$2$1");
	var p = y[1].replace(dateRE,"$3$2$1");
      if (o>p) return -1;
	  if (o <p) return 1;
	return 0; 
}

function mdyOrdD(a, b){

	var x = a.split(',');
	var y = b.split(',');
	
//	var o = x[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//	var p = y[1].replace(dateRE,"$3"+ pad(RegExp.$2,2) +"$1");
//alert (x[1]);
var o = x[1].replace(dateRE,"$3$1$2");
//	alert(o);
	var p = y[1].replace(dateRE,"$3$1$2");
//	alert(p);
      if (o>p) return -1;
	  if (o <p) return 1;
	return 0; 
}


dat.sort( mdyOrdD );
for (var z in dat) {
//	alert (dat[z]);
	d = dat[z].split(',');
//document.write (d[1] + "<br />");
}


function pad(number,length) {
    var str = '' + number;
    while (str.length < length)
       { str = '0' + str;}
//	   alert("padded str = " + str);
    return str;
}




/*var ar = dateRE.exec("03/02/2008");
document.write(ar.index, "<BR>",
               ar.input, "<BR>",
               ar[0],    "<BR>",
               ar[1],    "<BR>",
               ar[2],     "<br>");*/










String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

String.prototype.ltrim=function(){
    return this.replace(/^\s*/g,'');
}

String.prototype.rtrim=function(){
    return this.replace(/\s*$/g,'');
}

Number.prototype.toDecimals=function(n){
    n=(isNaN(n))?
        2:
        n;
    var
        nT=Math.pow(10,n);
    function pad(s){
            s=s||'.';
            return (s.length>n)?
                s:
                pad(s+'0');
    }
    return (isNaN(this))?
        this:
        (new String(
            Math.round(this*nT)/nT
        )).replace(/(\.\d*)?$/,pad);
}

nYourNumber=3,
    sYourFormattedNumber=nYourNumber.toDecimals(2); // => '300.30'
//	alert(sYourFormattedNumber);

/*  TRIM WHITESPACE


var
    sOriginal='  text  ',
    sTrim=sOriginal.trim(),
    sLTrim=sOriginal.ltrim(),
    sRTrim=sOriginal.rtrim();

/* After execution:
    sOriginal is '  text  '
    sTrim is 'text'
    sLTrim is 'text  '
    sRTrim is '  text'
*/



/*
dateArray = new Array('15/10/2000','8/05/1999','17/09/2005','06/12/2004','2/01/1998');
dateArray.sort( dmyOrdDx );
document.write('Ascending : ' + dateArray + '<br />');

*/



//allCourses=allCourses.noduplicates();

/*Array.prototype.noduplicates=function(){
 if (this.length<2){ return this; }
 this.temp=[this[8]];
 for (this.i1=0;this.i1<this.length;this.i1++){
  this.ck=true;
  for (this.i2=0;this.i2<this.temp.length;this.i2++){ if (this.temp[this.i2]==this[this.i1]){ this.ck=false; } }
  if (this.ck){ this.temp.push(this[this.i1]); }
 }
 return this.temp;
} 
*/



/*myArray.sort();

function customCompare(){
for (var i=0; i<myArray.length - 1; i++)
	{
	  if (myArray[i] == myArray[i+1])
		myArray[i+1] = '';
	}
}
//Note that the above solution does not account for objects stored in 
//the array which may be technically different (== computes to false) 
//but trivially the same. For example:

var myArray = [
   { name:'Gavin', age:31 },
   { name:'Lisa',  age:30 },
   { name:'Gavin', age:23 },
   { name:'Gavin', age:31 }
];

//In the above, technically
//   myArray[0] != myArray[3]
//even though you know it is. For something like this you can write your 
//own comparison function:

Array.prototype.removeDuplicates = function( customCompare ){
   if ( customCompare ){
      this.sort(customCompare);
      for (var i=0; i<(this.length-1); i++)
      {
         if ( !customCompare(this[i],this[i+1]) ){
            this.splice( (i--)+1, 1 );
         }
      }
   }else{
      this.sort();
      for (var i=0; i<(this.length-1); i++)
      {
         if (this[i]==this[i+1]){
            this.splice( (i--)+1, 1 );
         }
      }
   }
   return this;
}


//You would call the above passing in the same sort of custom comparison 
//function as the myArray.sort() method takes:

myArray.removeDuplicates( function(a,b){
   return a.name<b.name ? -1 : a.name>b.name ? 1 :
      a.age<b.age ? -1 : a.age > b.age ? 1 : 0;
   } );

*/
function dLocator(o){
	brk = o;
	sw = "";
	str = ' <p class="small_11pt" style="margin-left:12px"><strong>WORLDPAC Distribution Center' +
'        &amp;&nbsp;Branch&nbsp;Locator' +
'       </strong></p>       ' +
'      <form class="small_11pt" id="form1" name="form1" style="margin-left:12px"> ' +
'          <select name="select" class="medium" ONCHANGE="addOption(document.form1.st_prov,this.options[this.selectedIndex].value)"> ' +
'            <option value="" selected="selected">Select Country:</option> ' +
'            <option value="CA">Canada</option> ' +
'            <option value="US">United States</option> ' +
'          </select> ';
	if (brk == "v") {str += '<br /><br />'}else{str += '&nbsp;&nbsp;&nbsp;'};
		str += '          <select name="st_prov" id="st_prov" class="medium" style="width:120px" ONCHANGE="addStOption(document.form1.loc,this.options[this.selectedIndex].value)"> ' +
		'          </select> ';
	if (brk == "v") {str += '<br /><br />'; sw = '150px'}else{str += '&nbsp;&nbsp;&nbsp;'; sw = '200px'};
		str += '          <select name="loc" id="loc" class="medium" style="width:' + sw + '" ONCHANGE="eval(this.options[this.selectedIndex].value);"> ' +
		'          </select> ' +
		'    </form> ';
document.write(str);
}

function dLocatorx(o){
	brk = o;
	str = ' <span class="small_11pt" style="margin-left:12px"><strong>WORLDPAC Distribution Center ' +
'        &amp;&nbsp;Branch&nbsp;Locator' +
'       </strong></span><br /><br />       ' +
'      <form class="small_11pt" id="form1" name="form1" style="margin-left:12px"> ' +
'          <select name="select" class="medium" ONCHANGE="addOption(document.form1.st_prov,this.options[this.selectedIndex].value)"> ' +
'            <option value="" selected="selected">Select Country:</option> ' +
'            <option value="CA">Canada</option> ' +
'            <option value="US">United States</option> ' +
'          </select> ';
if (brk == "v") {str += '<br /><br />'}else{str += '&nbsp;&nbsp;&nbsp;'};
str += '          <select name="st_prov" id="st_prov" class="medium" style="width:140px" ONCHANGE="addStOption(document.form1.loc,this.options[this.selectedIndex].value)"> ' +
'          </select> ';
if (brk == "v") {str += '<br /><br />'}else{str += '&nbsp;&nbsp;&nbsp;'};
str += '          <select name="loc" id="loc" class="medium" style="width:140px" ONCHANGE="eval(this.options[this.selectedIndex].value);"> ' +
'          </select> ' +
'    </form> ';
document.write(str);
}
