/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function closeWindow(Window,refreshParent){
	if (!Window) return
	if (Window.opener && !Window.opener.closed) {
	 	if (refreshParent) Window.opener.location.reload(1);
	 	Window.opener.focus();
	}
	Window.close()
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
var Selection='';
var PrevRow  = new Array();
PrevRow['classname']='';
PrevRow['row']='';
PrevRow['id']='';
function selectRow(objRow,id,SelectClass){
	// deselect previous
	if (PrevRow['row'] != '') {
	  PrevRow['row'].className = PrevRow['classname'];
	  //window.status="row de-selected to "+PrevRow['row'].className;
	  if (PrevRow['row'] === objRow )  {
		  PrevRow['row'] = '';
		  PrevRow['classname'] = '';
		  PrevRow['id']='';
		  return;
	  }
	}
	// select new
	PrevRow['classname'] = objRow.className;
	PrevRow['row'] = objRow;
	PrevRow['row'].className = SelectClass;
	PrevRow['id'] = objRow.id;
	//window.status="row selected to "+PrevRow['row'].className;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function clearForm(sFormName){
	var cleared = true;
	if (document.forms.length == 0 ) return cleared;
	// loop through the fields and check if they are required
	var elements = document.forms[sFormName].elements;
	for (var field = 0 ; field <  elements.length; field++) {
		if (elements[field].type=="text") elements[field].value = ""
	}
	return cleared;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function trim(anystring, leading, trailing){
  var leading = (leading==null || leading != "")?true:false;
  var trailing = (trailing==null || trailing != "")?true:false;
  if (leading == true) var anystring = anystring.replace(/^(\s*)/gi,"");
  if (trailing == true ) var anystring = anystring.replace(/(\s*)$/gi,"");
  return anystring;
}
function Trim(anystring, leading, trailing){
	return trim(anystring, leading, trailing);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function validateForm(formname,classname,msg_header){
	var a = new Array, msg = "", req, caption;
	var classname=(!classname || classname=='')?"REQUIRED":classname;
	var msg_header=(!msg_header || classname=='')?"De volgende velden moeten nog worden ingevuld:\n\n":msg_header;

	if (!isObject(document.forms[formname])) return false;

	var elements = document.forms[formname].elements;
	for(var i = 0 ; i < elements.length ; i++) {
		var el = elements[i];
		if (el.name == '') continue;
		if (el.type == 'hidden') continue;
		if (el.className.indexOf(classname) == -1) continue;
		//alert(el.name +  ' = |' + el.value + '|');
		if (trim(el.value)=="") {
	    	//Required element found with empty value; store name:
	    	// if a label (id = lbl_<el.id> ) is found get that text
	    	objLab=GetElement("lbl_"+el.id);
	    	if (objLab==null) {
	    		a[a.length++] = el.name;
	    	} else {
	    		a[a.length++] = objLab.innerText;
	    	}
		}
	}

	for(i = 0; i < a.length; i++) {
		caption = a[i];
    	msg = msg + "-> " + caption + "\n";
	}

	if (msg != ""){
	    alert(msg_header + "\n" + msg);
	    obj=GetElement(a[0]);
	    if (obj) {
	    	try{
		    	if (obj.type!="hidden" || obj.disabled==false)
		    	// check type of object
		    	obj.focus();
	    	} catch(e){}
	    }
	    return false;
	}
	return true;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function IsNN(){ return ((navigator.appName.toLowerCase()).indexOf('netscape') != -1) }
function IsIE(){ return ((navigator.appName.toLowerCase()).indexOf('microsoft') != -1) }
function GetVersion(){ return parseInt(navigator.appVersion) }
function CompareStr(value1,value2) { return(value1==value2) }
function isObject(obj) {	return (typeof obj=="object") }
function isFunction(obj) {	return (typeof obj=="function") }


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && (!document.getElementById)) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
function GetElement(id) {
	if (!id) return;
	if (isNS4){
	   return document.layers[id];
	}	else if (isIE4) {
	   return document.all[id];
	}	else {
    	return document.getElementById(id);
	}
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function is800x600() {
	return (screen.availwidth<=800) && (screen.availheight<=600)
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
window.doHideAll_counter=0;
function doIntervalAll() {
	doHideAll_counter+=20
	if (doHideAll_counter>880) {
	  if (typeof window.doHideAll=="function") doHideAll();
	  doHideAll_counter=0;
  }
  if (typeof window.scrollmarquee=="function") scrollmarquee();
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
var obj_curtab=null;
function showTab(id) {
	objtemp=GetElement(id);

	if (obj_curtab==null) {
		obj_curtab=objtemp;
		obj_curtab.style.display='block';
		return;
	}
	if (obj_curtab===objtemp) return;
	obj_curtab.style.display='none';
	obj_curtab=objtemp;
	obj_curtab.style.display='block';
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function buttonToggleDisplay(id,path,img,img_hide,img_show,txt_hide,txt_show) {
	var r=0;
	try{
		var objS=GetElement(id).style;
		if (objS.display=="block" || objS.display!="none") {
			objS.display="none";
			img.src=path+img_show;
			img.alt=txt_show;
			r=0;
		} else {
			objS.display="block";
			img.src=path+img_hide;
			img.alt=txt_hide;
			r=1;
		}
	} catch(e){
		img.src=path+img_hide;
		r=0;
	}
	return r;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function XLNTSYS_findInChilds(window_name,current_window){
	try {
		var frame_count=current_window.frames.length;

		for (var i=0; i < frame_count; i++){
			if 	(current_window.frames[i].name == window_name) return current_window.frames[i];
			var the_window=XLNTSYS_findInChilds(window_name,current_window.frames[i]);
			if (the_window) return the_window;
		}
	} catch(e) {

	}
	return null;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function XLNTSYS_findInOpeners(window_name,current_window){
	try {
		if (current_window.opener && current_window.opener.closed==false){
			var the_window = XLNTSYS_findInChilds(window_name,current_window.opener.top);
			if (the_window) return the_window;
			var the_window = XLNTSYS_findInOpeners(window_name,current_window.opener);
			if (the_window) return the_window;
		}
	} catch (e) {

	}
	return null;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function XLNTSYS_findWindow(window_name,current_window) {
	try {
		// find in childs recursivly
		var the_window = XLNTSYS_findInChilds(window_name,current_window.top);
		if (the_window) return the_window;

		// Find in the openers
		var the_window = XLNTSYS_findInOpeners(window_name,current_window);
		if (the_window) return the_window;
	} catch(e) {

	}
	return null;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_onButtonOver(butID) {
	GetElement(butID+"_center").className="XLNT-SYSTEM-BUTTON-CENTER-OVER";
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_onButtonOut(butID) {
	GetElement(butID+"_center").className="XLNT-SYSTEM-BUTTON-CENTER";
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_onButtonDown(butID) {
	GetElement(butID+"_center").className="XLNT-SYSTEM-BUTTON-CENTER-DOWN";
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
window.xlnt_ButtonStates=new Array(); // Store the states of the statebuttons
window.xlnt_ButtonLocked="";          // Store the id of the locked button
function xlnt_onStateButtonOver(butID) {
	// change display if not locked
	if (xlnt_ButtonLocked==butID) return;
	if (!xlnt_ButtonStates[butID]) xlnt_onButtonDown(butID)
	if (xlnt_ButtonStates[butID]) xlnt_onButtonOut(butID)
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_onStateButtonOut(butID) {
	// change display
	if (!xlnt_ButtonStates[butID]) xlnt_onButtonOut(butID)
	if (xlnt_ButtonStates[butID]) xlnt_onButtonDown(butID)
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_onStateButtonDown(butID,lock) {
	var undefined;
	var temp;
	lock=(lock==undefined)?false:lock;

	// toggle locked state button
	if (lock && xlnt_ButtonLocked!="") {
		temp=xlnt_ButtonLocked
		xlnt_ButtonLocked="";
		xlnt_onStateButtonDown(temp);
	}

	// if we are locked then exit the function
	if (xlnt_ButtonLocked==butID) return;

	// toggle the state
	xlnt_ButtonStates[butID]=(xlnt_ButtonStates[butID]==undefined || !xlnt_ButtonStates[butID])

	// change display
	if (xlnt_ButtonStates[butID]) xlnt_onButtonDown(butID)
	if (!xlnt_ButtonStates[butID]) xlnt_onButtonOut(butID)

	// remember this button is lockedwe are locked
	if (lock) xlnt_ButtonLocked=butID;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_disableSelect(e){ return false;   }


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_enableSelect(){ return true; }


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
function xlnt_init_disable_select(){
	// if IE4+
    try{
        document.onselectstart=new Function ("return false");
    } catch(e) { }

    // if NS6
    if (window.sidebar){
        try{
            document.onmousedown=xlnt_disableSelect;
            document.onclick=xlnt_enableSelect
        } catch(e) { }
    }
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * *
 *
 */
XLNTSYS_isNS4 = (document.layers) ? true : false;
XLNTSYS_isIE4 = (document.all && !document.getElementById) ? true : false;
XLNTSYS_isIE5 = (document.all && document.getElementById) ? true : false;
XLNTSYS_isNS6 = (!document.all && document.getElementById) ? true : false;
function XLNTSYS_getElementById(id) {
	if (!id) return;
	if (XLNTSYS_isNS4){
	   	return document.layers[id];
	} else if (XLNTSYS_isIE4) {
	   	return document.all[id];
	} else {
    	return document.getElementById(id);
	}
}

/**
 * Hover function, open and close a menu onclick.
 */
function CXLNTTree_hover(element, img) {
    for (var x = 0; element.childNodes[x]; x++) {
        if (element.childNodes[x].tagName == 'UL') {
            if (element.childNodes[x].style.display != 'block') {
                element.childNodes[x].style.display = 'block';
                img.src = img.src.replace(/plus.gif/, 'min.gif');
            } else {
                element.childNodes[x].style.display = 'none';
                img.src = img.src.replace(/min.gif/, 'plus.gif');
            }
        }
    }
}

/**
 * Functions for a context menu.
 */
function getTarget(e) {
    var target;

    // IE fix.
    if (!e) e = window.event;
    if (e.target) {
        target = e.target;
    } else if (e.srcElement) {
        target = e.srcElement;
    }

    // Safari fix.
    if (target.nodeType == 3) {
        target = target.parentNode;
    }

    return target;
}

function isRightClick(e) {
    var target = getTarget(e);

    if (e.which) {
        if (e.which == 3) return true;
    }
    if (e.button) {
        if (e.button == 2) return true;
    }

    return false;
}

function xlntcms_onClick(e) {
    if (!e) e = window.event;
}

function xlntcms_onContextMenu(e) {
    return false;
}

function xlntcms_onMouseDown(e) {
    var targ = getTarget(e);

    if (!isRightClick(e)) return true;

    // Set the menu visible.
    //
    // Detect if we have a valid container.
    // Detect if we have a component.
}

function xlntcms_onLoad(e) {
    document.oncontextmenu = xlntcms_onContextMenu;
    document.onclick = xlntcms_onClick;
    document.onmousedown = xlntcms_onMouseDown;
}

//window.onload = xlntcms_onLoad;

