if (top.location != self.location){
	top.location = self.location;
}
var frm;
var isNav;
var links = new Array();
links["news_1"]="news/news_1.htm";
links["password"]="password.aspx";
links["aboutus"]="aboutus.aspx";
links["contact"]="contact.aspx";
links["browser"]="Info/browser.htm";
links["powered"]="powered.htm";
links["event"]="Events/ymca.htm";

function openWindow(url) {
	var f;
	var width;
	var height;
	var winName="catWin";
	if (arguments.length==1){
		width=600;
		height=450;
	}
	else{
		width=arguments[1];
		height=arguments[2];
	}
	var scroll=arguments[3];
	if (scroll==null)
		scroll="no";
	else 
		scroll="yes";
	f = "left=" + (window.screen.availWidth/2 - width/2)  + ",";
	f = f + "top=" + (window.screen.availHeight/2 - height/2) + ",";
	f = f + "height=" + height + ",";
	f = f + "width=" + width + ",";
	f = f + "status=no,toolbar=no,menubar=no,location=no,scrollbars=" + scroll + ",resizable=no";
  window.open(links[url] + "?lang=" + frm.hdnLanguage.value,winName,f);
}

function goHome(lang){
	window.location.href='http://' + ((lang == 0) ? 'www.Flextrack.ca' : 'www.Flextrack.ca');
}
function DoOnLoad()
{
	if (parseInt(navigator.appVersion) >=4) {
		if (navigator.appName=="Netscape"){
			isNav=true
		}
	}
	frm=document.Logon;
	frm.txtUserID.focus();
	if (isNav){
		document.captureEvents(Event.KEYPRESS);
	}
	document.onkeypress=checkKeyPress;
	var popupCalled = GetCookie("popup");
	if (popupCalled == null){
		SetCookie("popup", "yes")
             // openWindow("event",698,500)
	}
	/*
	*/
}
function checkKeyPress(evt){
	var key;
	if (isNav)
		key=evt.which;
	else{
		key=event.keyCode;
	}
	if (key==13)
		SubmitLogin();
}

function SubmitLogin()
{
	if(frm.txtUserID.value == "" || frm.pwdPassword.value == ""){
		alert("Please enter a valid user name and password.")
		return false
	}
	else
	{
		frm.submit();
	}
}

function changeLanguage()
{
	frm.hdnSubmit.value = "0"
	/*
	if(frm.hdnLanguage.value=="0")
	{
	    frm.hdnLanguage.value="1";
	}
	else
	{
	    frm.hdnLanguage.value="0";
	}
	*/
	frm.submit()
}

//Cookie functions 
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 null;
}

//
//  Function to create or update a cookie.
//    name - String object object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie(name, value) {
  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 = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to current date/time)
//    name - String object containing the cookie name
//
function DeleteCookie(name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);  // This cookie is history
  var cval = GetCookie(name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}