/* --------------------------------------------------
	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("YERMA", "yerma");
	logoList[i++] = new makeLogo("Dance 2004", "dance2004");
	logoList[i++] = new makeLogo("THE GRAPES OF WRATH", "grapesofwrath");
	logoList[i++] = new makeLogo("The Rivals", "rivals");
	logoList[i++] = new makeLogo("SHANGHAI SYMPHONY", "shanghai");
	logoList[i++] = new makeLogo("GIL SHAHAM", "gilshaham");
	logoList[i++] = new makeLogo("RIGOLETTO", "rigoletto");
	logoList[i++] = new makeLogo("SEAN CURRAN DANCE CO.", "seancurrandanceco");
	logoList[i++] = new makeLogo("LADYSMITH BLACK MAMBAZO", "lbm");
	logoList[i++] = new makeLogo("PARAGON RAGTIME ORCHESTRA", "paragon");
	logoList[i++] = new makeLogo("CINDERELLA", "cinderella");
	logoList[i++] = new makeLogo("BOLCOM AND MORRIS", "bolcomandmorris");
	logoList[i++] = new makeLogo("THAILAND FILM", "thailand");
	logoList[i++] = new makeLogo("THAILAND DINNER", "thailand");
	logoList[i++] = new makeLogo("NEW ZEALAND FILM", "newzealand");
	logoList[i++] = new makeLogo("NEW ZEALAND DINNER", "newzealand");
	logoList[i++] = new makeLogo("HOLLAND FILM", "holland");
	logoList[i++] = new makeLogo("HOLLAND DINNER", "holland");
	logoList[i++] = new makeLogo("BERMUDA FILM", "bermuda");
	logoList[i++] = new makeLogo("BERMUDA DINNER", "bermuda");
	logoList[i++] = new makeLogo("NORWAY FILM", "norway");
	logoList[i++] = new makeLogo("NORWAY DINNER", "norway");
	logoList[i++] = new makeLogo("WRIGHTS OF PASSAGE", "wrightsofpassage");
	logoList[i++] = new makeLogo("DAVID PARKER", "davidparker");
	logoList[i++] = new makeLogo("SARAH, PLAIN AND TALL", "sarahplainandtall");
	logoList[i++] = new makeLogo("Damn Yankees", "damnyankees");
	logoList[i++] = new makeLogo("Patsy Cline", "patsycline");
	logoList[i++] = new makeLogo("Smokey Joe&#39;s Cafe", "smokeyjoes");
	logoList[i++] = new makeLogo("Hair", "hair");
	logoList[i++] = new makeLogo("My Three Angels", "angels2");
	logoList[i++] = new makeLogo("As You Like It", "asyoulikeit2");
	logoList[i++] = new makeLogo("Dance 2005", "dance2");
	logoList[i++] = new makeLogo("The Children&#39;s Hour", "hour2");
	logoList[i++] = new makeLogo("Monday Subscription", "subscription");
	logoList[i++] = new makeLogo("Tuesday Subscription", "subscription");
	logoList[i++] = new makeLogo("Wednesday Subscription", "subscription");
	logoList[i++] = new makeLogo("Thursday Subscription", "subscription");		
	logoList[i++] = new makeLogo("Friday Subscription", "subscription");		
	logoList[i++] = new makeLogo("Saturday Subscription", "subscription");
	logoList[i++] = new makeLogo("Sunday Subscription", "subscription");
	logoList[i++] = new makeLogo("Saturday Subscription", "subscription");
	logoList[i++] = new makeLogo("Saturday Night Subscription", "subscription");
	logoList[i++] = new makeLogo("P06 Subscriptions", "P06");
	logoList[i++] = new makeLogo("The Pajama Game", "pj");
	logoList[i++] = new makeLogo("The Importance of Being Earnest", "ernest");
	logoList[i++] = new makeLogo("Dance 2006", "dance2006");
	logoList[i++] = new makeLogo("Godspell", "godspell");
	logoList[i++] = new makeLogo("The Time of Your Life", "time");	
	logoList[i++] = new makeLogo("Thursday Night Package", "P06");
	logoList[i++] = new makeLogo("Friday Night Package", "P06");
	logoList[i++] = new makeLogo("Saturday Night Package", "P06");
	logoList[i++] = new makeLogo("Sunday Matinee Package", "P06");
	logoList[i++] = new makeLogo("Monday Night Package", "P06");
	logoList[i++] = new makeLogo("Tuesday Night Package", "P06");
	logoList[i++] = new makeLogo("THE RAINBOW FISH", "rainbowfish");
	logoList[i++] = new makeLogo("AMBER BROWN IS NOT A CRAYON", "amber");
	logoList[i++] = new makeLogo("TOYING WITH SCIENCE", "toying");
	logoList[i++] = new makeLogo("MY HERO...REACHING FOR THE STARS", "storybook");
	logoList[i++] = new makeLogo("DALLAS BRASS", "dallasbrass");
	logoList[i++] = new makeLogo("MUNICH SYMPH. ORCHESTRA", "munich");
	logoList[i++] = new makeLogo("PILOBOLUS II", "pilobolus");
	logoList[i++] = new makeLogo("VAN CLIBURN MEDALIST", "van");
	logoList[i++] = new makeLogo("UNFORGETTABLE", "unforgettable");
	logoList[i++] = new makeLogo("THE BLACK WATCH", "blackwatch");
	logoList[i++] = new makeLogo("RUSSIAN NATIONAL BALLET", "russian");
	logoList[i++] = new makeLogo("BJ WARD: STAND UP OPERA", "bjward");	
	logoList[i++] = new makeLogo("PILOBUS II", "pilobolus");
	logoList[i++] = new makeLogo("Four Seasons Subscriptions", "fourseasons");
	logoList[i++] = new makeLogo("Four Seasons Concert #1", "gerlach");
	logoList[i++] = new makeLogo("Four Seasons Concert #2", "elina");
	logoList[i++] = new makeLogo("Four Seasons Concert #3", "ehnes");
	logoList[i++] = new makeLogo("Four Seasons Concert #4", "frautschi");
	logoList[i++] = new makeLogo("Hello Dolly!", "hellodolly");
	logoList[i++] = new makeLogo("The Underpants", "underpants");
	logoList[i++] = new makeLogo("Dance 2008", "dance2008");
	logoList[i++] = new makeLogo("Flora, The Red Menace", "flora");
	logoList[i++] = new makeLogo("Iphigenia in Aulis", "iphigenia");
	logoList[i++] = new makeLogo("Tueady Night Subscription", "subscription2");	 
	
	logoList[i++] = new makeLogo("FRIENDS & FAMILY", "playhouse");
	logoList[i++] = new makeLogo("BIG RIVER", "BRWO");
	logoList[i++] = new makeLogo("BIG RIVER SUNDAY MATINEE", "BRWO");
	logoList[i++] = new makeLogo("BIG RIVER SATURDAY MATINEE", "BRWO");	
	
	logoList[i++] = new makeLogo("VAGINA MONOLOGUES-1", "vm");
	logoList[i++] = new makeLogo("VAGINA MONOLOGUES-2", "vm");
	logoList[i++] = new makeLogo("VAGINA MONOLOGUES-3", "vm");
	logoList[i++] = new makeLogo("NOT IN THIS HOUSE", "Notinthishouse");	
	logoList[i++] = new makeLogo("BTJF-CHESTNUT", "CyrusChestnut");
	logoList[i++] = new makeLogo("BRIGADOON", "brigadoon");
	logoList[i++] = new makeLogo("DANCE 2011", "dance2011");
	logoList[i++] = new makeLogo("MERRY WIVES OF WINDSOR", "merrywives");
	logoList[i++] = new makeLogo("Orpheus Descending", "orpheusDesc");
	logoList[i++] = new makeLogo("PUTNAM COUNTY SPELLING BEE", "spellingbee");
	logoList[i++] = new makeLogo("FUNDRAISER", "scholarshipfund");
	logoList[i++] = new makeLogo("Stage Door", "StageDoor");
	logoList[i++] = new makeLogo("Oklahoma!", "Oklahoma");
	logoList[i++] = new makeLogo("Oklahoma", "Oklahoma");
	logoList[i++] = new makeLogo("Dance 2012", "Dance2012");
	logoList[i++] = new makeLogo("The Elephant Man", "ElephantMan");
	logoList[i++] = new makeLogo("Elephant Man", "ElephantMan");
	logoList[i++] = new makeLogo("The Threepenny Opera", "ThreePennyOpera");
	logoList[i++] = new makeLogo("Threepenny Opera", "ThreePennyOpera");
	logoList[i++] = new makeLogo("Encore!", "Encore");
	
	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";
	
	// NEW (accomodates more than one logo)
	function printLogo(name, mgroup) {
		var logo = new Array();
		name = name.toUpperCase();
		
		while(name.indexOf("  ")>-1) {
			name = name.replace(/  /g, " ");
		}
		
		
		for(var i=0; i < logoList.length; i++) {
			var listName = logoList[i].oname.toUpperCase();
			listName = listName.replace(/'/,"&#39;"); // fix apostrophes
			for(var j=0; j < extraList.length; j++) {
				var listExtra = extraList[j].toUpperCase();
				if(
					(listName + listExtra == name || listExtra + listName == name) && 
					!(logo.length>0 && logo[logo.length-1]==logoList[i].ologo)
				) {
					logo.push(logoList[i].ologo);
				}
			}
		}

		if(logo.length==0) {
		// custom code
			var str = name
			if (str.match("DAY OF DANCE 2012")) {
				logo[0] = "dayofdance2012";
			} else if(name.indexOf("XXXX") > -1) {
				logo[0] = "xxxx";
			}
		// end custom code
		}		 

		if(logo.length==0) {	
			if(typeof(fullGroupList)!="undefined" && mgroup!="") {			  
				while(logo.length==0 && mgroup!="") {
					switch(mgroup) {
						case "F": // football
							logo.push("football"); break;
						case "BB": // baseball
							logo.push("baseball"); break;
						case "SB": // softball
							logo.push("softball"); break;
						case "MB": case "WB": // basketball
							logo.push("basketball"); break;
						case "VB": case "MVB": case "WVB": // volleyball
							logo.push("volleyball"); break;
						case "H": // hockey
							logo.push("hockey"); break;							
						case "FOUR": // Four Seasons
							logo.push("fourseasons_grp"); break;
						case "OTIS":
							logo.push("OfTheeIsing"); break;	
						case "IMINV":
							logo.push("imaginary"); break;
						case "BBOY":
						 	logo.push("batboy"); break;
						case "AWEW":
							logo.push("ALLSWELL"); break;		
						case "DANCE09":
							logo.push("dance2009"); break;	
						case "PAS": // PAS
							logo.push("pas"); break;
						case "SUBS":
							logo.push("subscription"); break;								
						case "SOC": case "MS": case "WS": // soccer
							logo.push("soccer"); break;
						case "CRUCIBLE":
							logo.push("Crucible"); break;								
						case "SEVENBRIDES":
							logo.push("SevenBrides"); break;								
						case "DANCE2010":
							logo.push("Dance2010"); break;								
						case "PLAY":
							logo.push("PlaySam"); break;								
						case "WILD":
							logo.push("Wild-Party"); break;	
            case "FW":
						  logo.push("ECU_FW"); break;							
					}
					var parent = "";
					for(var i=0; i<fullGroupList.length; i++) {
						if(fullGroupList[i].code==mgroup) {
							parent = fullGroupList[i].parent;
						}
					}
					mgroup = parent;
				}
				if(logo.length==0) logo.push("ECU_FW"); // default
			} else {
				switch(mgroup) {
					case "F": case "FBS": case "FBI": // football
						logo.push("football"); break;
					case "BB": // baseball
						logo.push("baseball"); break;
					case "SB": // softball
						logo.push("softball"); break;
					case "MB": case "MBS": case "MBI":  // basketball
						logo.push("basketball"); break;
					case "WB": case "WBS": case "WBI":  // basketball
						logo.push("basketball"); break;
					case "VB": case "MVB": case "WVB": // volleyball
						logo.push("volleyball"); break;
					case "H": // hockey
						logo.push("hockey"); break;
					case "SOC": case "MS": case "WS": // soccer
						logo.push("soccer"); break;
					case "FW":
						logo.push("ECU_FW"); break;
					default: // not avail
						logo.push("ECU_FW"); break;
				}
			}
		}

		// custom code -  only for group code == SUBS
		if(logo.length==0) {		
		  if (pageName="DisplayEventList.html" && group.code=="SUBS") {
		    logo.push("ECU_FW");
		  }		
		}
		

		var imgSrc = "";

		if(logo.length>0) {
			for(var k=0; k<logo.length; k++) {
				imgSrc += '<img src="'+imageWWWPath+'/logos/'+logo[k]+'.gif" border="0" width="60" height="60" alt="'+name+'">';
			}
		}
		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);
	}
