/* --------------------------------------------------
	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("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Wednesday 09/24/08 7:30pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical -Friday 09/26/08 8:00pm", "unbeatable"); 
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical -Saturday 09/27/08 8:00pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Sunday 09/28/08 7:30pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Wednesday 10/01/08 7:30pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Friday 10/03/08 8:00pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Saturday 10/04/08 8:00pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre and Pink Ribbons Project presents Unbeatable: A Bold New Musical - Sunday 10/05/08 3:00pm", "unbeatable");
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Thursday 09/25/08 7:30pm", "apc");	
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Saturday 09/27/08 8:00pm", "apc");	
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Sunday 09/28/08 3:00pm", "apc");	
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Monday 09/29/08 7:30pm", "apc");	
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Saturday 10/04/08 3:00pm", "apc");	
	logoList[i++] = new makeLogo("Stages Repertory Theatre presents Always . . . Patsy Cline - Sunday 10/05/08 7:30pm", "apc");	 
	logoList[i++] = new makeLogo("The Music Man", "music_man");
	logoList[i++] = new makeLogo("Man of La Mancha", "la_mancha");
	logoList[i++] = new makeLogo("Initiative for Jewish Women presents Susan Stamberg - Sunday 10/26/08 12:30PM", "stamberg");	  
	logoList[i++] = new makeLogo("The Hungarian American Cultural Association of Houston presents Spirit of the Gypsies - Sunday 11/16/08 7:00pm", "spirit_of_gypsies");
	logoList[i++] = new makeLogo("Travesty Dance Group presents PORTABLES Thursday December 11, 2008 7:30pm", "travesty_dance");
	logoList[i++] = new makeLogo("Travesty Dance Group presents PORTABLES Friday December 12, 2008 7:30pm", "travesty_dance");
	logoList[i++] = new makeLogo("Travesty Dance Group presents PORTABLES Saturday December 13, 2008 6:30 pm", "travesty_dance");	
	logoList[i++] = new makeLogo("Children of Eden", "children_eden");
	logoList[i++] = new makeLogo("Evita", "evita");
	logoList[i++] = new makeLogo("The Producers", "producers");	
	logoList[i++] = new makeLogo("A Musical Offering", "musical_offering");
	logoList[i++] = new makeLogo("Hail, Bright Cecilia", "bright_cecilia");
	logoList[i++] = new makeLogo("A Neapolitan New Year", "neapolitan_new_year");
	logoList[i++] = new makeLogo("Springtime in Paris", "springtime_paris");
	logoList[i++] = new makeLogo("Roman Holiday", "roman_holiday");	 
	logoList[i++] = new makeLogo("Oliver!", "oliver");
	logoList[i++] = new makeLogo("A Christmas Carol", "christmas_carol");  
	logoList[i++] = new makeLogo("1909-2009: The Great Collaborators of the Ballets Russes", "ballets_russes");	
	logoList[i++] = new makeLogo("Arts in Motion presents DANSCAPE 2009 - Saturday, December 12 7:30pm", "danscape");
	logoList[i++] = new makeLogo("Camelot", "camelot");	 
	logoList[i++] = new makeLogo("MENOPAUSE THE MUSICAL", "menopause");	
	logoList[i++] = new makeLogo("Houston Bar Association presents Night Court Twenty - Thursday, March 04 7:30pm", "night_court");	
	logoList[i++] = new makeLogo("Kingwood Dance Theatre Ballet Gala", "kingwood");
	logoList[i++] = new makeLogo("Uptown Dance Company presents <i>Spring Dance Fusion</i>", "uptown");
	logoList[i++] = new makeLogo("Meet Me in St. Louis", "meet_me_stlouis");   
	logoList[i++] = new makeLogo("Company", "company");	
	logoList[i++] = new makeLogo("Mi Colombia", "mi_colombia");	
	logoList[i++] = new makeLogo("Ars Lyrica 2010-2011 Full Season Subscription", "ars_lyrica");
	logoList[i++] = new makeLogo("Ars Lyrica 2010-2011 Pick 4 Season Subscription", "ars_lyrica");
	logoList[i++] = new makeLogo("Ars Lyrica 2010-2011 Pick 3 Season Subscription", "ars_lyrica"); 
	logoList[i++] = new makeLogo("La Dirindina", "dirindina");	
	logoList[i++] = new makeLogo("Monteverdi Vespers", "vespers");	
	logoList[i++] = new makeLogo("Musical Resolutions", "ars_lyrica");	
	logoList[i++] = new makeLogo("Forbidden Pleasures", "forbidden");	
	logoList[i++] = new makeLogo("Bach St. John Passion", "stjohns");	
	logoList[i++] = new makeLogo("Masquerade Theatre", "rent");	
	logoList[i++] = new makeLogo("Rent", "rent");
	logoList[i++] = new makeLogo("Ars Lyrica 2010-2011 Season", "ars_lyrica");
	logoList[i++] = new makeLogo("Houston Brass Band presents FULL ON BRASS", "brass_band");
	logoList[i++] = new makeLogo("Foundation for Modern Music presents Katrina Ballads", "katrina_ballads"); 
	logoList[i++] = new makeLogo("Terra", "terra");
	logoList[i++] = new makeLogo("Masquerade Theatre", "chess");
	logoList[i++] = new makeLogo("CHESS", "chess");
	logoList[i++] = new makeLogo("Houston Ebony Opera", "operaGems");
	logoList[i++] = new makeLogo("Houston Ebony Opera presents Opera Gems Concert: &quot;Church Roots and Operatic Wings&quot;", "operaGems");	
	logoList[i++] = new makeLogo("Amahl and the Night Visitors", "amahl");
	logoList[i++] = new makeLogo("An Evening with Amy Grant", "amy_grant");
	logoList[i++] = new makeLogo("Synergy Production Group presents Pieces of our Lives - An Evening with Amy Grant", "amy_grant");
	logoList[i++] = new makeLogo("MUSIQA 2010-2011 SEASON", "realandImagined");
	logoList[i++] = new makeLogo("DOMINIC WALSH DANCE THEATER 2009-2010 SEASON", "FallRep");
	logoList[i++] = new makeLogo("SHE TOLD ME THIS", "sheToldMe");
	logoList[i++] = new makeLogo("REAL AND IMAGINED", "realandImagined");
	logoList[i++] = new makeLogo("ART OF CONVERSATION", "artofConversation");
	//logoList[i++] = new makeLogo("FALL MIXED REP", "FallRep");
	//logoList[i++] = new makeLogo("WINTER MIXED REP", "winterRep");
	//logoList[i++] = new makeLogo("SPRING MIXED REP", "springRep");
	logoList[i++] = new makeLogo("Divas World 2010-2011 Season", "newYork");
	logoList[i++] = new makeLogo("Divas World Season Subscription", "newYork");
	logoList[i++] = new makeLogo("New Orleans", "newOrleans");
	logoList[i++] = new makeLogo("Chicago", "chicago");
	logoList[i++] = new makeLogo("Jazz Brunch", "jazzBrunch");
	logoList[i++] = new makeLogo("New York", "newYork"); 
	
	logoList[i++] = new makeLogo("Jekyll & Hyde", "jekyllhyde");
	logoList[i++] = new makeLogo("The Drowsy Chaperone", "drowsychaperone");
	logoList[i++] = new makeLogo("Urinetown The Musical", "urinetown");
	logoList[i++] = new makeLogo("Sunday in the Park with George", "sundayswithgeorge");
	logoList[i++] = new makeLogo("Thoroughly Modern Millie", "millie");
	logoList[i++] = new makeLogo("MASQUERADE THEATRE 2011/2012 SEASON", "masq_th");
	logoList[i++] = new makeLogo("CHICAGO", "na");	 
	
	logoList[i++] = new makeLogo("The Civil War", "civilwar");	
	logoList[i++] = new makeLogo("Dirty Rotten Scoundrels", "dirtyrottenscoundrels");	
	logoList[i++] = new makeLogo("Galveston, The Musical", "galveston");	
	logoList[i++] = new makeLogo("Chicago", "masqueradechicago");	
	logoList[i++] = new makeLogo("My Fair Lady", "myfairlady");	

				  
	logoList[i++] = new makeLogo("Musical Alchemy", "musicalalchemy");
	logoList[i++] = new makeLogo("Paradise Found", "paradisefound");
	logoList[i++] = new makeLogo("Bach and Time", "bachandtime");
	logoList[i++] = new makeLogo("La Resurrezione", "laresurrezione");
	logoList[i++] = new makeLogo("Heaven and Hell", "heavenandhell");  
	
	logoList[i++] = new makeLogo("Made in Argentina", "madeinargentina");
	logoList[i++] = new makeLogo("Houston Symphonic Band", "houstonsymphonicband");	
	
	logoList[i++] = new makeLogo("Musiqa 2011-2012 Season", "musiqaLogo");
	logoList[i++] = new makeLogo("Full Concert Series", "musiqaLogo");
	logoList[i++] = new makeLogo("Musiqa 11/12 Season Subscription", "musiqaLogo");
	logoList[i++] = new makeLogo("Play a Song For Me", "playaSongforMe");
	logoList[i++] = new makeLogo("Free of the Ground", "freeoftheGround");
	logoList[i++] = new makeLogo("Crossings", "crossings"); 
  logoList[i++] = new makeLogo("Around the World with Musiqa", "showPhoto-aroundtheWorld.thumbnail"); 	


/* --------------------------------------------------
	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("SB"), "softball");
	//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("SOC","SO","MS","WS"), "soccer");
	logoGroupList[i++] = new makeLogo(new Array("CLD"), "calendar");

	logoGroupList[i++] = new makeLogo(new Array("CAVEMAN"), "caveman");
	logoGroupList[i++] = new makeLogo(new Array("APRIL09"), "joseph_n_atdc");
	logoGroupList[i++] = new makeLogo(new Array("ARS08", "ARS"), "ars_lyrica");
	logoGroupList[i++] = new makeLogo(new Array("DWDT"), "showPhoto-dwdt.thumbnail");
	logoGroupList[i++] = new makeLogo(new Array("FALL"), "showPhoto-fallMixedRep2011.thumbnail");
	logoGroupList[i++] = new makeLogo(new Array("WINTER"), "showPhoto-winterMixedRep2012.thumbnail");
	logoGroupList[i++] = new makeLogo(new Array("SPRING"), "na");
	logoGroupList[i++] = new makeLogo(new Array("APOLLO"), "showPhoto-fromRussiawithLove.thumbnail");
	logoGroupList[i++] = new makeLogo(new Array("SC"), "showPhoto-secondaryColors.thumbnail");
	logoGroupList[i++] = new makeLogo(new Array("VIRT"), "showPhoto-virtuosiofHouston.thumbnail");
	

/* --------------------------------------------------
	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;
			}
		}
		
		// custom code
		if(logo=="") {
			var str = name
			if (name.match("THE SCREWTAPE LETTERS")) {
				logo = "screwtape";
			} else if(name.indexOf("XXXXX") > -1) {
				logo = "xxxxx";
			}
		}
		// 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;
						}
					}
				}
			}
		}
		
		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="74" height="43" alt="'+extraName+'" align="absmiddle">';
			} else {
				for(var k=0; k<logo.length; k++) {
					imgSrc += '<img src="'+imageWWWPath+'/logos/'+logo[k]+'.gif" border="0" width="74" height="43" alt="'+extraName+'" align="absmiddle"> ';
				}
			}
			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="74" height="43/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="74" height="43/ig, 'width="30" height="30" align="absmiddle"');
			
			//remove full size code
			imgSrc = imgSrc.replace(/((<a href[^>]+>){1}|(<br>(<([^>]+)>)+ view large(<([^>]+)>)+ click to close(<([^>]+)>)+))/ig, "");
		}
		return(imgSrc);
	}
	
