
/**
 * 
 */
gm.widget.AreaCodes = {

	/**
	 * 
	 */
	data : [
		'201 - NJ - N New Jersey: Jersey City, Hackensack - 973, 551',
		'202 - DC - Washington, D.C.',
		'203 - CT - Connecticut - 860',
		'204 - MB - Manitoba Canada',
		'205 - AL - Alabama (including Huntsville and Birmingham], excludes only the southeastern corner of Alabama and the deep south.) - 256, 334',
		'206 - WA - W. Washington state: Seattle - 253, 360, 425, 564',
		'207 - ME - Maine',
		'208 - ID - Idaho',
		'209 - CA - Central California - 559',
		'210 - TX - San Antonio S. Texas - 830, 956',
		'212 - NY - New York City, New York - 646,718',
		'213 - CA - Los Angeles California - 310, 626, 818',
		'214 - TX - Dallas Texas - 469, 972',
		'215 - PA - Philadelphia Pennsylvania - 267',
		'216 - OH - Cleveland - 330, 440',
		'217 - IL - Central Illinois',
		'218 - MN - North Minnesota',
		'219 - IN - North Indiana - 260, 574',
		'224 - IL - Northern NE Illinois - 847',
		'225 - LA - Louisiana: Baton Rouge, New Roads, Donaldsonville, Albany, Gonzales, Greensburg, Palquemine, Vacherie - 504',
		'226 - ON - SW Ontario Canada',
		'228 - MS - South Mississippi - 601',
		'229 - GA - SW Georgia - 912, 478',
		'231 - MI - Michigan - 248, 810',
		'234 - OH - NE Ohio - 330',
		'236 - VA - Virginia',
		'239 - FL - Florida - 305',
		'240 - MD - West Maryland: Silver Spring, Frederick - 301',
		'242 - Bahamas',
		'246 - Barbados',
		'248 - MI - Michigan: Oakland county - 231, 810, 947',
		'250 - BC - British Columbia - 604',
		'251 - AL - South Alabama - 205, 256, 334',
		'252 - NC - NE Carolina - 919',
		'253 - WA - South Washington - 206, 425, 564',
		'254 - TX - Central Texas - 817, 940',
		'256 - AL - North and East Alabama - 205, 334',
		'260 - IN - NE Indiana - 219',
		'262 - WI - Wisconsin - 414, 920',
		'264 - Anguilla - 809',
		'267 - PA - SE Pennsylvania: Philadelphia - 215',
		'268 - Antigua and Barbuda - 809',
		'269 - MI - SW Michigan - 616',
		'270 - KY - West Kentucky - 502',
		'276 - VA - South Virginia - 540',
		'278 - MI - Michigan - 734',
		'280 - MD - Maryland - 240, 301',
		'281 - TX - Texas: Houston Metro - 713, 832',
		'282 - IL - Illinois - 309',
		'283 - OH - SW Ohio - 513',
		'284 - British Virgin Islands - 809',
		'289 - ON - South Central Canada - 905',
		'301 - MD - W Maryland: Silver Spring, Frederick - 240',
		'302 - DE - Delaware',
		'303 - CO - Central Colorado: Denver - 720, 970',
		'304 - WV - West Virginia',
		'305 - FL - SE Florida: Miami - 239, 786, 954',
		'306 - SK - Saskatchewan Canada',
		'307 - WY - Wyoming',
		'308 - NE - West Nebraska',
		'309 - IL - West Central Illinois - 282',
		'310 - CA - South California: Los Angeles - 424, 562',
		'312 - IL - Chicago, Illinois (Downtown only) - 630, 773, 847, 872',
		'313 - MI - Detroit and suburbs - 734',
		'314 - MO - SE Missouri: St Louis metro area only - 557, 573, 636',
		'315 - NY - North Central New York',
		'316 - KS - South Kansas - 620',
		'317 - IN - Central Indiana - 765',
		'318 - LA - Northern Louisiana - 337, 504',
		'319 - IA - East Iowa - 319',
		'320 - MN - Central. Minnesota',
		'321 - FL - Florida - 407',
		'323 - CA - Los Angeles - 213',
		'325 - TX - Central Texas - 915',
		'330 - OH - NE Ohio: Arkon, Canton, and Youngstown area - 216, 234, 440',
		'331 - IL - NE Illinois - 630, 708',
		'334 - AL - South Alabama',
		'336 - NC - Central North Carolina - 910',
		'337 - LA - SW Louisiana - 318',
		'339 - MA - Boston Massachusetts - 508, 617, 781',
		'340 - US Virgin Islands - 809',
		'345 - Cayman Islands',
		'347 - NY - New York - 718',
		'351 - MA - North Massachusetts - 508, 781, 978',
		'352 - FL - Florida - 904',
		'353 - WI - Wisconsin',
		'354 - FL - Florida',
		'356 - NJ - New Jersey',
		'358 - PA - Pennsylvania - 412, 724',
		'360 - WA - W. Washington State - 206',
		'361 - TX - South Texas: Corpus Christi - 512',
		'369 - CA - California',
		'380 - OH - Ohio - 614',
		'383 - ME - Maine',
		'384 - OH - Ohio',
		'385 - UT - Utah - 435, 801',
		'386 - FL - Daytona Beach, Florida - 904',
		'401 - RI - Rhode Island',
		'402 - NE - East Nebraska',
		'403 - AB - Alberta - 780, 867',
		'404 - GA - N Georgia: Atlanta - 678, 770',
		'405 - OK - Oklahoma City metro - 580, 918',
		'406 - MT - Montana',
		'407 - FL - Central Florida: Metro Orlando',
		'408 - CA - Cupertino, Los Gatos, Milpitas, Sunnyvale, Santa Clara, and San Jose area. - 415',
		'409 - TX - SE Texas: Galveston, Port Arthur - 936, 979',
		'410 - MD - East Maryland - 443',
		'412 - PA - West Pennsylvania - 724, 358',
		'413 - MA - West Massachusetts',
		'414 - WI - SE Wisconsin: Milwaukee - 920',
		'415 - CA - San Francisco, California - 408, 650',
		'416 - ON - Canada: Metrolpolitan Toronto - 647',
		'417 - MO - SW Missouri: Springfield',
		'418 - QC - NE Quebec',
		'419 - OH - NW Ohio: Toledo - 567',
		'423 - TN - East Tennessee - 615, 865',
		'424 - CA - Los Angeles, South California - 310, 562',
		'425 - WA - North Washington - 206, 253, 564',
		'430 - TX - NE Texas - 903',
		'432 - TX - West Texas - 915',
		'434 - VA - East Virginia - 757, 804',
		'435 - UT - Utah outside Salt Lake City - 801',
		'438 - QC - Canada: SW Quebec - 514',
		'440 - OH - Ohio: Cleveland metro area, excluding Cleveland - 216, 330',
		'441 - Bermuda - 809',
		'443 - MD - East Maryland - 410',
		'450 - QC - Southeastern Quebec outside metro Montreal',
		'464 - IL - Illinois',
		'469 - TX - Texas - 214, 972',
		'470 - GA - Georgia - 404, 678, 770',
		'473 - Grenada - 809',
		'475 - CT - Connecticut',
		'478 - GA - Central Georgia - 229, 912',
		'479 - AR - NW Arkansas - 501',
		'480 - AZ - Arizona - 520, 602, 623',
		'484 - PA - SE Pennsylvania: Allentown, Reading - 610',
		'501 - AR - Central Arkansas - 870',
		'502 - KY - W Kentucky: Louisville - 270',
		'503 - OR - Oregon - 541, 971',
		'504 - LA - East Louisiana: New Orleans - 225, 985, 318',
		'505 - NM - New Mexico',
		'506 - NB - New Brunswick Canada',
		'507 - MN - South Minnesota: Rochester',
		'508 - MA - Cent. Massachusetts: Framingham - 774, 978',
		'509 - WA - East Washington',
		'510 - CA - California: Oakland, East Bay - 925',
		'512 - TX - S Texas: Austin - 361',
		'513 - OH - SW Ohio - 937',
		'514 - QC - SW Quebec: Montreal - 438',
		'515 - IA - Central Iowa - 641',
		'516 - NY - Nassau county on Long Island and New York: Hempstead - 631',
		'517 - MI - Central Michigan - 989',
		'518 - NY - NE New York: Albany',
		'519 - ON - SW Ontario: Windsor - 226',
		'520 - AZ - Arizona outside the Phoenix area - 602, 928',
		'530 - CA - NE California: Chico, Redding - 916',
		'540 - VA - Fredericksburg and Roanoke and nearby areas - 276, 703',
		'541 - OR - Oregon - 503, 541',
		'546 - MI - E Michigan - 810',
		'551 - NJ - North New Jersey - 201',
		'557 - MO - SE Missouri - 314',
		'559 - CA - California: Fresno - 209',
		'561 - FL - Florida (S. Central) (West Palm Beach, Boca Raton, Vero Beach) - 772',
		'562 - CA - California: Long Beach - 310',
		'563 - IA - East Iowa - 319',
		'564 - WA - West Washington - 360, 206, 253, 425',
		'567 - OH - NW Ohio - 419',
		'570 - PA - E Pennsylvania: Wilkes-Barre, Scranton - 717',
		'571 - VA - North Virginia - 540, 703',
		'573 - MO - SE Missouri: excluding St Louis metro area',
		'574 - IN - North Indiana - 219',
		'580 - OK - Western and Sothern Oklahoma - 405, 918',
		'585 - NY - NW New York: Rochester - 716',
		'586 - MI - Michigan - 810',
		'590 - French West Indies',
		'600 - Canadian Services',
		'601 - MS - Mississippi - 228, 662, 769',
		'602 - AZ - Phoenix Arizona - 480, 520, 623',
		'603 - NH - New Hampshire',
		'604 - BC - Canada: British Columbia, Greater Vancouver - 250, 778',
		'605 - SD - South Dakota',
		'606 - KY - East Kentucky: Ashland - 859',
		'607 - NY - South Central New York: Ithaca, Binghamton',
		'608 - WI - SW Wisconsin: Madison',
		'609 - NJ - South New Jersey: Trenton - 856',
		'610 - PA - SE Pennsylvania: Allentown, Reading - 484, 835',
		'612 - MN - Central Minnesota, Minneapolis - 651, 763, 952',
		'613 - ON - Canada: SE Ontario, Ottawa',
		'614 - OH - SE Ohio: Columbus - 380',
		'615 - TN - East Tennessee: Nashville - 423, 931',
		'616 - MI - West Michigan: Grand Rapids - 269',
		'617 - MA - East Massachusetts: Boston - 857',
		'618 - IL - South Illinois',
		'619 - CA - South California: San Diego - 760, 858, 935',
		'620 - KS - South Kansas: Wichita - 316',
		'623 - AZ - Arizona - 480, 520, 602',
		'626 - CA - SE California: Pasadena - 818',
		'630 - IL - NE Illinois, Oak Brook or Chicago suburbs - 312, 331, 708',
		'631 - NY - New York: Suffolk County - 516',
		'636 - MO - Missouri - 314, 573',
		'641 - IA - Iowa - 515',
		'646 - NY - Manhattan New York - 212, 917',
		'647 - ON - South Central Ontario - 416',
		'650 - CA - Peninsula south of San Francisco -- San Mateo county, parts of Santa Clara county - 415',
		'651 - MN - Central Minnesota, St. Paul - 612, 763, 952',
		'657 - CA - North California - 714',
		'660 - MO - North Missouri - 816',
		'661 - CA - California: N. Los Angeles, Mckittrick, Mojave, Newhall, Oildale, Palmdal, Taft, Tehachapi, Bakersfield, Earlimart, Lancaster - 805',
		'662 - MS - Mississippi - 601',
		'664 - Montserrat - 809',
		'669 - CA - Central California coast - 408',
		'671 - Guam',
		'678 - GA - North Georgia: Atlanta - 404, 770',
		'682 - TX - Fort Worth Texas',
		'689 - FL - Central Florida - 321, 407',
		'701 - ND - North Dakota',
		'702 - NV - South Nevada - 775',
		'703 - VA - Northern Virginia: Arlington, McLean, Tysons Corner - 540, 571',
		'704 - NC - West North Carolina: Charlotte',
		'705 - ON - Canada: NW Ontario, Sault Ste. Marie',
		'706 - GA - North Georgia: Columbus, Augusta',
		'707 - CA - NW California: Santa Rosa',
		'708 - IL - Central NE Illinois: Oak Brook - 464, 630',
		'709 - NF - Canada Newfoundland',
		'710 - US Government',
		'712 - IA - West Iowa',
		'713 - TX - Mid SE Texas: Houston - 281, 832',
		'714 - CA - North and Central Orange County - 657, 949',
		'715 - WI - North Wisconsin: Eau Claire',
		'716 - NY - NW New York: Buffalo, Rochester - 585',
		'717 - PA - East Pennsylvania: Wilkes-Barre, Scranton - 570',
		'718 - NY - New York City Metro Area, New York - 212, 347',
		'719 - CO - SE Colorado: Pueblo, Colorado Springs',
		'720 - CO - Central Colorado: Denver - 303',
		'724 - PA - SW Pennsylvania - 412',
		'727 - FL - Tampa Metro: Saint Petersburg, Clearwater - 813',
		'731 - TN - West Tennessee - 901',
		'732 - NJ - Central New Jersey: New Brunswick, Bound Brook - 848, 908',
		'734 - MI - SE Michigan: west and south of Detroit -- Ann Arbor, Monroe - 313',
		'737 - TX - South Texas - 512, 614',
		'740 - OH - SE Ohio - 614',
		'757 - VA - E Virginia, Williamsburgh area, including Portsmouth - 804',
		'758 - St. Lucia - 809',
		'760 - CA - California: Southeastern San Diego north to Sierra Nevada - 619',
		'763 - MN - Minnesota - 612, 952',
		'765 - IN - Indiana: outside Indianapolis - 317',
		'770 - GA - Atlanta and suburbs - 285, 404, 678',
		'772 - FL - South central Florida - 561',
		'773 - IL - Non-downtown Chicago, Illinois - 312, 872',
		'774 - MA - Massachusetts - 508, 978',
		'775 - NV - Nevada - 702',
		'778 - BC - British Colombia Canada - 250, 604',
		'780 - AB - Alberta Canada - 403',
		'781 - MA - E Massachusetts: Boston suburbs - 339, 508, 617',
		'784 - St. Vincent/Grenadines - 809',
		'785 - KS - N Kansas: Topeka - 913',
		'786 - FL - SE Florida - 305',
		'787 - PR - Puerto Rico - 939',
		'801 - UT - Salt Lake City Metro - 385, 435',
		'802 - VT - Vermont',
		'803 - SC - South Carolina - 843, 864',
		'804 - VA - East Virginia: Richmond - 434, 757',
		'805 - CA - South Central Coastal California: Bakersfield - 661',
		'806 - TX - Panhandle Texas: Amarillo',
		'807 - ON - Canada: West Ontario, Thunder Bay',
		'808 - HI - HAWAII',
		'809 - Bermuda, Puerto Rico, Virgin Islands, Caribbean - 441,340',
		'810 - MI - East Michigan: Flint, Pontiac - 248, 586',
		'812 - IN - South Indiana: Evansville',
		'813 - FL - SW Florida: Tampa Metro - 727, 941',
		'814 - PA - Central Pennsylvania: Erie',
		'815 - IL - NE Illinois: Rockford, Kankakee',
		'816 - MO - N Missouri: Kansas City - 660, 975',
		'817 - TX - N Cent. Texas: Fort Worth area - 254, 940',
		'818 - CA - S California: Los Angeles - 213, 310, 562, 626',
		'819 - QC - Canada: NW Quebec: Trois Rivieres - 867',
		'828 - NC - West North Carolina: Asheville - 704',
		'830 - TX - Texas: North and West of San Antonio - 210',
		'831 - CA - California: central coast area from Santa Cruz through Monterey County',
		'832 - TX - Texas - 281, 713, 936',
		'835 - PA - SE Pennsylvania - 484, 610',
		'843 - SC - South Carolina - 803',
		'845 - NY - New York - 914',
		'847 - IL - Northern NE Illinois: Oak Brook - 224, 312',
		'848 - NJ - Central New Jersey - 732',
		'850 - FL - Florida panhandle, from east of Tallahassee to Pensacola - 904',
		'856 - SW New Jersey - 609',
		'857 - Massachusetts - 617',
		'858 - CA - S California: San Diego - 619, 760, 935',
		'859 - KY - Kentucky - 606',
		'860 - CT - Connecticut - 203',
		'861 - FL - SW Florida - 863, 941',
		'862 - NJ - North New Jersey - 973',
		'863 - FL - Florida',
		'864 - SC - South Carolina - 803',
		'865 - TN - Tennessee - 423, 615',
		'867 - YT - Canada: Yukon and Northwest Territories - 403,819',
		'868 - Trindad & Tobago',
		'869 - St. Kitts/Nevis',
		'870 - AR - South Arkansas - 501',
		'872 - IL - Illinois: Chicago - 312, 773',
		'876 - Jamaica',
		'877 - Domestic Toll-Free',
		'878 - PA - Pittsburgh - 412',
		'888 - Domestic Toll-Free',
		'900 - Personal paid service line',
		'901 - TN - W Tennessee: Memphis - 615, 731, 931',
		'902 - NS - Canada: Nova Scotia, Prince Edward Island',
		'903 - TX - NE Texas: Tyler - 430',
		'904 - FL - North Florida: Jacksonville - 352, 386, 850',
		'905 - ON - South central Ontario - 416, 647',
		'906 - MI - Upper Peninsula Michigan: Sault Ste. Marie, Escanaba, Marquette',
		'907 - AK - Alaska',
		'908 - NJ - Cent. New Jersey: Elizabeth, Basking Ridge, Somerville, Bridgewater - 732',
		'909 - CA - Inland empire: San Bernandino - 951',
		'910 - NC - South Central North Carolina: Fayetteville, Wilmington - 336',
		'912 - GA - South Georgia: Savannah - 229, 478',
		'913 - KS - North East Kansas/Kansas City Metro/Leavenworth - 785',
		'914 - NY - South New York: White Plains - 845',
		'915 - TX - West Texas: Sweetwater - 325, 432',
		'916 - CA - NE California: Sacramento - 530',
		'917 - NY - New York City, New York - 646',
		'918 - OK - East Oklahoma: Tulsa - 405, 580',
		'919 - NC - East North Carolina: Raleigh - 252, 984',
		'920 - WI - NE Wisconsin - 414',
		'925 - CA - California - 510',
		'928 - AZ - Arizona - 520',
		'931 - TN - Central Tennessee - 615',
		'935 - CA - South California: San Diego - 760, 858, 619',
		'936 - TX - SE Texas - 409, 254, 817, 940, 979',
		'937 - OH - SW Ohio: Dayton - 513',
		'939 - PR - Puerto Rico - 787',
		'940 - TX - North Central Texas: Denton, Wichita Falls - 254, 817, 936',
		'941 - FL - SW Florida: Tampa Area - 813, 863',
		'947 - MI - Michigan - 248',
		'949 - CA - South Coastal Orange County California - 714',
		'951 - CA - West riverside California - 909',
		'952 - MN - Minnesota - 612, 763',
		'954 - FL - Broward County area, including Ft. Lauderdale - 305, 754',
		'956 - TX - Valley of Texas area (Harlingen) - 210',
		'959 - CT - Connecticut - 860',
		'970 - CO - North and West Colorado - 303',
		'971 - OR - Oregon - 503',
		'972 - TX - Texas: Dallas Metro: Dallas and parts of Denton and Collin counties - 214, 469',
		'973 - NJ - North New Jersey: Newark Paterson Morristown - 201, 862',
		'975 - MO - North Missouri - 816',
		'976 - Personal paid service line',
		'978 - MA - Central Massachusetts - 508, 978',
		'979 - TX - SE Texas - 409, 936',
		'980 - NC - Carolina - 704',
		'984 - NC - Carolina - 919',
		'985 - LA - E Louisiana - 504',
		'989 - MI - Michigan - 517'
	],

	/**
	 * 
	 */
	submitForm : function(form) {
		var a = ($('areaCodeInput').value).substring(0,3);
		var u = this._URL.areaCodePage + "?artistid=" + (gm.artistid || "3") + "&areacode=" + a
		location.href = u;
	},

	/**
	 * The URLS used in the site
	 */
	_URL : {
		localAreaCodePics : 'eventpicfeed3.xml',
		areacodepics : "http://" + location.hostname + '/api/messages.php',
		eventPage      : "event_pics.html",
		areaCodePage   : "event_area_code.html"
	},

	/**
	 * Holds the html strings used in the picture blog
	 */
	_HTML : {
		galleryLink : "View As Slideshow",
		loading : '<div class="loadingDiv">Loading ...</div>',
		item :
			'<div class="imgWrapper"><img src="${imgsrc}" alt="${imgtxt}" /><div class="overlay"></div></div>' +
			'<div class="text">' + 
				'<div class="copy">${imgtxt}</div>' +
				'<div class="post">Posted ${post} ${imgtime}<br />${event} ${areacode}</div>' + 
			'</div>' +
			'<div class="clr"></div>',
		postedBy : 'By ${postedby} ',
		event    : 'Event: <a href="${eventurl}">${eventname}</a><br />',
		areaCode : 'Area Code: <a href="${areacodeurl}">${areacode}</a>'
	},

	/**
	 * Reference to the artist
	 * @type int
	 */
	_artistid : gm.artistid || 3,
	
	/**
	 * Holds the xml data
	 * @type XMLDocument
	 */
	_x : null,
	
	/**
	 * Holds the item data for the current page
	 * @type Array
	 */
	_d : [],
	
	/**
	 * Holds the xml data for a single event (showing in the gallery)
	 */
	_xe :null,
	
	/**
	 * Holds the item data for a single event (showing in the gallery)
	 */	
	_de :[],

	/**
	 * State trackers
	 * @type boolean
	 */
	isInit : false,

	/**
	 * @type boolean
	 */
	paging : false,

	/**
	 * @type int
	 */
	numItems : 0,
	
	/**
	 * Tracks the number of times the dialog has been opened
	 * @type int
	 */
	_dialogCounter : 0,
	
	/**
	 * Tracks the event that we are currently showing
	 * @type String
	 */	
	eventid : null,
	
	areacode : null,
	
	/**
	 * function initializes the object / html
	 */
	init : function() {
		this.eventid = gm.util.getURLParameter("eventid");
		this.areacode = gm.util.getURLParameter("areacode");
		if (gm.isDebug) {
			this._URL.areacodepics = this._URL.localAreaCodePics;
		}
		this.render();
		this.isInit = true;
	},
	
	/**
	 * Gets the data to show in the blogroll for a single page.
	 * @param {int} offset   the number to start loading the paged data from
	 */
	getPage : function(offset) {
		this.currentOffset = offset;
		pel = $('livePicContent');
		pel.innerHTML = this._HTML.loading;

		var u = this._URL.areacodepics + "?offset=" + offset + "&limit=" + this.elementsPerPage + "&artistid=" + this._artistid;
		u += (this.areacode) ? "&areacode=" + this.areacode : "";
		this._x = gm.util.AJAX.syncRequest(u);
		this.totalRecords = this._x.firstChild.getAttribute("totalRecords");
		this.setPagingLinks(offset);
	},

	/**
	 * Gets the item data for a single event
	 * @param {String} areacode
	 */
	getAreaCodeItems : function(areacode) {
		// generate the url
		var u = this._URL.areacodepics + "?artistid=" + this._artistid + "&areacode=" + areacode;

		// get the data
		var x = gm.util.AJAX.syncRequest(u);
		var a = x.getElementsByTagName("item");
		var d = [];
		
		for (var i = 0;i<a.length;i++) {
			if (a[i].getAttribute("areacode") == areacode) {
				d.push(a[i]);
			}
		}
		this._xe = x;
		this._de = d;
		return d;
	},

	/**
	 * Renders the picture blog roll
	 */
	render : function() {
		if (!this._x) {
			this.getPage(0);
		}
		var prevEvent = "",i,els,pel,t,a,self=this,isFirst=true,eventNameCnt=-1,picIndex = 0;
		els = this._x.getElementsByTagName("item");
		this.numItems = els.length;
		pel = $('livePicContent');
		pel.innerHTML = "";
		
		this._d = [];
		
		// no items
		if (this.numItems == 0) {
			pel.innerHTML = '<div class="noEventsFound">We\'re Sorry.<br /><br />There were no pictures or messages found for this event.  Please try another one.</div>'
			return;
		}
		
		// loop through the items and render them
		for (i = 0;i<this.numItems;i++) {
			if (prevEvent != els[i].getAttribute('areacode')) {
				// cache the pic for this event in one array
				eventNameCnt++;
				picIndex = 0;
				this._d[eventNameCnt] = [];
				t = document.createElement("div");
				t.className = (isFirst) ? "livePicEvent first" :"livePicEvent" ;
				prevEvent = els[i].getAttribute('areacode');
				t.innerHTML = prevEvent + "&nbsp;&nbsp;";
				a = document.createElement("a");
				this.attachEventAction(a,eventNameCnt);
				a.innerHTML = this._HTML.galleryLink;
				pel.appendChild(t);
				t.appendChild(a);
				isFirst = true;
			}

			// attach the link so that hash's will scroll to this item
			t = document.createElement("a");
			t.name = els[i].getAttribute('itemid');
			pel.appendChild(t);
			
			t = document.createElement("div");
			t.className = (isFirst) ? "livePicItem first" : "livePicItem";
			isFirst = false;
			h= gm.util.widget.template(this._HTML.item,{
				post     : (els[i].getAttribute('postedby')) ? this._HTML.postedBy : "",
				event    : (els[i].getAttribute('eventid')) ? this._HTML.event   : "",
				areacode : (els[i].getAttribute('areacode')) ? this._HTML.areaCode : ""
			});
	
			t.innerHTML = gm.util.widget.template(h,{
				imgtime     : els[i].getAttribute('timepassedstring'),
				postedby    : els[i].getAttribute('postedby'),
				imgtxt      : els[i].getAttribute('caption'),
				imgsrc      : els[i].getAttribute('image').replace("_F.jpg","_B.jpg"),
				eventname   : els[i].getAttribute('eventname'),
				eventurl    : this._URL.eventPage + "?artistid=" + this._artistid + "&eventid=" + els[i].getAttribute('eventid'),
				areacode    : els[i].getAttribute('areacode'),
				areacodeurl : this._URL.areaCodePage + "?artistid=" + this._artistid + "&areacode=" + els[i].getAttribute('areacode')
			});

			this.attachItemAction(t.firstChild,eventNameCnt,picIndex);
			this._d[eventNameCnt].push(els[i]);
			pel.appendChild(t);
			picIndex ++;
		}
	},

	/**
	 * Attaches actions to the event header
	 * @param {HTMLElement} el     the element that we are attaching events to
	 * @param {int}         index  the index of the event
	 */
	attachEventAction : function(el,index) {
		var self = this;
		YAHOO.util.Event.addListener(el, "click", function() {self.openGallery(index);}); 
	},

	/**
	 * Attaches actions to each item
	 * @param {HTMLElement} el         the item that we are attaching events to
	 * @param {int}         index      the index of the event
	 * @param {int}         itemIndex  the index of the item in the event
	 */
	attachItemAction : function(el,index,itemIndex) {
		var self = this;
		YAHOO.util.Event.addListener(el, "click", function() {self.openGallery(index,itemIndex);}); 
	},

	/**
	 * Calls the method to open a gallery
	 * @param {Object} index
	 */
	openGallery : function(index,picindex) {
		// get the handle to the els for this event
		var els = this.getAreaCodeItems(this._d[index][0].getAttribute("areacode"));
		var selEl = (!picindex && picindex != 0) ? els[0] : this._d[index][picindex] ;
		gm.widget.Gallery.open(els,selEl);
	},

	/**
	 * the number of elements we want to show per page
	 */
	elementsPerPage : 10,

	/**
	 * The current offset
	 * @type int
	 */
	currentOffset : 0,

	/**
	 * tracks the toal records
	 * @type int
	 */
	totalRecords : 0,

	/**
	 * gets the previous page
	 * @param {Object} el
	 */
	prev : function(el) {
		el.blur();
		if (gm.util.hasClass(el,"disabled")) {
			return;
		}
		
		this.getPage(this.currentOffset - this.elementsPerPage);
		this.render();
	},

	/**
	 * gets the next page
	 */
	next : function(el) {
		el.blur();
		if (gm.util.hasClass(el,"disabled")) {
			return;
		}

		this.getPage(this.currentOffset + this.elementsPerPage);
		this.render();
	},

	/**
	 * gets the first page
	 */
	first : function() {
		this.getPage(0);
		this.render();
	},

	/**
	 * gets the last page
	 */
	last : function() {
		this.getPage(this.totalRecords - (this.totalRecords % this.elementsPerPage) - 1);
		this.render();
	},

	/**
	 * sets the display of the paging links
	 * @param {Object} offset
	 */
	setPagingLinks : function(offset) {
		
		
		// if there are no paging links to show return;
		if (this.totalRecords < this.elementsPerPage) {
			gm.util.addClass($('prevPage1'),"invisible");
			gm.util.addClass($('prevPage2'),"invisible");
			gm.util.addClass($('nextPage1'),"invisible");
			gm.util.addClass($('nextPage2'),"invisible");
			return;
		}

		// set the paging numbers
		gm.util.removeClass($('prevPage1'),"disabled");
		gm.util.removeClass($('prevPage2'),"disabled");
		gm.util.removeClass($('nextPage1'),"disabled");
		gm.util.removeClass($('nextPage2'),"disabled");

		// disable the prev button
		if (offset == 0) {
			gm.util.addClass($('prevPage1'),"disabled");
			gm.util.addClass($('prevPage2'),"disabled");
		}

		// disable the next button
		if ( (offset + this.elementsPerPage) >= this.totalRecords) {
			gm.util.addClass($('nextPage1'),"disabled");
			gm.util.addClass($('nextPage2'),"disabled");
		}
		

	},

	/**
	 * unloads the data
	 */
	unload : function(){
		clearTimeout(this._t);
		this._x = null;
		this._d = null;
		this._xe = null;
		this._de = null;
		this._HTML.item = null;
		this._HTML = null;
		this.isInit = null;
		this.paging = null;
	}	
};