/* --------------------------------------------------
	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("SOUTHEASTERN LOUISIANA", "selu");
	logoList[i++] = new makeLogo("HOUSTON", "uh");
	logoList[i++] = new makeLogo("ALCORN STATE", "alcorn");
	logoList[i++] = new makeLogo("MISSISSIPPI STATE", "msstate");
	logoList[i++] = new makeLogo("EAST CAROLINA", "ecu");
	logoList[i++] = new makeLogo("CENTRAL FLORIDA", "ucf");
	logoList[i++] = new makeLogo("ALABAMA-BIRMINGHAM (DH)", "uab");
	logoList[i++] = new makeLogo("TULSA", "utulsa");
	logoList[i++] = new makeLogo("ALABAMA-BIRMINGHAM", "uab");
	logoList[i++] = new makeLogo("TULSA (DH)", "utulsa");
	logoList[i++] = new makeLogo("Southeastern LA", "selu");
	logoList[i++] = new makeLogo("NC State", "ncstate");
	logoList[i++] = new makeLogo("UAB", "uab");
	logoList[i++] = new makeLogo("Marshall", "marshall");
	logoList[i++] = new makeLogo("UCF", "ucf");
	logoList[i++] = new makeLogo("Tulsa", "utulsa");
	logoList[i++] = new makeLogo("Memphis", "memphis");
	logoList[i++] = new makeLogo("Tulane", "tulane");
	logoList[i++] = new makeLogo("Tennessee - Martin", "martinmethodist");
	logoList[i++] = new makeLogo("Alabama State", "alasu");
//	logoList[i++] = new makeLogo("Spring Hill", "");
	logoList[i++] = new makeLogo("Sam Houston State", "shsu");
	logoList[i++] = new makeLogo("Savannah State", "savstate");
//	logoList[i++] = new makeLogo("Southern - New Orleans", "");
//	logoList[i++] = new makeLogo("Reinhardt", "");
	logoList[i++] = new makeLogo("McNeese State", "mcneese");
	logoList[i++] = new makeLogo("Auburn", "auburn");
	logoList[i++] = new makeLogo("ECU", "ecu");
	logoList[i++] = new makeLogo("UTEP", "utep");
	logoList[i++] = new makeLogo("Stephen F Austin", "sfasu");
	logoList[i++] = new makeLogo("Jacksonville State Univeristy", "jsu");
	logoList[i++] = new makeLogo("Arkansas-little Rock", "ualr");
	logoList[i++] = new makeLogo("Centenary College", "centenary");
	logoList[i++] = new makeLogo("Southern Methodist", "smu");
	logoList[i++] = new makeLogo("Rice University", "rice");
	logoList[i++] = new makeLogo("C-USA Championship Game", "cusaChampGame");
	logoList[i++] = new makeLogo("AutoZone Liberty Bowl", "azlbpms");
	logoList[i++] = new makeLogo("GMAC Bowl", "gmac_bowl_logo");
	logoList[i++] = new makeLogo("South Alabama", "southalabama");
	logoList[i++] = new makeLogo("Jackson State", "jsums");
	logoList[i++] = new makeLogo("Louisiana-Monroe", "ulm");
	logoList[i++] = new makeLogo("Southern Illinois", "siu-siuc");
	logoList[i++] = new makeLogo("Louisville", "louisville");
	logoList[i++] = new makeLogo("Northwestern State", "nsula");
	logoList[i++] = new makeLogo("South Alabama", "southalabama");
	logoList[i++] = new makeLogo("New Orleans", "uno");
	logoList[i++] = new makeLogo("Louisiana-Lafayette", "louisiana");
	logoList[i++] = new makeLogo("Kent State", "kent");
	logoList[i++] = new makeLogo("Rice", "rice");
	logoList[i++] = new makeLogo("Nicholls State", "nich");
	logoList[i++] = new makeLogo("Mississippi", "olemiss");
	logoList[i++] = new makeLogo("Louisiana-Monroe", "ulm");
	logoList[i++] = new makeLogo("Dallas Baptist (DH)", "dbu");
	logoList[i++] = new makeLogo("Dallas Baptist", "dbu");
	logoList[i++] = new makeLogo("UT Martin", "utm");
	logoList[i++] = new makeLogo("SMU", "smu");
	logoList[i++] = new makeLogo("Arkansas State", "astate");
	logoList[i++] = new makeLogo("Power House Spring Football Game", "powerhouse");	  
	
	logoList[i++] = new makeLogo("Papajohns.com Bowl", "papajohns_bowl");
	logoList[i++] = new makeLogo("2007 Bowl Bash", "dreambbq");
	logoList[i++] = new makeLogo("University of Southern Mississippi Symphony Orchestra", "usm_seal");
//	logoList[i++] = new makeLogo("Southern Miss Athletic Events", "usm_seal");	 	
	logoList[i++] = new makeLogo("Shangri-La Gala", "usm_seal");
	
	logoList[i++] = new makeLogo("@ Auburn", "auburn2");
  	logoList[i++] = new makeLogo("@ Arkansas State", "astate");
 	logoList[i++] = new makeLogo("Boise State", "boisestate");
	logoList[i++] = new makeLogo("@ Rice", "Rice_Logo");
	logoList[i++] = new makeLogo("@ Memphis", "memphis");
	logoList[i++] = new makeLogo("@ UCF", "UCF3");
	logoList[i++] = new makeLogo("@ SMU", "smu");
	logoList[i++] = new makeLogo("Jackson State (DH)", "jsums");
	logoList[i++] = new makeLogo("Baylor", "baylor2");
	logoList[i++] = new makeLogo("East Carolina (DH)", "ecu");
	logoList[i++] = new makeLogo("Memphis (DH)", "memphis");
	logoList[i++] = new makeLogo("LSU", "lsu2");
	logoList[i++] = new makeLogo("UTEP (DH)", "utep");
	logoList[i++] = new makeLogo("Northwestern State (DH)", "Northwestern_State");
	logoList[i++] = new makeLogo("Houston (DH)", "uh"); 	
	logoList[i++] = new makeLogo("Cal State Fullerton", "fullerton");	
	logoList[i++] = new makeLogo("Louisiana Tech", "latech");
	logoList[i++] = new makeLogo("Northern Colorado", "northern_colorado2");
	logoList[i++] = new makeLogo("Mississippi Valley St.", "mvsu2");
	logoList[i++] = new makeLogo("Tennessee Tech", "tenntech");	 
	
	logoList[i++] = new makeLogo("Virginia", "uva");
	logoList[i++] = new makeLogo("Loyola (N.O.)", "lno");
	logoList[i++] = new makeLogo("Spring Hill", "SpringHillCollegeBadgers");
	logoList[i++] = new makeLogo("Dillard", "DU_Logo"); 
	logoList[i++] = new makeLogo("Cal State Bakersfield", "csub");	
	logoList[i++] = new makeLogo("Mississippi Valley State", "mvsu2");	
	logoList[i++] = new makeLogo("LeMoyne College", "lemoyne_owen");	
	logoList[i++] = new makeLogo("Louisiana Monroe", "louisianaMonroe");	
	logoList[i++] = new makeLogo("Troy", "troy");	
	logoList[i++] = new makeLogo("Missouri State", "smsu");	
	logoList[i++] = new makeLogo("UNO", "uno");	
	logoList[i++] = new makeLogo("St. Mary's College", "stmarys_ca");	 	
	logoList[i++] = new makeLogo("LSU @ Zephyr Field", "lsu2");
	logoList[i++] = new makeLogo("@ South Carolina", "sc");	
	logoList[i++] = new makeLogo("FestivalSouth 2010", "fs");
	
	logoList[i++] = new makeLogo("2010 Beef &#39;O&#39; Brady&#39;s Bowl", "beef_o_brady_s_bowl");
	
	logoList[i++] = new makeLogo("Eastern Illinois", "eastern_illinois");
	logoList[i++] = new makeLogo("Alabama A&M", "aamu");
	logoList[i++] = new makeLogo("Ole Miss", "olemiss");
	logoList[i++] = new makeLogo("Marshall (DH)", "marshall");
	logoList[i++] = new makeLogo("Alabama", "ua");
	logoList[i++] = new makeLogo("Navy", "usna");
	
	logoList[i++] = new makeLogo("Football", "football");
	
	logoList[i++] = new makeLogo("Loyola", "lno");
	logoList[i++] = new makeLogo("William Carey", "C-Helmet Art");
	logoList[i++] = new makeLogo("New Mexico State", "nmsu");
	logoList[i++] = new makeLogo("South Florida", "south_fl");
	logoList[i++] = new makeLogo("East Carolilna", "ecu");
	logoList[i++] = new makeLogo("East Carolina", "ecu");
	logoList[i++] = new makeLogo("UT-Martin", "utm2");
	logoList[i++] = new makeLogo("Jacksonville State", "jsu");
	logoList[i++] = new makeLogo("Florida A&M", "famu");
	logoList[i++] = new makeLogo("UL Monroe", "louisianaMonroe");
	logoList[i++] = new makeLogo("Belhaven", "belhaven");
	
	logoList[i++] = new makeLogo("Armed Forces Bowl", "Armed-Forces-Bowl");
	logoList[i++] = new makeLogo("Hawaii Bowl", "Hawaii-Bowl");
	logoList[i++] = new makeLogo("Hawaii Bowl Ticket for Troops", "Hawaii-Bowl");
	logoList[i++] = new makeLogo("Liberty Bowl", "Liberty-Bowl");
	logoList[i++] = new makeLogo("Ticket City Bowl", "TicketCity-Bowl");
	
	
/* --------------------------------------------------
	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("TD", "SY", "ART", "ST"), "usm_seal"); // custom code - Arts mgroups
	logoGroupList[i++] = new makeLogo(new Array("FSS", "FSP"), "FS");
  logoGroupList[i++] = new makeLogo(new Array("WBCUSA", "MBCUSA"), "CUSALogo");	

/* --------------------------------------------------
	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;
			}
		}

		if(logo=="" && name.indexOf("NEW ORLEANS BOWL")>-1) logo = "new_orleans_bowl";
		
		// 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 = "usm_seal";
		
		// 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);
	}
	
