
var wOpened = null;

function openWindow(url, width, height) {
    if (wOpened != null) {
                wOpened.close();
        }		
        var yPos = (window.screen.height - height)/2;
        var xPos = (window.screen.width - width)/2;
        wOpened	= window.open(url, null, 'width=' + width + ',height=' + height + ',left=' + xPos + ',top=' + yPos + ',screenX=' + xPos + ',screenY=' + yPos + ',status=no,menubar=no,scrollbars=yes');
}	


/**
    Global variables in head.jsp
    For hiliting images 
    @param imgId - the image id (name)
    @param hilite - boolean value; if true hilite, else unhilite
*/
function hilite(imgId, navType, hilite, navTopString) {
    //no change if already hilited through being the active category
    if (imgId == rubric) {
        return;
    }

    if (navTopString == undefined) {
	navTopString = "_navtop_";
    }

    var imgObj = document.images[imgId];
    imgObj.src = ctxtPath + "/docroot/templates/imgs/design/" + navType + navTopString + imgObj.name + (hilite ? "_active" : "") + ".gif";
}

var clickedFields = new Array();

function clearField(fieldObj) {
    for (var x = 0; x < clickedFields.length; x++) {
        if (clickedFields[x] == fieldObj) {
            //field already clicked once, meaning init-text appeared -> do nothing (user alter's her input)
            return;
        }
    }

    //id was not found in array; clear the field (init-text) and add it to the clickedFields-list
    fieldObj.value = "";
    clickedFields.push(fieldObj);
}



/*
    --------------
    Cookies (taken from http://www.w3schools.com/js/js_cookies.asp)
    --------------
*/

function setCookie(c_name,value,expire /*time in millis until expiration*/){
    var exdate=new Date();
    exdate.setTime(exdate.getTime() + expire);
    document.cookie=c_name+ "=" +escape(value)+((expire==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
if (document.cookie.length>0) {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


