//alternate window for 3.0 browsers
url="http://www.binaryrevelations.com/alphadog";
var state=1;
//Check Browser Vendor and Version
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

if (navigator.userAgent.indexOf("Mozilla/3.0") != -1) version = "n3";
else if (browserName == "Netscape" && browserVer >= 4) version = "n4";
else if (browserName == "Microsoft Internet Explorer" && browserVer >= 3)
		version = "n4";
else version = "n2";

var chatlayer;
function MakeLayer()
{
	if( version == "n4" )
	{
		if(document.layers)
		{
			lyr=new Layer(500);
			lyr.layerID='chatpopup';
			lyr.pageX=150;
			lyr.pageY=250;
			lyr.bgColor="black";
			lyr.document.write("Chat Layer");
			lyr.visibility="hide";
			lyr.document.close();
		}
		if(document.all)
		{
			lyr=document.all['chatpopup'];
		}
	}
	chatlayer=lyr;
}
window.onload=MakeLayer;
//Open a Separate browser window 
function openWindow(url)
{
	window.open(url, "myWindow", "width=600,height=400,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,location=no");
}
function checkstate()
{
 if(state==1)
 {
 extend("test");
 return;
 }
 if(state==0)
 { retract("test");
 return;
 }
}
//Turn on a layer
function extend(URL) 
{
state=0;
	if(version == "n4")
	{
		if(document.layers) 
		{
			if(chatlayer)
			{
				chatlayer.visibility="show";
				chatlayer.src="/chat.html";
			}
		}		
		else if(document.all)
		{
		
			if(chatlayer)
			{
				chatlayer.style.visibility="visible";
				chatlayer.src="/chat.html";	
				//chatlayer.focus();
				//document.all["chatpopup"].document.open();
				//document.all["chatpopup"].document.write("this is a test");
				//document.all["chatpopup"].document.close();
			} 
		}
	}
	else
	{
		openWindow(url);
	}
}

//Turn off a layer
function retract(layerid) 
{
state=1;
	if(document.layers) 
	{
		if(chatlayer != null)
		{
			chatlayer.visibility = "hide"; 
		}
			//document.layers[layerid].
			//document.close();
	}
	else if(document.all)
	{
		if(chatlayer != null) 
			chatlayer.style.visibility = "hidden"; 
	}
}

/////////////////////////////////////////////////////////////////////////
//     Cookie Code....
/////////////////////////////////////////////////////////////////////////

// Cookie Code
function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)
{
	var arg = name + "=";
	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 "not found";
}
function SetCookie (name, value)
{
	 var argv = SetCookie.arguments;
	 var argc = SetCookie.arguments.length;
	 var expires = (2 < argc) ? argv[2] : null;
	 var path = (3 < argc) ? argv[3] : null;
	 var domain = (4 < argc) ? argv[4] : null;
	 var secure = (5 < argc) ? argv[5] : false;
	 document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) +     ((domain == null) ? "" : ("; domain=" + domain)) +  ((secure == true) ? "; secure" : "");
}

var expdate = new Date();
var secure =false;

function setDate(b)
{
	if(b){ expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));}
	else { expdate=null }
}
function setSec(b)
{
	if(b){ secure=true}
	else { secure=false}
}
function showAllCookies()
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var offset=0;
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	document.writeln(unescape(document.cookie));
}

function readCookie() {
     if (document.cookie == "") {
	writeCookie();
        alertMessage();
     } else {
	var the_cookie = document.cookie;
	the_cookie = unescape(the_cookie);
	the_cookie_split = the_cookie.split(";");
	for (loop=0;loop<the_cookie_split.length;loop++) {
		var part_of_split = the_cookie_split[loop];
		var find_name = part_of_split.indexOf("nfti_date")
		if (find_name!=-1) {
			break;
		} // Close if
	} // Close for
	if (find_name==-1) {
		writeCookie();
	} else {
		var date_split = part_of_split.split("=");
		var last = date_split[1];
		last=fixTheDate(last);
		document.write("Welcome<BR>Your last visit was on:<BR> "+last);
		writeCookie();
	} // Close if (find_name==-1)
      }
} // Close function readCookie()


function writeCookie() {
     var today = new Date();
     var the_date = new Date("December 31, 2023");
     var the_cookie_date = the_date.toGMTString();
     var the_cookie = "nfti_date="+escape(today);
     var the_cookie = the_cookie + ";expires=" + the_cookie_date;
     document.cookie=the_cookie
}

function alertMessage(){
     document.write("Welcome<BR>This is your first visit here.");
}

function fixTheDate(date) {
     var split = date.split(" ");
     var fix_the_time = split[3].split(":")
     var hours = fix_the_time[0]
     if (hours>=12) {
	var ampm="PM"
     } else {
	var ampm="AM"
     }
     if (hours > 12) {
	hours = hours-12
     }
     var new_time = hours+":"+fix_the_time[1]+" "+ampm
     var new_date = split[0]+" "+split[1]+", "+split[2]+" at <BR>"+new_time+", "+split[5]
     return new_date;
}
