var panelCtr = 0; function cmsPanel( opt ) { this.init( opt ); } cmsPanel.prototype = { init:function( opt ) { this.ctr = panelCtr++; var pWidth = (opt.width != null && opt.width!='' )?opt.width:300; var pHeight = ( opt.height!= null )?opt.height:'auto'; var pTitle = (opt.title != null && opt.title!='' )?opt.title:'Loading, Please wait ...'; var maxHeight = (opt.maxHeight !=null && opt.maxHeight!='')?opt.maxHeight:$(window).height(); this.loadingimage = ( opt.loadingimage != null && opt.loadingimage != '' )?opt.loadingimage:'cms/scripts/jquery/loading.gif'; var pMsg = (opt.msg != null && opt.msg!='' )?opt.msg:'
'; var beforeClose = ( opt.beforeClose != null )?opt.beforeClose:null; if( $('#resultPanel' + this.ctr).length == 0) { $(document.body).append('
'+pMsg+'
'); $('#resultPanel'+this.ctr).dialog({ modal:true, width:pWidth, draggable:false, minHeight:10, resizable:false, autoOpen:false, height:pHeight, maxHeight:maxHeight, beforeClose : beforeClose, buttons: { "x": function() { $(this).dialog('close'); } } }); var dialogParent = $('#resultPanel').parent(); $('.ui-dialog-titlebar-close', dialogParent).css('display', 'none'); } else { $('#resultPanel' +this.ctr).html(pMsg); $('#ui-dialog-title-resultPanel'+this.ctr).html(pTitle); $('#resultPanel'+this.ctr).dialog('open'); } }, setTitle:function(pTitle ) { $('#ui-dialog-title-resultPanel'+this.ctr).html(pTitle); }, setContent:function(pContent ) { $('#resultPanel'+this.ctr).html(pContent); }, show:function() { $('#resultPanel'+this.ctr).dialog('open'); }, hide:function() { $('#resultPanel'+this.ctr).dialog('close'); }, setWaitingContent:function() { var pTitle = 'Loading, Please wait ...'; var pMsg = '
'; this.setContent( pMsg ); this.setTitle( pTitle ); }, beforeClose:function( fn ) { $('#resultPanel'+this.ctr).bind( "dialogbeforeclose",fn); } } var numberOnly = function( ev ) { try { var charcode = ( ev.charCode != null)?ev.charCode:ev.keyCode; var character = String.fromCharCode(charcode); if ((charcode==null) || (charcode==0) || (charcode==8) || (charcode==9) || (charcode==13) || (charcode==27) ) return true; if (("1234567890").indexOf(character) > -1) return true; } catch(E) { return true; } return false; } var decimalOnly = function( ev ) { try { var charcode = ( ev.charCode != null)?ev.charCode:ev.keyCode; var character = String.fromCharCode(charcode); if ((charcode==null) || (charcode==0) || (charcode==8) || (charcode==9) || (charcode==13) || (charcode==27) ) return true; if (("-1234567890.").indexOf(character) > -1) return true; } catch(E) { return true; } return false; } var alphaNumericOnly = function( ev ) { try { var charcode = ( ev.charCode != null)?ev.charCode:ev.keyCode; var character = String.fromCharCode(charcode); if ((charcode==null) || (charcode==0) || (charcode==8) || (charcode==9) || (charcode==13) || (charcode==27) ) return true; if (("0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_").indexOf(character) > -1) return true; } catch(E) { return true; } return false; } var customCharSet = function( ev, characterSet ) { try { var charcode = ( ev.charCode != null)?ev.charCode:ev.keyCode; var character = String.fromCharCode(charcode); // control keys if ((charcode==null) || (charcode==0) || (charcode==8) || (charcode==9) || (charcode==13) || (charcode==27) ) return true; else if (characterSet.indexOf(character) > -1) return true; } catch(E) { return true; } return false; } var isEmail = function(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } var dump = function(ob, print_method ){ var str = ''; if( ob instanceof Array ) { for( i=0; i/g, ">"); } return str; } function htmlspecialchars_rev(str) { if (typeof(str) == "string") { str = str.replace(/&/g, "&"); /* must do & first */ str = str.replace(/"/g, '"'); str = str.replace(/'/g, "'"); str = str.replace(/</g, "<"); str = str.replace(/>/g, ">"); } return str; } function tickAllCheckBox(val, fm ) { if( val == true ) $('input[type=checkbox]', fm).attr({'checked':'checked'}); else $('input[type=checkbox]', fm).removeAttr('checked'); } function loadChildSelection3(ev) { var data = ev.data; return loadChildSelection2( data.parentfieldname, data.childfieldname, data.modulename, 'name',data.parentfkfield ); } function loadChildSelection2( parentfieldname, childfieldname, modulename, namefield, parentfkfield ) { var previousChildVal = $('#' + childfieldname ).val(); var parentFieldVal = $('#' + parentfieldname).val(); if( namefield == '' || namefield == null ) namefield = 'name'; if( parentFieldVal == '' ) { $('#' + childfieldname ).html(''); return; } var selectfields = 'id,' + namefield +' as name '; var where = 'where ' +parentfkfield +'='+parentFieldVal; panel.setWaitingContent(); panel.show(); $.ajax({ type: "POST", url: "ajax.php?funcid=MODULE_SELECT", async:true, data: 'modulename='+escape(modulename)+'&select='+ escape(selectfields) +'&where='+ escape(where), success: function(msg,ret){ panel.setTitle( 'Load Selection List'); if( ret != 'success' ) { panel.setContent('
Load Selection List failed, please refresh
'); return; } try { var result = eval( '(' + msg +')' ); if( result.status != '1' ) { panel.setContent('
Load Selection List failed, please refresh
'); return; } else { var str = ''; var s = result.dataset; for( var i=0; i' + s[i].name +''; } $('#'+childfieldname).html(str); $('#'+childfieldname).val( previousChildVal +''); panel.hide(); } } catch(E) { panel.setContent(E.message+'
Network connection error, please try again later.
'); return; } } }); } function loadChildSelection(parentfieldname, childfieldname, data ) { if( $('#'+parentfieldname).val() == '' ) { $('#'+childfieldname).html(''); return; } var s = data; var str = ''; for( var i=0; i' + s[i].name +''; } $('#'+childfieldname).html(str); } function isIE7() { var res = ( navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf('MSIE 7') != -1); return res; } function isIE() { var res = ( navigator.appName == 'Microsoft Internet Explorer'); return res; } //Get cookie routine by Shelley Powers function getCookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) // if cookie exists if (offset != -1) { offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function getQueryString(variable) { z = window.location.search.substring(1); y = z.split("&"); for (i=0;i