
function Navigate(szURL, bForceRefresh, bContainsParams)
{
    var szChar;
    var m_date;

    if (bForceRefresh)
    {
      if (bContainsParams)
      {
        szChar = "&";
      }
      else
      {
        szChar = "?";
      }

      m_date = new Date();
      szURL = szURL + szChar + "time=" + m_date.getTime();
    }

    //window.navigate(szURL);
    window.location.href = szURL;
}


function PopupWindow(szURL, nWidth, nHeight, nScroll, bForceRefresh, bContainsParams)
{
    var szWindowOptions;
    var szChar;
    var m_date;

    szWindowOptions = "left=100,top=100,width=" + nWidth + ",height=" + nHeight +
                      ",scrollbars=" + nScroll + ",status=0,resizable=1";

    if (bForceRefresh)
    {
      if (bContainsParams)
      {
        szChar = "&";
      }
      else
      {
        szChar = "?";
      }

      m_date = new Date();
      szURL = szURL + szChar + "time=" + m_date.getTime();
    }

    window.open(szURL, "", szWindowOptions);
}

function SetCookie(szName, szValue) 
{  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	
	document.cookie = szName + "=" + escape (szValue) + 
					((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
					((path == null) ? "" : ("; path=" + path)) +  
					((domain == null) ? "" : ("; domain=" + domain)) +    
					((secure == true) ? "; secure" : "");
}

function GetCookie(szName) 
{  
	var arg = szName + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  

	while (i < clen) 
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		{
			return getCookieVal(j);
		}

		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0)
		{	
			break;   
		}
	}	  

	return null;
}


function getCookieVal(nOffset) 
{  
	var endstr = document.cookie.indexOf (";", nOffset);  

	if (endstr == -1)    
	{
		endstr = document.cookie.length;
	}

	return unescape(document.cookie.substring(nOffset, endstr));
}


function NavToMain(nSection)
{
	var szPrefix = "";
	var szRoot = "";
	var	szURL = "";
	
	//use only for local testing
	//szPrefix = "/dentassist";
	
	//admin
  	if (0 == nSection)
  	{
		szRoot = "/admin/";
   		szURL = "adminmain.jsp";
  	}
	//user
  	else
  	{
  		szRoot = "/user/";
		
		//ce-online
		if (1 == nSection)
		{
   			szURL = "usermain.jsp";
		}
		//seeking employment
		else
		if (2 == nSection)
		{
			szRoot = "/employment/";
   			szURL = "seekers.jsp"
		}
		//program instructor
		else
		if (3 == nSection)
		{
   			szURL = "program_instructor.jsp";
		}
		else
		if (4 == nSection)
		{
   			szURL = "program_student.jsp";
		}
  	}
	
	szURL = szPrefix + szRoot + szURL;
	
	Navigate(szURL, true, false);
}



function Logout(nSection)
{
	var szURL = "";
	var szPrefix = "";
	
	//use only for local testing
	//szPrefix = "/dentassist";
	
	szURL = "/";

	if ( (0 == nSection) ||
		 (1 == nSection) )
	{
		szURL += "ce-online.jsp";
	}
	else
	if (2 == nSection)
	{
		szURL += "seeking_employment.jsp";
	}
	else
	{
		szURL += "pathway.jsp";
	}
	
	szURL = szPrefix + szURL + "?txtLogout=1";	
	
	Navigate(szURL, true, true);	
}


