function checkFields(formName) { // check if all required fields are filled var theForm = document.getElementById(formName); var rx = new RegExp('[^_]+__[^_]+'); for (var i = 0; i < theForm.elements.length; i++) { if (theForm.elements[i].name) if (theForm.elements[i].name.match(rx)) { var error = false; if ((theForm.elements[i].name) && (theForm.elements[i].value == '')) error = true; else if ((theForm.elements[i].options) && (theForm.elements[i].options[theForm.elements[i].selectedIndex].text == '- Válassz -')) error = true; if (error) { alert('' + theForm.elements[i].title); theForm.elements[i].focus(); return false; } } } return true; } function checkEmail(field) { if (!document.getElementById(field)) return 1; var rx = /^[\w][-\w._]*[@][\w][-\w._]*[.][\w][\w]{1,4}$/i; var e = document.getElementById(field); var ok = rx.test(e.value); if (!ok) { alert('Invalid e-mail address'); e.focus(); } return ok; } function checkAll(op) { // (un)check all checkboxes in a list view var rx = new RegExp('checked_[^*]+'); var theForm; for (var i = 0; i < document.forms.length; i++) { theForm = document.forms[i]; for (var j = 0; j < theForm.elements.length; j++) { if (theForm.elements[j].name) if (theForm.elements[j].name.match(rx)) { theForm.elements[j].checked = op; } } } return true; } function checkList() { // (un)check all checkboxes in a list view var rx = new RegExp('checked_([^*]+)'); var theForm; var retString=''; for (var i = 0; i < document.forms.length; i++) { theForm = document.forms[i]; for (var j = 0; j < theForm.elements.length; j++) { if (theForm.elements[j].name){ var result = theForm.elements[j].name.match(rx); if ((result)&&(theForm.elements[j].checked)) { retString=retString + result[1] + ','; } } } } return retString; } function toggleCheck(cb) { // toggle a checkbox document.getElementById(cb).checked = !document.getElementById(cb).checked; } function showPage() { var mid = document.getElementById('body'); mid.style.display = 'block'; } function clearForm(formName) { var theForm = document.getElementById(formName); var rx = new RegExp('field_[_]?(.*)'); var rx2 = new RegExp('form_[_]?(.*)'); var rx3 = new RegExp('search_[_]?(.*)'); for (var i = 0; i < theForm.elements.length; i++) { if ((theForm.elements[i].name.match(rx))||(theForm.elements[i].name.match(rx2))||(theForm.elements[i].name.match(rx3))){ if (theForm.elements[i].type=='checkbox') theForm.elements[i].checked = false; if ((theForm.elements[i].type=='text')||(theForm.elements[i].type=='textarea')) theForm.elements[i].value = ''; if (theForm.elements[i].type=='select-one') theForm.elements[i].selectedIndex = 0; if (theForm.elements[i].type=='hidden') theForm.elements[i].value = ''; } } return false; } function insertOldSchool(theSel, newText, newValue) { if (theSel.length == 0) { var newOpt1 = new Option(newText, newValue); theSel.options[0] = newOpt1; theSel.selectedIndex = 0; } else if (theSel.selectedIndex != -1) { var selText = new Array(); var selValues = new Array(); var selIsSel = new Array(); var newCount = -1; var newSelected = -1; var i; for(i=0; i=0; i--) { if(theSel.options[i].selected) { theSel.options[i] = null; } } if (theSel.length > 0) { theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1; } } } function parseOldSchool(theSel){ var str = new String(); var delimiter = ''; for(i=0; i 58)&&(window.event && window.event.keyCode != 8)) return false; //alert(window.event.keyCode); //return false; } /* * PHP Serialize * Morten Amundsen * mor10am@gmail.com */ function php_serialize(obj) { var string = ''; if (typeof(obj) == 'object') { if (obj instanceof Array) { string = 'a:'; tmpstring = ''; count = 0; for (var key in obj) { tmpstring += php_serialize(key); tmpstring += php_serialize(obj[key]); count++; } string += count + ':{'; string += tmpstring; string += '}'; } else if (obj instanceof Object) { classname = obj.toString(); if (classname == '[object Object]') { classname = 'StdClass'; } string = 'O:' + classname.length + ':"' + classname + '":'; tmpstring = ''; count = 0; for (var key in obj) { tmpstring += php_serialize(key); if (obj[key]) { tmpstring += php_serialize(obj[key]); } else { tmpstring += php_serialize(''); } count++; } string += count + ':{' + tmpstring + '}'; } } else { switch (typeof(obj)) { case 'number': if (obj - Math.floor(obj) != 0) { string += 'd:' + obj + ';'; } else { string += 'i:' + obj + ';'; } break; case 'string': string += 's:' + obj.length + ':"' + obj + '";'; break; case 'boolean': if (obj) { string += 'b:1;'; } else { string += 'b:0;'; } break; } } return string; } function Base(str){ this.str = str; } var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function encodeBase64() { var input = this.str; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while (i < input.length); return output; } Base.prototype.encodeBase64 = encodeBase64; function base64serialize(formName){ var arr = new Array(); var rxform = new RegExp('form_[^_]+'); var rxfield = new RegExp('field_[^_]+'); var result; var theForm = document.getElementById(formName); for (var i = 0; i < theForm.elements.length; i++) { if ((theForm.elements[i].name)&&(theForm.elements[i].value!='')) //&& ((theForm.elements[i].name.match(rxform))||(theForm.elements[i].name.match(rxfield))) ) arr[theForm.elements[i].name] = htmlEntities(theForm.elements[i].value); } b = new Base(php_serialize(arr)); result = b.encodeBase64(); return result; } function htmlEntities(input) { //text in the input text area var v = input var f = document.forms[0]; /* if(f.remove_spaces.checked) {//remove spaces, tabs, line breaks in the text v = v.replace(/\s+/, ''); //or, remove line breaks in the text and spaces/tabs surrounding the text //v = v.replace(/[\n\r]+/g, '\n').replace(/^\s+/, '').replace(/\s+$/, ''); } */ //whether convert ranodomly chosen characters or every characters var rnd_conv = false; //f.random_convert.checked; //characters to be always converted regardless of 'rnd_conv' var conv_chars = String.fromCharCode(225,233,237,243,246,337,250,252,369,193,201,205,211,214,336,218,220,368/*,256,257,258,259,298,299,354,355,350,351*/); //f.convert_chars.value; //output format for conversion (0=mixed/1=decimal/2=hex) var format = 1;//f.entity_format.selectedIndex; var s=''; //converted string will be stored in this variable var c; // temporary variable for each characters in the text for(var i=0; i=0) { c = c.charCodeAt(0); if( (format == 2) || ((format == 0) && (Math.random()<0.5)) ) c = 'x'+ c.toString(16); c = '&#'+ c + ';' } s += c; } //the output text area return s; } function setPointer() { if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'wait'; } function resetPointer() { if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'default'; } var popup_array = new Array(); function createpopup(popup_name,x,y){ if(!document.getElementById(popup_name)){ var rx = new RegExp('auto_complete'); if(!x) x = 0; if(!y) y = 0; if(!popup_array.length) lngth = 1; else lngth = popup_array.length; popup_array[lngth] = popup_name; var newelement = document.createElement('div'); newelement.setAttribute('id',popup_name); if(popup_name.match(rx)) newelement.className='auto_complete'; else newelement.className='popup'; var sp2 = document.getElementById('entry_point'); var parentDiv = sp2.parentNode; parentDiv.insertBefore(newelement,sp2); document.getElementById(popup_name).style.zIndex='1000'; document.getElementById(popup_name).style.top=(y)+'px'; document.getElementById(popup_name).style.left=(x)+'px'; document.getElementById(popup_name).style.display='inline'; } else{ document.getElementById(popup_name).innerHTML=''; document.getElementById(popup_name).style.zIndex='1000'; document.getElementById(popup_name).style.top=(y)+'px'; document.getElementById(popup_name).style.left=(x)+'px'; document.getElementById(popup_name).style.display='inline'; } /* var str = new String; str=''; for(i=1;i < popup_array.length;i++) str = str + popup_array[i]+"\n"; alert(str);*/ } function clearpopup(popup_name){ document.getElementById(popup_name).style.display='none'; document.getElementById(popup_name).innerHTML = ''; } function getMousePos(e) { //you need the 'e', although it does NOT need to be defined //NS var a = new Array(); if (document.layers||document.getElementById&&!document.all) { a[0] = e.pageX; a[1] = e.pageY; } //IE else if (document.all) { a[0]=window.event.clientX; a[1]=window.event.clientY; } return a; }