//********************************************************************
//							COOKIE
//********************************************************************
function SetCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
		var expires_date = new Date( today.getTime() + (expires) );
	}

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function onChangeSelectTab(/*input type select element*/selectElement,/*Array of Elements*/containerArray,/*addEvent boolean*/addEvent)
{
	if (addEvent)
	{
		Event.observe(selectElement,'change',function(e) { onChangeSelectTab(selectElement,containerArray,false); });
	}
	else
	{	
		selectedIndex=Number(selectElement.value);
		
		for (var i=0;i<containerArray.length;i++)
		{
			if (i===selectedIndex)
			{
				if (containerArray[i]!==null)
					containerArray[i].style.display='';
			}
			else
			{				
				if (containerArray[i]!==null)
					containerArray[i].style.display='none';
			}			
		}
	}
}
							

// this function gets the cookie, if it exists
function GetCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function findFormNodeAnchestor(node) {
	node=toNode(node);
	while(node && node.tagName!='FORM')
		node=node.parentNode;
//	alert(node.tagName);
	if (node.tagName=='FORM')
		return node;
}

function findParentNode(node,tagName)
{
	if (typeof(tagName)=='string')
	{
		tagName=tagName.toUpperCase();
		while(node && node.tagName!=tagName)
			node=node.parentNode;
		if (node && node.tagName==tagName)
			return node;
	}
	else
	{
		while(node && node!=tagName)
			node=node.parentNode;
		if (node && node==tagName)
			return node;		
	}	
}


function print_r( e ) 
{
	var msg='';
	for (var propName in e)
		msg = msg+','+"\n"+propName;
	alert(msg);   
}

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 

function setComboValue(el,value)
{
	for (var i=0;i<el.options.length;i++)
		if (el.options[i].value==value)
			return el.selectedIndex=i;
	return -1;			
}

function toNode(node)
{
	if (typeof node != 'object')
		return document.getElementById(node);
	return node;
}

// this deletes the cookie when called
function DeleteCookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function fireEvent(element,eventToFire)
{
	if( document.createEvent )
	{//FF
		switch (eventToFire.toLowerCase())
		{
			case 'abort':
			case 'blur':
			case 'change':
			case 'error':
			case 'focus':
			case 'load':
			case 'reset':
			case 'resize':
			case 'scroll':
			case 'select':
			case 'submit':
			case 'unload':
				var evObj = document.createEvent('HTMLEvents');
				evObj.initEvent(eventToFire,true,true);
			break;
			case 'click':
			case 'mousedown':
			case 'mousemove':
			case 'mouseout':
			case 'mouseover':
			case 'mouseup':
				var evObj = document.createEvent('MouseEvents');
				evObj.initMouseEvent(eventToFire, true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null );
			break;
			case 'keydown':
			case 'keyup':
				var evObj = document.createEvent('KeyboardEvent');
				evObj.initKeyEvent (eventToFire, true, true, null, false, false, false, false, 9, 0);
				break;
		}

	  if (evObj)
	  {
	  	element.dispatchEvent(evObj);
	  }
	} else if( document.createEventObject )
	{//IE
		element.fireEvent('on'+eventToFire);
	}
	
}

//CLEARBOX EMBED MEDIA PLAYER BUGFIX
if (typeof(CB_Close)=='function')
{
	var oldCB_Close=CB_Close;
	CB_Close = function() 
	{
		if (window.embedbody)	window.embedbody.innerHTML='';
		oldCB_Close();		
		return true;
	}
	
}

function arrayUnique(array)
{
	var retVal = new Array();
	for (var v = 0;v<array.length;++v)
	{
		if (!in_array(array[v],retVal))
			retVal[retVal.length] = array[v];
		
	}
	return retVal;
}

function in_array(value,array)
{
	for (var v = 0;v<array.length;++v)
		if (array[v] == value)
			return true
	return false;
}

function arrayOfObjectUniqueByProperties(array)
{
	var retVal = new Array();
	for (var v = 0;v<array.length;++v)
	{
		if (!in_arrayOfObjectByProperties(array[v],retVal))
			retVal[retVal.length] = array[v];
		
	}
	return retVal;
}

function in_arrayOfObjectByProperties(value,array)
{
	for (var v = 0;v<array.length;++v)
		if (compareObjectsByProperties(array[v],value))
			return true
	return false;
}

function attachElementEvent(elements,eventNames,f)
{
	for (var i=0;i<elements.length;i++)
	{
		if (elements[i])
			for (var a=0;a<eventNames.length;a++)
			{
				if (window.attachEvent)	elements[i].attachEvent('on'+eventNames[a],f);
				else	{elements[i].addEventListener(eventNames[a],f, false)};
			}
	}
}

function getElementsByClass(className,tagType,root)
{
	if(!root)
		root=document;
	if (!tagType)
		tagType='*';
	var all = root.getElementsByTagName(tagType)
	var arr = []
	for(var k=0;k<all.length;k++) {
		if((cl=getClassName(all[k])) == className || (' '+cl+' ').indexOf(' '+className +' ')>-1)
			arr[arr.length] = all[k];
	}
	return arr
}


function getClassName(el,useAttr){
	if (typeof(el)=='object' && el!=null)
		return ((useAttr && el.getAttribute('class'))?el.getAttribute('class')+' ':'')+((tClass=el.className)?tClass:'');
	else
		return '';
}

function addClassName(id,class_name,el,useAttr,context){
	if (!el) el = getElementByIdCtx(id,context);
	class_string = ' '+getClassName(el,useAttr)+' ';
	if (class_string.indexOf(' '+class_name+' ') < 0 && el!=null)
	{
		el.className = class_string + ' ' + class_name;
		return true;
	}
	return false;
}

function removeClassName(id,class_name,el,context){
	if (!el) el = getElementByIdCtx(id,context);
	if (el)
		el.className = getClassName(el).replace(class_name, "");
	return true;
}

function startAlbumSlideShow(url)
{
	new Ajax.Request(url, 
	{
		method:'get',
		onSuccess:function(transport)
		{
			$('ajaxslideshowcontainer').innerHTML='';
			res=eval(transport.responseText);									
			if (typeof(res) == 'object')
			{
				for (var i=0;i<res.length;i++)
				{
					$('ajaxslideshowcontainer').appendChild(aEl=document.createElement('a'));
					aEl.setAttribute('href',res[i].url);
					aEl.setAttribute('title',res[i].lead);
					if (i==0)	aEl.setAttribute('id','firstclearbox');
					aEl.setAttribute('rel','clearbox[gallery='+res[i].album+',,slideshowtime=5,,autoslideshow]');
					var imgEl=document.createElement('img');
					imgEl.style.display='none';
					imgEl.setAttribute('src',res[i].thurl);
					aEl.appendChild(imgEl);
				}
				CB_Init();										
				fireEvent($('firstclearbox'),'click');										
			}
		}					
	});
}

function nameToSafeUniqueURL(str)
{
	str=str.toLowerCase();
	
	str=str.replace(/[ő]/g,"o");str=str.replace(/[ó]/g,"o");str=str.replace(/[ö]/g,"o");
	str=str.replace(/[ú]/g,"u");str=str.replace(/[ű]/g,"u");str=str.replace(/[ü]/g,"u");
	str=str.replace(/á/g,"a");str=str.replace(/é/g,"e");str=str.replace(/í/g,"i");
	str=str.replace(/[^a-zA-Z0-9_]/g, ' ');
 	str=str.replace(/\s+/g,'_');
	return (str.substr(-1)=='_')?str.substr(0,str.length-1):str;
}

function changeCheckBoxes(container,flag,chClass)
{
	for (var i=0;i<(el=container.getElementsByTagName('input')).length;i++)
		if (i>0 && el[i].className==chClass) 
			el[i].checked=flag;
}

function selectMenuJS(mainMenu,subMenu)
{
	if (mainMenu)
		for (var i=0;i<(el=$$('div#main_menu li a')).length;i++)
			if (el[i].childNodes[0] && el[i].childNodes[0].data==mainMenu)
				el[i].parentNode.className+=' selected';
				
		for (var i=0;i<(el=$$('div#main_submenu li a')).length;i++)
			if (el[i].childNodes[0] && el[i].childNodes[0].data==subMenu)
				el[i].parentNode.className+=' selected';
}

function strip_tags (str, allowed_tags) {
    // Strips HTML and PHP tags from a string  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strip_tags
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Marc Palau
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Eric Nagel
    // +      input by: Bobby Drake
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Tomasz Wesolowski
    // *     example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
    // *     example 4: strip_tags('1 < 5 5 > 1');
    // *     returns 4: '1 < 5 5 > 1'
    var key = '', allowed = false;
    var matches = [];
    var allowed_array = [];
    var allowed_tag = '';
    var i = 0;
    var k = '';
    var html = '';

    var replacer = function (search, replace, str) {
        return str.split(search).join(replace);
    };

    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
    }

    str += '';

    // Match tags
    matches = str.match(/(<\/?[\S][^>]*>)/gi);

    // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;
        }

        // Save HTML tag
        html = matches[key].toString();

        // Is tag not in allowed list? Remove from str!
        allowed = false;

        // Go through all allowed tags
        for (k in allowed_array) {
            // Init
            allowed_tag = allowed_array[k];
            i = -1;

            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

            // Determine
            if (i == 0) {
                allowed = true;
                break;
            }
        }

        if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }

    return str;
}

function ksort (array, sort_flags) {
    // Sort an array by key  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/ksort
    // +   original by: GeekFG (http://geekfg.blogspot.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // %          note: The examples are correct, this is a new way
    // -    depends on: i18n_loc_get_default
    // *     example 1: data = {2: 'van', 3: 'Zonneveld', 1: 'Kevin'};
    // *     example 1: ksort(data);
    // *     results 1: data == {1: 'Kevin', 2: 'van', 3: 'Zonneveld'}
    // *     returns 1: true
    var tmp_arr={}, keys=[], sorter, i, key, that=this;

    switch (sort_flags) {
        case 'SORT_STRING': // compare items as strings
            sorter = function (a, b) {
                return that.strnatcmp(a, b);
            };
            break;
        case 'SORT_LOCALE_STRING': // compare items as strings, based on the current locale (set with  i18n_loc_set_default() as of PHP6)
            var loc = this.i18n_loc_get_default();
            sorter = this.php_js.i18nLocales[loc].sorting;
            break;
        case 'SORT_NUMERIC': // compare items numerically
            sorter = function (a, b) {
                return (a - b);
            };
            break;
        case 'SORT_REGULAR': // compare items normally (don't change types)
        default:
            sorter = function (a, b) {
                if (a > b) {
                    return 1;
                }
                if (a < b) {
                    return -1;
                }
                return 0;
            };
            break;
    }

    // Make a list of key names
    for (key in array) {
        keys.push(key);
    }

    keys.sort(sorter);

    // Rebuild array with sorted key names
    for (i = 0; i < keys.length; i++) {
        key = keys[i];
        tmp_arr[key] = array[key];
        delete array[key];
    }
    for (i in tmp_arr) {
        array[i] = tmp_arr[i];
    }

    return true;
}

function zxcPos(zxcobj,relativePos)
{
	res=zxcobj.cumulativeOffset();
	
	return [res.left,res.top];
}

function generateAutoKeywords(tinyMCEElementId,resultContainer,tagElementId,titleElement)
{	
	var resultString='';	
	if (tinyMCE && tinyMCE.get(tinyMCEElementId) && (htmlContent=tinyMCE.get(tinyMCEElementId).getContent()) && htmlContent && resultContainer && tagElementId)
	{
		var tagElement=$(tagElementId);
		var wordList=[];
		for (var i=0;i<(w=tagElement.value.split(',')).length;i++)
			wordList[wordList.length]=(trim(w[i]));
			 
		new Ajax.Request('/?-=blog_ajaxkeywords',{
			asynchronous: false,
			parameters: {'text':htmlContent+((titleElement)?','+titleElement.value:'')},
			onSuccess : function(transport)
			{			
				var res=eval(transport.responseText);
				if (typeof(res)==='object')
				{		
					for (var i=0;i<res.length;i++)
						if (wordList.indexOf(res[i].word)<0)
							resultString+='<input type="checkbox" value="'+res[i].word+'"/>'+res[i].word+' ('+res[i].count+')</a><br/>';
					resultContainer.innerHTML=(resultString.length===0)?'Üres lista':resultString;
				}
			}
		});
	}
}

function toInt(str)
{
	return parseInt(str,10);
}

function trim (str) 
{
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function toggleEditor(id) {
    if (!tinyMCE.getInstanceById(id)) {
        tinyMCE.execCommand("mceAddControl", false, id);
    } else {
        tinyMCE.execCommand("mceRemoveControl", false, id);
    }
}

function factorial (n)
{ 
	if (n == 0)	return 1;
  	else	return n * factorial(n-1);
}

function openPopupWindow(url,id)
{
	window.open(url,id,'scrollbars=yes,resizable=no,width=500,height=625,screenX=500,screenY=100,top=150,left=300');
}

MaskInput = function(f, m){
	
	addEvent = function(o, e, f, s){
		var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
		r[r.length] = [f, s || o], o[e] = function(e){
			try{
				(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
				e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
				e.target || (e.target = e.srcElement || null);
				e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
			}catch(f){}
			for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
			return e = null, !!d;
	    }
	};
	
	removeEvent = function(o, e, f, s){
		for(var i = (e = o["_on" + e] || []).length; i;)
			if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
				return delete e[i];
		return false;
	};
	
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask);
};

function qsort(a,compareCallback){

	if (a.length <= 1){return a;}

	var p = a[0];
	var gr = [];
	var ls = [];

	for(i=1;i<a.length;i++){
		if (compareCallback(a[i],p) <0 ){
			ls.push(a[i]);
		}
		else{
			gr.push(a[i]);
		}
	}

	ls = qsort(ls,compareCallback);
	gr = qsort(gr,compareCallback);
	ls.push(p)

	return ls.concat(gr);
}

function removeKey(arrayName,key)
{
	var x;
	var tmpArray = new Array();
	for(x in arrayName)
	{
		if(x!=key) { tmpArray[x] = arrayName[x]; }
	}
	return tmpArray;
}

function number_format(number, decimals, dec_point, thousands_sep) {
    // Formats a number with grouped thousands  
    // 
    // version: 1004.1212
    // discuss at: http://phpjs.org/functions/number_format    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival    // +      input by: Kheang Hok Chin (http://www.distantia.ca/)
    // +   improved by: davook
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Jay Klehr
    // +   improved by: Brett Zamir (http://brett-zamir.me)    // +      input by: Amir Habibi (http://www.residence-mixte.com/)
    // +     bugfix by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Theriault
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');
    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);    // *     returns 9: '1'
    // *    example 10: number_format('1.20', 2);
    // *    returns 10: '1.20'
    // *    example 11: number_format('1.20', 4);
    // *    returns 11: '1.2000'    // *    example 12: number_format('1.2000', 3);
    // *    returns 12: '1.200'
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }    return s.join(dec);
}
	function isKeynumControlKey(keynum,e)
	{
		return (
			e && e.ctrlKey && (keynum == 99 || keynum ==  120 || keynum == 118 || keynum == 86 || keynum == 88 || keynum == 67) || //(CTRL + c,v,x,C,V,X

			keynum == 9 || // tab
			keynum == 13 || //enter
			keynum == 17 || //ctrl
			keynum == 27 || //esc
			(keynum >= 33 && keynum <= 40) || // arrows, home, end, page up, down
			keynum == 45 || // insert
			//keynum == 46 || //delete
			keynum == 8 //back space
		);
	}
	
	function filterIntInput(e)
	{
		var keynum;
	
		if(window.event) // IE
		{
			e=window.event;
			keynum = e.keyCode;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}
		
		var ok = (!keynum ||keynum >= 48 && keynum <= 57 || isKeynumControlKey(keynum,e) );
		if (!ok)
		{
			if (e.preventDefault)
				e.preventDefault();
		}
		return ok;
	}
