/**
 * CMS Library Initial Starting Point
 * http://advanceddomscripting.com/chapter1/CMS-start.js
 */
 
(function(){
 
//The CMS namespace
window['CMS'] = {};
 
function isCompatible(other) { };
window['CMS']['isCompatible'] = isCompatible;
 

/**
 * document.getElementById(); replacement.
 */
function $() {
    var elements = new Array();
    
    // Find all the elements supplied as arguments
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];
        
        // If the argument is a string assume it's an id
        if (typeof element == 'string') {
            element = document.getElementById(element);
        }
        
        // If only one argument was supplied, return the element immediately
        if (arguments.length == 1) {
            return element;
        }
        
        // Otherwise add it to the array
        elements.push(element);
    }
    
    // Return the array of multiple requested elements
    return elements;
};
window['CMS']['$'] = $;
 
function addEvent(node, type, listener) { };
window['CMS']['addEvent'] = addEvent;
 
function removeEvent(node, type, listener) { };
window['CMS']['removeEvent'] = removeEvent;
 
function getElementsByClassName(className, tag, parent){ };
window['CMS']['getElementsByClassName'] = getElementsByClassName;
 
/**
 * Toggle the style display value between none and the default
 */
function toggleDisplay(node, value) {
    if(!(node = $(node))) return false;
    if ( node.style.display != 'none' ) {
        node.style.display = 'none';
    } else {
        node.style.display = value || '';
    }
    return true;
}
window['CMS']['toggleDisplay'] = toggleDisplay;
 
function insertAfter(node, referenceNode) { };
window['CMS']['insertAfter'] = insertAfter;
 
function removeChildren(parent) { };
window['CMS']['removeChildren'] = removeChildren;
 
function prependChild(parent, newChild) { }; 
window['CMS']['prependChild'] = prependChild;

/**
 * Toggles the icons and content of the node, the id's fo the icons must preceeded the id of the node by 'exp-' (explode) ans 'imp-' (implode)
 */
function toggleIcons(node) {
	toggleDisplay('exp-'+node);
	toggleDisplay('imp-'+node);
    return true;
}
window['CMS']['toggleIcons'] = toggleIcons;

function HideNode(node) {
	if(!(node = $(node))) return false;
	node.style.display = 'none';
	return true;
}        
window['CMS']['HideNode'] = HideNode;

function ShowNode(node) {
	if(!(node = $(node))) return false;
	node.style.display = '';
	return true;
}        
window['CMS']['ShowNode'] = ShowNode;

function HideContainer(node) {
	if(!(vCtxt = $(node))) return false;
	var vCid = $('img-'+node)
	vCtxt.style.display = 'none';
	vCid.src = "phpcmsys/.resources/cont-plus.gif"
	AddToCookie('clpid',node);
	return true;
}        
window['CMS']['HideContainer'] = HideContainer;

function HideShowContainer(node) {
	if(!(vCtxt = $(node))) return false;
	var vCid = $('img-'+node)
	if(vCtxt.style.display == 'none') {
		vCtxt.style.display = '';
		vCid.src = "phpcmsys/.resources/cont-minus.gif"
		SubFromCookie('clpid',node);
	}
	else {
		vCtxt.style.display = 'none';
		vCid.src = "phpcmsys/.resources/cont-plus.gif"
		AddToCookie('clpid',node);
	}
	return true;
}        
window['CMS']['HideShowContainer'] = HideShowContainer;

function HideShowNode(node) {
	if(!(vCtxt = $(node))) return false;
	if(vCtxt.style.display == 'none') {
		vCtxt.style.display = '';
	}
	else {
		vCtxt.style.display = 'none';
	}
	return true;
}        
window['CMS']['HideShowNode'] = HideShowNode;

function SetBorder(node) {
	if(!(vBdr = $(node))) return false;
//	vBdr.style.border = '2px solid blue';
	vBdr.style.background = '#99ffff';
    return true;
}
window['CMS']['SetBorder'] = SetBorder;
 
function ClearBorder(node) {
	if(!(vBdr = $(node))) return false;
	vBdr.style.border = '0px';
	vBdr.style.background ='';
    return true;
}
window['CMS']['ClearBorder'] = ClearBorder;


function SetBackground(node,val) {
	if(!(vBgr = $(node))) return false;
	if (val != '') {
		vBgr.style.background = val;
	}
	else {
		vBgr.style.background = '#99ffff';
		vBgr.style.zIndex='10';	}
    return true;
}
window['CMS']['SetBackground'] = SetBackground;
 
function ClearBackground(node) {
	if(!(vBgr = $(node))) return false;
	vBgr.style.background ='';
    return true;
}
window['CMS']['ClearBackground'] = ClearBackground;

function SetBackgroundImage(node,val) {
	if(!(vBgr = $(node))) return false;
	vBgr.style.backgroundImage= val;
    return true;
}
window['CMS']['SetBackgroundImage'] = SetBackgroundImage;

 
})();
