var Application =  {
	lastId: 0,
	currentSampleNb: 0,
	
	getNewId: function() {
	Application.lastId++;
	return "window_id_" + Application.lastId;
	},
	

	addLoginWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"welcome\" style=\"cursor: pointer;\" onclick=\"Application.openLoginWindow('" + theme + "')\">Sign in here.</a>";
	document.write(html)
	},
	
	addForumLoginWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"darkBlue\" style=\"cursor: pointer; font-size: 100%;\" onclick=\"Application.openLoginWindow('" + theme + "')\">signed in</a>";
	document.write(html)
	},
	
	loginLink: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"darkBlueUnderline\" style=\"cursor: pointer; font-size: 100%;\" onclick=\"Application.openLoginWindow('" + theme + "')\">login</a>";
	document.write(html)
	},
	
	registerLink: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"darkBlueUnderline\" style=\"cursor: pointer; font-size: 100%;\" onclick=\"Application.openCreateProfileWindow('" + theme + "')\">register</a>";
	document.write(html)
	},
	
	addLogoutWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<span class='login' onclick=\"Application.openLoginWindow('" + theme + "')\">Logout</span>";
	document.write(html)
	},
	
	addCreateProfileWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<a href=\"javascript: Application.openCreateProfileWindow('" + theme + "')\" id=\"join\"><i>Join GameHuddle</i></a>";
	document.write(html)
	},
	
	/* Link on gameprofile to add a score from another site */
	addReviewLinkWindow: function(theme, gid, sid, mid, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openReviewWindow('" + theme + "', '" + gid + "', '" + sid + "', '" + mid + "')\">+ Add a Score</a>";
	document.write(html)
	},
	
	/* Link on gameprofile to add a score from any another site  */
	addOtherReviewLinkWindow: function(theme, gid, sid, mid, modal) {
	  idButton = theme + '_theme_button';
		html = "<a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openOtherReviewWindow('" + theme + "', '" + gid + "', '" + sid + "', '" + mid + "')\">+ Add a Score</a>";
	document.write(html)
	},
	
	addBasicWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openBasicWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addSystemWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openSystemWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},

	addGamesWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openGamesWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addAccWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openAccWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addOnlineWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openOnlineWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addInterestsWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openInterestsWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addContactWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openContactWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addRigWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openRigWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	addPrivacyWindow: function(theme, modal) {
	  idButton = theme + '_theme_button';
		html = "<img class=\"icon\" src=\"/images/help.png\" alt=\"Help\" /><a class=\"darkBlue\" style=\"cursor: pointer;\" onclick=\"Application.openPrivacyWindow('" + theme + "')\">Help</a>";
	document.write(html)
	},
	
	/* reply comment */
	openReplyToComment: function(theme, type, nid, commentID, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:400, height:190, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 372px;'>Add a Reply</div>"});
	  win.getContent().innerHTML = "<form id='windowReplyForm'><table class='marginTop15 marginLeft15'><tr><td><textarea multiline='true' id='replyBox' name='replyBox' cols='50' rows='5' class='textarea' style='font-size: 100%;'></textarea></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td><input type='button' class='button' id='submit' value='Post Reply' OnClick=\"windowAjaxCall('/ajax/addCommentReply.aspx', 'windowReplyForm');\"/><span style='padding-right: 31px;'></span></td></tr></table><input type='hidden' name='type' id='type' value='" + type + "'/><input type='hidden' name='nid' id='nid' value='" + nid + "'/><input type='hidden' name='commentID' id='commentID' value='" + commentID + "'/></form>";
	  win.showCenter(modal);
	},
	
	/* open window to share a review via email */
	openShareReviewWindow: function(theme, headline, rid, game, modal) {
	  var subject = "Check out this " + game + " Review on GameHuddle";	
	  var win = new Window(Application.getNewId(), {className: theme, width:400, height:200, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 422px;'>Share This Review</div>"});
	  win.getContent().innerHTML = "<form id='windowShareReviewForm'><table width='100%' class='marginTop15 marginLeft15'><tr><td valign='top' class='darkGray100'>To: </td><td><input type='text' id='toBox' name='toBox' class='textbox' style='font-size: 100%; width: 300px;'></input></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td valign='top' class='darkGray100'>From: </td><td><input type='text' id='fromBox' name='fromBox' class='textarea' style='font-size: 100%; width: 300px;'></input></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td valign='top' class='darkGray100'>Subject: </td><td class='darkGray100' style='width: 300px;'>" + subject + "</td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td></td><td align='left'><input type='button' class='button' id='submit' value='Share' OnClick=\"windowAjaxCall('/ajax/shareGameReview.aspx', 'windowShareReviewForm');\"/></td></tr></table><input type='hidden' name='game' id='game' value='" + game + "'/><input type='hidden' name='headline' id='headline' value='" + headline + "'/><input type='hidden' name='subject' id='subject' value='" + subject + "'/><input type='hidden' name='rid' id='rid' value='" + rid + "'/></form>";
	  win.showCenter(modal);
	},
	
	/* Window on gameprofile that pops up to add a score from another site */
	openOtherReviewWindow: function(theme, gid, sid, mid, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:300, height:275, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 272px;'>Add a Score</div>"});
	  win.getContent().innerHTML= "<form id='windowReviewForm'><p class='lightGray100' style='margin-top: 10px;'>To add a score, please select or enter the site that the review is coming from, enter the URL of the review, and enter the overall score (out of 10) of the review.  When you're done, click ''Add Score'' to add it to GameHuddle.  </p><table width='100%' class='marginTop15 marginLeft15'><tr><td class='darkGray100'>Site: </td><td><select id='reviewSite' name='reviewSite' class='dropdown' style='font-size: 100%;'><option>- Site -</option><option>1Up</option><option>360 Gamer Magazine UK</option><option>AceGamez</option><option>ActionTrip</option><option>Armchair Empire</option><option>Atomic Gamer</option><option>Boomtown</option><option>Cheat Code Central</option><option>Computer and Video Games (CVG)</option><option>Console Gameworld</option><option>Console Monster</option><option>DailyGame</option><option>Deeko</option><option>Destructoid</option><option>Digital Entertainment News</option><option>Edge Magazine</option><option>Electronic Gaming Monthly</option><option>EuroGamer</option><option>Extreme Gamer</option><option>Ferrago</option><option>Firing Squad</option><option>G4 TV</option><option>Game Almighty</option><option>Game Chronicles</option><option>Game Informer</option><option>Game Over Online</option><option>Game Revolution</option><option>GameDaily</option><option>Gameplayer</option><option>GamePro</option><option>Gamer 2.0</option><option>GamerNode</option><option>Gamer's Hell</option><option>Gamers Europe</option><option>Gamertell</option><option>games(TM)</option><option>Games Master UK</option><option>Gamespot</option><option>GameSpy</option><option>GamesRadar</option><option>Gamestyle</option><option>GameTap</option><option>GameTrailers</option><option>GameZone</option><option>Gaming Age</option><option>GamingExcellence</option><option>Gaming Target</option><option>GotNext</option><option>Hardcore Gamer Magazine</option><option>IC-Games</option><option>IGN</option><option>IGN AU</option><option>IGN UK</option><option>Jolt Online Gaming UK</option><option>Just RPG</option><option>Kombo</option><option>Maxi Consolas(Portugal)</option><option>MS Xbox World</option><option>My Gamer</option><option>NTSC-uk</option><option>NZGamer</option><option>Official Xbox Magazine</option><option>Official Xbox Magazine UK</option><option>PALGN</option><option>Pelit (Finland)</option><option>Planet Xbox 360</option><option>Play Magazine</option><option>PTGamers</option><option>Talk Xbox</option><option>Team Xbox</option><option>The New York Times</option><option>The Onion (A.V. Club)</option><option>Thunderbolt</option><option>Total Video Games</option><option>VGPub</option><option>Video Game Talk</option><option>VideoGamer</option><option>WHAM! Gaming</option><option>Worth Playing</option><option>X360 Magazine UK</option><option>Xbox World 360 Magazine UK</option><option>Xbox World Australia</option><option>Xboxic</option><option>Yahoo! Games</option><option>ZTGameDomain</option></select></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td></td><td><span class='lightGray100' style='padding-left: 35px;'>- or -</span></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td></td><td><input class='textbox' style='font-size: 100%;' type='text' id='otherSite' name='otherSite'></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>URL: </td><td><input type='text' id='reviewUrl' class='textbox' style='font-size: 100%;' name='reviewUrl'></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>Score:  </td><td><input class='textbox' style='font-size: 100%;' width='25' type='text' id='reviewScore' name='reviewScore'></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td></td><td><input type='button' class='button' id='submit' value='Add Score' OnClick=\"windowAjaxCall('/ajax/addOtherReview.aspx', 'windowReviewForm');\"/></td></tr></table><input type='hidden' name='gid' id='gid' value='" + gid + "'/><input type='hidden' name='sid' id='sid' value='" + sid + "'/><input type='hidden' name='mid' id='mid' value='" + mid + "'/></form><div id='successDiv' style='display:none;'>Thank you for submitting that score.  You will be rewarded points after we verify the submission.</div>";
	  win.showCenter(modal);
	},
	
	/* Window on gameprofile that pops up to add a score from another site */
	openReviewWindow: function(theme, gid, sid, mid, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:300, height:225, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 272px;'>Add a Score</div>"});
	  win.getContent().innerHTML= "<form id='windowReviewForm'><p class='lightGray100' style='margin-top: 10px;'>To add a score, please select the site that the review is coming from, enter the URL of the review, and enter the overall score of the review. When you're done, click ''Add Score'' to add it to GameHuddle.  </p><table width='100%' class='marginTop15 marginLeft15'><tr><td class='darkGray100'>Site: </td><td><select id='reviewSite' name='reviewSite' class='dropdown' style='font-size: 100%;'><option>1Up</option><option>360 Gamer Magazine UK</option><option>AceGamez</option><option>ActionTrip</option><option>Armchair Empire</option><option>Atomic Gamer</option><option>Boomtown</option><option>Cheat Code Central</option><option>Computer and Video Games (CVG)</option><option>Console Gameworld</option><option>Console Monster</option><option>DailyGame</option><option>Deeko</option><option>Destructoid</option><option>Digital Entertainment News</option><option>Edge Magazine</option><option>Electronic Gaming Monthly</option><option>EuroGamer</option><option>Extreme Gamer</option><option>Ferrago</option><option>Firing Squad</option><option>G4 TV</option><option>Game Almighty</option><option>Game Chronicles</option><option>Game Informer</option><option>Game Over Online</option><option>Game Revolution</option><option>GameDaily</option><option>Gameplayer</option><option>GamePro</option><option>Gamer 2.0</option><option>GamerNode</option><option>Gamer's Hell</option><option>Gamers Europe</option><option>Gamertell</option><option>games(TM)</option><option>Games Master UK</option><option>Gamespot</option><option>GameSpy</option><option>GamesRadar</option><option>Gamestyle</option><option>GameTap</option><option>GameTrailers</option><option>GameZone</option><option>Gaming Age</option><option>GamingExcellence</option><option>Gaming Target</option><option>GotNext</option><option>Hardcore Gamer Magazine</option><option>IC-Games</option><option>IGN</option><option>IGN AU</option><option>IGN UK</option><option>Jolt Online Gaming UK</option><option>Just RPG</option><option>Kombo</option><option>Maxi Consolas(Portugal)</option><option>MS Xbox World</option><option>My Gamer</option><option>NTSC-uk</option><option>NZGamer</option><option>Official Xbox Magazine</option><option>Official Xbox Magazine UK</option><option>PALGN</option><option>Pelit (Finland)</option><option>Planet Xbox 360</option><option>Play Magazine</option><option>PTGamers</option><option>Talk Xbox</option><option>Team Xbox</option><option>The New York Times</option><option>The Onion (A.V. Club)</option><option>Thunderbolt</option><option>Total Video Games</option><option>VGPub</option><option>Video Game Talk</option><option>VideoGamer</option><option>WHAM! Gaming</option><option>Worth Playing</option><option>X360 Magazine UK</option><option>Xbox World 360 Magazine UK</option><option>Xbox World Australia</option><option>Xboxic</option><option>Yahoo! Games</option><option>ZTGameDomain</option></select></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>URL: </td><td><input type='text' id='reviewUrl' class='textbox' style='font-size: 100%;' name='reviewUrl'></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>Score:  </td><td><input class='textbox' style='font-size: 100%;' width='25' type='text' id='reviewScore' name='reviewScore'></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td></td><td><input type='button' class='button' id='submit' value='Add Score' OnClick=\"windowAjaxCall('/ajax/otherReview.aspx', 'windowReviewForm');\"/></td></tr></table><input type='hidden' name='gid' id='gid' value='" + gid + "'/><input type='hidden' name='sid' id='sid' value='" + sid + "'/><input type='hidden' name='mid' id='mid' value='" + mid + "'/></form><div id='successDiv' style='display:none;'>Thank you for submitting that score.  You will be rewarded points after we verify the submission.</div>";
	  win.showCenter(modal);
	},
	
	/* Window on createevent that pops up to select member's timezone */
	addTimeZoneWindow: function(theme, mid, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:500, height:100, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 472px;'>Select Your Time Zone</div>"});
	  win.getContent().innerHTML= "<form id='windowReviewForm'><table width='100%' class='marginTop15 marginLeft15'><tr><td class='darkGray100'>Time Zone: </td><td><select id='timezones' name='timezones' class='dropdown' style='font-size: 100%;'><option>- Select Time Zone -</option><option>(GMT -12:00) Eniwetok, Kwajalein</option><option>(GMT -11:00) Midway Island, Samoa</option><option>(GMT -10:00) Hawaii</option><option>(GMT -9:00) Alaska</option><option>(GMT -8:00) Pacific Time (US and Canada)</option><option>(GMT -7:00) Mountain Time (US and Canada)</option><option>(GMT -6:00) Central Time (US and Canada), Mexico City</option><option>(GMT -5:00) Eastern Time (US and Canada), Bogota, Lima</option><option>(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option><option>(GMT -3:30) New Foundland</option><option>(GMT -3:00) Brazil, Buenos Aires, Georgetown</option><option>(GMT -2:00) Mid-Atlantic</option><option>(GMT -1:00) Azores, Cape Verde Islands</option><option>(GMT 0:00) Western Europe Time, London, Lisbon, Casablanca</option><option>(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option><option>(GMT +2:00) Kaliningrad, South Africa</option><option>(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option><option>(GMT +3:30) Tehran</option><option>(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option><option>(GMT +4:30) Kabul</option><option>(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option><option>(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option><option>(GMT +6:00) Almaty, Dhaka, Colombo</option><option>(GMT +7:00) Bangkok, Hanoi, Jakarta</option><option>(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option><option>(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option><option>(GMT +9:30) Adelaide, Darwin</option><option>(GMT +10:00) Eastern Australia, Guam, Vladivostok</option><option>(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option><option>(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option></select></td></tr><tr><td><div style='display: block; height: 5px;'></td></tr><tr><td></td><td><input type='button' class='button' id='submit' value='Save Time Zone' OnClick=\"windowAjaxCall('/ajax/timeZone.aspx', 'windowReviewForm');\"/></td></tr></table><input type='hidden' name='mid' id='mid' value='" + mid + "'/></form><div id='successDiv' style='display:none;'>Time Zone Saved.</div>";
	  win.showCenter(modal);
	},
	
	/* Gameprofile: Add a video */
	addGameVideoWindow: function(theme, gid, mid, sid, name, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:500, height:225, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 472px;'>Add a Video</div>"});
	  win.getContent().innerHTML= "<form id='windowReviewForm'><p class='lightGray100 marginBottom25 marginTop10'>To add a video for " + name + ", select the type of video, enter a description, supply us with the video's URL, and click \"Add Video\". <br/><i>Note: Please use the video's URL when adding a video, not the embedded video code.</i></p><table width='100%'><tr><td class='darkGray100' width='160'>Video Type: </td><td><select id='vidTypeDrop' name='vidTypeDrop' class='dropdown' style='font-size: 100%;'><option>Game Trailer</option><option>Game Review</option><option>Single-Player Footage</option><option>Multi-Player Footage</option><option>Interview</option><option>Game Preview</option><option>Technical Demo</option><option>Easter Egg/Cheat</option></select></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>Quick Description of Video: </td><td><input type='text' id='reviewUrl' class='textbox' style='font-size: 100%;' id='vidTitle' name='vidTitle' size='50'></td></tr><tr><td colspan='2'><div style='display: block; height: 5px;'></div></td></tr><tr><td class='darkGray100'>Video URL:</td><td><input type='text' id='vidUrl' id='reviewUrl' class='textbox' style='font-size: 100%;' name='vidUrl' size='50'></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'></div></td></tr><tr><td></td><td><input type='image' id='vidSubmitButton' name='vidSubmitButton' value='Add Score' src='/images/addVideo.png' OnClick=\"gameVideoAjaxCall('/ajax/addvideo.aspx', 'windowReviewForm');\"/></td></tr></table><input type='hidden' name='gid' id='gid' value='" + gid + "'/><input type='hidden' name='sid' id='sid' value='" + sid + "'/><input type='hidden' name='mid' id='mid' value='" + mid + "'/><input type='hidden' name='gameName' id='gameName' value='" + name + "'/></form><div id='successDiv' style='display:none; font-size: 100%;' align='center' class='marginTop25 lightGray70'>Thank you for submitting a video.</div>";
	  win.showCenter(modal);
	},
	
	/* Gameprofile: Add news */
	addNewsWindow: function(theme, gid, mid, sid, name, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:350, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Add " + name + " News</div>"});
	  win.getContent().innerHTML= "<form id='windowNewsForm'><table width='100%' class='marginTop10'><tr><td align='left' colspan='2' class='darkGray100'>Enter the Article's URL:</td><td align='right' colspan='2'><div id='urlIcon' class='lightGray100' style='display:inline;'></div></td></tr><tr><td colspan='4'><input type='text' id='storyurl' name='storyurl' class='textbox' style='font-size: 100%;' runat='server' size='101' onblur='checkUrl()'/></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td align='left' colspan='2' class='darkGray100'>Enter the Article's Title:</td><td align='right' colspan='2'><div id='titleIcon' class='lightGray100' style='display:inline;'></div></td></tr><tr><td colspan='4'><input type='text' class='textbox' style='font-size: 100%;' id='storytitle' name='storytitle' runat='server' size='101' onblur='checkTitle()'/></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td align='left' colspan='2' class='darkGray100'>Enter a Description of the Article:</td><td align='right' colspan='2' class='paddingLeft15'><span class='lightGray100 marginRight15'><div id='charCount' class='charCount' style='display:inline;'>500</div> Characters Left</span></td></tr><tr><td colspan='4'><textarea id='storydescription' class='textarea' style='font-size: 100%;' name='storydescription' runat='server' cols='98' rows='5' onkeyup=\"charLimit('storydescription', 'charCount')\"></textarea></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td colspan='4'><span class='darkGray100 block marginBottom5'>Select the Article Type:</span><select id='storytype'  name='storytype' runat='server' class='dropdown' style='font-size: 100%;'><option value='0'>-Select-</option><option>Article</option><option>Blog</option><option>Images</option><option>Interview</option><option>News</option><option>Podcast</option><option>Preview</option><option>Review</option><option>Rumor</option><option>Screenshots</option><option>Trailer</option><option>TV</option><option>Video</option></select></td></tr><tr><td colspan='4'><div style='display: block; height: 20px;'></div></td></tr><tr><td colspan='2'><input type='image' id='butsubmit' name='butsubmit' src='/images/sendArticle.png' OnClick=\"gameNewsAjaxCall('/ajax/addnews.aspx', 'windowNewsForm');\"/></td></tr></table><span class='darkGray100' id='errorMessage'></span><input type='hidden' name='gid' id='gid' value='" + gid + "'/><input type='hidden' name='sid' id='sid' value='" + sid + "'/><input type='hidden' name='mid' id='mid' value='" + mid + "'/><input type='hidden' name='gameName' id='gameName' value='" + name + "'/></form><div id='successDiv' style='display:none; font-size: 100%;' align='center' class='marginTop25 lightGray70'>Thank you for submitting a news story. </div>";
	  win.showCenter(modal);
	},
	
	/* Systemprofile: Add news */
	addSystemNewsWindow: function(theme, mid, sid, name, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:350, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Add " + name + " News</div>"});
	  win.getContent().innerHTML= "<form id='windowNewsForm'><table width='100%' class='marginTop10'><tr><td align='left' colspan='2' class='darkGray100'>Enter the Article's URL:</td><td align='right' colspan='2'><div id='urlIcon' class='lightGray100' style='display:inline;'></div></td></tr><tr><td colspan='4'><input type='text' id='storyurl' name='storyurl' class='textbox' style='font-size: 100%;' runat='server' size='101' onblur='checkUrl()'/></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td align='left' colspan='2' class='darkGray100'>Enter the Article's Title:</td><td align='right' colspan='2'><div id='titleIcon' class='lightGray100' style='display:inline;'></div></td></tr><tr><td colspan='4'><input type='text' class='textbox' style='font-size: 100%;' id='storytitle' name='storytitle' runat='server' size='101' onblur='checkTitle()'/></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td align='left' colspan='2' class='darkGray100'>Enter a Description of the Article:</td><td align='right' colspan='2' class='paddingLeft15'><span class='lightGray100 marginRight15'><div id='charCount' class='charCount' style='display:inline;'>500</div> Characters Left</span></td></tr><tr><td colspan='4'><textarea id='storydescription' name='storydescription' class='textarea' style='font-size: 100%;' runat='server' cols='98' rows='5' onkeyup=\"charLimit('storydescription', 'charCount')\"></textarea></td></tr><tr><td colspan='4'><div style='display: block; height: 10px;'></div></td></tr><tr><td colspan='4'><span class='darkGray100 block marginBottom5'>Select the Article Type:</span><select id='storytype'  name='storytype' runat='server' class='dropdown' style='font-size: 100%;'><option value='0'>-Select-</option><option>Article</option><option>Blog</option><option>Images</option><option>Interview</option><option>News</option><option>Podcast</option><option>Preview</option><option>Review</option><option>Rumor</option><option>Screenshots</option><option>Trailer</option><option>TV</option><option>Video</option></select></td></tr><tr><td colspan='4'><div style='display: block; height: 20px;'></div></td></tr><tr><td colspan='2'><input type='image' id='butsubmit' name='butsubmit' src='/images/sendArticle.png' OnClick=\"systemNewsAjaxCall('/ajax/addnews.aspx', 'windowNewsForm');\"/></td></tr></table><span class='darkGray100' id='errorMessage'></span><input type='hidden' name='sid' id='sid' value='" + sid + "'/><input type='hidden' name='mid' id='mid' value='" + mid + "'/><input type='hidden' name='sysName' id='sysName' value='" + name + "'/></form><div id='successDiv' style='display:none;' align='center' class='marginTop25'>Thank you for submitting that news. </div>";
	  win.showCenter(modal);
	},
	
	/* Memberprofile: Send Message */
	sendMessage: function(theme, memID, mid, username, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:170, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Send " + username + " a Private Message</div>"});
	  win.getContent().innerHTML= "<div class='marginTop15 marginLeft15'><form id='windowMessageForm'><table width='100%'><tr><td><textarea id='message' name='message' class='textarea' style='font-size: 100%;' cols='73' rows='5'></textarea></td></tr><tr><td><div style='display: block; height: 10px;'></div></td></tr><tr><td><input type='button' class='buttonStyle block' value='Send Message' id='butsubmit' name='butsubmit' OnClick=\"sendMessageAjaxCall('/ajax/sendMessage.aspx', 'windowMessageForm');\"/></td></tr></table><span class='darkGray100' id='errorMessage'></span><input type='hidden' name='mid' id='mid' value='" + mid + "'/><input type='hidden' name='memID' id='memID' value='" + memID + "'/></form><div id='successDiv' style='display:none;' align='center' class='marginTop25'>Your message has been sent to " + username + ".</div></div>";
		win.showCenter(modal);
	},
	
	/* New message alert */
	newMessage: function(theme, mid, username) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:200, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>You Have a New Message</div>"});
	  win.getContent().innerHTML= "<div class='padding10'><form id='newMessageForm'><center><span class='lightGray100 block marginTop25 marginBottom10'>You have a new message from " + username + ".</span><a class='darkBlue' style='font-size: 100%;' href=\"javascript:readMessage('" + mid + "', '" + username + "')\">Read Message</a> <span class='lightGray70'>|</span> <a class='darkBlue' style='font-size: 100%;' href=\"javascript:readLater('" + mid + "', '" + username + "', 'profile')\">Take Me to My Profile</a> <span class='lightGray70'>|</span> <a class='darkBlue' style='font-size: 100%;' href=\"javascript:readLater('" + mid + "', '" + username + "', 'here')\">Read Later</a></center><input type='hidden' name='mid' id='mid' value='" + mid + "'/></form></div>";
	  win.showCenter();
	},
	
	/* Profile: Send Message */
	broadCastMessage: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:325, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Send a Private Message</div>"});
	  win.getContent().innerHTML= $('sendMessageWin').innerHTML;
	  win.showCenter(modal);
	},
	
	openBasicWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:400, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Basic Information</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Changing Your Username</span><p class='lightGray70' style='font-size: 100%;'>To change your username, enter your new username into the textbox and click ''Upate Username''.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Changing Your Basic Information</span><p class='lightGray70' style='font-size: 100%;'>To update your basic information, enter your first name, last name, gender, birthday, or motto into their respective input boxes and click ''Save''. Tell as much or as little about yourself as you want. None of this information is required and can be made private at anytime. The more you let the GameHuddle community know about yourself, the easier it will be for other gamers to find you.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Updating Your Photo</span><p class='lightGray70' style='font-size: 100%;'>Your current photo is displayed directly to the right of ''Current Photo''. This will be displayed as your main photo when other GameHuddle members view your profile. To change your main photo, click ''Browse'' to find a new photo, then click ''Update Photo'' to make the change.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Adding Current and Favorite Games</span><p class='lightGray70' style='font-size: 100%;'>To add current or favorite games, select a game from their respective ''Add Game'' dropdown lists and click ''Add'' to update your list. To remove a game, click ''Remove'' beside the game you would like removed.</p><p class='lightGray70 italic marginTop5 block' style='font-size: 100%;'>Note: In order to add a game to your current or favorites list, it must already be in your collection. To add games to your collection, click the ''Add Games'' tab at the top of this page.</p>";
	  win.showCenter(modal);
	},

	openSystemWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - System Selection</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Adding Systems to Your Collection</span><p class='lightGray70' style='font-size: 100%;'>To add systems to your collection, browse through the systems list, checking off all the systems you own. After checking off a system, it will be automatically added to you collection.</p><p class='lightGray70 italic marginTop5 block' style='font-size: 100%;'>Note: In order to add games to your collection, you will need to add their corresponding system to your collection first.</p>";
	  win.showCenter(modal);
	},
	
	openGamesWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Game Selection</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Adding Games to Your Collection</span><p class='lightGray70' style='font-size: 100%;'>To add games to your collection, start by selecting a system that you own from the systems dropdown list. Then navigate your way through the alphabetical list, checking off which games you own. After you check a game, it will be automatically added to your collection.</p><p class='lightGray70 italic marginTop5 block' style='font-size: 100%;'>Note: In order to associate a Friend Code or screen name with a game, you must have the game in your collection first. </p>";
	  win.showCenter(modal);
	},
	
	openAccWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Accessory Selection</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Adding Games to Your Collection</span><p class='lightGray70' style='font-size: 100%;'>To add an accessory to your collection, start by selecting a system that you own from the systems dropdown list. Next, add how many controllers you own for that system. Finally, navigate your way through the accessories list, checking off which ones you own. If you can't find an accessory, you can add it to GameHuddle's database at the bottom of the page.</p>";
	  win.showCenter(modal);
	},
	
	openOnlineWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:250, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Online Information</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Adding Your Online Console Information</span><p class='lightGray70' style='font-size: 100%;'>To add your Xbox Live gamertag, Nintendo Wii system Friend Code, or PS3/PS2 Network ID, enter it into the corresponding textbox and click ''Save''.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Adding Game Friend Codes and Screen Names</span><p class='lightGray70' style='font-size: 100%;'> If you have any multiplayer Wii, DS, or PC games added to your collection, a bottom section will appear which gives you the ability to add game Friend Codes and PC screen names. To do so, start by clicking ''+ Add a Friend Code'' for Wii or DS, or by clicking ''+ Add a Screen Name'' for PC games. Next, select the game you would like to add a code for from the ''Select Game'' dropdown list. Finally, enter in the Friend Code or screen name in the text box to the right and click ''Save Friend Code''.</p><p class='lightGray70 italic marginTop5 block' style='font-size: 100%;'>Note: In order to add a Friend Code or screen name for a game, you must first add that game to your collection, otherwise you will not be able to select it from the ''Select Game'' dropdown list.</p>";
	  win.showCenter(modal);
	},
	
	openInterestsWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Personal Interests</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Editing Your Interests</span><p class='lightGray70' style='font-size: 100%;'>This section gives you chance to let other GameHuddle members know a little more about yourself. You can fill out any of the pre-selected interests or you can create your own interests. Feel free to create as many interests as you'd like, but remember that you'll need to fill out a category name and description. </p>";
	  win.showCenter(modal);
	},
	
	openContactWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Contact Information</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Updating Your Contact Information</span><p class='lightGray70' style='font-size: 100%;'>To update your contact information, enter your email, screen name, location or website into its corresponding textbox. If you want to add more screen names, click ''+ Add Another Screen Name'' and fill out the textboxes that appear. When you're finished updating your contact information, click ''Save'' to save your changes.</p>";
	  win.showCenter(modal);
	},

	
	openRigWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:350, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Edit Your Gaming Rig</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Updating Your Console Rig</span><p class='lightGray70' style='font-size: 100%;'>To add a photo of your console rig, click ''Browse'' and select your rig photo. After selecting your photo, click ''Update'' to save it. Fill out the remaining input boxes and click ''Save'' to save your updates.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Updating Your PC Rig</span><p class='lightGray70' style='font-size: 100%;'>To add a photo of your PC rig, click ''Browse'' and select your rig photo. After selecting your photo, click ''Update'' to save it. If you have more than one video card in your PC, you can add more by clicking ''+ Add Another Video Card''. If you have more than one monitor, you can add more by clicking ''+ Add Second Monitor''. Fill out the remaining input boxes and click ''Save'' to save your updates.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Updating Your Console Connections</span><p class='lightGray70' style='font-size: 100%;'>In this section, you can specify what kind of connections you have your console hooked up with. For any console you own, a set of video and audio connection dropdown boxes will appear. When you're finished, click ''Save'' to update your changes.</p>";
	  win.showCenter(modal);
	},	
	
	openPrivacyWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:550, height:225, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 522px;'>Help - Edit Your Privacy Settings</div>"});
	  win.getContent().innerHTML= "<span class='darkBlue90 bold block marginBottom5 marginTop20' style='font-size: 110%;'>Updating Your Privacy Settings</span><p class='lightGray70' style='font-size: 100%;'>To update your privacy settings, use the dropdown lists to the right of each category to select whether you want that information shown to other GameHuddle members. When you're finished, click ''Save'' to update your privacy settings.</p><div class='dottedGrayDivide'></div><span class='darkBlue90 bold block marginBottom5 marginTop10' style='font-size: 110%;'>Updating Your Email Options</span><p class='lightGray70' style='font-size: 100%;'>This section will determine if GameHuddle will send you an email when certain actions occur. You can choose to receive an email, not receive an email, or only receive an email when you're offline.</p>";
	  win.showCenter(modal);
	},	
	
	system: function(sid, mid, modal) {
		var requestPage = '/ajax/viewCollection.aspx';
		var method = 'post';
		var params = 'mid=' + mid + '&sid=' + sid;
		
		var win = new Window(Application.getNewId(), {className: 'bluelighting', width:450, height:375, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 422px;'>Game Collection</div>"});
		win.getContent().innerHTML = '<br/><br/><center><img src="/images/memberloading.gif"/></center>';
		win.showCenter(modal);
						
		new Ajax.Request(
			requestPage,
			{
				method: method,
				postBody: params,
				onSuccess: function(response){
					response = response.responseText.split('|');
					
					if(response[0] == 'Success'){
						win.getContent().update(response[1]);
					}			
				}
			}
		);	
	},
	
	openCreateProfileWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:400, height:300, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 372px;'>Create a Profile</div>"});
	  win.getContent().innerHTML= "<form id='windowRegisterForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 100%;' align='center'>Enter your email, username, and password to create a profile.</p><table style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Email</td><td><input class='signInTextbox' type='text' name='regEmail' id='regEmail' size='35' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Username</td><td><input size='35' class='signInTextbox' type='text' name='regUsername' id='regUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='regPass' id='regPass' /></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Create Profile' name='Register' id='Register' OnClick=\"windowAjaxCall('register.aspx', 'windowRegisterForm');\" /></td></tr><tr><td colspan='2'><a class='darkBlueUnderline block marginTop20' href=\"javascript:changeWindow('login')\" style='font-size:100%; width: 185px;'>Already a member?  Sign in here.</a></td></tr><tr><td colspan='2'><span id='errorMessage'></span></td></tr></table></form>";
	  win.showCenter(modal);
	},
	
	openLoginWindow: function(theme, modal) {
	  var win = new Window(Application.getNewId(), {className: theme, width:400, height:300, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 372px;'>Sign In</div>"});
	  win.getContent().innerHTML= "<form id='windowLoginForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 100%;' align='center'>Enter your username and password to login.</p><table style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Username</td><td><input size='35' class='signInTextbox' type='text' name='loginUsername' id='loginUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='loginPass' id='loginPass' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Sign In' name='login' id='login' OnClick=\"homeAjaxCall('register.aspx', 'windowLoginForm');\" /></td></tr></table></form><br/><br/><a class='darkBlueUnderline block marginTop20 marginLeft15' style='font-size:100%; width: 185px;' href=\"javascript:changeWindow('register')\">Not Registered?  Create A Profile.</a>";
	  win.showCenter(modal);
	},
	
	addRightColumn: function() {
    document.write();    
    
    setTimeout(Application.moveFrame, 100);
	},
	
	moveFrame: function() {
	  var f =$$("iframe")[0]; 
    if (f) {
      $("g").appendChild(f)
    }
    else
      setTimeout(Application.moveFrame, 100)
	},
	
	loginWindow: function(theme, modal) {
		idButton = theme + '_theme_button';
		html = "<input type='button' id='butsubmit' style=\"cursor: pointer;\" value='Submit Article' class='button' onclick=\"Application.storyLoginWindow('" + theme + "')\"/>";
		document.write(html)
	},
	
	storyLoginWindow: function(theme, modal) {
		var win = new Window(Application.getNewId(), {className: theme, width:300, height:200, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 172px;'>Login</span>"});
		win.getContent().innerHTML= "<form id='windowLoginForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>Enter your username and password to login.</p><table cellpadding='5' cellspacing='5' style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Username</td><td><input size='35' class='signInTextbox' type='text' name='loginUsername' id='loginUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='loginPass' id='loginPass' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Login' name='login' id='login' OnClick=\"storyAjaxCall('register.aspx', 'windowLoginForm');\" /></td></tr></table></form><br/><br/><a class='darkBlueUnderline' style='font-size: 100%;' href=\"javascript:storyChangeWindow('register')\">Not Registered?  Create A Profile</a>";
		win.showCenter(modal);
	},
	
	playNow: function(theme, memID, modal){
		var win = new Window(Application.getNewId(), {className: theme, width:450, height:300, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 422px;'>Play Now</div>"});
		
		var requestPage = '/ajax/playNowSystems.aspx';
		var method = 'post';
		var params = 'memID=' + memID;
		
		new Ajax.Request(
			requestPage,
			{
				method: method,
				postBody: params,
				onSuccess: function(response){
					win.getContent().innerHTML = response.responseText;	
				}
			}
		);	
		
		win.showCenter(modal);
	},
	
	playNowLimit: function(theme, username, modal){
		var win = new Window(Application.getNewId(), {className: theme, width:450, height:70, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 422px;'>Play Now Limit Reached</div>"});
		
		win.getContent().innerHTML= "<p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>" + username + " has reached their personal PlayNow quota for this month.</p>";
		
		win.showCenter(modal);
	},
	
	playNowNotSetup: function(theme, memID, email, profileName, viewerName, modal){
		var win = new Window(Application.getNewId(), {className: theme, width:450, height:120, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 422px;'>Play Now</div>"});

		win.getContent().innerHTML = "<form id='playNowForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;'>" + profileName + " has not set up their PlayNow information.  Would you like to send them an email requesting they setup their PlayNow status?<br/><br/><span style='align: center; padding-left: 300px;'><input type='button' class='button' value='Send Email' name='emailButton' id='emailButton' OnClick=\"sendPlayNowEmailAjaxCall('/ajax/sendplaynowemail.aspx', 'playNowForm');\" /></span></p><input type='hidden' name='viewerName' id='viewerName' value='" + viewerName + "'/><input type='hidden' name='email' id='email' value='" + email + "'/></form>";

		win.showCenter(modal);
	},
	
	playNowInactive: function(theme, username, modal){
		var win = new Window(Application.getNewId(), {className: theme, width:300, height:70, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 372px;'>Play Now</div>"});

		win.getContent().innerHTML = "<form id='windowLoginForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;'  align='center'>" + username + "'s PlayNow is currently inactive.</p>";

		win.showCenter(modal);
	},
	
	playNowWindow: function(theme, modal) {
		var win = new Window(Application.getNewId(), {className: theme, width:400, height:150, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 372px;'>What is Play Now?</div>"});
		win.getContent().innerHTML= "<p class='lightGray100' style='font-size: 100%; padding: 10px;'>GameHuddle's Play Now feature allows you to notify friends of immediate gaming events through text messaging. So, let's say you wanted to get a game of Call of Duty 4 going, but your friends don't happen to be sitting in front of their computers at the moment. As long as they have updated their profile with their cell phone information, this feature will send them a text message with all of the necessary event data.</p>";
		win.showCenter(modal);
	},
	
	flag: function(theme, commentType, newsID, commentID, memID, modal){
		var win = new Window(Application.getNewId(), {className: theme, width:350, height:200, resizable: false, minimizable: false, maximizable: false, title: "<div style='width: 322px;'>Flag User</div>"});
		win.getContent().innerHTML= "<div id='divFlag' name='divFlag'><div class='darkGray100 lightGrayBG bold' style='padding: 3px 0 3px 5px; width: 95%;'>Flag a Fanboy</div><span class='lightGray100 block marginTop10'>Are fanboys getting in the way of your reading pleasure? Stick it to them here. Once a fanboy has passed the threshold defined by you on your profile, they will have their stories and comments hidden to you throughout GameHuddle.</span><a class='darkBlue block marginTop10' style='font-size: 100%;' href=\"javascript:fanboy('" + commentType + "', '" + newsID + "', '" + commentID + "', '" + memID + "', 'Microsoft')\">Flag as a Microsoft Fanboy</a><a class='darkBlue block' style='font-size: 100%;' href=\"javascript:fanboy('" + commentType + "', '" + newsID + "', '" + commentID + "', '" + memID + "', 'Nintendo')\">Flag as a Nintendo Fanboy</a><a class='darkBlue block' style='font-size: 100%;' href=\"javascript:fanboy('" + commentType + "', '" + newsID + "', '" + commentID + "', '" + memID + "', 'Sony')\">Flag as a Sony Fanboy</a></div>";
		win.showCenter(modal);
	}
}

function fanboy(var1, var2, var3, var4, var5){
	var method = 'post';
	if(var1 == 'News'){
		var params = 'newsID=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5;
	}else if(var1 == 'NewsReply'){
		var params = 'newsID=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'gameDiscussions'){
		var params = 'fid=' + var2 + '&pk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'gameDiscussions_Reply'){
		var params = 'fid=' + var2 + '&replypk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'accessoryDiscussions'){
		var params = 'fid=' + var2 + '&pk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'accessoryDiscussions_Reply'){
		var params = 'fid=' + var2 + '&replypk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'systemDiscussions'){
		var params = 'fid=' + var2 + '&pk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'systemDiscussions_Reply'){
		var params = 'fid=' + var2 + '&replypk=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'Blog'){
		var params = 'bid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5;
	}else if(var1 == 'blog_reply'){
		var params = 'bid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;	
	}else if(var1 == 'gameReview'){
		var params = 'rid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'gameReview_reply'){
		var params = 'rid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'accReview'){
		var params = 'rid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'accReview_reply'){
		var params = 'rid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5 + '&flagType=' + var1;
	}else if(var1 == 'Game Video'){
		var params = 'gamevid=' + var2 + '&commentID=' + var3 + '&memID=' + var4 + '&platform=' + var5;
	}
	
	var requestPage = '/ajax/fanboy.aspx';
	
	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $('divFlag').update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				new Effect.Fade(Windows.focusedWindow.getId());		
			}
		}
	);	
}

function sendPlayNowEmailAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				new Effect.Fade(Windows.focusedWindow.getId());		
			}
		}
	);	
}

function playNowAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				new Effect.Fade(Windows.focusedWindow.getId());		
			}
		}
	);	
}

function playNowGetGames(memID){
	var index = $('playNowSystems').selectedIndex; 
	var system = $('playNowSystems')[index].value;
	
	var requestPage = '/ajax/playNowGames.aspx';
	var method = 'post';
	var params = 'memID=' + memID + '&system=' + system;
	
	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				$('playNowGamesDiv').update(response.responseText);	
			}
		}
	);
}

function storyChangeWindow(type)
{
	if(type == 'register'){
		new Effect.Fade($('windowLoginForm') , {duration: 1});
		var div = "<form id='windowRegisterForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>Enter your email, username, and password to create a profile.</p><table cellpadding='5' cellspacing='5' style='margin-left: 13px;' width='100%'><tr><td class='createProfile' width='100'>Email</td><td><input class='signInTextbox' type='text' name='regEmail' id='regEmail' size='35' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Username</td><td><input size='35' class='signInTextbox' type='text' name='regUsername' id='regUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='regPass' id='regPass' /></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' value='Create Profile' class='button' name='Register' id='Register' OnClick=\"storyAjaxCall('register.aspx', 'windowRegisterForm');\" /></td></tr><tr><td colspan='2'><a class='darkBlueUnderline block marginTop10' href=\"javascript:storyChangeWindow('login')\" style='font-size:100%'>Already a member?  Sign in here</a></td></tr><tr><td colspan='2'><span id='errorMessage'></span></td></tr></table></form>";
		
		Windows.focusedWindow.getContent().innerHTML= div;
		Windows.focusedWindow.setTitle("<span style='color: #ffffff; font-size: 12px; font-weight: bold;'>Register</span>");
		
		$('windowRegisterForm').style.visibility = 'visible';
		$('windowRegisterForm').style.display = 'block';
		$('windowRegisterForm').hide();
		
		Effect.Appear($('windowRegisterForm') , {duration: 1});
	}else{
		new Effect.Fade($('windowRegisterForm') , {duration: 1});
		var div = "<form id='windowLoginForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>Enter your email and password to login.</p><table cellpadding='5' cellspacing='5' style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Email</td><td><input size='35' class='signInTextbox' type='text' name='loginEmail' id='loginEmail' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='loginPass' id='loginPass' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Login' name='login' id='login' OnClick=\"storyAjaxCall('register.aspx', 'windowLoginForm');\" /></td></tr><tr><td colspan='2'><div style='display: block; height: 10px;'</td></tr><tr><td colspan='2'><a class='darkBlueUnderline marginTop10' style='font-size: 100%;' href=\"javascript:storyChangeWindow('register')\">Not Registered?  Create A Profile</a></td></tr><tr><td colspan='2'><span id='errorMessage'></span></td></tr></table></form>";
		
		Windows.focusedWindow.getContent().innerHTML= div;
		Windows.focusedWindow.setTitle("<span style='color: #ffffff; font-size: 12px; font-weight: bold;'>Login</span>");
		
		$('windowLoginForm').style.visibility = 'visible';
		$('windowLoginForm').style.display = 'block';
		$('windowLoginForm').hide();
		
		Effect.Appear($('windowLoginForm') , {duration: 1});
	}
}

function changeWindow(type)
{
	if(type == 'register'){
		new Effect.Fade($('windowLoginForm') , {duration: 1});
		var div = "<form id='windowRegisterForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>Enter your email, username, and password to create a profile.</p><table style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Email</td><td><input class='signInTextbox' type='text' name='regEmail' id='regEmail' size='35' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Username</td><td><input size='35' class='signInTextbox' type='text' name='regUsername' id='regUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='regPass' id='regPass' /></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Create Profile' name='Register' id='Register' OnClick=\"homeAjaxCall('register.aspx', 'windowRegisterForm');\" /></td></tr><tr><td colspan='2'><a class='darkBlueUnderline block marginTop20' style='font-size: 100%; width: 185px;' href=\"javascript:changeWindow('login')\" style='font-size:100%'>Already a member?  Sign in here.</a></td></tr><tr><td colspan='2'><span id='errorMessage'></span></td></tr></table></form>";
		
		Windows.focusedWindow.getContent().innerHTML= div;
		Windows.focusedWindow.setTitle("<span style='color: #414141; font-size: 12px; font-size: 120%; font-family: arial, helvetica, sans-serif; font-weight: bold;'>Create a Profile</span>");
		
		$('windowRegisterForm').style.visibility = 'visible';
		$('windowRegisterForm').style.display = 'block';
		$('windowRegisterForm').hide();
		
		Effect.Appear($('windowRegisterForm') , {duration: 1});
	}else{
		new Effect.Fade($('windowRegisterForm') , {duration: 1});
		var div = "<form id='windowLoginForm'><p style='margin: 15px 0 15px 0; color: #555555; font-family: Arial, Helvetica, sans-serif; font-size: 12px;' align='center'>Enter your username and password to login.</p><table style='margin-left: 13px;'><tr><td class='createProfile' width='100'>Username</td><td><input size='35' class='signInTextbox' type='text' name='loginUsername' id='loginUsername' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td class='createProfile'>Password</td><td><input size='35' class='signInTextbox' type='password' name='loginPass' id='loginPass' /></td></tr><tr><td colspan='2'><div style='height: 4px; display: block;'></div></td></tr><tr><td colspan='2'><div style='height: 8px; display: block'></div></td></tr><tr><td></td><td><input type='button' class='button' value='Login' name='login' id='login' OnClick=\"homeAjaxCall('register.aspx', 'windowLoginForm');\" /></td></tr><tr><td colspan='2'><a class='darkBlueUnderline block marginTop20' style='font-size:100%; width: 185px;' href=\"javascript:changeWindow('register')\">Not Registered?  Create A Profile.</a></td></tr><tr><td colspan='2'><span id='errorMessage'></span></td></tr></table></form>";
		
		Windows.focusedWindow.getContent().innerHTML= div;
		Windows.focusedWindow.setTitle("<span style='color: #414141; font-size: 12px; font-size: 120%; font-family: arial, helvetica, sans-serif; font-weight: bold;'>Sign In</span>");
		
		$('windowLoginForm').style.visibility = 'visible';
		$('windowLoginForm').style.display = 'block';
		$('windowLoginForm').hide();
		
		Effect.Appear($('windowLoginForm') , {duration: 1});
	}
}

/* Functions for popup new message alert */
function newMessageAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: windowSuccessHandler
		}
	);	
}

function readLater(mid, username, type){
	var requestPage = '/ajax/markAsRead.aspx';
	var method = 'post';
	var params = 'mid=' + mid + '&username=' + username;

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				if(type == "profile"){
					window.location = "/member.aspx";
				}else{
					new Effect.Fade(Windows.focusedWindow.getId());	
				}
			},
			onFailure: function(response){
				if(type == "profile"){
					window.location = "/member.aspx";
				}else{
					new Effect.Fade(Windows.focusedWindow.getId());	
				}
			}
		}
	);	
}

function readMessage(mid, username){
	var requestPage = '/ajax/readNewMessage.aspx';
	var method = 'post';
	var params = 'mid=' + mid + '&username=' + username;

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade($('newMessageForm'), {queue: 'front', duration: .3,
						afterFinish: function (obj) {
							$('newMessageForm').update(response[2] + '<div class="dottedGrayDivide"></div><span class="block"><a class="darkBlue" style="font-size: 100%;" href="javascript:flipMessage(\'' + mid + '\', \'' + response[1] + '\', \'' + username + '\')\">Reply to This Message</a></span>');
							new Effect.Appear($('newMessageForm'), {queue: 'front', duration: .5});
						}
					});
				}
			}
		}
	);	
}

function flipMessage(mid, memID, username){
	new Effect.Fade($('newMessageForm'), {duration: .3,
		afterFinish: function (obj) {
			$('newMessageForm').update("<table width='100%' class='marginTop10'><tr><td><textarea id='message' name='message' class='textarea' style='font-size: 100%;' cols='95' rows='5'></textarea></td></tr><tr><td><div style='display: block; height: 10px;'></div></td></tr><tr><td><input type='image' id='butsubmit' name='butsubmit' src='/images/sendMessageButton.png' OnClick=\"sendMessageAjaxCall('/ajax/sendMessage.aspx', 'newMessageForm');\"/></td></tr></table><span class='darkGray100' id='errorMessage'></span><input type='hidden' name='mid' id='mid' value='" + mid + "'/><input type='hidden' name='memID' id='memID' value='" + memID + "'/><div id='successDiv' style='display:none;' align='center' class='marginTop25 lightGray100'>Your message has been sent to " + username + ".</div>");
			new Effect.Appear($('newMessageForm'), {duration: .5});
		}
	});
}
/* End of functions for popup new message alert */

function windowAjaxCall(requestPage, form){
	var method = 'post';
	var params = Form.serialize($(form));
	
	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				new Effect.Fade(Windows.focusedWindow.getId());	
			}
		}
	);	
}

function homeAjaxCall(requestPage, form)
{
	method = 'post';
	params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: windowLoadingHandler,
			onSuccess: windowSuccessHandler,
			onFailure: windowFailureHandler
		}
	);	

}

function windowFailureHandler (response)
{
	alert(response.responseText);
}

function windowLoadingHandler ()
{
	$('windowIcon').addClassName('loadingIcon');
	new Effect.Appear($('windowIcon'));	
}


function windowSuccessHandler (response)
{
	response = response.responseText.split('|');

	if(response[0] == 'Success')
	{
		new Effect.Fade($('windowReviewForm'), {queue: 'front', duration: .3,
			afterFinish: function (obj) {
				new Effect.Appear($('successDiv'), {queue: 'front', duration: .3});
			}
		});
	}else if(response[1] == 'success')
	{
		//$('windowIcon').removeClassName('loadingIcon');
		//$('windowIcon').removeClassName('errorIcon');
		//$('windowIcon').addClassName('successIcon');
		window.location = window.location;
	}

}

function gameVideoAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $('windowReviewForm').update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade($('windowReviewForm'), {queue: 'front', duration: .3,
						afterFinish: function (obj) {
							new Effect.Appear($('successDiv'), {queue: 'front', duration: 2,
								afterFinish: function (obj) {
									new Effect.Fade(Windows.focusedWindow.getId());
								}
							});
						}
					});
				}
			}
		}
	);	

}

/* Function used to send a member a message */
function sendMessageAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $(form).update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade($(form), {queue: 'front', duration: .3,
						afterFinish: function (obj) {
							//new Effect.Appear($('successDiv'), {queue: 'front', duration: 2,
								//afterFinish: function (obj) {
									new Effect.Fade(Windows.focusedWindow.getId());
								//}
							//});
						}
					});
				}
			}
		}
	);	

}
/* End of send member message */

/* Function used from member.aspx to send friends a message */
function sendMessageMembersCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $(form).update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade(Windows.focusedWindow.getId());
				}
			}
		}
	);	

}
/* End of member.aspx friend message */

/* Functions used for gameprofile  & systemprofile news */
function gameNewsAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $('windowNewsForm').update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade($('windowNewsForm'), {queue: 'front', duration: .3,
						afterFinish: function (obj) {
							new Effect.Appear($('successDiv'), {queue: 'front', duration: 2,
								afterFinish: function (obj) {
									new Effect.Fade(Windows.focusedWindow.getId());
								}
							});
						}
					});
				}else{
					$('errorMessage').update(response[1]);
				}
			}
		}
	);	

}

function systemNewsAjaxCall(requestPage, form)
{
	var method = 'post';
	var params = Form.serialize($(form));

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onLoading: $('windowNewsForm').update("<center><br/><br/><img src='/images/memberLoading.gif'/></center>"),
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[0] == "Success"){
					new Effect.Fade($('windowNewsForm'), {queue: 'front', duration: .3,
						afterFinish: function (obj) {
							new Effect.Appear($('successDiv'), {queue: 'front', duration: 2,
								afterFinish: function (obj) {
									new Effect.Fade(Windows.focusedWindow.getId());
								}
							});
						}
					});
				}else{
					$('errorMessage').update(response[1]);
				}
			}
		}
	);	

}

function checkTitle(){
	var title = $('storytitle').value
	var url = $('storyurl').value
	
	if(title != ''){
		method = 'post';
		params = 'title=' + title + '&url=' + url;
	
		new Ajax.Request(
			'/ajax/checkstory.aspx',
			{
				method: method,
				postBody: params,
				onLoading: function(response){
					$('titleIcon').update("<img src='/images/loading.gif' alt='loading'/>");	
				},
				onSuccess: function(response){
					response = response.responseText.split('|');
					
					if(response[1] == '1'){
						$('titleIcon').update('Duplicate Title <img class="successIcon" src="/images/cancel.png" alt="URL Not OK Icon" />');
						document.form1.butsubmit.disabled = true;
					}else{
						$('titleIcon').update('Title OK <img class="successIcon" src="/images/accept.png" alt="URL OK Icon" />');
						document.form1.butsubmit.disabled = false;
					}
					
				}
			}
		);
	}
}

function checkUrl(){
	var url = $('storyurl').value
	if(url != ''){
		method = 'post';
		params = 'url=' + url;
		
		new Ajax.Request(
			'/ajax/checkstory.aspx',
			{
				method: method,
				postBody: params,
				onLoading: function(response){
					$('urlIcon').update("<img src='/images/loading.gif' alt='loading'/>");	
				},
				onSuccess: function(response){
					response = response.responseText.split('|');
					
					if(response[1] == '1'){
						$('urlIcon').update('Duplicate URL <img class="successIcon" src="/images/cancel.png" alt="URL Not OK Icon" />');
						document.form1.butsubmit.disabled = true;
					}else{
						$('urlIcon').update('URL OK <img class="successIcon" src="/images/accept.png" alt="URL OK Icon" />');
						document.form1.butsubmit.disabled = false;
					}
				}
			}
		);	
	}
}

function charLimit(textbox, divToUpdate){
	var maxLimit = 500;
	
	if($(textbox ).value.length > maxLimit){
		$(textbox).value = $(textbox).value.substring(0, maxLimit);
	}else{
		$(divToUpdate).update((maxLimit-$(textbox).value.length));
	}
}
/* End of functions for gameprofile news */

/* Member Sign In */
function signIn(usernameBox, passwordBox){
	var username = $(usernameBox).value;
	var password = $(passwordBox).value;
	
	var requestPage = '/register.aspx';
	var method = 'post';
	var params = 'loginUsername=' + username + '&loginPass=' + password;

	new Ajax.Request(
		requestPage,
		{
			method: method,
			postBody: params,
			onSuccess: function(response){
				response = response.responseText.split('|');
				
				if(response[1] == "success"){
					window.location = window.location;	
				}else{
					if(usernameBox == 'loginUsername'){
						$('errorLoginMessage').innerHTML = response[2];
					}else{
						$('loginError').innerHTML = response[2];
					}
				}

			}
		}
	);	
}

function fadeSignIn(){
	new Effect.Fade($('signInLink'), {queue: 'front', duration: .3,
		afterFinish: function (obj) {
			new Effect.Appear($('signInForm'), {queue: 'front', duration: 2});
		}
	});
}
/* End of Member Sign In */

function setFocus(field){
	$(field).focus();	
}

function handleKeyPress(e,form){
	var key=e.keyCode || e.which;
	if (key==13){
		var exists = checkForObject('loginUsername', 'input');
		if(exists){
			var username = $('loginUsername').value;
		}else{
			var username = $('loginUsername1').value;
		}
		
		if(username != ''){
			signIn('loginUsername', 'loginPass');
		}else{
			signIn('loginUsername1', 'loginPass1');
		}
		
	}
}

function checkForObject(id, tag)
{
	//get id 
	var o = document.getElementById(id)
		//if exists
		if(o)
		{
			//if variable tag (span, div, etc.) was passed in
			if(tag)
			{
				//if element exists where (name=passed in name) and (tag type=tag type passed in)
				if(o.tagName.toLowerCase() == tag.toLowerCase())
				{
					//return name of tag
					return o;
				}
			}
			else
			{
				//return name of tag
				return o;
			}
		}
	return null;
}
