//code for exit popup

//exit popup settings
var exitcookie = 'csborgx';  //the cookie name
var showdelay = 0; //how many days to wait before showing it again.
//NOTE: the following (pageoffset) needs to be a pretty BIG number to make
//any real difference, 10 will make it to where ANY scrolling will trigger.
//1500 or so will make it to where they have to go down the page a ways before
//the exit popup can be triggered.
var pageoffset = 5; //how much the user has to have scrolled for the exit popup to be shown.
var elementid = 'exitpop';   //the id of the <div> for the exit pop


//======================================
//cookie related code =================>
function SetCookie( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );
	
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function GetCookie( name ) 
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	
	if ( start == -1 ) return null;
	
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
}

function DeleteCookie( name, path, domain ) 
{
        if ( Get_Cookie( name ) ) document.cookie = name + "=" +
        ( ( path ) ? ";path=" + path : "") +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


//======================================
//popup specific code =================>

//blank status text
function blankStatus () {

	window.status=''; 

}

//function to get scroll position:
function getScrollPos() {
        var scrollpos = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
            //Netscape compliant
            scrollpos = window.pageYOffset;
        } else if( document.body && ( document.body.scrollTop ) ) {
            //DOM compliant
            scrollpos = document.body.scrollTop;
        } else if( document.documentElement && (document.documentElement.scrollTop ) ) {
            //IE6 standards compliant mode
            scrollpos = document.documentElement.scrollTop;
        }
        return scrollpos;
}
//set the days for the cookie to expire
function setDelay (daysdelay)
{
	SetCookie(exitcookie, 'noshowfor', daysdelay, '/', '', '' );
}

function showExitPop () { 

  if (GetCookie(exitcookie) == null)
  { 
	if (getScrollPos() > pageoffset)
	{
		setDelay (showdelay); //set the expire/reshow cookie
 	 	var ele = document.getElementById(elementid);  //get the popup elememnt
	 	ele.style.display = "block";  //show the popup element
	}
  }

}

function closeExit () {
  
	var ele = document.getElementById(elementid);  //get the popup elememnt
	ele.style.display = "none";  //hide the popup element

}



