/* WEEBO : CONTENT MADE EASY                                                                          */                                                                        
/* -------------------------------------------------------------------------------------------------- */
/* Original development began in 2001, where a need came about to develop a content management system */
/* that catered for business and not only graphic designers. Weebo has come a long way and this new   */
/* content management system was derived to cater for the small, medium and large enterprise websites */
/* This code is the intellectual property of Gilbert Martin II, anyone attempting to copy, alter or   */
/* modify this code is committing patent fraud. Beyond this you are a miserable human being if you    */
/* are trying to copy somebody else/*s work, because you are not good enough to do your own.          */
/* -------------------------------------------------------------------------------------------------- */
/* Copyright (C) 2000 - 2020 . Gilbert Martin II (www.gilbertmartin.co.za) . All Rights Reserved      */
/* Visit www.gilbertmartin.co.za or www.weebo.co.za for more information regarding this development   */
/* -------------------------------------------------------------------------------------------------- */

/*DIALOG CONTROL*/
var TIMER = 5;
var SPEED = 5;
var WRAPPER = 'contentNX';
function pageWidth() {
return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}
function topPosition() {
return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function leftPosition() {
return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function showDialog(title,message,type,autohide) {
if (NOTIFICATIONS==="OFF" && type != 'prompt') 
{
return false;
}
if(!type) {
type = 'error';
}
if (type === 'error') {autohideX=2} else {autohideX=3}
var dialog;
var dialogheader;
var dialogclose;
var dialogtitle;
var dialogcontent;
var dialogmask;
if(!document.getElementById('dialog')) {
dialog = document.createElement('div');
dialog.id = 'dialog';
dialogheader = document.createElement('div');
dialogheader.id = 'dialog-header';
dialogtitle = document.createElement('div');
dialogtitle.id = 'dialog-title';
dialogclose = document.createElement('div');
dialogclose.id = 'dialog-close'
dialogcontent = document.createElement('div');
dialogcontent.id = 'dialog-content';
dialogmask = document.createElement('div');
dialogmask.id = 'dialog-mask';
document.body.appendChild(dialogmask);
document.body.appendChild(dialog);
dialog.appendChild(dialogheader);
dialogheader.appendChild(dialogtitle);
dialogheader.appendChild(dialogclose);
dialog.appendChild(dialogcontent);;
dialogclose.setAttribute('onclick','hideDialog()');
dialogclose.onclick = hideDialog;
} else {
dialog = document.getElementById('dialog');
dialogheader = document.getElementById('dialog-header');
dialogtitle = document.getElementById('dialog-title');
dialogclose = document.getElementById('dialog-close');
dialogcontent = document.getElementById('dialog-content');
dialogmask = document.getElementById('dialog-mask');
dialogmask.style.visibility = "visible";
dialog.style.visibility = "visible";
}
dialog.style.opacity = .00;
dialog.style.filter = 'alpha(opacity=0)';
dialog.alpha = 0;
var width = pageWidth();
var height = pageHeight();
var left = leftPosition();
var top = topPosition();
var dialogwidth = dialog.offsetWidth;
var dialogheight = dialog.offsetHeight;
var topposition = top + (height / 3) - (dialogheight / 2);
var leftposition = left + (width / 2) - (dialogwidth / 2);
dialog.style.top = topposition + "px";
dialog.style.left = leftposition + "px";
dialogheader.className = type + "header";
dialogtitle.innerHTML = title;
dialogcontent.className = type;
msg = message;
msg = msg.replace(/#/gi,'"');
msg = msg.replace(/~/gi,"'");
msg = msg.replace(/getelementbyid/gi,"getElementById");
msg = msg.replace(/hidedialog/gi,"hideDialog");
dialogcontent.innerHTML = msg;
var content = document.getElementById(WRAPPER);
dialogmask.style.height = content.offsetHeight + 'px';
dialogclose.style.visibility = "visible";
dialog.timer = setInterval("fadeDialog(1)", TIMER);
if (type != 'prompt') {
window.setTimeout("hideDialog()", (autohideX * 1000));
}
}
function hideDialog() {
var dialog = document.getElementById('dialog');
clearInterval(dialog.timer);
dialog.timer = setInterval("fadeDialog(0)", TIMER);
}
function fadeDialog(flag) {
if(flag == null) {
flag = 1;
}
var dialog = document.getElementById('dialog');
var value;
if(flag == 1) {
value = dialog.alpha + SPEED;
} else {
value = dialog.alpha - SPEED;
}
dialog.alpha = value;
dialog.style.opacity = (value / 100);
dialog.style.filter = 'alpha(opacity=' + value + ')';
if(value >= 99) {
clearInterval(dialog.timer);
dialog.timer = null;
} else if(value <= 1) {
dialog.style.visibility = "hidden";
document.getElementById('dialog-mask').style.visibility = "hidden";
clearInterval(dialog.timer);
}
}
