/* --------------------------------------------------
	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("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("Guard (Fayetteville, NC)  vs. Stingers", "stinger");
	logoList[i++] = new makeLogo("Hinder w/ Special Guest: Papa Roach", "aiken");
	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 HOMECOMING TOUR 2010", "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("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("Taylor Swift", "tswift");
	logoList[i++] = new makeLogo("Tyler Perry - Madea&#39;s Big Happy Family - 8PM Friday", "tp");
	logoList[i++] = new makeLogo("Tyler Perry - Madea&#39;s Big Happy Family - 3PM Saturday", "tp");
	logoList[i++] = new makeLogo("Tyler Perry - Madea&#39;s Big Happy Family - 8PM Saturday", "tp");
	logoList[i++] = new makeLogo("Carrie Underwood - Play On Tour 2010", "carrie");
	logoList[i++] = new makeLogo("Jeff Dunham - Identity Crisis Tour 2010", "dunham");
	logoList[i++] = new makeLogo("Jimmy Buffett", "buffett");
	logoList[i++] = new makeLogo("Maxwell: Dance With Me VIP Package", "maxwell");
	logoList[i++] = new makeLogo("Maxwell: Fortunate VIP Package", "maxwell");
	logoList[i++] = new makeLogo("Maxwell", "maxwell");
	logoList[i++] = new makeLogo("Jason Aldean", "j_aldean");
	logoList[i++] = new makeLogo("Trans-Siberian Orchestra", "tso_usc");
	logoList[i++] = new makeLogo("NBA Pre-Season: Charlotte Bobcats vs. Detroit Pistons", "charlotte_detroit");
	logoList[i++] = new makeLogo("LIPIZZANER STALLIONS", "lip");
	logoList[i++] = new makeLogo("Lipizzaner Stallions", "lip");
	logoList[i++] = new makeLogo("Professional Bull Riders<br>Lucas Oil Touring Pro Series", "pbr-12");
	logoList[i++] = new makeLogo("Keith Urban - Get Closer Tour 2011", "keithurban");
	logoList[i++] = new makeLogo("Cirque du Soleil: Alegria", "alegria");
	logoList[i++] = new makeLogo("Patti LaBelle & Kenny G - &quot;A Night of Elegance&quot;", "patti_kenny");
	logoList[i++] = new makeLogo("USHER - OMG TOUR 2011 (CONCERT TICKETS)", "usher");
	logoList[i++] = new makeLogo("Kenny Chesney - Goin&#39; Coastal Tour 2011", "kenny");
	logoList[i++] = new makeLogo("Monster Jam", "mj");
	logoList[i++] = new makeLogo("Monster Jam 2012", "mj");
	logoList[i++] = new makeLogo("MONSTER JAM 2012", "mj");
	logoList[i++] = new makeLogo("Taylor Swift - Speak Now Tour 2011", "swift");
	logoList[i++] = new makeLogo("Taylor Swift - Speak Now Tour 2011 (TICKET LINK - CLICK TO PURCHASE)", "swift");
	logoList[i++] = new makeLogo("R. KELLY - &quot;LOVE LETTER TOUR&quot;", "rkelly");
	logoList[i++] = new makeLogo("Michael Jackson the IMMORTAL World Tour by Cirque du Soleil", "cirquemj");
	logoList[i++] = new makeLogo("Michael Jackson the IMMORTAL World Tour by Cirque du Soleil - VIP TICKETS", "cirquemj");
	logoList[i++] = new makeLogo("CIRQUE du SOLEIL", "cirquemj");
	logoList[i++] = new makeLogo("Cirque du Soleil", "cirquemj");
	logoList[i++] = new makeLogo("Disney&#39;s Phineas and Ferb - 4 PM", "disney");
	logoList[i++] = new makeLogo("Disney&#39;s Phineas and Ferb - 7 PM", "disney");
	logoList[i++] = new makeLogo("Disney&#39;s Phineas and Ferb", "disney");
	logoList[i++] = new makeLogo("Drake - The Club Paradise Tour", "drake");
	logoList[i++] = new makeLogo("WWE RAW SUPERSHOW", "wwe2");
	logoList[i++] = new makeLogo("Royal Comedy Tour", "royal");
	logoList[i++] = new makeLogo("RED HOT CHILI PEPPERS", "rhcp");
	logoList[i++] = new makeLogo("Keith Sweat - The Mixed Music Tour", "mmt");
	logoList[i++] = new makeLogo("DISNEY ON ICE", "doi");
	logoList[i++] = new makeLogo("Zac Brown Band", "zbb");
	
	
	

/* --------------------------------------------------
	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"), "cc");
	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("TP"), "tp");
	logoGroupList[i++] = new makeLogo(new Array("CIR", "RBC", "CIR1", "CIR2", "CIR3", "CIR4"), "ringling_fully_charged");
	logoGroupList[i++] = new makeLogo(new Array("DOI", "DOI1", "DOI2", "DOI3", "DOI4"), "doi");

/* --------------------------------------------------
	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, "");
		
		// 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(name.match("COLONIAL CUP")) {logo = "colonial_cup";}
		else if(name.match("RINGLING")) {logo = "ringling_fully_charged";}
		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="'+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="40" height="40" align="absmiddle"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	
