$(document).ready(function(){
	//When you click on a link with class of poplight and the href starts with a #
  if (getCookie('Riftforge') != 'Riftforge'){ 
	var popID = 'popup1'; //Get Popup Name
	var popWidth = 300; //Gets the first query string value
	
	//Fade in the Popup and add close button
	$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="images/close_pop.png" border="0" class="btn_close" title="Close" alt="Close" /></a>');
	
	//Fade in Background
	$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
	$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer

	//Close Popups and Fade Layer
	$('a.close').live('click', function() { //When clicking on the close or fade layer...
		 $('#fade , .popup_block').fadeOut(function() {
			setCookie('Riftforge','Riftforge',1)
			$('a.close').remove();
		}); //fade them both out
		
		return false;
	});

  return false;
}

});

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
