/* --------------------------------------------------
	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("@ Univ of Virginia", "virginia");
	logoList[i++] = new makeLogo("@ Temple", "temple");
	logoList[i++] = new makeLogo("Boston College", "bc");
	logoList[i++] = new makeLogo("New Hampshire", "unh");
	logoList[i++] = new makeLogo("W. Carolina", "wcu");
	logoList[i++] = new makeLogo("Morgan State", "morgan");
	logoList[i++] = new makeLogo("Old Dominion", "odu");
	logoList[i++] = new makeLogo("VMI", "vmi");
	logoList[i++] = new makeLogo("Radford", "runet");
	logoList[i++] = new makeLogo("William & Mary", "wm");
	logoList[i++] = new makeLogo("Boston College 1/24", "bc");
	logoList[i++] = new makeLogo("UCONN 1/27", "uconn");
	logoList[i++] = new makeLogo("Seton Hall 2/3", "shu");
	logoList[i++] = new makeLogo("Miami 2/14", "muohio");
	logoList[i++] = new makeLogo("Pittsburgh 2/28", "pittstate");
	logoList[i++] = new makeLogo("St. John&#39;s 3/2", "stjohns");
	logoList[i++] = new makeLogo("Notre Dame", "nd");
	logoList[i++] = new makeLogo("UCONN", "uconn");
	logoList[i++] = new makeLogo("Providence", "providence");
	logoList[i++] = new makeLogo("Georgetown", "georgetown");
	logoList[i++] = new makeLogo("St. John&#39;s", "stjohns");
	logoList[i++] = new makeLogo("West Virginia", "wvu");
	logoList[i++] = new makeLogo("Rutgers", "rutgers");	  
	
	logoList[i++] = new makeLogo("Gardner-Webb", "gardner-webb");
	logoList[i++] = new makeLogo("Mt. St. Mary&#39;s", "msm");
	logoList[i++] = new makeLogo("Elon", "elon");
	logoList[i++] = new makeLogo("Wisconsin", "wisc");
	logoList[i++] = new makeLogo("Longwood", "longwood");
	logoList[i++] = new makeLogo("Virginia", "virginia");
	logoList[i++] = new makeLogo("Richmond", "richmond");
	logoList[i++] = new makeLogo("Boston College", "bc");
	logoList[i++] = new makeLogo("Clemson", "clemson");
	logoList[i++] = new makeLogo("N.C. State", "ncstate");
	logoList[i++] = new makeLogo("Georgia Tech", "gatech");
	logoList[i++] = new makeLogo("Florida State", "fsu");
	logoList[i++] = new makeLogo("Duke", "duke");
	logoList[i++] = new makeLogo("North Carolina", "unc");	  
	logoList[i++] = new makeLogo("Deleware St.", "dsc"); 
	logoList[i++] = new makeLogo("Marshall", "marshall");
	logoList[i++] = new makeLogo("Miami", "miami");	
	
	logoList[i++] = new makeLogo("Georgia", "uga");
	logoList[i++] = new makeLogo("Charleston Southern", "csuniv");
	logoList[i++] = new makeLogo("UMBC", "umbc");
	logoList[i++] = new makeLogo("NC Central", "nccu");
	logoList[i++] = new makeLogo("Wake Forest", "wfu");
	logoList[i++] = new makeLogo("Maryland", "umd");
	logoList[i++] = new makeLogo("N. C. State", "ncstate");
	logoList[i++] = new makeLogo("James Madison", "jmu");
	logoList[i++] = new makeLogo("East Carolina", "ecu");
	logoList[i++] = new makeLogo("Central Michigan", "cmich");
	
	logoList[i++] = new makeLogo("Purdue", "purdue");
	logoList[i++] = new makeLogo("Penn State", "penn_state");
	
	logoList[i++] = new makeLogo("Orange Bowl", "orange_bowl");
	logoList[i++] = new makeLogo("Chick-fil-A", "chickfila");
	
	logoList[i++] = new makeLogo("ACC Championship", "acclogo");
	logoList[i++] = new makeLogo("Chick-fil-A Bowl", "chickfila");
	logoList[i++] = new makeLogo("Champs Bowl", "ChampsSportsBowl");
	logoList[i++] = new makeLogo("Sun Bowl", "sun_bowl");
	logoList[i++] = new makeLogo("Belk Bowl", "BelkBowl");
	logoList[i++] = new makeLogo("Music City Bowl", "music_city_bowl");
	logoList[i++] = new makeLogo("Independence Bowl", "IndependenceBowl");
	logoList[i++] = new makeLogo("Military Bowl", "militarybowllogo");
	
	logoList[i++] = new makeLogo("St. Bonaventure", "st_bonaventure");
	logoList[i++] = new makeLogo("Kansas State", "ksu");
	logoList[i++] = new makeLogo("Norfolk State", "nsu");
	logoList[i++] = new makeLogo("Campbell", "campbell");
	logoList[i++] = new makeLogo("North Florida", "unf");
	logoList[i++] = new makeLogo("Eastern Michigan", "emich");
	logoList[i++] = new makeLogo("BYU", "byu");
	logoList[i++] = new makeLogo("East Tenn. State", "etsu");
	
	logoList[i++] = new makeLogo("N.C. Central", "nccu");
	
	
	/*
	logoList[i++] = new makeLogo("@ ECU - $60", "ecu");
	logoList[i++] = new makeLogo("@ Marshall University -$50", "marshall");
	logoList[i++] = new makeLogo("@ Wake Forest - $50", "wfu");
	logoList[i++] = new makeLogo("@ Duke University -$45", "duke");
	logoList[i++] = new makeLogo("@ Georgia Tech - $50", "gatech");
	logoList[i++] = new makeLogo("@ Virginia - $70", "uva2");
	*/

/* --------------------------------------------------
	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","FBP"), "vatech-football-helmet");
	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","BBI","BBN"), "vt-basketball");
	logoGroupList[i++] = new makeLogo(new Array("WB","WBS","WBI"), "vt-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");

/* --------------------------------------------------
	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.length==0) {
		// custom code
			var str = name
			if (str.match("CHICK")) {
				logo[0] = "chickfila";
			} else if(name.indexOf("xxxxx") > -1) {
				logo[0] = "na";
			}
		// end custom code
		}		
		
		// 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(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="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);
	}
	
