
var cookieEnabled = false; //only used for NS4
var  hostName = window.location.hostname
var URL = 'http://' + hostName + '/pcomreg/includes/CookieHelp.htm'  //hyperlink for more information of cookie
if ((typeof inquiry)=='undefined')
	checkCookieinJavascript();

//***************************************************************
// NS4 doesn't support property .cookieEnabled
// solution: NS4: create a cookie then check if it's created 
//***************************************************************
// supporting functions

function checkCookieinJavascript()
{
	if (!isNS4() && !window.navigator.cookieEnabled)
	{	
		writeCookieMessage();
		return false;
	}
	else
	{
		if (isNS4())
		{	
			doCookie();
			getCookie();
			if (!cookieEnabled)
			{
				writeCookieMessage();
				return false;
			}
		}
	}
	return true;
}


function writeCookieMessage()
{
	
	var text = '<table width="400" border="0" cellpadding="0" cellspacing="1" bgcolor="#FF0000">'
	text += '<tr><td><table width="100%"  border="0" cellpadding="2" cellspacing="2" bgcolor="#ADC6F9">'
	text += '<tr><td><strong>Your cookies are disabled. Please enable your cookies so you can use our online services. After enabling cookies, refresh your page to continue. '
	text += '<a href="Javascript:OpenHelpCookie(URL);">More Information</a></strong></td>'
	text += '</tr></table></td></tr></table>'
	text += '<table width="400" border="0" cellpadding="0" cellspacing="0" >'
	text += '<tr><td>&nbsp;</td></tr></table>'
	
	document.writeln(text);
}

//***************************************************************

//write hyperlink back for user go back to where they come from
// used by inquiry_sourcerer & inquiryProcess

function writeBack()
{
	var text = '<table width="400" border="0" cellpadding="0" cellspacing="0" >'
	text += '<tr><td><img src="images/shim.gif" height="20" width="20"></td></tr>'
	text += '<tr><td align="right"><a href="javascript:void 0;" onClick="window.history.back();return false;">Back</a></td></tr>'
	text += '</table>'
	document.writeln(text);
}


//***************************************************************
//check browser is NS4 or not
function isNS4()
{
	var user_agent = navigator.userAgent;
	var ns4;
	if (user_agent.indexOf('compatible;') == -1 && user_agent.indexOf('Mozilla/4.') != -1)   //  netscape 4.79 version
	{	
		//alert(user_agent);
		 ns4 = true
	}
	else
		ns4 = false;
		
	return ns4;
}

//***************************************************************
// create a javascript cookie -- for NS4 cookie detection
function doCookie() 
{ 
	cookieName = "Cookie_Test"; 
	num_days = 1;
    var today = new Date();
    var expr = new Date(today.getTime() + num_days*24*60*60*1000);
    expr =  expr.toGMTString();

	document.cookie = cookieName + "=1;expires=" + expr; 
} 


//***************************************************************
//check if cookie is created successfully  - for NS4 cookie detection
function getCookie() 
{ 
	if(document.cookie)  
		cookieEnabled = true;

} 

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//open pop-up window to help user turn on cookies

function OpenHelpCookie(URL)
{
	
day = new Date();
id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=350');");
}





		
