﻿
// Utility function that handles the manipulation of class names in the UI
// generally responding to user events (e.g. mouseovers/mouseouts/etc.). Supports:
//  1. swap - swaps one class for another
//  2. add - adds a class (if it's not already there)
//  3. remove - removes a class (if it is there)
//  4. check - checks if a class exists on the element
//  5. swapAdd - if c1 exists, swap c2 in its place, else
//               add c2.
// Source: http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
//
function jscss(a,o,c1,c2)
{
    switch (a)
    {
        case 'swapAdd':
            if(jscss('check', o, c1))
                jscss('swap', o, c1, c2);
            else
                jscss('add', o, c2);
        case 'swap':
            o.className=!jscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
            break;
        case 'add':
            if(!jscss('check',o,c1))
            {
                o.className+=o.className?' '+c1:c1;
            }
            break;
        case 'remove':
            var rep=o.className.match(' '+c1)?' '+c1:c1;
            o.className=o.className.replace(rep,'');
            break;
        case 'check':
            return new RegExp('\\b'+c1+'\\b').test(o.className)
            break;
    }
}

/* 
J. Scot Johnston 
02.12.2008
*/
function PopUp(url, id, scroll, resizable, iwidth, iheight, ileft, itop) {
	var __myWindow = window.open (url,id,"scrollbars=" + scroll + ",resizeable=" + resizable + ",width=" + iwidth + ",height=" + iheight + "");
	if(__myWindow)
	  __myWindow.moveTo(ileft,itop);
}