﻿// If this page is loaded inside a frame, load the page in the top window
var topHost = top.location.hostname.toLowerCase();
if (topHost.indexOf(".irmi.com") > -1) {
    if (top.location != self.location) 
        {top.location = self.location; }
}
// Get cookie value
function getCookie(name)
 {
    var cookie = "";
    var all_cookies = document.cookie;
    var label = name + "=";
    var offset = all_cookies.indexOf(label);
    if (offset != -1)
    {   var start = offset + label.length;
        var end = all_cookies.indexOf(";", start);
        if (end == -1)
        {end = all_cookies.length;}
        cookie = all_cookies.substring(start, end);
    }
    cookie = unescape(cookie);
    return cookie;
 }   
 function setPermanentCookie(name,value)
 {
    var theDate = new Date();
    var oneYearLater = new Date( theDate.getTime() + 31536000000);
    var expiryDate = oneYearLater.toGMTString();
    document.cookie = name + '=' + value + ';expires=' + expiryDate + ';path=/';
}
function setCookie(name, value) 
{ 
    document.cookie = name + '=' + value + ';path=/';
}
// Add page to Favorites
function AddToFavorites()
{window.external.AddFavorite(location.href, document.title);}
// Close window
function Close()
{window.close();}
// E-mail page
function Email()
{window.navigate("mailto:?subject=Information from IRMI&body=Here is something you might find interesting from IRMI: " + location.href);}
// Print page
function Print()
{window.print();}
// Open window
function Open(url, name, features)
{	if (url == null)
	{window.alert("Web Site Error: No 'url' parameter passed to 'Open' JavaScript function.");
		return;}
	if (name == null)
	{name = "Popup";}
    if (features == null)
	{features = "width=780,height=560,resizable=yes,scrollbars=yes,left=20,top=20";}
	window.open(url, name, features).focus();
}

// Create a cookie with javascript to differentiate between users and search engines
if (getCookie('SystemStatus') == '') { setPermanentCookie('SystemStatus', '0'); }

function ClickSearchButton(buttonName, e) {
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var key;

    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13) {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null) { //If we find the button click it
            btn.click();
            event.keyCode = 0
        }
    }
}