/* --------------------------------------------------
	Created:	March 6, 2007
	Purpose:	Functions to create and print logos. 
				Used primarily on:
				- displaySimpleEventList
				- displayGroupList 
-------------------------------------------------- */
	function makeLogo(name, logo) {
		this.oname = name;
		this.ologo = logo;
	}

/* --------------------------------------------------
	LOGO LIST
-------------------------------------------------- */
	logoList = new Array;
	var i = 0;
//	logoList[i++] = new makeLogo("Florida Int&#39;l", "fiu");
	logoList[i++] = new makeLogo("Sesame Street Live", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 2010", "elmo");
	logoList[i++] = new makeLogo("Hellfest 05", "hellfest");
	logoList[i++] = new makeLogo("Asha Bhosle Unplugged", "ashaBhosle");
	logoList[i++] = new makeLogo("Yuengling&#39;s Chrome, Smoke and BBQ VIP Party", "yuengling");
	logoList[i++] = new makeLogo("BET Presents SCREAM IV", "scream");
	logoList[i++] = new makeLogo("The World Famous Lipizzaner Stallions", "lipizzaner");
	logoList[i++] = new makeLogo("Hellfest &#39;05 Friday", "hellfest");
	logoList[i++] = new makeLogo("Hellfest &#39;05 Saturday", "hellfest");
	logoList[i++] = new makeLogo("Hellfest &#39;05 Sunday", "hellfest");
	logoList[i++] = new makeLogo("Smucker&#39;s Stars on Ice", "starsoniceevents");
	logoList[i++] = new makeLogo("John Hancock Champions on Ice 2006 Tour", "championsonice");
	logoList[i++] = new makeLogo("Benjamin Franklin", "benFranklin");
	logoList[i++] = new makeLogo("Gretchen Wilson: The Redneck Revolution Tour 2006", "gretchenWilson");
	logoList[i++] = new makeLogo("The Harlem Globetrotters", "globbies-2");
	logoList[i++] = new makeLogo("Monster Truck Nationals and Thrill Show", "monsterTruck");
	logoList[i++] = new makeLogo("Saturday Night Fights", "saturdayNightFights");
	logoList[i++] = new makeLogo("Aap Kaa Surroor - Live", "aap");
	logoList[i++] = new makeLogo("Hootie and the Blowfish", "hootie");
	logoList[i++] = new makeLogo("Fashion on Ice", "fashiononice");
	logoList[i++] = new makeLogo("The Boston Pops Esplanade Orchestra", "pops");
	logoList[i++] = new makeLogo("Gospel Praise Fest", "gospel");
	logoList[i++] = new makeLogo("Doodlebops Live", "Doodlebops");
	logoList[i++] = new makeLogo("94.5 PST&#39;s 2006 Popfest", "popfest");
	logoList[i++] = new makeLogo("The Harlem Globetrotters 2007 Tour", "globetrotters");
	logoList[i++] = new makeLogo("Miller Lite Classic Rock Fest 5 Pre-Party Combo", "skynyrd");
	logoList[i++] = new makeLogo("The Hawk&#39;s Classic Rock Fest 5", "skynyrd");
	logoList[i++] = new makeLogo("Brad Paisley - Time Well Wasted 2006", "bradpaisley");
	logoList[i++] = new makeLogo("Disney On Ice Celebrates 100 Years of Magic", "100Magic");
	logoList[i++] = new makeLogo("The Cheetah Girls", "cheetah");
	logoList[i++] = new makeLogo("Ringling Bros. and Barnum & Bailey Presents BELLOBRATION", "bellobration");
	logoList[i++] = new makeLogo("Ringling Bros. and Barnum & Bailey Presents BELLOBRATION", "bellobration");
	logoList[i++] = new makeLogo("Globetrotters Family 4 Pack", "globetrotters");
	logoList[i++] = new makeLogo("bodogfight.com presents: The 2007 ADCC World Submission Wrestling Championships", "adcc");
	logoList[i++] = new makeLogo("2007 ADCC World Submission Wrestling Championships - 2 DAY PACK", "adcc");
	logoList[i++] = new makeLogo("Larry the Cable Guy IN CONCERT", "larry");
	logoList[i++] = new makeLogo("Bodog Fight - Eddie Alvarez VS. Matt Lee", "bodog");
	logoList[i++] = new makeLogo("38 Special at Horsepark of NJ", "38");
	logoList[i++] = new makeLogo("Third Day at Freedom Fest Fair", "third");
	logoList[i++] = new makeLogo("The &quot;World Famous&quot; Lipizzaner Stallions", "Lipps");
	logoList[i++] = new makeLogo("Feld Entertainment Presents Doodlebops Live!", "doodle");
	logoList[i++] = new makeLogo("Disney&#39;s High School Musical The Ice Tour", "hsm");
	logoList[i++] = new makeLogo("Feld Ent. Presents Playhouse Disney Live", "disney");
	logoList[i++] = new makeLogo("Professional Bull Riders Trenton Invitational", "pbr");
	logoList[i++] = new makeLogo("AVP 2008 Hot Winter Nights Tour", "volley");
	logoList[i++] = new makeLogo("USA Women&#39;s Basketball", "usa");
	logoList[i++] = new makeLogo("CMT on Tour 2007 w/ Sugarland", "sugarland");
	logoList[i++] = new makeLogo("Devils vs Flyers Preseason Game", "flyer_devil");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Wed @ 7", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Thurs @ 7", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Friday @ 10:30", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Friday @ 7", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Sat @ 11", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Sat @ 7", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Sat @ 3", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Sun @ 11am", "nemo");
	logoList[i++] = new makeLogo("Finding Nemo on Ice Sun @ 3", "nemo");
	logoList[i++] = new makeLogo("The Ten Tenors", "ttt");
	logoList[i++] = new makeLogo("NY Titans vs Philadelphia Wings Lacrosse", "ny");
	logoList[i++] = new makeLogo("Primetime Shootout 2008", "prime");
	logoList[i++] = new makeLogo("Primetime Shootout 2 Day Pass", "prime");
	logoList[i++] = new makeLogo("Cats", "cats");
	logoList[i++] = new makeLogo("Ice Racing 2008", "ice");
	logoList[i++] = new makeLogo("Blue Man Group", "bmg");
	logoList[i++] = new makeLogo("Sesame Street Live 3/27 Opening Night", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 3/28", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 3/29 10:30AM", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 3/29 2PM", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 3/29 5:30PM", "elmo");
	logoList[i++] = new makeLogo("Sesame Street Live 3/30 2PM", "elmo");
	//logoList[i++] = new makeLogo("Celtic Woman", "celtic_woman");
	logoList[i++] = new makeLogo("NJSIAA Tournament of Champions Semifinal", "njsiaa");
	logoList[i++] = new makeLogo("PROFESSIONAL BULL RIDING", "pbr");
	logoList[i++] = new makeLogo("Ringling Bros. and Barnum & Bailey Circus", "circus");
	logoList[i++] = new makeLogo("Wired 96.5's Freestyle Invasion", "freestyle");
	logoList[i++] = new makeLogo("DISNEY LIVE 2009", "disney");
	logoList[i++] = new makeLogo("DISNEY LIVE 20", "disney");
	logoList[i++] = new makeLogo("LIPIZZANER STALLIONS", "lipizzaner");
	logoList[i++] = new makeLogo("Monster Trucks Winter Nationals", "monster");
	logoList[i++] = new makeLogo("Disney On Ice", "doi");
	logoList[i++] = new makeLogo("Hairspray", "hairspray");
	logoList[i++] = new makeLogo("Jesus Christ Superstar", "jcss");
	logoList[i++] = new makeLogo("Ice Racing 2010 Family 4 Pack", "moto_ice");
	logoList[i++] = new makeLogo("34th Annual World Championship Ice Racing Series", "moto_ice");
	logoList[i++] = new makeLogo("Lingerie Football 4 Pack", "passion");
	logoList[i++] = new makeLogo("Lingerie Football League", "passion");
	logoList[i++] = new makeLogo("Primetime Shootout 2010 Two Day Pass", "prime");
	logoList[i++] = new makeLogo("Primetime Shootout", "prime");
	logoList[i++] = new makeLogo("The Harlem Globetrotters 2011", "globies-2");
	logoList[i++] = new makeLogo("MAGIC PASS", "globies-2");
	logoList[i++] = new makeLogo("Carrie Underwood", "carrie");
	logoList[i++] = new makeLogo("Daughtry", "daughtry");
	logoList[i++] = new makeLogo("Martina McBride", "martina");
	logoList[i++] = new makeLogo("Justin Bieber", "justin_b");
	logoList[i++] = new makeLogo("Kings and Queens of Freestyle", "wired");
	logoList[i++] = new makeLogo("Cirque Du Soleil: Dralion", "cirque");
	logoList[i++] = new makeLogo("WRAT&#39;s Rockin&#39; Brewfest", "rbf");
	logoList[i++] = new makeLogo("So You Think You Can Dance 2010", "sytycd");
	logoList[i++] = new makeLogo("Gospel Concert", "gospel");
	logoList[i++] = new makeLogo("Stand Up for WWE presents RAW WORLD TOUR", "raw");
	logoList[i++] = new makeLogo("Monster Jam 2011", "mj");
	logoList[i++] = new makeLogo("Disney On Ice: Princess Classics", "princess");
	logoList[i++] = new makeLogo("Monster Jam 2012", "mj");
	logoList[i++] = new makeLogo("PIT PASS PARTY", "mj");
	logoList[i++] = new makeLogo("Celtic Woman", "celtic_woman");
	logoList[i++] = new makeLogo("Ringling Bros. Fully Charged", "ringling");
	logoList[i++] = new makeLogo("Disney&#39;s Phineas and Ferb: The Best LIVE Tour Ever", "dislive");
	logoList[i++] = new makeLogo("Philadelphia 76ers vs. New Jersey Nets Preseason Game", "76ers");
	logoList[i++] = new makeLogo("WWE RAW World Tour", "wweraw");
	logoList[i++] = new makeLogo("Sesame Street Live: Elmo Makes Music", "ssl");
	logoList[i++] = new makeLogo("Avicii with special guest Cazzette", "acii");
	logoList[i++] = new makeLogo("Avicii", "acii");
	logoList[i++] = new makeLogo("SUNNY SEATS PACKAGE 10:30AM SHOW", "ssl");
	logoList[i++] = new makeLogo("SUNNY SEATS PACKAGE 7PM SHOW", "ssl");
	logoList[i++] = new makeLogo("SUNNY SEATS PACKAGE", "ssl");
	logoList[i++] = new makeLogo("SUNNY SEATS PACKAGE ", "ssl");
	logoList[i++] = new makeLogo("SUNNY SEATS PACKAGE 7:00PM SHOW", "ssl");
	logoList[i++] = new makeLogo("TRENTON TITANS", "titans");
	logoList[i++] = new makeLogo("FEB 2ND TRENTON TITANS", "titans");
	logoList[i++] = new makeLogo("Harlem Globetrotters 2pm 2012", "globies");
	logoList[i++] = new makeLogo("MAGIC PASS 12:30-1pm SHOW", "magic");
	logoList[i++] = new makeLogo("Harlem Globetrotters 7pm 2012", "globies");
	logoList[i++] = new makeLogo("MAGIC PASS 5:30-6pm SHOW", "magic");
	logoList[i++] = new makeLogo("Globetrotters 2:00pm Courtside PLUS Package", "globies");
	logoList[i++] = new makeLogo("Globetrotters 7:00pm Courtside PLUS Package", "globies");
	logoList[i++] = new makeLogo("Disney&#39;s Phineas and Ferb: The Best LIVE Tour Ever!", "disneyferb");
	logoList[i++] = new makeLogo("Advanced Auto Parts Monster Jam", "mj");
	logoList[i++] = new makeLogo("Philadelphia Wings vs Rochester Knighthawks", "wings");
	logoList[i++] = new makeLogo("Dayglow BLU Tour - 2nd SHOW ADDED for Friday December 2nd", "glow");
	logoList[i++] = new makeLogo("Jersey&#39;s Most Wanted", "jmw");
	logoList[i++] = new makeLogo("An Evening with Buddy Valastro: The Cake Boss", "buddy");
	logoList[i++] = new makeLogo("Winter White Tour 2012", "winter-white");
	logoList[i++] = new makeLogo("Ringling Brothers", "ringling");	
	

/* --------------------------------------------------
	EXTRA LIST
-------------------------------------------------- */
	extraList = new Array;
	var i = 0;
	extraList[i++] = ""; // DO NOT remove
	extraList[i++] = "The ";
	extraList[i++] = "at ";
	extraList[i++] = "@ ";
	extraList[i++] = "vs ";
	extraList[i++] = "vs. ";
	extraList[i++] = " FAMILY 4 PACK";
	extraList[i++] = " - Family Four Packs";
	extraList[i++] = " - Group Tickets";
	extraList[i++] = " - Student Matinee";
	extraList[i++] = " Time TBA";
	
	// sort extraList, greatest length first
	extraList.sort(function(a,b) {
		return (a.length > b.length) ? -1 : 1;
	});

/* --------------------------------------------------
	FULL-SIZED IMAGES LIST
-------------------------------------------------- */
	fullsizeList = new Array;
	var i = 0;
//	fullsizeList[i++] = new makeLogo("Rutgers Student Test", "StudentShirt");

/* --------------------------------------------------
	GROUP LIST
-------------------------------------------------- */
	logoGroupList = new Array;
	var i = 0;
	logoGroupList[i++] = new makeLogo(new Array("F","FB","FBS","FBI","FB3","STFB"), "football");
	logoGroupList[i++] = new makeLogo(new Array("BB"), "baseball");
	logoGroupList[i++] = new makeLogo(new Array("SB"), "softball");
	logoGroupList[i++] = new makeLogo(new Array("TS"), "steel");
	logoGroupList[i++] = new makeLogo(new Array("TT"), "titans");
	logoGroupList[i++] = new makeLogo(new Array("T"), "devils");
	logoGroupList[i++] = new makeLogo(new Array("NCAA09"), "ncaa");
	logoGroupList[i++] = new makeLogo(new Array("CLD"), "calendar");

/* --------------------------------------------------
	MAIN LOGO FUNCTIONS
-------------------------------------------------- */
	function printLogo(name, group) {
		var logo = "";
		name = cleaner(name.toUpperCase());
		
		// remove appending dates/times (ie: "TITLE - Wed., Sept. 17 - 2pm")
		name = name.replace(/(( |,|-|\(|\bon\b|\bat\b){0,2} ?\b(mon|tue(s)?|wed(nes)?|thu(r(s)?)?|fri|sat(ur)?|sun)(day)?\b\.?( morning| afternoon| eve| evening| mat)?\)?)?(( |,|-|\(|\bon\b|\bat\b){0,2} ?(\b(jan(uary)?|feb(ruary)?|mar(ch)?|apr(il)?|may|jun(e)?|jul(y)?|aug(ust)?|sep(t(ember)?)?|oct(ober)?|nov(ember)?|dec(ember)?)\b\.? \d{1,2}(,? ?(20)?\d{2})?\)?|\d{1,2}[/\- ]\d{1,2}([/\- ](20)?\d{2})?\)?))?(( |,|-|\(|\bon\b|\bat\b){0,2} ?\d{1,2}(:\d{2})? ?(am|pm)\)?)?$/ig, "");
		
		// process extralist
		var extraName = name;
		for(var i=0; i<extraList.length; i++) {
			if(extraName.indexOf(extraList[i].toUpperCase())==0) {
				extraName = extraName.slice(extraList[i].length, extraName.length);
				break;
			}
		}
		for(var i=0; i<extraList.length; i++) {
			if(extraName.length - extraList[i].length>0 && extraName.indexOf(extraList[i].toUpperCase())==extraName.length - extraList[i].length) {
				extraName = extraName.slice(0, extraName.length - extraList[i].length);
				break;
			}
		}
		extraName = extraName.replace(/(( |,|-|\(|\bon\b|\bat\b){0,2} ?\b(mon|tue(s)?|wed(nes)?|thu(r(s)?)?|fri|sat(ur)?|sun)(day)?\b\.?( morning| afternoon| eve| evening| mat)?\)?)?(( |,|-|\(|\bon\b|\bat\b){0,2} ?(\b(jan(uary)?|feb(ruary)?|mar(ch)?|apr(il)?|may|jun(e)?|jul(y)?|aug(ust)?|sep(t(ember)?)?|oct(ober)?|nov(ember)?|dec(ember)?)\b\.? \d{1,2}(th)?(,? ?(20)?\d{2})?\)?|\d{1,2}[/\- ]\d{1,2}([/\- ](20)?\d{2})?\)?))?(( |,|-|\(|\bon\b|\bat\b|@){0,2} ?\d{1,2}(:\d{2})? ?(a.?m.?|p.?m.?)\)?)?$/ig, "");
		// custom code new era - display opponent team logo automatically
		// based on string match
		if(logo=="") {
			if(name != "") {
				if(name.match("TRENTON STEEL"))
					logo = "steel";
				if(name.match("TITANS"))
					logo = "titans";
				if(name.match("MONSTER JAM") || name.match("PIT PASS"))
					logo = "mj";
				
			}
		}
		// end custom code new era - display opponent team logo automatically
		
		// find logo match (start from end for most recently added logos)
		for(var i=logoList.length-1; i>=0; i--) {
			var listName = logoList[i].oname.toUpperCase();
			if(name==cleaner(listName) || extraName==cleaner(listName)) {
				logo = logoList[i].ologo;
				break;
			}
		}
		
		// find logo based on group
		if(logo=="") {
			if(typeof(fullGroupList)!="undefined" && group!="") {
				while(logo=="" && group!="") {
					for(var k=0; k<logoGroupList.length; k++) {
						for(var l=0; l<logoGroupList[k].oname.length; l++) {
							if(logoGroupList[k].oname[l]==group) {
								logo = logoGroupList[k].ologo;
								break;
							}
						}
						if(logo!="") break;
					}
					if(logo!="") break;
					var parent = "";
					for(var i=0; i<fullGroupList.length; i++) {
						if(fullGroupList[i].code==group) {
							parent = fullGroupList[i].parent;
						}
					}
					group = parent;
				}
			} else {
				for(var k=0; k<logoGroupList.length; k++) {
					for(var l=0; l<logoGroupList[k].oname.length; l++) {
						if(logoGroupList[k].oname[l]==group) {
							logo = logoGroupList[k].ologo;
							break;
						}
					}
				}
			}
		}
		
		// set DEFAULT LOGO if still not assigned	
		//template enhancement, no default logo for renewals
		if(group!="renewals") {
			if(logo=="") logo = "na";
		} else {
			if(logo=="") logo = "football";  //change to different default renewal logo, or comment out to remove default logo function on Renewal Process	
		}	
		
		// determine if full sized image exists
		var fullSize = "";
		for(var i=0; i < fullsizeList.length; i++) {
			var listName = fullsizeList[i].oname.toUpperCase();
			if(name==cleaner(listName) || extraName==cleaner(listName)) {
				fullSize = fullsizeList[i].ologo;
				break;
			}
		}
		
		var imgSrc = "";
		
		// create and return logo source
		if(logo!="") {
			if(typeof(logo)=="string") {
				imgSrc = '<img src="'+imageWWWPath+'/logos/'+logo+'.gif" border="0" width="75" height="75" alt="'+name+'">';
			} else {
				for(var k=0; k<logo.length; k++) {
					imgSrc += '<img src="'+imageWWWPath+'/logos/'+logo[k]+'.gif" border="0" width="75" height="75" alt="'+name+'"> ';
				}
			}
			if(fullSize!="" && group!="ticketTransfers") {
				imgSrc = '<a href="#" onclick="toggleFullSize(this); return false;" class="thumbHide">' + imgSrc + '<br><small style="white-space:nowrap"><img src="'+imageWWWPath+'/fullsize/mag.gif" border="0" width="11" height="11" align="absmiddle"> view large</small><span><img src="'+imageWWWPath+'/fullsize/'+fullSize+'.gif" border="0" alt="'+name+'"><br><small style="white-space:nowrap"><img src="'+imageWWWPath+'/fullsize/close.gif" border="0" width="11" height="11" align="absmiddle"> click to close</small></span></a>';
			}
		}
		return(imgSrc);
	}
	
	function toggleFullSize(thumb) {
		if(thumb.className=="thumbHide") {
			thumb.className = 'thumbShow';
		} else if(thumb.className=="thumbShow") {
			thumb.className = 'thumbHide';
		}
	}
	
	// print smaller logo for calendar
	function printCalLogo(name, group) {
		var imgSrc = printLogo(name, group);
		if(imgSrc!="") {
			imgSrc = imgSrc.replace(/width="75" height="75"/ig, 'width="40" height="40"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	
	// print very small logo
	function printSmallLogo(name, group) {
		var imgSrc = printLogo(name, group);
		if(imgSrc!="") {
			imgSrc = imgSrc.replace(/width="75" height="75"/ig, 'width="30" height="30" align="absmiddle"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	

