function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadoverlaypopup(){

	var popDetails = loadoverlaypopup.arguments;
	var divId, popWidth;

	//if (get_cookie('fehfreeinetpromopopup')==''){ || get_cookie('fehfreeinetpromopopup')=='1'){
		//var w = openpopup();
		//if(w != null)
		if (get_cookie('fehfreeinetpromopopup')=='')
		{
			divId = popDetails[0];
			popWidth = popDetails[1];
			document.cookie = "fehfreeinetpromopopup=1";
			poplightpopup(divId, popWidth);
		}
		/*else
		{
			if(popDetails.length == 4)
			{
				divId = popDetails[2];
				popWidth = popDetails[3];
			}
			else
			{
				divId = popDetails[0];
				popWidth = popDetails[1];
			}
			document.cookie = "fehfreeinetpromopopup=2";
		}*/

		//poplightpopup(divId, popWidth);
	//}

}

	function poplightpopup(popID, popWidth){

		//Fade in the Popup and add close button
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="/FEHospitality.Upload/VILLAGE-EN-US/CMS/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
		
		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
		var popMargTop = ($('#' + popID).height() + 40) / 2;
		var popMargLeft = ($('#' + popID).width() + 40) / 2;
		
		//Apply Margin to Popup
		$('#' + popID).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		//Fade in Background
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
		{
			$("#fade").css({"width": "10000px", "height": "10000px"});
		}
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
		
	};

	//Close Popups and Fade Layer
	$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
	  	$('#fade , .popup_block').fadeOut(); //fade them both out
		$('#fade').remove();
		$('#introvid_content').empty();
		return false;
	});



