/* --------------------------------------------------
	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("USC", "usc");
	logoList[i++] = new makeLogo("UCLA", "ucla");
	logoList[i++] = new makeLogo("Cal", "berkeley");
	logoList[i++] = new makeLogo("Oregon", "uoregon");
	logoList[i++] = new makeLogo("Oregon State", "oregonstate");
	logoList[i++] = new makeLogo("Washington", "washington")
	logoList[i++] = new makeLogo("NEBRASKA 10/15/05", "unl");
	logoList[i++] = new makeLogo("TEXAS TECH 10/29/05", "ttu");
	logoList[i++] = new makeLogo("TEXAS 11/5/05", "utexas");
	logoList[i++] = new makeLogo("OKLAHOMA STATE 11/19/05", "okstate");
	logoList[i++] = new makeLogo("CELEBRITY ALL-STARS", "bball");
	logoList[i++] = new makeLogo("SAMFORD 09/10/05", "samford");
	logoList[i++] = new makeLogo("FULL SEASON", "na");
	logoList[i++] = new makeLogo("Nelly Furtado", "nelly");
	logoList[i++] = new makeLogo("Whispers 2007", "whispers");
	logoList[i++] = new makeLogo("National Step Show Championship", "stomp");
	logoList[i++] = new makeLogo("Globetrotters", "globies");
	logoList[i++] = new makeLogo("Cheyney vs. Lincoln", "chey");
	logoList[i++] = new makeLogo("All About Comedy - Valentine Comedy show", "comedy");
	logoList[i++] = new makeLogo("Valentine&#39;s Day Soul Jam", "heart");
	logoList[i++] = new makeLogo("GOSPEL SHOW - THINK IT NOT STRANGE", "shek");
	logoList[i++] = new makeLogo("Jill Scott", "jill");
	logoList[i++] = new makeLogo("Steve Harvey Comedy", "steve");
	logoList[i++] = new makeLogo("LADIES NIGHT OUT", "lno");
	logoList[i++] = new makeLogo("Philly Blues Festival", "blues");
	logoList[i++] = new makeLogo("Tha Poppin&#39; Bottles Concert - Featuring Lil&#39;Wayne and friends", "lil");
	logoList[i++] = new makeLogo("Greatest Love Story Ever Told", "love");
	logoList[i++] = new makeLogo("ALICIA KEYS - AS I AM TOUR", "alicia");
	logoList[i++] = new makeLogo("KATT WILLIAMS - IT&#39;S PIMPIN&#39; PIMPIN&#39; TOUR", "katt");
	logoList[i++] = new makeLogo("RAVEN&#39;S PJ PARTY", "raven");
	logoList[i++] = new makeLogo("My Dad Is So Crazy", "fathers");
	logoList[i++] = new makeLogo("MY 106.1 PHILLY FREESTYLE CONCERT!", "80");
	logoList[i++] = new makeLogo("And 1 Mix Tape Tour", "and1");
	logoList[i++] = new makeLogo("TNA Wrestling presents &quot;Lockdown&quot; Cross the Line", "tna");
	logoList[i++] = new makeLogo("STOMPING ON THE YARD - NAT. STEP CHAMPIONSHIP", "stomp");
	logoList[i++] = new makeLogo("Carrie Underwood - Carnival Ride Tour", "carrie");
	logoList[i++] = new makeLogo("Charlie Mack Celebrity Basketball", "charlie_mack");
	logoList[i++] = new makeLogo("The Philly Blues Festival", "blues");
	logoList[i++] = new makeLogo("70&#39;s Soul Jam 02-14-09", "valentine");
	logoList[i++] = new makeLogo("Brotherly Love Gospel Concert - featuring Hezekiah Walker, Byron Cage & More", "love");
	logoList[i++] = new makeLogo("Globetrotters School Show", "globies");
	logoList[i++] = new makeLogo("Never Could Have Made It Without Mom - featuring Yolanda Adams, Marvin Sapp and Ricky Dillard", "mdg");
	logoList[i++] = new makeLogo("Harlem Globetrotters 2009", "globies");
	logoList[i++] = new makeLogo("LOVE TRAIN - The Sound of Philadelphia", "love");
	logoList[i++] = new makeLogo("Karl J Celebrity Hair & Fashion Battle", "karl");
	logoList[i++] = new makeLogo("Cirque Du Soleil : Alegria", "cirque");
	logoList[i++] = new makeLogo("PHILADELPHIA FUNK FEST", "funk");
	logoList[i++] = new makeLogo("Tyler Perry&#39;s Laugh To Keep From Crying", "tyler_p");
	logoList[i++] = new makeLogo("Laugh Yo A** Off Comedy Jam - Featuring Bruce Bruce; Arnez J; Capone, Tiffany Haddish & B Phlat", "lyao");
	logoList[i++] = new makeLogo("LUPE FIASCO - TEMPLE HOMECOMING CONCERT", "fiasco");
	logoList[i++] = new makeLogo("Philadelphia Music Festival", "maze");
	logoList[i++] = new makeLogo("BOB DYLAN", "dylan");
	logoList[i++] = new makeLogo("BROAD STREET BRAWL: Hopkins vs Ornelas", "hopkins");
	logoList[i++] = new makeLogo("Harlem Globetrotters 2010 World Tour", "globies");
	logoList[i++] = new makeLogo("Magic Pass: an Interactive Event 90 Minutes Before Show Time", "globies");
	logoList[i++] = new makeLogo("The Tri-State of Mind Comedy Show with Arnez J and Don DC Curry", "comedy");
	logoList[i++] = new makeLogo("Mike Epps and Friends", "mike_epps");
	logoList[i++] = new makeLogo("Mike Epps & Friends", "me");
	logoList[i++] = new makeLogo("FRESH FEST: Salt n&#39; Pepa, Biz Markie, Whodini, Rob Base, Slick Rick, & Force MD&#39;s", "ff");
	logoList[i++] = new makeLogo("Steve Harvey LIVE", "sh");
	logoList[i++] = new makeLogo("Royal Comedy Tour: Sommore, George Willborn, DL Hughley, & Tu Rae", "rc");
	logoList[i++] = new makeLogo("Tyler Perry&#39;s Madea&#39;s Big Happy Family", "madea");
	logoList[i++] = new makeLogo("The Irish Tenors", "it");
	logoList[i++] = new makeLogo("All Star Mothers Day Celebration", "md");
	logoList[i++] = new makeLogo("Royal Comedy Tour: Sommore, D.L. Hughley and TuRae", "rct");
	logoList[i++] = new makeLogo("Mike Epps, Bruce Bruce, & Friends", "mike_epps");
	logoList[i++] = new makeLogo("Lincoln vs Cheyney HBCU Classic", "lvc");
	logoList[i++] = new makeLogo("MISSA LATINA &#39;PRO PAX&#39;", "miss");

	

/* --------------------------------------------------
	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("FB", "F", "FB3", "STFB"), "foot");
	logoGroupList[i++] = new makeLogo(new Array("MBB", "WB", "MB"), "temple");
	logoGroupList[i++] = new makeLogo(new Array("KIXX"), "kixx");
	logoGroupList[i++] = new makeLogo(new Array("K"), "kixx");
	logoGroupList[i++] = new makeLogo(new Array("H"), "hockey");
	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;
			}
		}
		
		// 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);
	}