var _ie = navigator.userAgent.match(/opera|firefox/i) ? false : true;
var _opera = navigator.userAgent.match(/opera/i) ? true : false;
var _gecko = navigator.userAgent.match(/gecko/i) ? true : false;
var _l=new Object;
//--- LANG: ENGLISH
_l['en'] = new Object;
_l['en']['so_blank'] = 'Please fill in the missing field';
_l['en']['so_ivlt']= 'This field should only contain char: ';
_l['en']['ivl_date']='Invalid date format !';
_l['en']['so_not_email']=[
'Email address should not contain white characters (eg: SPACE)',
'Email address should not contain repeated . (dot)',
'Email address should not contain repeated @',
'Email address should not contain . before or after @',
'First or last character of email should not contain . or @',
'Email address should have one @ ',
'Email Address\'s allowed characters are:\n\n a-z A-Z 1-9 - _ . @'
];
function make_self_object(f){
//- =================
var so = new Object;
var u = make_utilities();
so.u = u;
so.frame = f;
//--- so.id
so.id = function(obj) {
if(typeof(obj)=='string'){
if(f.document.getElementById(obj)){return f.document.getElementById(obj)}
alert('Debug: "'+obj+'" not exist');
return;
}
return obj;
};
//--- so.exist
so.exist = function(obj){
if(f.document.getElementById(obj)){return f.document.getElementById(obj)}
return false;
};
//--- so.exist_all
so.exist_all = function(objs){
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){
if(!f.document.getElementById(at[i])){return false;}
}
return true;
}
//--- so.ids
so.ids = function(obj) { return so.id(obj).style; };
//--- so.show
so.show = function(objs) {
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){so.ids(at[i]).display = ''}
};
//--- so.hide
so.hide = function(objs){
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){so.ids(at[i]).display = 'none'}
};
//--- so.trim
so.trim = function(objs){
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){so.id(at[i]).value = so.id(at[i]).value.replace(/^\s+|\s+$/g,'')}
};
//--- so.clear
so.clear = function(objs){
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){so.id(at[i]).value=''}
};
//-Input yang ada so.id(obj).value dan untuk error checking
//--- so.blank
so.blank = function(objs,err_msg){
var at = objs.split(','),i,b=at.length-1;
for(i=0;i<=b;i++){
so.trim(at[i]);
if(so.id(at[i]).value == '' ){
alert(err_msg?err_msg:_l['en']['so_blank']);
so.id(at[i]).value = ' ';
so.id(at[i]).select();
return true;
}
}
return false;
};
//--- so.w
so.w = function (str){f.document.write(str)};
//--- so.sl
so.sl = function(obj){if(!so.exist(obj)){return};so.f(obj);so.id(obj).select()};
//--- so.f
so.f = function(obj){if(!so.exist(obj)){return};so.id(obj).focus()};
//--- so.v
so.v = function(obj,val){if(!val && val!=0){so.trim(obj); return so.id(obj).value}else{so.id(obj).value = val}};
//--- so.ih
so.ih = function(obj,val){if(!val && val!=0){return so.id(obj).innerHTML}else{so.id(obj).innerHTML = val}};
//--- so.it
so.it = function(obj,val){
if(!val && val!=0){
return (_ie ? so.id(obj).innerText : so.id(obj).textContent);
}else{
_ie ? (so.id(obj).innerText = val) : (so.id(obj).textContent = val);
}
};
//--- so.is_hide
so.is_hide = function(obj){return (so.ids(obj).display==''?false:true)};
so.is_show = function(obj){return (!so.is_hide(obj))};
//--- so.hs
so.hs = function(objs_hide,objs_show){so.hide(objs_hide); so.show(objs_show)};
//--- so.ivlt
so.ivlt = function(obj,opt,sep1,sep2){
sep1 || (sep1=';');
sep2 || (sep2=':');
if(typeof(opt)=='string'){opt = u.str2hash(opt,sep1,sep2);}
if(opt['not_blank']){if (so.blank(obj)){return true}};
if(opt['chars']){if (so.v(obj).match(new RegExp('[^'+opt['chars']+']'))){alert(_l['en']['so_ivlt']+opt['chars'].replace(/\\/g,''));so.sl(obj);return true}};
if(opt['email']){if (so.not_email(obj)){return true}};
return false;
};
//--- so.kd
so.kd = function(e,inf,alt,ctrl,shift){
var k = e.keyCode;
if(!(k==9 || k==13)){return true}
if(alt && !e.altKey ){return true}
if(shift && !e.shiftKey){return true}
if(ctrl && !e.ctrlKey ){return true}
inf = u.str2hash(inf);
var s = inf['s'],t = inf['t'],st = inf['st'];
switch(k){
case 9: //- tab
if(e.shiftKey){if(!st){break;} so.f(st); return false;}
if(!t){break;} so.f(t); return false;
break;
case 13: //- enter
if(!s){break;} so.id(s).click(); return false;
break;
}
return true;
};
//--- so.opt
so.opt = function(obj) { return so.id(obj).options[so.id(obj).selectedIndex]};
//--- so.not_email
so.not_email = function(obj){
so.trim(obj);if(so.v(obj)==''){return false}
var _lt = 'en';
var str = so.v(obj),not_ok=false;
if(str.match(/\s+/)){alert(_l[_lt]['so_not_email'][0]);not_ok=true}
if(str.match(/\.{2,}/)){alert(_l[_lt]['so_not_email'][1]);not_ok = true}
if(str.match(/@{2,}/)){alert(_l[_lt]['so_not_email'][2]);not_ok= true}
if(str.match(/\.@|@\./)){alert(_l[_lt]['so_not_email'][3]);not_ok=true}
if(str.match(/^@|^\.|@$|\.$/)){alert(_l[_lt]['so_not_email'][4]);not_ok=true}
var arr_str = str.split(/@/);
if(arr_str.length != 2){alert(_l[_lt]['so_not_email'][5]);not_ok=true}
if(str.match(/[^\w@\.-]/)){alert(_l[_lt]['so_not_email'][6]);not_ok=true}
not_ok && so.id(obj).select();
return not_ok;
};
return so;
//- =================
}
//--------
function make_utilities(f){
//- =================
var u = new Object;
//--- u.make_cmb
u.make_cmb = function(id,hash,attr,def){
attr || (attr='');
def || (def='\275\275');
var str = '';
};
//--- u.trim
u.trim = function(str) { return str.replace(/^\s+|\s+$/g,'')};
//--- u.str2hash
u.str2hash = function (inf,sep1,sep2){
//-str='key1:val1;key2:val2;...';
var a,i,t;
sep1 || (sep1 = ';'); sep2 || (sep2 = ':');
inf || (inf = '');
var a = inf.split(sep1);
inf = new Object;
for(i in a){t = u.trim(a[i]).split(sep2);inf[t[0]] = t[1];}
return inf;
};
//--- u.hash
u.hash = function(arr_key,arr_value){
var b = arr_key.length-1,i,obj=new Object;
for(i=0;i<=b;i++){obj[arr_key[i]] = (arr_value ? arr_value[i] : true)}
return obj;
};
//--- u.ivl_date(dt,no_msg)
u.ivl_date = function(dt,no_msg){
var t,tm='0';
dt = dt.toString();
var msg = _l['en']['ivl_date'];
if(dt.match(/[^0-9]/)){!no_msg && alert(msg);return true}
if(!(dt.length == 8 || dt.length == 14)){!no_msg && alert(msg);return true}
var _chk_date = function(_dt){
var _dom = [0,31,28,31,30,31,30,31,31,30,31,30,31];
_dt = _dt.match(/(\d{4})(\d{2})(\d{2})/);
var yyyy = parseInt(u.n0(_dt[1]));
var m = parseInt(u.n0(_dt[2])); var d = parseInt(u.n0(_dt[3]));
if(isNaN(yyyy) || isNaN(m) || isNaN(d) || m < 1 || m > 12 || d < 1 || d > 31){return false}
if(m==2){
(yyyy % 4==0) && (_dom[2] = 29);
(yyyy % 100==0) && ((yyyy/100) % 4 != 0) && (_dom[2] = 28);
}
if(d > _dom[m]){return false}
return true;
};
var _chk_time = function(_tm){
var ok;
_tm = _tm.match(/(\d{2})(\d{2})(\d{2})/);
var h = u.n0(_tm[1]); h = h == '' ? 0 : parseInt(h);
var n = u.n0(_tm[2]); n = n == '' ? 0 : parseInt(n);
var s = u.n0(_tm[3]); s = s == '' ? 0 : parseInt(s);
if(isNaN(h) || isNaN(n) || isNaN(s) || h < 0 || h > 23 || n < 0 || n > 59 || s < 0 || s > 59){return false}
return true;
};
if(dt.length==14){
t = dt.match(/(.{8})(.{6})/);
dt = t[1]; tm = t[2];
}
if(!_chk_date(dt)){!no_msg && alert(msg);return true}
if(tm.length==6){
if(!_chk_time(tm)){!no_msg && alert(msg);return true}
}
return false;
};
//--- u.make_hidden_input
u.make_hidden_input = function(d,sep1,sep2){
sep1 || (sep1=',');sep2 || (sep2=':');
var i,t,t1,s='';
d = d.split(sep1);
for(i in d){
t = d[i].split(sep2);
if(t.length==1){
t1 = 'name="'+t+'"';
}else{
t1 = 'name="'+t[0]+'" value="'+t[1]+'"';
}
s+='';
}
return s;
};
//--- u.n0
u.n0 = function(str){return str.replace(/^0+/,'')};
//--- u.kd
u.kd = function(kd_str){
return ''+
'onkeypress="return event.keyCode==9 ? false : true" '+
'onkeydown="return so.kd(event,\''+kd_str+'\')"'
};
u.text2html = function(str){
return str.replace(/&/g,'&'
).replace(//g,'>'
).replace(/"/g,'"'
).replace(/'/g,'''
).replace(/\n/g,'
'
).replace(/\r/g,'');
};
//--- u.get_rnd
u.get_rnd=function(arr){
var l=arr.length-1;
var r = Math.random()*l;
return arr[Math.floor(r==l ? r-1 : r)];
};
return u;
//- =================
}
//--------
self.so = make_self_object(self);
self.u = make_utilities(self);
self.framework_load=true;
var menuids=new Array("verticalmenu") //Enter id(s) of UL menus, separated by commas
var submenuoffset=-2 //Offset of submenus from main menu. Default is -2 pixels.
function createcssmenu(){
for (var i=0; i