function checkCookie()
{
  if (location.search != "")
 {
 	var urlkey = 0;
	var x = location.search.substr(1).split("&")
	for (var i=0; i<x.length; i++)
	{
		var y = x[i].split("=");
		var urlkey = y[1];
		if (urlkey=="GED")
		{
		setCookie("QuinnDirect_Region","GED",30);
		}
		if (urlkey=="GNI")
		{
		setCookie("QuinnDirect_Region","GNI",30);
		}
	} 
  }	
  
  var username=getCookie("QuinnDirect_Region");
  if (username=="GNI")
  {
  window.location = "http://www.quinn-direct.co.uk/ni"
  }
  else if (username=="GED")
  {
  
  }
  else if (username=="undefined")
  {
  
  }
else 
  {
    showregiondiv();
  }
}


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);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : ";path=/; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
	if (value=="GNI")
	{
	window.location = "http://www.quinn-direct.co.uk/ni"
	}
}


function showregiondiv() {

// select the overlay element - and "make it an overlay"
$("#region").overlay({
// custom top position
top: 330,

// some mask tweaks suitable for facebox-looking dialogs
mask: {

// you might also consider a "transparent" color for the mask
color: '#000',

// load mask a little faster
loadSpeed: 200,

// very transparent
opacity: 0.8
},

// disable this for modal dialog-type of overlays
closeOnClick: false,

// load it immediately after the construction
load: true
})};
