File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/javascript/admin.common.js
var iwp = {
lang : {
vars: {},
get: function(name){
return iwp.util.defaultVal(iwp.lang.vars[name], '[Undefined JS Variable ' + name + ']');
},
set: function(name, val){
if(typeof(name) == 'object'){
for (i in name){
iwp.lang.vars[i] = name[i];
}
}else{
iwp.lang.vars[name] = val;
}
}
},
config : {
vars: {},
get: function(name){
return iwp.util.defaultVal(iwp.config.vars[name], '[Undefined JS Config Variable ' + name + ']');
},
set: function(name, val){
if(typeof(name) == 'object'){
for (i in name){
iwp.config.vars[i] = name[i];
}
}else{
iwp.config.vars[name] = val;
}
}
},
util : {
isDefined: function(obj) {
return (typeof(obj) != 'undefined');
},
defaultVal: function(x, val){
if(!iwp.util.isDefined(x)){
return val;
}
return x;
},
inArray: function(needle, array){
for(i=0;i<array.length;i++){
if(array[i] == needle){
return true;
}
}
return false;
},
clone: function(oldObj) {
var newObj = (oldObj instanceof Array) ? [] : {};
for (i in oldObj) {
if (i == 'clone') continue;
if (oldObj[i] && typeof oldObj[i] == "object") {
newObj[i] = iwp.util.clone(oldObj[i]);
} else newObj[i] = oldObj[i]
} return newObj;
},
randomString: function(length) {
var chars = "0123456789abcdefghiklmnopqrstuvwxyz";
var string_length = iwp.util.defaultVal(length, 8);
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring;
},
htmlEscape: function(str){
str = str.replace(/</g, '<');
str = str.replace(/>/g, '>');
return str;
},
BindOnCheckShow : function(checkbox, displayItem) {
$(checkbox).bind('click', function(){
if($(checkbox).attr('checked') == true){
$(displayItem).show();
}else{
$(displayItem).hide();
}
});
if($(checkbox).attr('checked') == true){
$(displayItem).show();
}else{
$(displayItem).hide();
}
},
BindOnCheckHide : function(checkbox, displayItem) {
$(checkbox).bind('click', function(){
if($(checkbox).attr('checked') == true){
$(displayItem).hide();
}else{
$(displayItem).show();
}
});
if($(checkbox).attr('checked') == true){
$(displayItem).hide();
}else{
$(displayItem).show();
}
}
}, // IWP.Util
form: {
BindNumbersOnly: function(fieldId){
$('#' + fieldId).bind('keyup', function(){
var value = $(this).val();
value = value.replace(/[^0-9]/g, '');
$(this).val(value);
});
}
},
loadingIndiciatorTimeout: false,
showLoadingIndicator: function () {
iwp.loadingIndiciatorTimeout = window.setTimeout(iwp._showLoadingIndicator, 150);
},
_showLoadingIndicator: function () {
$('#statusdiv')
.removeClass('statusOff')
.addClass('statusOn');
iwp._positionLoadingIndicator();
},
_positionLoadingIndicator: function () {
iwp.loadingIndiciatorTimeout = window.setTimeout(iwp._positionLoadingIndicator, 16);
},
hideLoadingIndicator: function () {
if (iwp.loadingIndiciatorTimeout) {
window.clearTimeout(iwp.loadingIndiciatorTimeout);
iwp.loadingIndiciatorTimeout = false;
}
$('#statusdiv').removeClass('statusOn').addClass('statusOff');
},
clearCache: function(){
if (!confirm({$lang.field_ClearCache_Confirm|iwp_FilterJavascriptString})) {
return;
}
$.getJSON('remote.php?section=settings&action=clearcache', function(response){
if(response.success){
alert('{$lang.CacheClearedSuccess|iwp_js}');
}else{
alert('{$lang.CacheClearedFail|iwp_js}');
}
});
}
} // IWP
var callbacks = {};
function RegisterCallback(section, callFunction){
if(typeof(callbacks[section]) == 'undefined'){
callbacks[section] = Array();
}
callbacks[section].push(callFunction);
//console.log(callbacks[section]);
}
function RunCallbacks(section){
if(typeof(callbacks[section]) == 'undefined'){
return;
}
for(i=0;i<callbacks[section].length;i++){
callbacks[section][i]();
}
}
// Array.unshift - Add an element to the beginning of an array
if( typeof Array.prototype.unshift==='undefined' ) {
Array.prototype.unshift = function() {
this.reverse();
var a = arguments, i = a.length;
while(i--) {
this.push(a[i]);
}
this.reverse();
return this.length;
};
}
// Array.splice() - Splice out and / or replace several elements of an array and return any deleted elements
if( typeof Array.prototype.splice==='undefined' ) {
Array.prototype.splice = function(start, deleteCount) {
if (deleteCount == null || deleteCount == '') deleteCount = this.length - start;
// create a temporary copy of the array
var tempArray = this.copy();
// Copy new elements into array (over-writing old entries)
for (var i = start; i < start + arguments.length - 2; i++) {
this[i] = arguments[i - start + 2];
}
// Copy old entries after the end of the splice back into array and return
for (var i = start + arguments.length - 2; i < this.length - deleteCount + arguments.length - 2; i++) {
this[i] = tempArray[i + deleteCount - arguments.length + 2];
}
this.length = this.length - deleteCount + (arguments.length - 2);
return tempArray.slice(start, start + deleteCount);
};
}
function DisableField(disabler, toDisable){
var tmp = $('#'+disabler).attr('checked');
if(tmp != true){
tmp = false;
}
$('#'+toDisable).attr('disabled', tmp);
if(tmp == true){
$('#'+toDisable).hide();
}else{
$('#'+toDisable).show();
}
}
function EnableField(enabler, toEnable){
var tmp = $('#'+enabler).attr('checked');
if(tmp != true){
tmp = false;
}
$('#'+toEnable).attr('disabled', !tmp);
if(tmp == false){
$('#'+toEnable).hide();
}else{
$('#'+toEnable).show();
}
}
function ShowField(enabler, toEnable, reverse){
if (reverse === undefined) {
var reverse = false;
}
var tmp = $('#'+enabler).attr('checked');
if(tmp != true){
tmp = false;
}
if (reverse) {
tmp = !tmp;
}
if(tmp == false){
$('#'+toEnable).hide();
}else{
$('#'+toEnable).show();
}
}
var xml = '';
function clearFont()
{
code = wysiwyg.getHTMLContent();
code = code.replace(/<font([^>])*face="([^"]*)"/gi,"<font $1");
code = code.replace(/<([\w]+) style="([^"]*)font-family:[^;"]*[;]?([^"]*)"/gi, "<$1 style=\"$2 $3\"");
code = code.replace(/<([\w]+) style=" "/gi, "<$1 ");
wysiwyg.writeHTMLContent(code);
}
function isdefined(variable) {
return (typeof('+variable+') != "undefined");
}
function getXMLData(name){
// we rely on a global variable called 'xml'
if(isdefined('xml')){
return xml.getElementsByTagName(name)[0].firstChild.data;
}else{
return '';
}
}
function getNextXMLData(name,i){
// we rely on a global variable called 'xml'
if(isdefined('xml')){
return xml.getElementsByTagName(name)[i].firstChild.data;
}else{
return '';
}
}
/* shared functions */
function toggleCheckboxes(master,formName){
if(formName == ''){
formName = 'ListForm';
}
if(master.checked == true){
checkAll(formName);
}else{
uncheckAll(formName);
}
}
function checkAll(formName){
formObj = document.getElementById(formName);
for (var i=0;i < formObj.length;i++) {
fldObj = formObj.elements[i];
if (fldObj.type == 'checkbox' && !fldObj.disabled) {
// its a checkbox, toggle it to true
fldObj.checked = true;
}
}
}
function uncheckAll(formName){
formObj = document.getElementById(formName);
for (var i=0;i < formObj.length;i++) {
fldObj = formObj.elements[i];
if (fldObj.type == 'checkbox' && !fldObj.disabled) {
// its a checkbox, toggle it to false
fldObj.checked = false;
}
}
}
function checkSelectedBoxes(formName){
// load up the form of articles and navigate the input types
// to find what we need, i.e. checkboxes
formObj = document.getElementById(formName);
for (var i=0;i < formObj.length;i++) {
fldObj = formObj.elements[i];
if (fldObj.type == 'checkbox' && fldObj.checked == true) {
// at least one check box is checked so we return true
return true;
}
}
// no check boxes are checked
return false;
}
function BulkAction(ContentType,formName){
var bulkaction = '';
if(!document.getElementById("bulkaction") && document.getElementById(ContentType+"bulkaction")){
bulkaction = document.getElementById(ContentType+"bulkaction").value;
}
if(document.getElementById("bulkaction")){
bulkaction = document.getElementById("bulkaction").value;
}
// ContentType = article or blog or news or comment
if(bulkaction == "none"){
// means no option has been chosen.
// "none" is the default menu item that does nothing
alert('{$lang.PleaseChooseAnAction}');
$('#bulkaction').focus();
return false;
} else {
// before we do any bulk action, make sure at least one checkbox is selected
if(checkSelectedBoxes(formName)){
var ConfirmDeleteBulk = '{$lang.ConfirmDeleteBulk}';
switch (ContentType) {
case 'categories':
var ConfirmDeleteBulk = {$lang.ConfirmDeleteBulkCategories|iwp_FilterJavascriptString};
break;
}
if(bulkaction == "delete"){
if(!confirm(ConfirmDeleteBulk)){
return false;
}
// delete option selected
document.getElementById(formName).action = 'index.php?section='+ ContentType +'&action=deletemulti';
document.getElementById(formName).submit();
}
if(bulkaction == "approve"){
if(!confirm("{$lang.ConfirmApproveBulk}")){
return false;
}
// delete option selected
document.getElementById(formName).action = 'index.php?ToDo=approve'+ ContentType +'s';
document.getElementById(formName).submit();
}
if(bulkaction == "disapprove"){
if(!confirm("{$lang.ConfirmDisapproveBulk}")){
return false;
}
// delete option selected
document.getElementById(formName).action = 'index.php?ToDo=disapprove'+ ContentType +'s';
document.getElementById(formName).submit();
}
if(bulkaction == "movetocat"){
if($('#masscats').selectedValues() == "_loading"){
return false;
}else{
// delete option selected
document.getElementById(formName).action = 'index.php?ToDo=moveArticlesCat&catId='+ $('#masscats').selectedValues();
document.getElementById(formName).submit();
}
}
if(bulkaction == "addtocat"){
if($('#masscats').selectedValues() == "_loading"){
return false;
}else{
// delete option selected
document.getElementById(formName).action = 'index.php?ToDo=addArticlesCat&catId='+ $('#masscats').selectedValues();
document.getElementById(formName).submit();
}
}
if(bulkaction == "removecat"){
if($('#masscats').selectedValues() == "_loading"){
return false;
}else{
// delete option selected
document.getElementById(formName).action = 'index.php?ToDo=removeArticlesCat&catId='+ $('#masscats').selectedValues();
document.getElementById(formName).submit();
}
}
if (bulkaction == "activate") {
if (!confirm("{$lang.ConfirmActivateBulk}")) {
return false;
}
// activate option selected
adminModules.bulkAction('activate');
}
if (bulkaction == "deactivate") {
if (!confirm("{$lang.ConfirmDeactivateBulk}")) {
return false;
}
// deactivate option selected
adminModules.bulkAction('deactivate');
}
}else{
// no checkboxes were selected
var SelectcategoriesBulk = '{$lang.SelectCategoryBulk}';
var SelectmodulesBulk = '{$lang.SelectModulesBulk}';
var SelectcontenttypesBulk = '{$lang.SelectContenttypesBulk}';
var SelectlistsBulk = '{$lang.SelectListsBulk}';
var SelectcontentBulk = '{$lang.SelectContentBulk}';
eval("var AlertMsg = Select"+ ContentType +"Bulk;")
alert(AlertMsg);
}
}
}
function SetCookie(cookieName,cookieValue,nDays)
{
var today = new Date();
var expire = new Date();
if(nDays==null || nDays==0){
nDays = 1;
}
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}
function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
var cookiename = n+ '=';
var cookiebegin = document.cookie.indexOf(cookiename);
var cookieend = 0;
if(cookiebegin > -1) {
cookiebegin += cookiename.length;
cookieend = document.cookie.indexOf(";",cookiebegin);
if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
cookiecontent = document.cookie.substring(cookiebegin,cookieend);
}
}
return unescape(cookiecontent);
}
function UpdateWindow(){
var w = screen.availWidth;
var h = screen.availHeight;
var l = (w/2) - 250;
var t = (h/2) - 250;
var win = window.open("index.php?ToDo=databaseUpgrade&ForceStep1=true", "DatabaseUpgrade", "top="+t+",left="+l+",width=500,height=500,status=yes");
win.focus();
}
function OptionInSelect(id, select)
{
for (var i=0; i< document.getElementById(select).options.length; i++) {
if (document.getElementById(select).options[i].value == id) {
return true;
}
}
return false;
}
function animate_color(id,color){
var htmlColor = '';
var duration = 100;
if(color == 'green'){
htmlColor = '#99FF66';
} else if (color == 'orange') {
htmlColor = '#FFCC66';
} else if(color == 'red'){
htmlColor = '#FC7575';
duration = 300;
} else if( color == 'default'){
htmlColor = '#F9F9F9';
duration = 300;
}
$("#" + id).animate({ backgroundColor:htmlColor }, { queue: true, duration: duration });
}
/**
*
*/
function ChangePaging(object, todo, pagenumber) {
pagingId = object.selectedIndex;
pagingamount = object[pagingId].value;
document.location = 'index.php?ToDo=' + todo + '&page=' + pagenumber + '&perpage='+ pagingamount;
}
function CheckValidDate(day, month, year){
year = parseInt(year, 10);
month = parseInt(month, 10);
day = parseInt(day, 10);
/* check the year is correct */
if( year < 1900 || year > 2100){
return false;
}
/* check the month is correct */
if(month < 1 || month > 12){
return false;
}
/* check the day is correct */
if(month == 2){
days = daysInFebruary(year);
if(day > days) {
return false;
}
}else{
var daysInMonth = DaysArray(12);
if(day > daysInMonth[month]){
return false;
}
}
// looks good!
return true;
}
function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
// global loading indicator
$(function(){
$(document).ajaxStart(iwp.showLoadingIndicator);
$(document).ajaxStop(iwp.hideLoadingIndicator);
$('.ClearCacheLink').bind('click', function() {
iwp.clearCache();
return false;
});
});
function LaunchHelpCategory(categoryid) {
var help_win = window.open("http://www.anonym.to/?http://www.viewkb.com/inlinehelp.php?searchOverride=" + parseInt(categoryid) + "&tplHeader=" + escape({$whitelabel.ApplicationName|iwp_FilterJavascriptString}), "help", "width=650, height=550, left="+(screen.availWidth-700)+", top=100");
}
function LaunchHelp(articleid) {
var help_win = window.open("http://www.anonym.to/?http://www.viewkb.com/inlinehelp.php?searchOverride=" + escape('142') + "&tplHeader=" + escape({$whitelabel.ApplicationName|iwp_FilterJavascriptString}) + "&helpid="+ parseInt(articleid, 10), "help", "width=650, height=550, left="+(screen.availWidth-700)+", top=100");
}
function CurrentStyle(element, prop) {
if(element.currentStyle) {
return element.currentStyle[prop];
}
else if(document.defaultView && document.defaultView.getComputedStyle) {
prop = prop.replace(/([A-Z])/g,"-$1");
prop = prop.toLowerCase();
return document.defaultView.getComputedStyle(element, "").getPropertyValue(prop);
}
}
$(document).ready(function() {
$('.PopDownMenu').each(function() {
$(this).click(function(e) {
closeMenu();
if(document.topCurrentMenu) {
$(document.topCurrentMenu).hide();
$(document.topCurrentButton).removeClass('ActiveButton');
$('.ControlPanelSearchBar').show();
}
var id = this.id.replace(/Button$/, '');
if(!('#'+id))
return false;
var menu = $('#'+id);
var obj = this;
offsetTop = 0;
offsetLeft = 0;
while(obj)
{
offsetLeft += obj.offsetLeft;
offsetTop += obj.offsetTop;
obj = obj.offsetParent;
if(obj && CurrentStyle(obj, 'position')) {
var pos = CurrentStyle(obj, 'position');
if(pos == "absolute" || pos == "relateive") {
break;
}
}
}
var tagName = $(this).attr('tagName').toLowerCase();
var customOffsetTop = 1;
var customOffsetLeft = 2;
switch (tagName) {
case 'button':
if ($.browser.safari) {
// safari
var customOffsetTop = 4;
var customOffsetLeft = 10;
} else {
var customOffsetTop = 4;
var customOffsetLeft = 4;
}
break;
}
$(this).addClass('ActiveButton');
$('embed').css('visibility', 'hidden');
$('object').css('visibility', 'hidden');
$(menu).css('position', 'absolute');
$(menu).addClass('PopDownMenuContainer');
$(menu).css('top', (offsetTop+ this.offsetHeight + customOffsetTop) +"px");
this.blur();
$(menu).css('left', (offsetLeft + customOffsetLeft) + "px");
$(menu).show();
e.stopPropagation();
$(document).click(function() {
$(menu).hide(); $(document.topCurrentButton).removeClass('ActiveButton');
document.topCurrentMenu = '';
$('embed').css('visibility', 'visible');
$('object').css('visibility', 'visible');
});
document.topCurrentMenu = menu;
document.topCurrentButton = this;
return false;
});
});
});
$().ajaxSuccess(doAjaxLogin);
$().ajaxError(doAjaxLogin);
var __lastAjaxRequestParams = {};
function doAjaxLogin (event, request, params) {
if (typeof params.dataType != 'undefined' && params.dataType.toLowerCase() == 'xml' && $('status', request.responseXML).text() == 'fail' && $('error', request.responseXML).text() == 'login_fail') {
if ($('errOverlay').exists()) {
$('errOverlay').remove();
}
if ($('loginAjaxBox').exists()) {
$('loginAjaxBox').remove();
}
__lastAjaxRequestParams = params;
$("body").append("<div style='height:100%;left:0px;position:fixed;top:0px;width:100%;z-index:100;background-color:#000000;opacity:0.75;' id='errOverlay'></div>");
$("body").append("<div id='loginAjaxBox' style='z-index:102;opacity:1;'>" + $('loginbox', request.responseXML).text() + "</div>");
}
return true;
}
function in_array(needle, array){
for(i=0;i<array.length;i++){
if(array[i] == needle){
return true;
}
}
return false;
}
/**
* This sets up a input element to work with the admin url browser. It hooks into the given clickable element to launch the browser when clicked, and feeds back information into the provided url and text elements when closed.
*
* Usage: new IWPUrlBrowser($('#id_of_clickable_element'), $('#id_of_link_url_input_element'), $('#id_of_link_text_input_element'));
*
* Third parameter, textElement, is optional.
*
*/
IWPUrlBrowser = function (clickElement, urlElement, textElement) {
var self = this;
self.clickElement = clickElement;
self.urlElement = urlElement;
self.textElement = textElement;
self.onBeforeBrowserClose = function () {
var url = $('#urlbrowser-selected-url').val();
if (!url) {
return;
}
$(self.urlElement).val(url);
if (!self.textElement) {
return;
}
var text = $('#urlbrowser-selected-text').val();
if (!text) {
return
}
$(self.textElement).val(text);
};
self.openBrowser = function () {
IWPUrlBrowserWindow = $.iModal({
type: 'ajax',
url: 'remote.php?section=content&action=urlbrowser&type=file&mode=text',
title: {$lang.URLBrowser|iwp_FilterJavascriptString},
buttons: '<div id="urlbrowser-buttons"><div class="urlbrowser-insertbuttons urlbrowser-insertbuttons--default" style="display:none;"><button disabled="disabled" class="urlbrowser-insert" id="urlbrowser-insert">'+ {$lang.InsertURL|iwp_FilterJavascriptString} +'</button></div>' +
'<button id="urlbrowser-cancel">'+ {$lang.Cancel|iwp_FilterJavascriptString} +'</button></div><br style="clear: both;" />',
width: 700,
onBeforeClose: self.onBeforeBrowserClose
});
};
self.onClick = function (event) {
event.preventDefault();
self.openBrowser();
};
self.bindClick = function () {
$(self.clickElement).click(self.onClick);
};
self.unbindClick = function () {
$(self.clickElement).unbind('click', self.onClick);
};
self.bindEvents = function () {
self.bindClick();
};
self.unbindEvents = function () {
self.unbindClick();
};
self.bindEvents();
};
var IWPUrlBrowserWindow = {};