// JavaScript Document

function getCookie( name ) {
	 		//alert ("into get_cookie");
			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 setCookie( name, value, expires, path, domain, secure ) 
			{
			// set time, it's in milliseconds
			var today = new Date();
			today.setTime( today.getTime() );
			/*
			if the expires variable is set, make the correct 
			expires time, the current script below will set 
			it for x number of days, to make it for hours, 
			delete * 24, for minutes, delete * 60 * 24
			*/
			
			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 checkAdmissionsPopCookie () {
	  	var activeSession = false;
		var noShow = false;
		 //check to see if cookie exists
		 checkSessionCookie = getCookie("rmuAdmissionSession");
		 checkNoShowCookie = getCookie("rmuAdmissionsNoShow")
		 
		 //if no cookie, set create one and set var to pop window
		 if (checkSessionCookie == null){
		 	setCookie("rmuAdmissionSession", "session");
			} else {
			 activeSession = true;
			}
		 if (checkNoShowCookie != null){
		 	noShow = true
			}
		 //alert("noShow = " + noShow);
		 //alert("activeSession = " + activeSession);
		 if (activeSession == true || noShow == true){
			return false;
			} else { 
			return true; 
			}
		 
	  	}
	
	
	   function openWindow(mypage, myname, w, h, toolbar, resizable, scrollbars) {
	   		
			firePopup = checkAdmissionsPopCookie();
			if (firePopup){
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
			winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+', toolbar='+toolbar+', resizable='+resizable+', scrollbars='+scrollbars+','
			win = window.open(mypage, myname, winprops)
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
			}
		}