/* --------------------------------------------------
	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("Meat Loaf Live in Concert!", "meatloaf");
	logoList[i++] = new makeLogo("Stars On Ice", "soi");
	logoList[i++] = new makeLogo("Sears Stars on Ice", "soi");
	logoList[i++] = new makeLogo("Trailer Park Boys", "tpb");
	logoList[i++] = new makeLogo("Bachman Cummings", "bc");
	logoList[i++] = new makeLogo("Lord of the Dance", "lotd");
	logoList[i++] = new makeLogo("Playhouse Disney Live!", "disney");
	logoList[i++] = new makeLogo("The Wiggles", "thewiggles");
	logoList[i++] = new makeLogo("The Wiggles Go Bananas", "thewiggles");
	logoList[i++] = new makeLogo("SO YOU THINK YOU CAN DANCE CANADA", "sytycd");
	logoList[i++] = new makeLogo("Sears Stars on Ice", "SOI2010");
	logoList[i++] = new makeLogo("METRIC", "metric");
	logoList[i++] = new makeLogo("World Rock Symphony Orchestra - Britain Rocks", "wr");
	logoList[i++] = new makeLogo("ZZ Top", "zz_top");
	logoList[i++] = new makeLogo("DODGE RODEO", "rodeo");
	logoList[i++] = new makeLogo("CIRQUE DU SOLEIL – DRALION", "cirque");
	logoList[i++] = new makeLogo("SUMMER FEST - SULTANS OF STRING/SERENA RYDER", "summerfest");
	logoList[i++] = new makeLogo("SUMMER FEST - MICHOU/THE TREWS ACOUSTIC", "summerfest");
	logoList[i++] = new makeLogo("SUMMER FEST - WINDSOR SYMPHONY ORCHESTRA & FRIENDS", "summerfest");
	logoList[i++] = new makeLogo("SUMMER FEST - JUNIOR WALKER'S ALL STAR BAND", "summerfest");
	logoList[i++] = new makeLogo("SUMMER FEST FULL EVENT PACKAGE", "summerfest");
	logoList[i++] = new makeLogo("HEDLEY", "hedley");
	logoList[i++] = new makeLogo("DISNEY LIVE! MICKEY'S ROCKIN' ROAD SHOW", "disney-road-show");
	logoList[i++] = new makeLogo("TIM ALLEN LIVE!", "tim_allen");
	logoList[i++] = new makeLogo("CIRQUE DU SOLEIL - DRALION", "dralion");
	logoList[i++] = new makeLogo("GORDON LIGHTFOOT", "gl");
	logoList[i++] = new makeLogo("GORDON LIGHTFOOT DINNER PACKAGE", "gl");
	logoList[i++] = new makeLogo("HARLEM GLOBETROTTERS: 2011 WORLD TOUR", "globies");
	logoList[i++] = new makeLogo("Winter Dreams on Ice", "wdoi");
	logoList[i++] = new makeLogo("THE WIGGLES BIG BIRTHDAY", "wiggles");
	logoList[i++] = new makeLogo("DISNEY LIVE! Three Classic Fairy Tales", "dlive");
	logoList[i++] = new makeLogo("BORDER WARS - ROUND 1", "border");
	logoList[i++] = new makeLogo("SHRINE CIRCUS 2011", "shrine");
	logoList[i++] = new makeLogo("ALAN JACKSON", "ajackson");
	logoList[i++] = new makeLogo("ALAN JACKSON DINNER PACKAGE", "ajackson");
	logoList[i++] = new makeLogo("AN EVENING WITH ELTON JOHN", "ejohn");
	logoList[i++] = new makeLogo("AN EVENING WITH ELTON JOHN - PRE PARTY", "ejohn");
	logoList[i++] = new makeLogo("AN EVENING WITH ELTON JOHN ", "ejohn");
	logoList[i++] = new makeLogo("TNA - IMPACT WRESTLING WORLD TOUR", "tna_wrestling");
	logoList[i++] = new makeLogo("TNA ", "tna_wrestling");
	logoList[i++] = new makeLogo("TNA", "tna_wrestling");
	logoList[i++] = new makeLogo("2012 SKATE CANADA SYNCHRONIZED FIGURE SKATING CHAMPIONSHIPS - FULL EVENT PACKAGE", "skatecanada");
	logoList[i++] = new makeLogo("THE HARLEM GLOBETROTTERS", "globetrotters");
	logoList[i++] = new makeLogo("CIRQUE DU SOLEIL: QUIDAM", "quidam");
	logoList[i++] = new makeLogo("THE HARLEM GLOBETROTTERS – MAGIC PASS", "globetrotters");
	logoList[i++] = new makeLogo("THE HARLEM GLOBETROTTERS – Courtside Plus Vip Package", "globetrotters");
	logoList[i++] = new makeLogo("2012 WORLD UNDER 17 HOCKEY CHALLENGE - WFCU CENTRE FACILITY PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("2012 WORLD UNDER 17 HOCKEY CHALLENGE- VOLLMER COMPLEX FACILITY PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM GERMANY: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM QUEBEC: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM ONTARIO: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM SWEDEN: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM CZECH REPUBLIC: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM WEST: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM USA: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM RUSSIA: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM PACIFIC: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("TEAM ATLANTIC: 2012 WORLD UNDER 17 HOCKEY CHALLENGE - FAMILY & FRIENDS 5 GAME PACKAGE", "hockey17");
	logoList[i++] = new makeLogo("THE NUTCRACKER: CAPITOL THEATRE", "nutcracker");
	
	
/* --------------------------------------------------
	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("SC"), "international");
	logoGroupList[i++] = new makeLogo(new Array("MB","MBS","MBI"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("WB","WBS","WBI"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("V","VB","MVB","WVB"), "volleyball");
	logoGroupList[i++] = new makeLogo(new Array("H"), "hockey");
	logoGroupList[i++] = new makeLogo(new Array("PFC"), "border");
	logoGroupList[i++] = new makeLogo(new Array("CLD"), "calendar");
	logoGroupList[i++] = new makeLogo(new Array("SF"), "spits");  // spitfires
	logoGroupList[i++] = new makeLogo(new Array("ASP"), "ohlallstar");
	logoGroupList[i++] = new makeLogo(new Array("U17"), "hockey17");

/* --------------------------------------------------
	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}(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, "");
		
		// 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("Skate Canada") || name.match("SKATE CANADA"))
					logo = "skatecanada";
			}
		}
		// 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 = "na";  //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="'+extraName+'">';
			} else {
				for(var k=0; k<logo.length; k++) {
				imgSrc += '<img src="'+imageWWWPath+'/logos/'+logo[k]+'.gif" border="0" width="75" height="75" alt="'+extraName+'">';
				}
			}
			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="35" height="35" align="absmiddle"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	

