//Leaving site popup
	$("a").click(function(){
		//Strip down the url
		if($(this).attr("href"))
		{
			var url = $(this).attr("href").toLowerCase();
			var domain = url.replace("http://", "").replace("https://").replace("www.", "");
			//See if it's our own
			var regex= /^[0-9A-Za-z]+$/;
			if((domain.substr(0, 14) != "vigilgames.com" || regex.test(domain.substr(10, 1))) && (url.substr(0, 7) == "http://" || url.substr(0, 8) == "https://") && $(this).attr("class") != "map_link" && !$(this).hasClass("no-popup"))
			{
				//Analytics tracking for externals
				_gaq.push(['_trackEvent', 'Outgoing', 'Click', $(this).attr('href')]);
				do
				{
					if($(this).attr("rel") == 'social')
					{
						$("#hidden_link").fancybox({overlayColor:"#000", height:70, width: 385, padding: 10, autoDimensions: false, content:"<p class='aligncenter'>Are you sure you want to leave <strong>vigilgames.com</strong>?</p><div class='aligncenter'><a class='bbutton' style='display: inline-block' href='"+$(this).attr("href")+"' onclick='$.fancybox.close();' target='"+$(this).attr("target")+"'>Yes</a> <a class='bbutton' style='display: inline-block' href='javascript:$.fancybox.close();'>No</a></div>"}).trigger('click');
						setTimeout('$("#fancybox-wrap").css("margin-top", "10%");', 75);
					}
					//Different sizing options
					else if($(this).attr("rel") == 'thq')
					{
						$("#hidden_link").fancybox({overlayColor:"#000", height:70, width: 385, padding: 10, autoDimensions: false, content:"<p class='aligncenter'>Are you sure you want to leave <strong>vigilgames.com</strong>?</p><div class='aligncenter'><a class='bbutton' style='display: inline-block' href='"+$(this).attr("href")+"' onclick='$.fancybox.close();' target='"+$(this).attr("target")+"'>Yes</a> <a class='bbutton' style='display: inline-block' href='javascript:$.fancybox.close();'>No</a></div>"}).trigger('click');
						setTimeout('$("#fancybox-wrap").css("margin-top", "-10%");', 75);
					}
					else
					{
						$("#hidden_link").fancybox({overlayColor:"#000", height:70, width: 385, padding: 10, autoDimensions: false, content:"<p class='aligncenter'>Are you sure you want to leave <strong>vigilgames.com</strong>?</p><div class='aligncenter'><a class='bbutton' style='display: inline-block' href='"+$(this).attr("href")+"' onclick='$.fancybox.close();' target='"+$(this).attr("target")+"'>Yes</a> <a class='bbutton' style='display: inline-block' href='javascript:$.fancybox.close();'>No</a></div>"}).trigger('click');
						setTimeout('$("#fancybox-wrap").css("margin-top", "0");', 100);
					}
				}
				while(!$("#leaving-site"));
				return false;
			}
			else if(url.substr(0, 7) == "mailto:")
			{
				_gaq.push(['_trackEvent', 'Emails', 'Email', $(this).attr('href')]);
			}
		};
//	$("#legal_link").fancybox({overlayColor:"#000", height:230, width: 500, padding: 10, autoDimensions: false, content:"<h3 class='aligncenter'>Legal Information</h3><p class='aligncenter' style='font-size: 14px;'>THQ, Vigil Games, Darksiders, and their respective logos are trademarks and/or registered trademarks of THQ Inc. GW, Games Workshop, the Games Workshop logo, 40K, Warhammer, Warhammer 40,000, Warhammer 40,000 Device, 40,000, the Double-headed Eagle device and all associated marks, logos, places, names, creatures, races and race insignia/devices/logos/symbols, vehicles, locations, weapons, units and unit insignia, characters, products, illustrations and images from the Space Marine game and the Warhammer 40,000 universe are either &#0174;, &#0153; and/or &copy; Games Workshop Ltd 2000-2010, variably registered in the UK and other countries around the world, and used under license. All rights reserved. All other trademarks, logos and copyrights are the property of their respective owners.</p>"});		
	});
$("#legal_link").fancybox({overlayColor:"#000", height:230, width: 500, padding: 10, autoDimensions: false, content:"<h3 class='aligncenter'>Legal Information</h3><p class='aligncenter' style='font-size: 14px;'>THQ, Vigil Games, Darksiders, and their respective logos are trademarks and/or registered trademarks of THQ Inc. GW, Games Workshop, the Games Workshop logo, 40K, Warhammer, Warhammer 40,000, Warhammer 40,000 Device, 40,000, the Double-headed Eagle device and all associated marks, logos, places, names, creatures, races and race insignia/devices/logos/symbols, vehicles, locations, weapons, units and unit insignia, characters, products, illustrations and images from the Space Marine game and the Warhammer 40,000 universe are either &#0174;, &#0153; and/or &copy; Games Workshop Ltd 2000-2010, variably registered in the UK and other countries around the world, and used under license. All rights reserved. All other trademarks, logos and copyrights are the property of their respective owners.</p>"});			

function grabVid(id)
{
	//Check for age
	if(!isInt($("#age").val()))
	{
		$("#errors").html("You must enter a numerical age!").show();
		setTimeout( function() { $( "#errors" ).fadeOut( 'slow' ); }, 2000 )
	}
	else if(parseInt($("#age").val()) < 18)
		ageBlock();
	else if(parseInt($("#age").val()) >= 18)
		$.post(path+"ajax.php", {action: "grab_vid", id: id}, function(data) { $("#vid_content").html(data); });
}
function ageBlock()
{
	//Set a cookie that prevents them from viewing vids (check again in 2 weeks)
	setCookie('age_block', 'T', 14);
	//Redirect to homepage
	window.location = "/";
}
function setCookie(c_name, value, expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}
function toggle()
{
	if(document.getElementById('shown').style.display == 'none')
		$("#shown").fadeIn();
	else
		$("#shown").fadeOut();
}
function toggleCat()
{
	//Temp name and hide
	$("#category").attr("name", "category2").attr("id", "category2").hide();
	//Show other
	$("#category1").attr("name", "category").attr("id", "category").show();
	//Change temp to real name
	$("#category2").attr("name", "category1").attr("id", "category1");
	//Change helper text
	if($("#new").text() == "(new)")
		$("#new").text("back");
	else
		$("#new").text("(new)");
}
function isInt(str)
{
	var i = parseInt (str);

	if (isNaN (i))
		return false;

	i = i . toString ();
	if (i != str)
		return false;

	return true;
}

