/* --------------------------------------------------
	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("Rutgers Student Test", "StudentShirt");
//	logoList[i++] = new makeLogo("UCLA - Homecoming 2", new Array("ucla","berkeley"));
	logoList[i++] = new makeLogo("Washington", "washington");
	logoList[i++] = new makeLogo("Ringling Bros. and Barnum & Bailey Circus", "blank");
	logoList[i++] = new makeLogo("Elton John", "eltonjohn");
	logoList[i++] = new makeLogo("Blue Man Group", "bmg");
	logoList[i++] = new makeLogo("Indoor Football Season Tickets", "stinger");
	logoList[i++] = new makeLogo("Marshals (Cincinnati, Ohio) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Revolution (Greensboro, NC) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Tarpons (Ft. Myers) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Pelicans (Jacksonville, FL) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Thoroughbreds (Atlanta, GA) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Marshals (Cincinnati, OH) vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Monster Jam - Friday, Feb 1, 2008", "mj");
	logoList[i++] = new makeLogo("Monster Jam - Saturday, Feb 2, 2008", "mj");
	logoList[i++] = new makeLogo("Professional Bull Riders - Friday 3/23/07", "pbr");
	logoList[i++] = new makeLogo("Professional Bull Riders - Saturday 3/24/07", "pbr");
	logoList[i++] = new makeLogo("Guard (Fayetteville, NC)  vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Hinder w/ Special Guest: Papa Roach", "aiken");
	logoList[i++] = new makeLogo("Disney on Ice - Thursday, April 26  7:00 PM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Friday, April 27  7:00 PM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Saturday, April 28  11:00 AM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Saturday, April 28  3:00 PM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Saturday, April 28  7:00 PM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Sunday, April 29  1:00 PM", "doi2");
	logoList[i++] = new makeLogo("Disney on Ice - Friday, April 27  10:30 AM", "doi2");
	logoList[i++] = new makeLogo("10th Annual Black Expo", "bx");
	logoList[i++] = new makeLogo("Dancing With The Stars", "dwts");
	logoList[i++] = new makeLogo("Doodlebops Live!", "doodle");
	logoList[i++] = new makeLogo("BALL4REAL - Streetball World Tour", "ball");
	logoList[i++] = new makeLogo("Freestyle Motocross", "moto");
	logoList[i++] = new makeLogo("Maroon 5", "maroon");
	logoList[i++] = new makeLogo("Doodlebops Live!", "doodle");
	logoList[i++] = new makeLogo("New York Knicks vs. Philadelphia 76ers", "bball");
	logoList[i++] = new makeLogo("Dierks Bentley", "dierks");
	logoList[i++] = new makeLogo("Trans-Siberian Orchestra - 3:00 Show", "tso");
	logoList[i++] = new makeLogo("Trans-Siberian Orchestra - 7:30 Show", "tso");
	logoList[i++] = new makeLogo("George Strait", "george_strait");
	logoList[i++] = new makeLogo("R Kelly - Double Up Tour", "rkelly");
	logoList[i++] = new makeLogo("Bill Gaither & the Homecoming Friends", "gaither");
	logoList[i++] = new makeLogo("Miley Cyrus", "miley");
	logoList[i++] = new makeLogo("Dane Cook - GLOBAL THERMO COMEDY TOUR", "dane");
	logoList[i++] = new makeLogo("THOMAS & FRIENDS LIVE! ON STAGE", "thomas");
	logoList[i++] = new makeLogo("ICEY CITY TOUR w/ Gucci Mane & Soulja Boy", "icey");
	logoList[i++] = new makeLogo("Jamie Foxx - The Blame It Tour", "jamie_fox");
	/*logoList[i++] = new makeLogo("Colonial Cup Admission/Grandstand Badge", "src");
	logoList[i++] = new makeLogo("Colonial Cup Admission/Grandstand Pass", "src");
	logoList[i++] = new makeLogo("Colonial Cup Parking", "src");
	logoList[i++] = new makeLogo("2009 Colonial Cup Admission Tickets", "src");
	logoList[i++] = new makeLogo("2009 Colonial Cup Grandstand Box Seating", "src");
	logoList[i++] = new makeLogo("2009 Colonial Cup Reserved Parking", "src");*/
	logoList[i++] = new makeLogo("WWE Smackdown & ECW", "wwe");
	logoList[i++] = new makeLogo("The Radio City Christmas Spectactular", "radio_city");
	logoList[i++] = new makeLogo("The Radio City Christmas Spectactular - 7:00 Show", "radio_city");
	logoList[i++] = new makeLogo("Sesame Street Live", "ssl");
	logoList[i++] = new makeLogo("Martina McBride w/Blake Shelton", "martina");
	logoList[i++] = new makeLogo("Martina McBride", "martina");

	/*logoList[i++] = new makeLogo("2009 COLONIAL CUP RACES", "dupont");
	logoList[i++] = new makeLogo("2009 COLONIAL CUP <br>GRANDSTAND BOX SEATING", "dupont");*/

/* --------------------------------------------------
	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("SSL1","SSL2","SSL"), "ssl");
	logoGroupList[i++] = new makeLogo(new Array("WWD"), "wwd");
	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("SRC", "TEST"), "dupont");
	logoGroupList[i++] = new makeLogo(new Array("SOC","SO","MS","WS"), "soccer");
	logoGroupList[i++] = new makeLogo(new Array("CLD"), "calendar");
	logoGroupList[i++] = new makeLogo(new Array("DL"), "disney");
	logoGroupList[i++] = new makeLogo(new Array("MJ"), "mj");
	logoGroupList[i++] = new makeLogo(new Array("CIR, RBC"), "circus");

/* --------------------------------------------------
	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;
			}
		}
		
		// 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
		if(logo=="") logo = "na";
		
		// 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);
	}