/* --------------------------------------------------
	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("After the War", "afterTheWar");
	logoList[i++] = new makeLogo("Blackbird", "blackBird");
	logoList[i++] = new makeLogo("Hedda Gabler", "heddaGabler");
	logoList[i++] = new makeLogo("The Imaginary Invalid", "imaginaryInvalid");
	logoList[i++] = new makeLogo("Kiki & Herb Alive on Broadway", "kikiAndHerb");
	logoList[i++] = new makeLogo("Kiki & Herb<br><i>Alive From Broadway</i>", "kikiAndHerb");
	logoList[i++] = new makeLogo("The A.C.T. Young Conservatory presents<br>Fields of Gold: The Music of Sting", "fields_gold");
	logoList[i++] = new makeLogo("Not A Genuine Black Man", "not_genuine_black");
	logoList[i++] = new makeLogo("Sweeney Todd", "sweeney");
	logoList[i++] = new makeLogo("The Rainmaker", "rainmaker");
	logoList[i++] = new makeLogo("Speed the Plow", "plow");
	logoList[i++] = new makeLogo("The Blood Knot", "knot");
	logoList[i++] = new makeLogo("Blood Knot", "knot");
	logoList[i++] = new makeLogo("The Government Inspector", "inspector");
	logoList[i++] = new makeLogo("Curse of the Starving Class", "starving");
	logoList[i++] = new makeLogo("&#39;Tis Pity She&#39;s a Whore", "pity");  
	logoList[i++] = new makeLogo("Make a gift to The Next Generation Campaign!", "next_gen");
	logoList[i++] = new makeLogo("Subscriptions 2008-2009", "08_09logo");
	logoList[i++] = new makeLogo("Seven Play Subscriptions<br>2008-2009 Season", "08_09logo");
	logoList[i++] = new makeLogo("Partial Series Subscriptions<br>2008-2009 Season", "08_09logo");
	logoList[i++] = new makeLogo("5 Play Subscription Series<br>2008-2009 Season", "08_09logo");
	logoList[i++] = new makeLogo("4 Play Subscription Series<br>2008-2009 Season", "08_09logo");
	logoList[i++] = new makeLogo("Rock &#39;n&#39; Roll", "rock_roll");
	logoList[i++] = new makeLogo("The Quality of Life", "quality_life");
	//logoList[i++] = new makeLogo("A Christmas Carol", "cc09");
	logoList[i++] = new makeLogo("Rich and Famous", "rich_famous");
	logoList[i++] = new makeLogo("Souvenir: A Fantasia on the Life of Florence Foster Jenkins", "souvenir");
	logoList[i++] = new makeLogo("War Music", "war_music");
	logoList[i++] = new makeLogo("Boleros for the Discenchanted", "boleros_thumb");
	logoList[i++] = new makeLogo("Peter and Jerry", "peter_jerry");	  
	logoList[i++] = new makeLogo("At Home at the Zoo", "home_zoo");	
	
	logoList[i++] = new makeLogo("Brief Encounter", "brief_encounter_evenue");
	logoList[i++] = new makeLogo("November", "november_evenue");
	logoList[i++] = new makeLogo("A Christmas Carol", "carol09_evenue");
	logoList[i++] = new makeLogo("Phedre", "phedre_evenue");
	logoList[i++] = new makeLogo("The Caucasian Chalk Circle", "chalk_circle_evenue");
	logoList[i++] = new makeLogo("Vigil", "vigil_evenue");
	logoList[i++] = new makeLogo("Round and Round the Garden", "garden_evenue");
	logoList[i++] = new makeLogo("The Tosca Project", "tosca_evenue"); 
	logoList[i++] = new makeLogo("Add a Donation to Your Ticket Order", "kids_thumb");	
	logoList[i++] = new makeLogo("The Brother/Sister Plays - Trilogy Package", "marcus");
	
	logoList[i++] = new makeLogo("Scapin", "Scapin");
	logoList[i++] = new makeLogo("Clybourne Park", "Clybourne-Park");
	logoList[i++] = new makeLogo("The Homecoming", "The-Homecoming");
	logoList[i++] = new makeLogo("No Exit", "No-Exit");
	logoList[i++] = new makeLogo("Marcus", "marcus"); 
	logoList[i++] = new makeLogo("Armistead Maupin&#39;s<br>Tales of the City", "totc");
	
	logoList[i++] = new makeLogo("Marcus; or The Secret of Sweet", "brother_sister_thumb");	
	
	logoList[i++] = new makeLogo("Scorched", "scorched");
	logoList[i++] = new makeLogo("The Scottsboro Boys", "scottsboro");
	logoList[i++] = new makeLogo("Twelfth Night", "twelfth_night");
	logoList[i++] = new makeLogo("Humor Abuse", "humor_abuse");
	logoList[i++] = new makeLogo("Maple and Vine", "maple_vine");
	logoList[i++] = new makeLogo("Once in a Lifetime", "once");
	logoList[i++] = new makeLogo("Race", "race");
	logoList[i++] = new makeLogo("Higher", "higher");
	logoList[i++] = new makeLogo("Endgame and Play", "endgame_n_play");

/* --------------------------------------------------
	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("SUBS09"), "09_10logo");
	logoGroupList[i++] = new makeLogo(new Array("NEW6", "NEW6B", "DESIS"), "10_11logo");	


/* --------------------------------------------------
	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
		if(logo=="") logo = "10_11logo";
		
		// 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" alt="'+extraName+'">';
			} else {
				for(var k=0; k<logo.length; k++) {
					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!="") {
			imgSrc = imgSrc.replace(/width="60" height="60"/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="60" height="60"/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);
	}
	
