﻿// JScript File
function _gel(a) { /*get element*/ return document.getElementById ? document.getElementById(a) : document.all ? document.all[a] : document.layers ? document[a] : null }
function _gelstn(a, b) { /*get elements by tagname in node a*/ if(b) { return a.getElementsByTagName ? a.getElementsByTagName(b) : []; } else { if(a=="*" && document.all) return document.all; return document.getElementsByTagName ? document.getElementsByTagName(a) : []; } }        
function _gneltn(a, b) { /*get next element by tagname after node a*/ var c = a.nextSibling; while(c && c.tagName != b) { c = c.nextSibling; } return c; }        
function _uc(a) { /*to uppercase*/ return a.toUpperCase() }    
function _lc(a) { /*to lowercase*/ return a.toLowerCase() }   
function _trim(a) { /*trim string*/ return a.replace(/^\s*|\s*$/g,"") }    
function _esc(a) { /*encode string*/ return window.encodeURIComponent ? encodeURIComponent(a) : escape(a) }    
function _unesc(a) { /*decode string*/ return window.decodeURIComponent ? decodeURIComponent(a) : unescape(a) }
function _show(a, b) { /*show element*/ var e = _gel(a); if(e) { e.style.display= b ? "block" : "inline"; e.style.visibility="visible"; } }
function _hide(a) { /*hide element*/ var e = _gel(a); if(e) { e.style.display == "none"; } }    
function _hesc(a) { /*convert to hex string*/ a = a.replace(/</g,"&lt;").replace(/>/g,"&gt;"); a = a.replace(/"/g,"&quot;").replace(/'/g,"&#39;"); return a }    
function _striptags(a) { /*strip string from html tags*/ return a.replace(/<\/?[^>]+>/gi,"") }
function _txt(node) { /*get text from xmlnode*/ return (node.textContent || node.innerText || node.text); }          
function _gelh(a) { /*gets the height of an element relative to the layout*/ var e = _gel(a); if(e) { return document.layers ? e.height : e.offsetHeight; } return 0; }    
function _gelw(a) { /*gets the width of an element relative to the layout*/ var e = _gel(a); if(e) { return document.layers ? e.width : e.offsetWidth; } return 0; }
function _cel (a) { /*center element (entire page)*/ var dim = _gwid(); _selp(a, Math.floor((dim[0] - _gelw(a)) / 2), Math.floor((dim[1] - _gelh(a)) / 2)); }
function _toggle(a) { /*show/hide element*/ var e = _gel(a); if(e) { if(e.style.display == "" || e.style.display == "inline") { e.style.display = "none" } else if(e.style.display == "none") { e.style.display="inline" } } }            
function _args() { /*get parameters from current page (GET)*/ var a = {}, b = location.search.substring(1), c = b.split("&"); for(var d = 0; d < c.length; d++) { var e = c[d].indexOf("="); if(e == -1) continue; var f = c[d].substring(0, e), g = c[d].substring(e + 1); g = g.replace(/\+/g," "); a[f] = _unesc(g) } return a }   /*this can only be used with GET method, not POST*/    
function _gelscn (a) { /*get elements by class name*/ var all = _gelstn("*"), elements = new Array(); for (var e = 0; e < all.length; e++) if (all[e].className.indexOf(a) >= 0) elements[elements.length] = all[e]; return elements; }    
function _selp(a, b, c) { /*set element position*/ var e = _gel(a); if(e) { if (document.layers) { e.left = b; e.top = c; e.visibility = 'show'; } else if (document.all || document.getElementById) { e.style.left = b + 'px'; e.style.top = c + 'px'; e.style.visibility = 'visible'; } } }                
function _gos() { /*get offsets (scroll)*/ var x = 0, y = 0; if( typeof( window.pageYOffset ) == 'number' ) { /*Netscape compliant*/ y = window.pageYOffset; x = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { /*DOM compliant*/ y = document.body.scrollTop; x = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { /*IE6 standards compliant mode*/ y = document.documentElement.scrollTop; x = document.documentElement.scrollLeft; } return [ x, y ]; }    
function _gwid() { /*get inner dimensions of window*/ var w = 0, h = 0; if( typeof( window.innerWidth ) == 'number' ) { /*Non-IE*/ w = window.innerWidth; h = window.innerHeight; }else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { /*IE 6+ in 'standards compliant mode'*/ w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { /*IE 4 compatible*/ w = document.body.clientWidth; h = document.body.clientHeight; } return [ w, h ]; }    
function _celscr(a) { /*center element (follow scrolling)*/ var offset = _gos(); var dim = _gwid(); _selp(a, Math.floor((dim[0] - _gelw(a)) / 2), Math.floor(offset[1] + (dim[1] / 2))); }
function _vald(a) {  /*validate date*/ var el = _gel(a); if(el) { var regex = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/; if(!regex.test(el.value)) return false; /*doesn't match pattern, bad date*/ else { var sep = el.value.substring(2,3), date_array = el.value.split(sep); /*create a lookup for months not equal to february*/ var month_array = { '01' : 31,'03' : 31, '04' : 30,'05' : 31, '06' : 30,'07' : 31, '08' : 31,'09' : 30, '10' : 31,'11' : 30,'12' : 31}; var day = parseInt(date_array[0], 10); /*check if month value and day value agree*/ if(month_array[date_array[1]] != null) { if(day <= month_array[date_array[1]] && day != 0) return true; /*found in lookup table, good date*/ } /*check for february*/ var month = parseInt(date_array[1], 10); if (month == 2) { var year = parseInt(date_array[2]); if (day > 0 && day < 29) { return true; } else if(day == 29) { if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) { return true; /*year div by 4 and ((not div by 100) or div by 400) ->ok*/ } } } } } return false; /*any other values, bad date*/ }  

//
function MM_openBrWindow(theURL, winName, features) { window.open(theURL,winName,features); }
function SetLanguage(lang, url) { document.lang.langcode.value = lang; document.lang.targeturl.value = url; document.lang.submit(); }