/* ==================================================
	Created:	March 6, 2007
	Purpose:	Functions to create and print logos. 
				Used primarily on:
				- displaySimpleEventList
				- displayGroupList 
================================================== */
	var defaultLogo = "na"; // custom code
	
	function makeLogo(name, logo, divider) {
		this.oname = name;
		this.ologo = logo;
		this.divider = (typeof(divider)!="undefined" && divider!="" ? divider : "");
	}

/* ==================================================
	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("UCLA - Homecoming 2", new Array("ucla","berkeley"));
	logoList[i++] = new makeLogo("Josie & the Pussycats", "josie_pussycats");
	logoList[i++] = new makeLogo("Chicago", "Chicago");
	logoList[i++] = new makeLogo("Gretchen Wilson", "Gretchen-Wilson");
	logoList[i++] = new makeLogo("Doodlebops", "Doodlebops");
	logoList[i++] = new makeLogo("Sean Kingston & Baby Bash", "Sean-Kingston-Baby-Bash");
	logoList[i++] = new makeLogo("Earth, Wind and Fire", "Earth-Wind-Fire");
	logoList[i++] = new makeLogo("newsboys", "newsboys");
	logoList[i++] = new makeLogo("Average White Band & Tower Of Power", "Average-White-Band-Tower");
	logoList[i++] = new makeLogo("Smokey Robinson", "Smokey-Robinson");
	logoList[i++] = new makeLogo("Lloyd, The-Dream and Colby O'Donis", "Lloyd-The-Dream-and-Colby");
	logoList[i++] = new makeLogo("Bret Michaels with Great White", "Bret-Michaels-with-Great-Wh");
	logoList[i++] = new makeLogo("Del Taco Presents 'Monster Truck Spectacular'", "monsterTruck");
	logoList[i++] = new makeLogo("Chicago", "chicago_musical");
	logoList[i++] = new makeLogo("Pepper", "pepper");
	logoList[i++] = new makeLogo("Randy Travis", "randyTravis");
	logoList[i++] = new makeLogo("Demi Lovato", "demiLovato");
	logoList[i++] = new makeLogo("Jenni Rivera", "JenniRivera");
	logoList[i++] = new makeLogo("Pepe Aguilar", "PepeAguilar");
	logoList[i++] = new makeLogo("Xtremely Amped Freestyle Motocross", "XtremelyAmpedFreestyleMotocross");
	logoList[i++] = new makeLogo("Donavon Frankenreiter plus Gary Jules", "Donovon");
	logoList[i++] = new makeLogo("Battle Grounds", "Fight-Quest");
	logoList[i++] = new makeLogo("Gabriel Iglesias with Special Guest", "Gabriel-Iglesias");
	logoList[i++] = new makeLogo("George Jones", "George-Jones");
	logoList[i++] = new makeLogo("Jack Ingram", "Jack-Ingram");
	logoList[i++] = new makeLogo("The Pretenders with Special Guest", "Pretenders");
	logoList[i++] = new makeLogo("An Evening with Stoney Larue", "Stoney");
	logoList[i++] = new makeLogo("STYX", "Styx");
	logoList[i++] = new makeLogo("The Temptations", "Temptations");
	logoList[i++] = new makeLogo("Pennywise", "pennywise");
	logoList[i++] = new makeLogo("Cal Poly Wine Festival 2009", "calPolyWineFest");
	logoList[i++] = new makeLogo("Cal Poly Wine Festival 2009 Bus Ticket", "calPolyWineFest");
	logoList[i++] = new makeLogo("311 with Special Guest", "311");
	/*
	logoList[i++] = new makeLogo("Bakersfield Jazz Festival", "BakoJazzfest");
//	logoList[i++] = new makeLogo("Bakersfield Jazz Festival Friday", "BakoJazzfest");
//	logoList[i++] = new makeLogo("Bakersfield Jazz Festival Saturday", "BakoJazzfest");
	logoList[i++] = new makeLogo("Bakersfield Jazz Festival 2 Day Pass", "BakoJazzfest");
	*/
	logoList[i++] = new makeLogo("Avila Beach Blues Festival", "blues");
	logoList[i++] = new makeLogo("Guitars & Saxes", "GSaxs");
	logoList[i++] = new makeLogo("BBQ Dinner Ticket for Guitars & Saxes", "GSaxs");
	logoList[i++] = new makeLogo("Jackson Browne with His Band", "jacksonBrowne");
	logoList[i++] = new makeLogo("Carlos Mencia with Special Guest", "mencia");
	logoList[i++] = new makeLogo("Menopause The Musical", "meno");
/*
Menopause The Musical - Sat May 9th 2pm
Menopause The Musical - Sat May 9th 7:30pm
Menopause The Musical - Sun May 10th 2pm
*/
	logoList[i++] = new makeLogo("Boz Scaggs", "bozScaggs");
	logoList[i++] = new makeLogo("George Thorogood", "georgeThorogood");
	logoList[i++] = new makeLogo("Los Lonely Boys & Los Lobos", "ll60");
	logoList[i++] = new makeLogo("No Fear Energy Music Tour Feat: Lamb Of God", "lamb60");
	logoList[i++] = new makeLogo("Mel Tillis", "buck60");
	logoList[i++] = new makeLogo("Neal McCoy", "buck60");
	logoList[i++] = new makeLogo("Neal McCoy 6:30pm show", "buck60");
	logoList[i++] = new makeLogo("Ronnie Milsap", "buck60");
	logoList[i++] = new makeLogo("Ronnie Milsap 6:30pm Show", "buck60");
	logoList[i++] = new makeLogo("Ronnie Milsap 9pm Show", "buck60");
	logoList[i++] = new makeLogo("Chuck Mead", "buck60");
	logoList[i++] = new makeLogo("Marty Stuart", "buck60");
	logoList[i++] = new makeLogo("Aaron Tippin", "buck60");
	logoList[i++] = new makeLogo("Aaron Tippin 6:30 Show", "buck60");
	logoList[i++] = new makeLogo("Aaron Tippin 9:30pm Show", "buck60");
	logoList[i++] = new makeLogo("Graffiti Art Show & Music Festival 2.0", "graffiti");
	logoList[i++] = new makeLogo("Jugfest", "KJUGLOGO");
	logoList[i++] = new makeLogo("TECH N9NE & Murs", "tt960");
	logoList[i++] = new makeLogo("Tech N9NE with Murs", "tt960");
	logoList[i++] = new makeLogo("George Thorogood w/ The Dani Paige Band", "gt60");
	logoList[i++] = new makeLogo("Winefest 2009", "winefest2009");
	logoList[i++] = new makeLogo("Wine Fest 2009", "winefest2009");
	logoList[i++] = new makeLogo("The Mary Jane Girls", "maryJaneGirls");
	logoList[i++] = new makeLogo("DJ Quick Live", "djQuick");
	logoList[i++] = new makeLogo("La Raza Tour 2009 The Godfather Performing Live Kid Frost", "frost");
	logoList[i++] = new makeLogo("Wounded Heroes Patriotic Concert", "woundedHeroes");
	logoList[i++] = new makeLogo("Village Fest 2009", "villageFest");
	logoList[i++] = new makeLogo("Cash&#39;d Out - Ultimate Tribute To Johnny Cash", "fish");
	logoList[i++] = new makeLogo("Which One&#39;s Pink - A Tribute to Pink Floyd", "fish");
	logoList[i++] = new makeLogo("An Evening with Jimmie Van Zant", "fish");
	logoList[i++] = new makeLogo("An Evening with Les Dudek former Allman Bros Guitarist", "fish");
	logoList[i++] = new makeLogo("Moonalice f/G.E. Smith & Jack Casady", "fish");
	logoList[i++] = new makeLogo("Gonzales Summertime Festival - Music, Food, Kids Zone & More!", "gonzales");
	logoList[i++] = new makeLogo("Jose M. Napoleon & King Clave", "JoseMNapoleon");
	logoList[i++] = new makeLogo("Players Ball Concert & Party Too Short Live", "TooShort");
	logoList[i++] = new makeLogo("Rehab Plus Special Guest", "Rehab");
	logoList[i++] = new makeLogo("Cal Poly Wine Festival 2010 BBQ", "calPolyWineFest");
	logoList[i++] = new makeLogo("Cal Poly Wine Festival 2010", "calPolyWineFest");
	logoList[i++] = new makeLogo("Cal Poly Wine Festival 2010 Bus Ticket", "calPolyWineFest");
	logoList[i++] = new makeLogo("Avila Beach Blues Festival", "AvilaBeachBluesfest");
	logoList[i++] = new makeLogo("Winefest 2010", "winefest2009");
	logoList[i++] = new makeLogo("Fat Freddy&#39;s Drop, Dirty Heads, Still Time & Alborosie", "avila");
	logoList[i++] = new makeLogo("Village Fest 2010", "villageFest");
	logoList[i++] = new makeLogo("Rocky Horror Picture Show", "RHPS_60x60");
	logoList[i++] = new makeLogo("Oaktoberfest VII", "oaktoberfest");
	logoList[i++] = new makeLogo("Avila Beach Blues Festival - Experience Hendrix 2011", "AvilaBeachBluesfest-Hendrix");
	logoList[i++] = new makeLogo("OPTIONS Music Festival with Sheryl Crow", "SherylCrow");
	logoList[i++] = new makeLogo("Wine, Women & Wealth", "wineWomenWealth");
	logoList[i++] = new makeLogo("Trace Adkins", "TraceAdkins");
	logoList[i++] = new makeLogo("Bassnectar - Divergent Spectrum Tour", "Bassnectar");
	logoList[i++] = new makeLogo("Blaze Fest On The Green 2011", "BlazeFest");
	logoList[i++] = new makeLogo("Anjelah Johnson", "AnjelahJohnsondet60");
	logoList[i++] = new makeLogo("Village Fest 2011", "VillageFest2011");
	logoList[i++] = new makeLogo("Incubus plus Special Guests", "Incubus");

	logoList[i++] = new makeLogo("Tiesto with Porter Robinson", "tiesto");
	logoList[i++] = new makeLogo("Cage vs Cons Pro MMA and Halloween Bash", "CageVsConsPro");
	logoList[i++] = new makeLogo("Avila Beach Blues Festival", "AvilaBeachBluesfest-DoobieBros");


/* ==================================================
	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";
	extraList[i++] = "Cal Poly Men&#39;s Basketball vs. ";
	extraList[i++] = " Shows";
	
	// 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("FOT"), "football");
	logoGroupList[i++] = new makeLogo(new Array("BB"), "baseball");
	logoGroupList[i++] = new makeLogo(new Array("SB"), "softball");
	logoGroupList[i++] = new makeLogo(new Array("MB","MBS","MBI","BAK"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("WB","WBS","WBI"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("VOL"), "volleyball");
	logoGroupList[i++] = new makeLogo(new Array("H"), "hockey");
	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("FES"), "mammothFest");
	logoGroupList[i++] = new makeLogo(new Array("LEC"), "LEC");
	logoGroupList[i++] = new makeLogo(new Array("maderaFair"), "maderaFair");
	logoGroupList[i++] = new makeLogo(new Array("bakersfieldfoxtheater"), "bakersfieldfoxtheater");
	logoGroupList[i++] = new makeLogo(new Array("avila"), "avila");

/* ==================================================
	MAIN LOGO FUNCTIONS
================================================== */
	function printLogo(name, group) {
		var logo = "";
		var divider = "";
		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;
				divider = logoList[i].divider;
				break;
			}
		}

		// custom code
		if(logo=="") {
			if (name.match("MAMMOTH&#39;S BLUE SKY")) {
				logo = "bs60";
			} else if(name.indexOf("BLUE SKY MUSIC FESTIVAL") > -1) {
				logo = "bs60";
			} else if(name.indexOf("CAL POLY WINE")==0) {
				logo = "calPolyWineFest";
			} else if(name.indexOf("MAMMOTH BLUE SKY")>-1) {
				logo = "BlueSkyFest";
			} else if(name.indexOf("MAMMOTH")>-1) {
				logo = "mammothFest";
			} else if(name.indexOf("BAKERSFIELD JAZZ FESTIVAL")==0) {
				logo = "BakersfieldJazzFest";
			}
		}
		// end cc
		
		// 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 = defaultLogo;
		
		// 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="60" height="60" alt="'+extraName+'">';
			} else {
				for(var k=0; k<logo.length; k++) {
					if(k>0 && divider!="") {
						imgSrc += '<span class="logoDivider">'+divider+'</span>';
					} else {
						imgSrc += ' ';
					}
					imgSrc += '<img src="'+imageWWWPath+'/logos/'+logo[k]+'.gif" border="0" width="60" height="60" 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!="") {
			// custom code BELOW (w/h)
			imgSrc = imgSrc.replace(/width="60" height="60"/ig, 'width="30" height="30"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	
	// print very small logo (for mini cart)
	function printSmallLogo(name, group) {
		var imgSrc = printLogo(name, group);
		if(imgSrc!="") {
			imgSrc = imgSrc.replace(/width="60" height="60"/ig, 'width="25" height="25" align="absmiddle"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
