<?xml version='1.0' encoding='UTF-8' ?>
<Module>
	<ModulePrefs 
		title="SonicLiving Calendar" 
		screenshot="http://sonicliving.com/gadget/images/gadgetScreenshot.png"
		thumbnail="http://sonicliving.com/gadget/images/gadgetbadge.png"
		scrolling="false"
		author="SonicLivning Folks"
		author_email="iheartmusic@sonicliving.com"
		author_affiliation="sonicliving.com"
		author_location="Oakland, CA"
		description="SonicLiving helps you find shows in your area. Add events to your calendar and see what your friends are up to. Sync with iTunes / Pandora / Last.fm / Google Calendar / iCal and more!"
		height="235"
		scaling="true">
    <Require feature="setprefs" />
	</ModulePrefs>

	<UserPref name="current_tab" datatype="hidden" />

	<UserPref name="user_id" display_name="User ID" default_value="0" />

	<Content type="html">
<![CDATA[
<script type="text/javascript">
	var arVersion = navigator.appVersion.split("MSIE");
	var browserVersion = parseFloat(arVersion[1]);

	function fixPNG(myImage)
	{
		if ((browserVersion >= 5.5) && (browserVersion < 7) && (document.body.filters))
		{
			var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""

			var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""

			var imgTitle = (myImage.title) ?  "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "

			var imgStyle = "display:inline-block; vertical-align:middle;" + myImage.style.cssText

			var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + myImage.width 
				+ "px; height:" + myImage.height 
				+ "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + myImage.src + "\', sizingMethod='image');\"></span>"

			myImage.outerHTML = strNewHTML	  
		}
	}
</script>

<link href="http://sonicliving.com/gadget/gadgetStyle.css?" rel="stylesheet" type="text/css">

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="http://sonicliving.com/gadget/iehacks.css" />
<![endif]-->
<div class="sl_gadget">
	<div class="sl_gadget_outer_box">
		<div class="sl_gadget_header_top">
			<img class="sl_gadget_button" src="http://sonicliving.com/gadget/images/gadgetButton-trans.png" width="35" height="35" onload="fixPNG(this)" />
			<span id="sl_gadget_pre_image"></span>
			<a target="_main" id="sl_gadget_logo_link" href="http://sonicliving.com">
				<img class="sl_gadget_logo" src="http://sonicliving.com/gadget/images/sonicLogo-trans.png" border="0" width="90" height="27" alt="SonicLiving" onload="javascript:fixPNG(this);" />
			</a>
			<span id="sl_gadget_post_image"></span>
		</div>

		<div id="sl_gadget_tabs" class="sl_gadget_header_bottom">
			<table border="0" width="100%" cellspacing="0" align="center">
				<tr>
					<td class="sl_gadget_tab" id="sl_gadget_pop_tab"><a href="javascript:displayEvents('sl_gadget_pop_tab');">Popular</a></td>
					<td class="sl_gadget_tab" id="sl_gadget_today_tab"><a href="javascript:displayEvents('sl_gadget_today_tab');">Today</a></td>
				</tr>
			</table>
		</div>

		<div id="sl_gadget_content_div" class="sl_gadget_content"></div>
		<div id="sl_gadget_bottom_tabs" class="sl_gadget_header_bottom sl_gadget_footer_tabs"></div>

		<div class="sl_gadget_footer">
			<form name="search_form" id="sl_gadget_search_form" action="javascript:displaySearchResults();">
				Search <input name="search" id="sl_gadget_search" type="text" onfocus="clearText(this);" onblur="resetText(this);"  value="Artist or Venue"/>
				<input type="image" id="sl_gadget_arrow" src="http://sonicliving.com/gadget/images/gadgetArrow-trans.png" width="22" height="22" onload="fixPNG(this)" />
			</form>
		</div>
	</div>
</div>
<script src="http://sonicliving.com/uid.js"></script>			

<script  type="text/javascript">
	prefs__MODULE_ID__ = new _IG_Prefs(__MODULE_ID__);

// Get some preference settings from google
current_tab = prefs__MODULE_ID__.getString("current_tab");
zip_code_id   = prefs__MODULE_ID__.getString("zip_code_id");
user_id     = prefs__MODULE_ID__.getString("user_id");				


// Decide if we're going to use the user_id from the website or the google settings
if (__sonicliving_user_id > 0)
{
	user_id = __sonicliving_user_id;
}
else if ( ! user_id ) 
{
	user_id = 0;
}

// Set the user_id in google gadget settings
prefs__MODULE_ID__.set("user_id", user_id);

// WebService Callers {{{

function getRegionInfo(zip_code_id)
{/*{{{*/
	//////////////
	/// This function gets the region info and updates the page layout
	//////////////
	var url = "http://sonicliving.com/region/" + zip_code_id + "/gadget/info.xml?" + get_random_param();

	if ( ! zip_code_id )
	{
		displayInfoPage('');			
		return;
	}

	_IG_FetchXmlContent(url, function (response)
	{
		// declare some vars
		var region_name = '';
	
		if (response == null || typeof(response) != "object" || response.firstChild == null)
		{
			region_name = 'invalid';
			return;
		}					

		// There is only ever a single element here.
		var itemList = response.getElementsByTagName("region");
		var nodeList = itemList.item(0).childNodes;

		for (var j = 0; j < nodeList.length ; j++)
		{
			var node = nodeList.item(j);
			if (node.nodeName == "name")
			{
				region_name = node.firstChild.nodeValue;									
			}
		}

		_gel('sl_gadget_pre_image').innerHTML = '';
		_gel('sl_gadget_post_image').innerHTML = 'in ' + region_name;

	});

	_gel('sl_gadget_bottom_tabs').innerHTML ='<table border="0" width="100%" cellspacing="0" align="center">' +
		'<tr>' +
		'<td class="sl_gadget_tab" id="sl_gadget_login_tab"><a href="javascript:displayLoginPage();">Sign In</a></td>' +
		'<td class="sl_gadget_tab" id="sl_gadget_newacct_tab"><a href="javascript:displayNewAcctPage();">Create Account</a></td>' +
		'<td class="sl_gadget_tab" id="sl_gadget_about_tab"><a href="javascript:displayInfoPage(\'\');">About SL</a></td>' +
		'</tr>' +
		'</table>';				
}/*}}}*/

function displaySearchResults()
{/*{{{*/
	//////////////
	/// This function gets the user info and updates the page layout with that users info
	//////////////

	var searchstr = _gel('sl_gadget_search').value;					 
	displayLoading('Searching For ' + searchstr + '...');

	var url = "http://sonicliving.com/gadget/search/" + encodeURI(searchstr) + "?" + get_random_param();
	var searchResults = new String();

	_IG_FetchXmlContent(url, function (response)
	{
		if (response == null || typeof(response) != "object" || response.firstChild == null)
		{
			// something sad
		}					
		var resultSectionList = response.getElementsByTagName("result_section");						
		for (var i = 0; i < resultSectionList.length ; i++)
		{
			var resultSections = resultSectionList.item(i).childNodes;
			var result_list = new String();

			for (var j = 0; j < resultSections.length ; j++)
			{
				var node = resultSections.item(j);

				if (node.nodeName == "title")
				{
					var title = node.firstChild.nodeValue;
				}

				if (node.nodeName == "sub_title")
				{
					var sub_title = node.firstChild.nodeValue;
				}
				if (node.nodeName == "secondary_info")
				{
					var secondary_info = node.firstChild.nodeValue;
				}

				if (node.nodeName == "result")
				{	
					var search_results = node.childNodes;

					for (var l = 0; l < search_results.length ; l++)
					{ 
						var result_node = search_results.item(l);
						if (result_node.nodeName == "result_title"){
							var result_title = result_node.firstChild.nodeValue;
						}
						if (result_node.nodeName == "result_secondary_info"){
							var result_secondary_info = result_node.firstChild.nodeValue;
						}
						if (result_node.nodeName == "result_link"){
							var result_link = result_node.firstChild.nodeValue;
						}
					}
					result_list += '<li><div class="sl_gadget_list_column-2">' + result_secondary_info + '</div>'
						+ ' <a href="http://sonicliving.com' + result_link 
						+ '" target="_main" class="sl_gadget_item_title">' + result_title + '</a></li>';
				}
			}

			var header_row = '<li class="sl_gadget_header"><div class="sl_gadget_list_column-2">'
				+ secondary_info + '</div> <h4>' + title + '</h4> <span class="sl_gadget_tally">'
				+ sub_title + '</span></li>';																

			searchResults += header_row + result_list;
		}


		_gel('sl_gadget_content_div').innerHTML = '<ul>' + searchResults + '</ul>';
	});					
}/*}}}*/

function getUserInfo(user_id)
{/*{{{*/
	//////////////
	/// This function gets the user info and updates the page layout with that users info
	//////////////
	if ( ! user_id ) 
	{
		displayInfoPage('');			
		return;
	}

	var url = "http://sonicliving.com/user/" + user_id + "/gadget/info.xml?" + get_random_param();
 	_IG_FetchXmlContent(url, function (response)
	{
		if (response == null || typeof(response) != "object" || response.firstChild == null)
		{
			name = 'invalid';
		}

		var itemList = response.getElementsByTagName("user");
		for (var i = 0; i < itemList.length ; i++)
		{ 
			var nodeList = itemList.item(i).childNodes;
			for (var j = 0; j < nodeList.length ; j++)
			{
				var node = nodeList.item(j);
				if (node.nodeName == "name")
				{
					name = node.firstChild.nodeValue;
				}
			}	

			if (name == "null" || name.length == 0)
			{
				getRegionInfo(zip_code_id);
				displayErrorLoginPage();
			}
			else
			{
				_gel('sl_gadget_pre_image').innerHTML = name + "'s ";
				_gel('sl_gadget_logo_link').href = 'http://sonicliving.com/user/' + user_id;	
				_gel('sl_gadget_bottom_tabs').innerHTML ='<table border="0" width="100%" cellspacing="0" align="center">'+
					'<tr><td class="sl_gadget_tab" id="sl_gadget_cal_tab"><a href="javascript:displayEvents(\'sl_gadget_cal_tab\');">Calendar</a></td>' + 
					'<td id="sl_gadget_wl_tab" class="sl_gadget_tab"><a href="javascript:displayEvents(\'sl_gadget_wl_tab\');">Wishlist</a></td>' + 
					'<td class="sl_gadget_tab" id="sl_gadget_friend_tab"><a href="javascript:displayEvents(\'sl_gadget_friend_tab\')">Friends</a></td></tr></table>';	    													                    
				current_tab = prefs__MODULE_ID__.getString("current_tab");

				if ( current_tab 
					&&  (
						current_tab == 'sl_gadget_cal_tab' || current_tab == 'sl_gadget_wl_tab'
						|| current_tab == 'sl_gadget_friend_tab' || current_tab == 'sl_gadget_pop_tab'
						|| current_tab == 'sl_gadget_today_tab' 
						)
					)
				{
					displayEvents(current_tab);	
				}
				else
				{
					displayInfoPage('');			
				}
			}
		}

	});
}/*}}}*/

function setUserIDfromGuest()
{/*{{{*/
	email = _gel('sl_gadget_userid_form').value;
	url = 'http://sonicliving.com/email_to_id/' + escape(email) + "?" + get_random_param();
	_IG_FetchContent(url, function (response)
	{
		if (response == null)
		{
			// do something mean
		}

		user_id = response;

		prefs__MODULE_ID__.set('user_id', user_id);
		if (!user_id)
		{
			user_id = 0;
			displayInfoPage('');
		}
		else
		{
			getUserInfo(user_id);	
		}
	});
}/*}}}*/

function displayEvents(type)
{/*{{{*/
	//////////////
	/// This function is for displaying the different user related calendars: Popular, Upcoming WL and Clanedar
	//////////////
	zip_code_id = prefs__MODULE_ID__.getString("zip_code_id");					
	user_id = prefs__MODULE_ID__.getString("user_id");					

	if ( ! zip_code_id && ! user_id )
	{
		displayInfoPage('');
		return;
	}
			
	if (type == 'sl_gadget_wl_tab')
	{
		var url = "http://sonicliving.com/user/" + user_id + "/gadget/upcoming_wl.xml?" + get_random_param();
		var no_event_text = "No Events on your Wishlist!<br /><a target=\"_main\" href=\"http://sonicliving.com/s/wl_upload\">Try adding more artists that you want to see live.</a>";
					
		set_current_tab('sl_gadget_wl_tab');
		displayLoading('Loading Upcoming WishList Shows...');
				
	}
	else if (type == 'sl_gadget_cal_tab')
	{
		var url = "http://sonicliving.com/user/" + user_id + "/gadget/calendar.xml?" + get_random_param(); 
		var no_event_text = "No Upcoming Events on your Calendar!<br /><a target=\"_main\" href=\"http://sonicliving.com/events\">Find some events to add.</a>";

		set_current_tab('sl_gadget_cal_tab');
		displayLoading('Loading Upcoming Events...');						

	}
	else if (type == 'sl_gadget_friend_tab')
	{
		var url = "http://sonicliving.com/user/" + user_id + "/gadget/friends.xml?" + get_random_param(); 
		var no_event_text = "Your Friends aren't going to any shows!<br /><a target=\"_main\" href=\"http://sonicliving.com/friends\">Invite your friends to SonicLivng.</a>";
		set_current_tab('sl_gadget_friend_tab');
		displayLoading('Loading Your Friends Events...');						
	}
	else if (type == 'sl_gadget_pop_tab')
	{
		if (user_id > 0)
		{
			var url = "http://sonicliving.com/user/" + user_id + "/gadget/popular.xml?" + get_random_param(); 						
		}
		else
		{
			var url = "http://sonicliving.com/region/" + zip_code_id + "/gadget/popular_artist_events.xml?" + get_random_param(); 
		}
		var no_event_text = "No Popular Events Found!<br /><a target=\"_main\" href=\"http://sonicliving.com/events\">Lets find some other events.</a>";							

		set_current_tab('sl_gadget_pop_tab');
		displayLoading('Loading Popular Events...');

	}
	else if (type == 'sl_gadget_today_tab')
	{
		if (user_id > 0)
		{
			var url = "http://sonicliving.com/user/" + user_id + "/gadget/today.xml?" + get_random_param(); 
		}
		else
		{
			var url = "http://sonicliving.com/region/" + zip_code_id + "/gadget/today.xml?" + get_random_param();
		}							
		var no_event_text = "No Events Today!<br /><a target=\"_main\" href=\"http://sonicliving.com/events\">How strange... Let's look harder.</a>";													
		set_current_tab('sl_gadget_today_tab');
		displayLoading('Loading Todays Events...');
	}

	_IG_FetchXmlContent(url, function (response)
	{
		if (response == null || typeof(response) != "object" || response.firstChild == null)
		{
			_gel("sl_gadget_content_div").innerHTML = "<i>Invalid data.</i>";
			return;
		}					
		html = '<ul class="sl_gadget_loggedin">';
		var itemList = response.getElementsByTagName("event");
		for (var i = 0; i < itemList.length ; i++)
		{ 
			var nodeList = itemList.item(i).childNodes;
			for (var j = 0; j < nodeList.length ; j++)
			{
				var node = nodeList.item(j);
				if (node.nodeName == "url")
				{
					var url = node.firstChild.nodeValue;
				}
				else if (node.nodeName == "date")
				{
					var date = node.firstChild.nodeValue; 
				}
				else if (node.nodeName == "title")
				{
					var title = node.firstChild.nodeValue; 
				}
				else if (node.nodeName == "class")
				{
					var event_class = node.firstChild.nodeValue; 
				}
			}	
			// Append extracted data to the HTML string.
			html += '<li class="sl_gadget_' +  event_class + '"><div class="sl_gadget_list_column-2">' 
				+ date + '</div> <a target="_main" href="' + url 
				+ '" class="sl_gadget_item_title">' + title + '</a></li>';
		}


		html += '</ul>';
		event_count = itemList.length;
		if (event_count == 0)
		{
			displayNoEvents(no_event_text);
		}
		else
		{
			_gel("sl_gadget_content_div").innerHTML =  html;						  
		}

	});
}/*}}}*/

function lookupZipCodeId(search_term, successCallback, failureCallback)
{/*{{{*/
	var url = 'http://sonicliving.com/gadget/zip_search/' + escape(search_term) + "?" + get_random_param();

	var responseCallback = function (response) 
	{/*{{{*/

		var zipIdCityArray = new Array();

		if (response == null || typeof(response) != "object" || response.firstChild == null)
		{
			// The call failed.
			failureCallback(zipIdCityArray)
			return
		}
		else 
		{
			// The call found some stuff.
			var zipIdCityMap = response.getElementsByTagName("location");						
			for (var i = 0; i < zipIdCityMap.length ; i++)
			{

				mapNode = zipIdCityMap.item(i);

				var id = undefined;
				var city = undefined;

				for (var j = 0; j < mapNode.childNodes.length ; j++)
				{
					var node = mapNode.childNodes.item(j);

					if (node.nodeName == "id")
					{
						id = node.firstChild.nodeValue;
					}
					if (node.nodeName == "name")
					{
						city = node.firstChild.nodeValue;
					}
				}

				if (id != undefined && city != undefined)
				{
					var ob = new Object();
					ob['id'] = id;
					ob['city'] = city;
					zipIdCityArray.push(ob);
				}

			}

			successCallback(zipIdCityArray);
		}
	}/*}}}*/

	_IG_FetchXmlContent(url, responseCallback);
}/*}}}*/
// }}}

// Procedural Functions {{{

function handleLocationSearchEvent()
{/*{{{*/
	search_term = _gel('sl_gadget_location_search').value;
	if (! search_term) 
	{
		_gel('sl_gadget_location_search_err').innerHTML = "You have to enter something!";
		return;
	}
	lookupZipCodeId(search_term, displayLocationChoices, displayNoLocations);
}/*}}}*/

function displayLocationChoices(zipIdCityArray)
{/*{{{*/

	var innerhtml = "";
	for (i in zipIdCityArray)
	{
		var ob = zipIdCityArray[i];

		if (zipIdCityArray.length == 1)
		{
			setRegionFromWelcome(ob['id']);
			return;
		}

		innerhtml += "<option value='" + ob['id'] + "'/>" + ob['city'] + "</option>";
	}

 	var html = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>Hey Kids!  It's SonicLiving!</h2>" + 
		'<form action="javascript:setRegionFromWelcome(0);" >' +
		'<select id="sl_gadget_region_form">' +
		innerhtml +
		"</select>&nbsp;" +
		'<input type="submit" value="Yes!" id="sl_gadget_submit_form" />' +
		"</form></p>" +
		"</div>";
	
	_gel('sl_gadget_content_div').innerHTML = html;	

}/*}}}*/

function displayNoLocations(zipIdCityArray)
{/*{{{*/
	displayInfoPage("No locations found!");
}/*}}}*/

function LoadScript(url, eval_str)
{/*{{{*/
	_sendx(url, function (result)
	{
		window.eval(result);
		eval(eval_str);
	}, false, null);
}/*}}}*/

function set_current_tab(tab)
{/*{{{*/
	var common_tabs = new Array('sl_gadget_pop_tab', 'sl_gadget_today_tab');
	var logged_out_tabs = new Array('sl_gadget_login_tab', 'sl_gadget_newacct_tab', 'sl_gadget_about_tab');
	var logged_in_tabs = new Array('sl_gadget_wl_tab', 'sl_gadget_cal_tab', 'sl_gadget_friend_tab');

	prefs__MODULE_ID__.set("current_tab", tab);

	for (var i = 0; i < common_tabs.length ; i++)
	{ 
		var tabby = _gel(common_tabs[i])
		if (tabby)
		{
			tabby.className = 'sl_gadget_tab'; 
		}
	}

	if (user_id > 0)
	{
		for (var i = 0; i < logged_in_tabs.length ; i++)
		{ 
			var tabby = _gel(logged_in_tabs[i])
			if (tabby)
			{
				tabby.className = 'sl_gadget_tab'; 
			}
		}
	}
	else
	{
		for (var i = 0; i < logged_out_tabs.length ; i++)
		{ 
			var tabby = _gel(logged_out_tabs[i])
			if (tabby)
			{
				tabby.className = 'sl_gadget_tab'; 
			}
		}
	}

	var the_tab = _gel(tab);
	if (the_tab)
	{
		_gel(tab).className = 'sl_gadget_tab sl_gadget_tab_selected';						  
	}
}/*}}}*/

function displayNoEvents(text)
{/*{{{*/
	_gel('sl_gadget_content_div').innerHTML = '<div style="text-align:center; padding-top:30px;"><p>' + text + '</p></div>';
}/*}}}*/

function displayLoading(text)
{/*{{{*/
	_gel('sl_gadget_content_div').innerHTML = '<div style="text-align:center; padding-top:30px;"><p>' + text + '</p><img src="http://sonicliving.com/images/ajax-loader.gif" /></div>';
}/*}}}*/

function displayErrorLoginPage()
{/*{{{*/
	var loginPage = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>Invalid Email Address</h2>" + 
		"<p>SonicLiving doesn't know who that is. <span style=\"font-weight:bold;\">Use the same email address you log into SonicLiving with.</span></p>" +
		'<form action="javascript:javascript:setUserIDfromGuest();" >' +
		'<input type="text" value="Email Address" id="sl_gadget_userid_form" onfocus="clearText(this);" onblur="resetText(this);" /> ' +
		'<input type="submit" value="I want in!" id="sl_gadget_submit_form" />' +
		"</form>" +
		"</div>";

	_gel('sl_gadget_content_div').innerHTML = loginPage;
}/*}}}*/

function displayInfoPage(error_message)
{		/*{{{*/
	set_current_tab('sl_gadget_about_tab');  

	var guest_welcome = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>Hey Kids!  It's SonicLiving!</h2>" + 
		'<p>Find out when your favorite artists are coming to town. Enter a city and state or a zip code below to see who\'s playing.' +
		'<form action="javascript:handleLocationSearchEvent();" >' +
		'<div id="sl_gadget_location_search_err">'+ error_message+'</div>' +
		'<input type="text" name="sl_gadget_location_search" id="sl_gadget_location_search"/>' +
		'<input type="submit" value="Find It" name="findit"/>' +
		"</form></p>" +
		"</div>";

	var logged_in_welcome = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>It's Pocket-sized!</h2>" + 
		"<p>You’re logged into SonicLiving! Click on the tabs to view upcoming events.<br /><br />" +
		"<strong>Calendar</strong>: <span style=\"color: #88B6CA; font-weight:bold;\">Interested</span> " +
		"/ <span style=\"font-weight:bold;color: #8CC57C;\">confirmed</span> events.<br /> " +
		"<strong>Wishlist</strong>: Events that match your artists.<br /> " +
		"<strong>Friends</strong>: Events on your friends' calendars." +        				
		"</p></div>";


	if (user_id > 0)
	{
		var message = logged_in_welcome; 
	}
	else
	{
		var message = guest_welcome;
	}
	_gel('sl_gadget_content_div').innerHTML = message;				  
}/*}}}*/

function setRegionFromWelcome(zip_code_id)
{/*{{{*/
	if ( ! zip_code_id ) 
	{
		zip_code_id = _gel('sl_gadget_region_form').value;
	}
	prefs__MODULE_ID__.set('zip_code_id', zip_code_id);
	getRegionInfo(zip_code_id);	
	displayEvents('sl_gadget_pop_tab');
}/*}}}*/

function displayLoginPage()
{/*{{{*/

	set_current_tab('sl_gadget_login_tab');

	var loginPage = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>Already Have An Account?</h2>" + 
		"<p>You rock. Enter your email address to sync with your SonicLiving account.</p>" +
		'<form action="javascript:javascript:setUserIDfromGuest();" >' +
		'<input type="text" value="Email Address" id="sl_gadget_userid_form" onfocus="clearText(this);" onblur="resetText(this);" /> ' +
		'<input type="submit" value="I want in!" id="sl_gadget_submit_form" />' +
		"</form>" +
		"</div>";

	_gel('sl_gadget_content_div').innerHTML = loginPage;
}/*}}}*/

function displayNewAcctPage()
{/*{{{*/

	set_current_tab('sl_gadget_newacct_tab');

	var newAcctPage = '<div class="sl_gadget_freshmeat_content">' + 
		"<h2>Not Plugged In Yet?</h2>" + 
		"<p>With a SonicLiving account you can track bands, create a calendar, see what your friends are up to and show up.</p>" +
		'<p style="text-align:center;"><a href="http://sonicliving.com/login" target="_main">' +
		'<img src="http://sonicliving.com/images/signup.png" width="139" height="24" alt="Sign Up" border="" onload="fixPNG(this)" /></a></p>' + 
		"</div>";

	_gel('sl_gadget_content_div').innerHTML = newAcctPage;
}/*}}}*/

function clearText(thefield)
{/*{{{*/
	//////////////
	/// This function clears text fields and sets their style
	//////////////
	if (thefield.defaultValue==thefield.value)
	{
		thefield.value = "";
		thefield.style.color = "black";
	}
}/*}}}*/

function resetText(thefield)
{/*{{{*/
	//////////////
	/// This function resets the text field if nothing has been entered
	//////////////
	if (thefield.value == "")
	{
		thefield.value = thefield.defaultValue;
		thefield.style.color = "#ccc";
	}
}/*}}}*/


function load_gadget()
{/*{{{*/
	//////////////
	/// This function checks to see if the user gave a user_id and direcets all the flow
	//////////////

	current_tab = prefs__MODULE_ID__.getString("current_tab");

	if (user_id > 0)
	{
		getUserInfo(user_id);
	}
	else
	{
		getRegionInfo(zip_code_id);

		if (current_tab == 'sl_gadget_about_tab')
		{
			displayInfoPage('');
		}
		else if (current_tab == 'sl_gadget_today_tab' || current_tab == 'sl_gadget_pop_tab')
		{
			displayEvents(current_tab);						  
		}
		else
		{
			displayInfoPage('');
		}
	}
}/*}}}*/
//}}}

// Helper Functions {{{

function get_random_param()
{
	return "__sl_rnd=" + Math.floor(Math.random() * 1000000);
}
// }}}

_IG_RegisterOnloadHandler(load_gadget);
</script>
]]> 
	</Content>
</Module>

