// removed rollovers
// removed language cookie redirect
function drawNav(x,y,z) {
}

function goback() {
    if ( history.length > 1 ) {
        history.back();
    } else {
        window.close();
    }
}

function exitpop() {
}

function getBaseDomain() {
    if ( !document.domain.match(/innocentive\.com/gi) ) {
        return null;
    } else {
        return "innocentive.com";
    }
}
function setEcode() {
    ecodes = getEcodes();
    if ( null==ecodes ) {
        return;
    }

    cookie = Cookie_get("ecodes");
    if ( null==cookie ) {
        cookie = new Cookie("ecodes","");
    }
    newValue = false;

    for (i=0; i < ecodes.length; i++) {
       if ( cookie.value.indexOf(ecodes[i])<0 ) {
          cookie.value += "," + ecodes[i];
          newValue = true;
       }
    }
    if ( newValue ) {
        if ( cookie.value[0]=="," ) {
            cookie.setValue(cookie.value.substring(1));
        }
        cookie.set();
    }
}

function getEcodes() {
    e = document.URL.match(/[\?&]e=[^\?&]*/gi);

    if ( null==e || 0==e.length ) {
        return null;
    }

    ecodes = new Array();
    if ( typeof e=="string" ) {
        ecodes[0] = e;
    } else {
        ecodes = e;
    }
    // strip ?e=
    for (i=0; i < ecodes.length; i++ ) {
        ecodes[i] = ecodes[i].substring(3);
    }
    return ecodes;
}

function Cookie(name, value, path) {
    this.name = name;
    this.value = value;
    this.path = null;
    this.domain = getBaseDomain();
    if ( arguments.length >=3 ) {
        this.path = path;
    }

    nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear() + 1);
    this.expires = nextyear.toGMTString();

    this.set = Cookie_set = function () {
        document.cookie = this.name+"="+this.value +
            ";path=" +
            ((this.path==null||this.path=="") ? "/" : this.path) +
            (null==this.domain ? "" : ";domain="+this.domain ) +
            ";expires=" + this.expires;
    };
    this.setValue = function (v) {
        this.value = v;
    };
    this.setPath = function (path) {
        this.path = path;
    };
    this.setDomain = function (domain) {
        this.domain = domain;
    }
    this.toString = function () {
        return this.name + "=" + this.value + 
               (this.path==null?"":"; path="+this.path) +
               (null==this.domain?"":"; domain="+this.domain);
    }
}

function Cookie_get(name) {
    cArray = document.cookie.split(";"); 
    for ( i=0; i < cArray.length; i++ ) {
        if ( cArray[i].indexOf(name)>=0 ) {
            me = cArray[i].split("=");
            return new Cookie(me[0], me[1]);
            break;
        }
    }
    return null;
}

function Set() {
    this.myString = ",";
    this.add = Set_add;
    this.toString = Set_toString;
    this.contains = Set_contains;
    this.toArray = Set_toArray;
    this.remove = function(item) {
        a = this.myString.split(","+item+",");
        if ( a.length>1 ) {
            this.myString = a[0]+","+a[1];
        }
    }
    this.isEmpty = function() {
        return this.myString==",";
    }
}
function Set_toString() {
    r = "[";
    a = this.myString.split(",");
    for (i=0; i < a.length; i++) {
        if ( a[i]!="" ) {
            r += (r.length>1?",":"") + a[i];
        }
    }
    return r+"]";
}
function Set_add(newItem) {
    if ( !this.contains(newItem)) {
        this.myString += newItem +",";
    }
}
function Set_contains(s) {
    return this.myString.indexOf(","+s+",")>=0;
}
function Set_toArray() {
    a = this.myString.split(",");
    return a.slice(1,a.length-1); 
}
function Map() {
    this.myArray = new Array();
    this.put = function(key,value) {
        if ( this.myArray[key]==null ) {
            this.myArray.length++;
        }
        this.myArray[key]=value;
    }
    this.get = function(key) {
        return this.myArray[key];
    }
    this.size = function() {
        return this.myArray.length;
    }
    this.toString = function() {
        return this.myArray.toString();
    }
}

/****************************************************
* Seeker Hierarcy stuff
****************************************************/
STATE_CLOSED = "closed";
STATE_OPEN = "open";
STYLE_CLOSED = "none";
STYLE_OPEN = "";
var headerMap = new Map();

function Row(rowid) {
    if ( typeof rowid=="string" ) {
        this.rowNode = document.getElementById(rowid);
    } else {
        this.rowNode = rowid;
    }
    if ( this.rowNode!=null ) {
        this.state = this.rowNode.getAttribute("state");
        this.style = this.rowNode.getAttribute("style");
        this.headerRow = this.rowNode.getAttribute("headerRow");
        this.parents = this.rowNode.getAttribute("parents");
        this.id = this.rowNode.getAttribute("id");
    }
    this.setState = Row_setState;
    this.setStyle = Row_setStyle;
    this.open = Row_open;
    this.close = Row_close;
    this.closeHeader = Row_closeHeader;
    this.openHeader = Row_openHeader;
    this.hasHeaderRow = function() {
        return !(this.headerRow==null || this.headerRow=="");
    }
    this.setVisibility = function(hide,id) {
        if ( hide ) {
            this.close(id);
        } else {
            this.open(id);
        }
    }
    this.next = function() {
        try {
            return new Row(this.rowNode.nextSibling);
        } catch (e) {
            return null;
        }
    }
    
    this.hasParent = Row_hasParent; 
    if ( this.parents==null ) {
        this.parent = "";
    } else {
        a = this.parents.split(",");
        this.parent = a[a.length-1];
    }
    
    this.toString = function() {
        return "id=" + this.id + 
                "; parent=" + this.parent +
                "; parents=" + this.parents + 
               "; state=" + this.state + 
               "; headerRow=" + this.headerRow;
    }
}
function Row_hasParent(p, all) {
    if (this.parents==null) {
        return false;
    }
    if ( all ) {
        return this.parents.indexOf(p)>=0;
    } 
    return this.parent==p;
}
function Row_close(closer) {
    // anyone can close row
    this.setStyle(STYLE_CLOSED);
    // only immediate parent can change state to closed
    if ( this.hasParent(closer) ) {
        this.setState(STATE_CLOSED);
    }
    this.closeHeader();
}
function Row_open(opener) {
    if ( this.hasParent(opener) ) { 
        // only immediate parent can change the state 
        this.setState(STATE_OPEN);
    }
    if ( this.state==STATE_OPEN ) {
        // anyone can open a row if it's state is open 
        this.setStyle(STYLE_OPEN);
        this.openHeader()
    }
}
function Row_closeHeader() {
    if ( this.hasHeaderRow() ) { 
        set = headerMap.get(this.headerRow);
        if ( set!=null ) { 
            set.remove(this.parent);
            if ( set.isEmpty() ) { 
                hRow = new Row(this.headerRow);
                if (hRow.rowNode!=null ) {
                    hRow.setState(STATE_CLOSED);
                    hRow.setStyle(STYLE_CLOSED);
                }
            }
        }
    }
}
function Row_openHeader() {
    if ( this.hasHeaderRow() ) {
        hRow = new Row(this.headerRow);
        if (hRow.rowNode!=null ) {
            hRow.setState(STATE_OPEN);
            hRow.setStyle(STYLE_OPEN);
            set = headerMap.get(this.headerRow);
            if ( set==null ) {
                set = new Set();
            }
            set.add(this.parent);
            headerMap.put(this.headerRow, set);
        }
    }
}
function Row_setState(myState) {
    this.state = myState;
    if ( this.rowNode!=null ) {
        this.rowNode.setAttribute("state", myState);
    }
}
function Row_setStyle(myStyle) {
    this.style = myStyle;
    if ( this.rowNode!=null ) {
        this.rowNode.style.display = myStyle;
    }
}

function toggleRow(arrowImg, userId) {
    arrowImg.blur();
    hide = arrowImg.src.toLowerCase().indexOf("right")<0;
    setArrowImg(arrowImg, hide);
    row = new Row(userId).next();
    while ( row!=null && row.hasParent(userId,true) ) {
        if ( hide ) {
            row.close(userId);
            row = row.next(); 
        } else { 
            row.open(userId);
            if ( row.state==STATE_CLOSED ) {
                // skip all it's children
                tParent = row.parent;
                while ( row!=null && row.hasParent(tParent,true) ) {
                    row = row.next();
                }
            } else {
                row = row.next(); 
            }
        } 
    }
}

function closeAll(id) {
    setAll(id,true);
}
function openAll(id) {
    setAll(id,false);
}
function setAll(id,hide) {
    parentSet = new Set();
    row = new Row(id);
    while ( row!=null ) {
        try {
            if ( !parentSet.contains(row.parent) ) {
                setArrowImg(row.parent, hide);
            }
            parentSet.add(row.parent);

            if ( hide && row.parent!="" ) {
                row.setStyle(STYLE_CLOSED);
                row.setState(STATE_CLOSED);
                row.closeHeader();
            } else {
                row.setStyle(STYLE_OPEN);
                row.setState(STATE_OPEN);
                row.openHeader();
            }
         } catch (e) {
            break;
         }
         row = row.next();
    }
}

function toggleDetails (username,rowStart,rowEnd) {
    arrowImg = document.getElementById("img"+username);
    hide = arrowImg.src.toLowerCase().indexOf("right")<0;

    // toggle arrow 
    setArrowImg(arrowImg, hide);

    // toggle rows
    if ( rowStart>=0 ) {
        for (i=rowStart+1; i<=rowEnd; i++ ) {
            row = new Row("row"+i, username);
            if ( hide ) {
                row.close() // close
            } else {
                row.open() // open
            }
        }
    } else {
        // Close project rows
        p = username;
        check = false;
        myCount = 1;
        while ( true ) {
            try {
                row = new Row("row"+myCount, username);
                if ( row.parent==username ) {
                    if ( hide ) {
                        row.close();
                    } else {
                        row.open();
                    }
                    check = true;
                } else if ( check ) { 
                    break;
                }
                myCount++;
            } catch (e) {
                break;
            }
        }
    }
}

function setArrowImg(arrowImg, hide) {
    try {
        if ( typeof arrowImg=="string") {
            myArrow = document.getElementById("img"+arrowImg);
        } else {
            myArrow = arrowImg; 
        }
        if ( hide ) {
            myArrow.src = myArrow.src.replace("_down","_right");
        } else {
            myArrow.src = myArrow.src.replace("_right","_down");
        }
    } catch (e) {}
}

/*************************************************************/
/* reassign Seeker
/*************************************************************/
var reassignSelected = null;
var reassignIP = false;
var IMAGE_ORGCHART_SINGLE = '/images/orgchartsingle.gif';
var IMAGE_ORGCHART_SINGLE_H = '/images/orgchartsingle_h.gif';
var IMAGE_ORGCHART= "/images/orgchart.gif";
var IMAGE_ORGCHART_H = "/images/orgchart_h.gif";
function reassign(me) {
    accountId = me.getAttribute("id");
    if ( reassignSelected==null ) {
        reassignSelected = accountId;
        me.src = IMAGE_ORGCHART_SINGLE; 
    } else if (reassignSelected==accountId) {
        // unselect me
        me.src = IMAGE_ORGCHART; 
        reassignSelected = null;
    } else {
        reassignIP = true;
        me.src = IMAGE_ORGCHART_H; 
        document.reassignForm.id.value = reassignSelected;
        document.reassignForm.mid.value = accountId;
        document.reassignForm.submit();
    }
    me.blur();
}

function toggleImage(me, highlight) {
    if ( me.src.indexOf("single")<0 && 
         !(reassignIP || reassignSelected==null) ) { 
        if ( highlight ) {
            me.src = IMAGE_ORGCHART_H; 
        } else {
            me.src = IMAGE_ORGCHART; 
        }
    }
}
function toggleImageOnOff(image) {
    isOn = image.src.indexOf("-on")>0;
    base = image.src.replace("-on.gif","");
    base = base.replace("-off.gif","");
    image.src = base+(isOn?"-off.gif":"-on.gif");
    return !isOn;
}

function toggleFilter() {
    // toogle image
    var filterImage = document.getElementById("filterImage");
    isOn = toggleImageOnOff(filterImage);

    // set cookie
    cookieName = "filter";
    filterCookie = Cookie_get(cookieName);
    if (filterCookie==null) {
        filterCookie = new Cookie(cookieName,"off","/");
    }
    filterCookie = new Cookie(cookieName, (isOn?"on":"off"), "/"); 
    filterCookie.set();

    // refresh page
    document.location.reload();
}

function homepageSetup() {
    try {
        loadUsername();
    } catch (e) {}
    try {
        document.loginForm.userName.focus();
    } catch (e) {}
}
function loadUsername() {
    username = null;
    uCookie = Cookie_get("ruser");

    if ( uCookie!=null ) {
        username = uCookie.value;
    } 

    if ( !(null==username || "no"==username) ) {
            var colonIndex =username.indexOf(":")
            if (colonIndex != -1) { username = username.substring(0,colonIndex); }
            document.loginForm.userName.value = username;    
    } 
    if ( "no"==username ) {
        document.loginForm.remember.checked = false;
    }
}

function Issue(line) {
    bits = line.split(":");
    this.status = bits[0];
    this.id = bits[1];
    if ( bits.length > 3 ) {
        this.ticket = bits[3];
    }

    // set next status
    this.nextStatus = bits[2];
    try {
        if ( document .getElementById("emailImg"+this.id).src.indexOf(IMAGE_XED)>=0 ) {
            this.nextStatus = STATUS_DECLINED;
        } else if ( "n/a"==document.getElementById("emailSent"+this.id).firstChild.nodeValue ) {
            this.nextStatus = "n/a";
        }
    } catch (e) { }

    this.toString = function() {
        return line;
    }
}

//*********************************************************************************
// jspell code
//*********************************************************************************
var spellCheckURL="/jspellhtml-servlet/JSpell.jsp"; // change to point to the JSpell Spell Check Servlet
var styleSheetURL="/jspellhtml/jspell.css";
var imagePath="/jspellhtml/images"; // relative URL to JSpell button images directory

//var blankURL="about:blank"; // used for preview panels, if you are using SSL you'll need an
var blankURL="/jspellhtml/blank.html"; // actual HTML file to be the 'blank' panel, in which case uncomment this line

var ww;	// holds reference to popup
var disableLearn=false; // set to true, to remove the Learn words capability
var forceUpperCase=false; // force suggestions and spell checker to use upper case
var ignoreIrregularCaps=false;	// ignore lower case sentence beginnings, etc.
var ignoreFirstCaps=false;	// ignore if first character in a field is lowercase
var ignoreNumbers=false; // ignore words with embedded numbers
var ignoreUpper=false; // ignore words in upper case
var ignoreDouble=false; // ignore repeated words
var confirmAfterLearn=false; // show warning before user 'learns' a word
var confirmAfterReplace=true; // show warning when replacing using a word not in the suggestions list.
var supplementalDictionary=""; // optional supplemental word list kept at server.
var hidePreviewPanel=false; // You can use this to hide the preview panel when running in directEdit mode in IE
var directmode=false; // is highlighting done in original text control or is there a preview panel (IE Windows only)

function getSpellCheckItem(jspell_n) {
	var fieldsToCheck=getSpellCheckArray();
	return fieldsToCheck[jspell_n];
}
function runspellcheck() {
	var width=450; var height=200;
	if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.toLowerCase().indexOf("opera")==-1 && hidePreviewPanel==false) {
		directmode=true; width=220;
	}

	if(hidePreviewPanel==true)
		width=220;

	var w = 1024, h = 768;
	if (document.all || document.layers)
	{
		w=eval("scre"+"en.availWidth"); h=eval("scre"+"en.availHeight");
	}

	var leftPos = (w/2-width/2), topPos = (h/2-height/2);

	// need to check if window is already open.
	ww=window.open("/jspellhtml/jspellpopup.html", "checker", "width="+width+",height="+height+",top="+topPos+",left="+leftPos+",toolbar=no,status=no,menubar=no,directories=no,resizable=yes");
	ww.focus();
}
function updateForm(jspell_m,newvalue) { eval(getSpellCheckItemValue(jspell_m)+"=newvalue"); }
function getSpellCheckItemValue(jspell_j) { return getSpellCheckItem(jspell_j)+".value"; }
function getSpellCheckItemValueValue(jspell_k) { return eval(getSpellCheckItemValue(jspell_k)); }
