//--------------------------------
// Do nothing (void function placeholder)
//--------------------------------
function doNothing() {
}

//--------------------------------
// Display status bar message.
//--------------------------------
function showStatus(msg) {
	window.status = msg
	return true
}

//--------------------------------
// Browser checker
//--------------------------------
var browserOK = false

function checkBrowser() {
  var verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr)

  if (app.indexOf('Netscape') != -1) {
    //  Netscape does not implement full CCS1 behaviors.
    //  if (version >= 4.0) browserOK = true
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= 4.0 || verStr.indexOf(4.0) != -1)
     browserOK = true
  }
}

//--------------------------------
// Chat Window creator.
// syntax: launchChat(room)
//
//     where room = <name of chatroom>
//--------------------------------

var newChatWindow

function launchChat(room) {

var chatURL,windowFeatures

if (room == null) {
    chatURL = "/avilar/carelearning/chat/index.html"
} else {
    chatURL = "/avilar/carelearning/chat/" + room + ".html"
}

windowFeatures = "width=500,height=342"
    
if (!newChatWindow || newChatWindow.closed) {

    newChatWindow = window.open(chatURL,"Chat",windowFeatures) 

    // Create .opener property if necessary for old browsers.
    if (!newChatWindow.opener) {
    	newChatWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newChatWindow.focus()
    }
}

//--------------------------------
// SiteMap Window creator.
// syntax: launchSiteMap()
//--------------------------------

var newSiteMapWindow

function launchSiteMap(loc) {

if (loc == null) {
	mapURL = "/treemenu/index.html"
} else {
	mapURL = "/locale/" + loc + "/treemenu/index.html"
}

if (!newSiteMapWindow || newSiteMapWindow.closed) {
    // create the sitemap window
    // newSiteMapWindow = window.open("/sitemap/index.php?p=0|","SiteMap","status,menubar,scrollbars,resizable,width=325,height=300")
	newSiteMapWindow = window.open(mapURL,"SiteMap","status,menubar,scrollbars,resizable,width=275,height=300")

    // Create .opener property if necessary for old browsers.
    if (!newSiteMapWindow.opener) {
        newSiteMapWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newSiteMapWindow.focus()
    }
}

//--------------------------------
// LifeCycle Window creator.
// syntax: launchLifeCycle()
//--------------------------------

var newLifeCycleWindow

function launchLifeCycle() {

if (!newLifeCycleWindow || newLifeCycleWindow.closed) {
    // create the LifeCycle window
    newLifeCycleWindow = window.open("/flash/sniffer.asp","LifeCycle","width=680,height=584")

    // Create .opener property if necessary for old browsers.
    if (!newLifeCycleWindow.opener) {
        newLifeCycleWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newLifeCycleWindow.focus()
    }
}

//--------------------------------
// Popup window creator.
// syntax: launchPopup(file)
//
//     where path = <path or URL to load into the window>
//--------------------------------

var newPopupWindow

function launchPopup(path) {

var popupURL = path;
var windowFeatures = "scrollbars,toolbar,menubar,resizable,width=800,height=600"
    
if (!newPopupWindow || newPopupWindow.closed) {

    newPopupWindow = window.open(popupURL,"Popup",windowFeatures) 

    // Create .opener property if necessary for old browsers.
    if (!newPopupWindow.opener) {
    	newPopupWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newPopupWindow.focus()
    }
}

//--------------------------------
// Sendform launcher (to email form data)
// syntax: invoke_sendform(filename)
//--------------------------------

function invoke_sendform(filename){
    var working_url = window.location.href
    window.location = "/cgi-bin/sendform.cgi?init="+filename+"&working_url="+escape(working_url);
}

//--------------------------------
// Maintenance Alert
// syntax: display_alert()
//--------------------------------

function display_alert(){
    var message = "NOTICE: The web server that operates this site will undergo scheduled maintenance\non Tuesday, March 19, 2002 from 6:00-7:00 am EST. You may experience some brief\ninterruptions in service during this period. We apologize for any inconvenience that\nthis may cause."
    alert (message)
}

//----------------------------
// Email address masking
//----------------------------

// Set global variables. 
 
var special= "#$%^&*()-+=!@|.:";
var atsign = special.charAt(12);
var dot = special.charAt(14);
var colon = special.charAt(15);
var zzz = "c" + "o" + "m";
var emailProtocol = "mai" + "lto" + colon;
var Domain = atsign + "avilar" + dot + zzz;

function eMail (masked,visible) {
    this.masked = masked
    this.visible = visible
}

// Associate each masked email address with its visible link text.
// Edit only the items in quotes. 

var emailAddrs = new Array ()
    emailAddrs[0] = new eMail(emailProtocol + "webmaster" + Domain,"Webmaster")
    emailAddrs[1] = new eMail(emailProtocol + "webmentor" + Domain,"Webmentor")
    emailAddrs[2] = new eMail(emailProtocol + "sales" + Domain,"Sales")
    emailAddrs[3] = new eMail(emailProtocol + "support" + Domain,"Tech Support")
    emailAddrs[4] = new eMail(emailProtocol + "hr" + Domain,"Human Resources")
    emailAddrs[5] = new eMail(emailProtocol + "security" + Domain,"Security")
	emailAddrs[6] = new eMail(emailProtocol + "webmaster" + Domain,"Webmaster")
    emailAddrs[7] = new eMail(emailProtocol + "webmentor" + Domain,"Webmentor")
    emailAddrs[8] = new eMail(emailProtocol + "ventas" + Domain,"Ventas")
    emailAddrs[9] = new eMail(emailProtocol + "support" + Domain,"Soporte Técnico")
    emailAddrs[10] = new eMail(emailProtocol + "hr" + Domain,"Recursos Humanos")
    emailAddrs[11] = new eMail(emailProtocol + "security" + Domain,"Seguridad")
    emailAddrs[12] = new eMail(emailProtocol + "sales" + Domain,"Email Us")
//    emailAddrs[0] = new eMail(emailProtocol + "w3bm4st3r" + Domain,"Webmaster")
//    emailAddrs[1] = new eMail(emailProtocol + "w3bm3nt0r" + Domain,"Webmentor")
//    emailAddrs[2] = new eMail(emailProtocol + "s4l3s" + Domain,"Sales")
//    emailAddrs[3] = new eMail(emailProtocol + "s2pp0rt" + Domain,"Tech Support")
//    emailAddrs[4] = new eMail(emailProtocol + "8chare" + Domain,"Human Resources")
//    emailAddrs[5] = new eMail(emailProtocol + "s3c2r1ty" + Domain,"Security")

function writeMaskedAddr (addrID,subject,style) {
// Write an email link onto the page. 
// Arguments: addrID  = array index of one of the address in the emailAddrs array defined above. 
//                     This identifies which address you want to send the email to.
//                     Example: writeMaskedAddr(0) sends email to the "webmaster" address.
//            subject = Optional quoted string variable for email Subject line. If omitted, no Subject
//                     is supplied for the email message. Users, of course, may add a subject manually.
//                     Example: writeMaskedAddr(2,'Sales inquiry from the web site')
//            style   = Optional CSS style for the link

		// Add text to message body for mail sent to the Sales address.
		var body = "Please%20tell%20us%20how%20you%20heard%20about%20Avilar%3A%20%0A%0AYour%20Name%3A%20%0A%0AYour%20Telephone%20Number%3A%20%0A%0AYour%20question%3A%20%0A%0A%0A%0A----------------------%0AThank%20you%20for%20your%20inquiry.%0A%0AThe%20Avilar%20Sales%20Team%0A(888)%20759-7053%0A(410)%20290-0008%20ext.%20705";

//	document.write("<a href=\"javascript:doNothing()\;\"");
	document.write("<a href=\"javascript:pageTracker._trackPageview('/outgoing/email')\;\"");
	if (style != '') {
		document.write(" class='" + style + "' ");
	}
	document.write(" onMouseOver=\"return showStatus('Send email.')\" onMouseOut=\"return showStatus('')\"");
	document.write(" onClick=\"parent.location='");
	document.write(emailAddrs[addrID].masked);
	if (subject == '') {
		document.write("'\">");
	} else {
		document.write("?subject=" + subject);
	}
	if (addrID == '2') {
		document.write("&body=" + body + "'\">");
	} else {
		document.write("'\">");
	}
	document.write(emailAddrs[addrID].visible);
	document.write("</a>");
}

function fillTo(f,addrID){
// Supply the TO field to sendform.cgi. 
// Arguments: f       = name of the FORM object invoking sendform.cgi. Typically 'document.name'. 
//            addrID  = array index of one of the address in the emailAddrs array defined above. 
//                     This identifies which address you want to send the email to.
//                     Example: fillTo(xyz,1) sends email to the 'Sales Inquiries' address.
//
// Note: We're stripping off the first 7 chars to remove 'mailto:' from the front of the string.
    f.TO.value = emailAddrs[addrID].masked.substring(7);
    return true;
}


//--------------------------------
// setLang (cookie creator)
// syntax: setState(ckName,ckValue)
// requires: cookie.js
//--------------------------------

function setLang(ckName,ckValue) {

    // Set the cookie expiration date.
    var expdate = new Date ();
    FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
    expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)); // Set cookie to expire 1 year from now 
    
    // Set the cookie.
    SetCookie (ckName,ckValue,expdate);
//    alert("Thank you. Language set to: " + ckValue);
	switch (ckValue) {
		case "en_us" : url = "/index.html"; break;
		case "es_es" : url = "/locale/es_es/index.htm"; break;
	}
	location.href=url
}

//-------------------------------
// Global vars for copyright year.
//-------------------------------

var today = new Date()
  var year = today.getYear()
  if(year < 1000){
    year += 1900
  }
