/* --------------------------------------------------
	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("Lehigh", "lehigh");
	logoList[i++] = new makeLogo("James Madison", "jmu");
	logoList[i++] = new makeLogo("Massachusetts", "umass");
	logoList[i++] = new makeLogo("Delaware", "udel");
	logoList[i++] = new makeLogo("Drexel", "drexel");
	logoList[i++] = new makeLogo("Northeastern", "northeastern");
	logoList[i++] = new makeLogo("Hofstra", "hofstra");
	logoList[i++] = new makeLogo("Towson", "towson");
	logoList[i++] = new makeLogo("Richmond", "richmond");
	logoList[i++] = new makeLogo("Georgia State", "gsu");
	logoList[i++] = new makeLogo("William & Mary", "wm");
	logoList[i++] = new makeLogo("UNC Wilmington", "uncwil");
	logoList[i++] = new makeLogo("ODU", "odu");
	logoList[i++] = new makeLogo("Hampton", "hamptonu");
	logoList[i++] = new makeLogo("KENNY ROGERS", "siegel");
	logoList[i++] = new makeLogo("Bo Diddley", "siegel");
	logoList[i++] = new makeLogo("Scooby-Doo 10/19", "siegel");
	logoList[i++] = new makeLogo("TNA WRESTLING", "siegel");
	logoList[i++] = new makeLogo("Scooby-Doo 10/20", "siegel");
	logoList[i++] = new makeLogo("Genworth Tennis", "siegel");	
	logoList[i++] = new makeLogo("Virginia State (Exh)", "vastate");
	logoList[i++] = new makeLogo("Virginia Union (Exh)", "vuu");
	logoList[i++] = new makeLogo("Houston", "uh");
	logoList[i++] = new makeLogo("UAB", "uab");
	logoList[i++] = new makeLogo("Appalachian State", "appstate");
	logoList[i++] = new makeLogo("George Mason", "gmu");
	logoList[i++] = new makeLogo("JMU", "jmu");
	logoList[i++] = new makeLogo("Scooby-Doo 10/19", "scooby");
	logoList[i++] = new makeLogo("Scooby-Doo 10/20", "scooby");
	logoList[i++] = new makeLogo("Cirque Dreams", "cirquedreams");
	logoList[i++] = new makeLogo("KENNY ROGERS", "kenny-rogers");
	logoList[i++] = new makeLogo("Bo Diddley", "bo-diddley");
	logoList[i++] = new makeLogo("TNA WRESTLING", "tna-wrestling");
	logoList[i++] = new makeLogo("Thomas & Friends LIVE!", "thomasthemestar");
	logoList[i++] = new makeLogo("Thomas & Friends - 7PM Show", "thomasthemestar");
	logoList[i++] = new makeLogo("TNA WRESTLING-07", "tna_wrestling");
	logoList[i++] = new makeLogo("CAPITAL PUNISHMENT II", "tna_wrestling");
	logoList[i++] = new makeLogo("James Taylor Concert", "james_taylor");
	logoList[i++] = new makeLogo("VA State - Exhibition", "va_state");
	logoList[i++] = new makeLogo("VA Union Panthers - Exb.", "va_union");
	logoList[i++] = new makeLogo("Maryland-Eastern Shore", "umes");
	logoList[i++] = new makeLogo("Elon University", "elon");
	logoList[i++] = new makeLogo("William and Mary", "wm");
	logoList[i++] = new makeLogo("Longwood", "longwood");
	logoList[i++] = new makeLogo("Old Dominion", "odu");
	logoList[i++] = new makeLogo("Anthem Tennis Event", "anthem_tennis");
	logoList[i++] = new makeLogo("Genworth Concert w/ Sheryl Crow", "sheryl_crow");
	logoList[i++] = new makeLogo("2008-09 Men&#39;s Basketball Season Ticket Deposit", "basketball");
	logoList[i++] = new makeLogo("Valhalla Fights", "valhalla_fights");

	logoList[i++] = new makeLogo("VA Union - Exb.", "vuu");
	logoList[i++] = new makeLogo("VA State - Exb.", "va_state");
	logoList[i++] = new makeLogo("Citadel", "citadel");
	logoList[i++] = new makeLogo("South Dakota State", "southdakotast");
	logoList[i++] = new makeLogo("Western Michigan", "wmich");
	logoList[i++] = new makeLogo("Akron Zips", "uakron");
	logoList[i++] = new makeLogo("Hampton Pirates", "hamptonu");
	logoList[i++] = new makeLogo("Hofstra Pride", "hofstra");
	logoList[i++] = new makeLogo("Northeastern Huskies", "northeastern");
	logoList[i++] = new makeLogo("James Madison Dukes", "jmu");
	logoList[i++] = new makeLogo("Delaware Blue Hens", "delaware");

	logoList[i++] = new makeLogo("Virginia Union - Exhibition", "vuu");
	logoList[i++] = new makeLogo("Bethune Cookman Wildcats", "cookman");
	logoList[i++] = new makeLogo("Nevada", "unr");
	logoList[i++] = new makeLogo("Rhode Island", "uri");
	logoList[i++] = new makeLogo("East Carolina", "ecu");
	logoList[i++] = new makeLogo("UNC-Wilmington", "uncwil");
	
	logoList[i++] = new makeLogo("Tulane", "Tulane");
	logoList[i++] = new makeLogo("UNC Greensboro", "UNC-Greensboro");
	logoList[i++] = new makeLogo("VA Union - Exhibition", "Virginia-Union");
	logoList[i++] = new makeLogo("VMI", "VMI");
	logoList[i++] = new makeLogo("Wofford", "Wofford");
	logoList[i++] = new makeLogo("George Mason", "George-Mason");
	
	logoList[i++] = new makeLogo("NIT Preseason Tip Off vs. Winthrop", "winthrop");
	logoList[i++] = new makeLogo("VCU at South Florida", "south_fl");
	logoList[i++] = new makeLogo("VCU at Richmond", "richmond2");
	logoList[i++] = new makeLogo("VCU at Univ. of Alabama-Birmingham0", "uab");
	logoList[i++] = new makeLogo("VCU at Georgia State", "gsu");
	logoList[i++] = new makeLogo("VCU at UNCW", "uncwil");
	logoList[i++] = new makeLogo("VCU at William & Mary", "wm");
	logoList[i++] = new makeLogo("VCU at ODU", "odu");
	logoList[i++] = new makeLogo("VCU at Towson", "towson");
	logoList[i++] = new makeLogo("VCU at Northeastern", "northeastern");
	logoList[i++] = new makeLogo("VCU at JMU", "jmu");
	logoList[i++] = new makeLogo("VCU at Delaware", "delaware_GIF");
	logoList[i++] = new makeLogo("VCU at Drexel", "drexel");
	logoList[i++] = new makeLogo("UNCW Bus Trip", "uncwil");
	logoList[i++] = new makeLogo("Old Dominion Bus Trip", "odu");
	logoList[i++] = new makeLogo("Towson Bus Trip", "towson");
	logoList[i++] = new makeLogo("James Madison Bus Trip", "jmu");
	logoList[i++] = new makeLogo("Delaware Bus Trip", "delaware_GIF");
	logoList[i++] = new makeLogo("Drexel Bus Trip", "drexel");
	
	logoList[i++] = new makeLogo("UNCW", "uncwil");
	
	logoList[i++] = new makeLogo("VCU Rams Road to the Final Four", "DVD COVER");
	
	logoList[i++] = new makeLogo("Basketball Season Ticket", "basketball");
	logoList[i++] = new makeLogo("Season Long Parking Pass", "basketball");
	logoList[i++] = new makeLogo("RAF Donor Benefit - Complimentary Parking", "basketball");
	
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Navy", "usna");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Richmond", "richmond2");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Elon", "elon");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. George Mason", "gmu");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. James Madison", "jmu");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. William & Mary", "wm");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Towson", "towson");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Georgia State", "gsu");
	logoList[i++] = new makeLogo("Men&#39;s Soccer vs. Delaware", "delaware_GIF");
	
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. Marshall", "marshall");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. Appalachian St.", "appstate");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. George Mason", "gmu");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. UNC Wilmington", "uncwil");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. Georgia St.", "gsu");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. Old Dominion", "odu");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. William & Mary", "wm");
	logoList[i++] = new makeLogo("Women&#39;s Soccer vs. James Madison", "jmu");
	
	logoList[i++] = new makeLogo("Volleyball vs. Cornell", "cornell");
	logoList[i++] = new makeLogo("Volleyball vs. North Carolina A&T", "NCAT2_GIF");
	logoList[i++] = new makeLogo("Volleyball vs. George Washington", "gwu");
	logoList[i++] = new makeLogo("Volleyball vs. Howard", "howard");
	logoList[i++] = new makeLogo("Volleyball vs. Towson", "towson");
	logoList[i++] = new makeLogo("Volleyball vs. Delaware", "delaware_GIF");
	logoList[i++] = new makeLogo("Volleyball vs. James Madison", "jmu");
	logoList[i++] = new makeLogo("Volleyball vs. UNC Wilmington", "uncwil");
	logoList[i++] = new makeLogo("Volleyball vs. Georgia State", "gsu");
	logoList[i++] = new makeLogo("Volleyball vs. William & Mary", "wm");
	logoList[i++] = new makeLogo("Volleyball vs. Norfolk State", "nsu");
	
	logoList[i++] = new makeLogo("California University (Pa.)", "california_pa");
	logoList[i++] = new makeLogo("Saint Francis (Pa.)", "st_francis_PA");
	logoList[i++] = new makeLogo("South Florida", "south_fl");
	logoList[i++] = new makeLogo("Richmond", "richmond2");
	logoList[i++] = new makeLogo("William & Mary", "William-and-Mary-Loog");
	logoList[i++] = new makeLogo("Volleyball vs. George Mason", "George-Mason-logo");
	
	logoList[i++] = new makeLogo("High Point", "highpoint");
	logoList[i++] = new makeLogo("Charlotte", "uncc");
	logoList[i++] = new makeLogo("Coppin State", "coppin");
	logoList[i++] = new makeLogo("Norfolk State", "nsu");
	
	logoList[i++] = new makeLogo("@ WKU", "wku");
	logoList[i++] = new makeLogo("@ Alabama", "ua");
	logoList[i++] = new makeLogo("@ Akron", "uakron");
	logoList[i++] = new makeLogo("@ William & Mary", "wm");
	logoList[i++] = new makeLogo("@ George Mason", "gmu");
	logoList[i++] = new makeLogo("William & Mary", "wm");
	logoList[i++] = new makeLogo("George Mason", "gmu");
	
	logoList[i++] = new makeLogo("HOOPS FOR THE HOLIDAYS", "SantaHat");
	
	logoList[i++] = new makeLogo("Friends & Family Night - VCU vs. Towson", "towson");
	logoList[i++] = new makeLogo("ESPNU Brackbuster vs. Northern Iowa", "uni");
	logoList[i++] = new makeLogo("VCU Baseball vs. Long Beach State - 2/18/12 at 5:30 PT", "csulb3");
	logoList[i++] = new makeLogo("VCU Baseball vs. Long Beach - Pregame Alumni Reception", "csulb3");

/* --------------------------------------------------
	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","BS"), "baseball");
	logoGroupList[i++] = new makeLogo(new Array("SB"), "softball");
	logoGroupList[i++] = new makeLogo(new Array("MB","MBS","MBI","MBK"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("WB","WBS","WBI"), "basketball");
	logoGroupList[i++] = new makeLogo(new Array("V","VB","MVB","WVB"), "volleyball2");
	logoGroupList[i++] = new makeLogo(new Array("H"), "hockey");
	logoGroupList[i++] = new makeLogo(new Array("SOC","SO","MS","WS"), "soccer2");
	logoGroupList[i++] = new makeLogo(new Array("CLD"), "calendar");
	logoGroupList[i++] = new makeLogo(new Array("KC"), "JuniorRowdyRamFINAL");

/* --------------------------------------------------
	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(group!="renewals") {
		if(logo=="") logo = "na";
		} else {
			if(logo=="") logo = "football";  //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="60" height="60" alt="'+extraName+'" align="absmiddle">';
			} 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+'" 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="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);
	}
	
