function updateStrength(pw) {
	var strength = getStrength(pw);
	var percentage = Math.round((100/8)*strength);
	manualPB.setPercentage(percentage); 
}

function getStrength(passwd) {
	intScore = 0;
	if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter
	{
		intScore = (intScore+1)
	} 
	if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter
	{
		intScore = (intScore+1)
	} // NUMBERS
	if (passwd.match(/\d+/)) // [verified] at least one number
	{
		intScore = (intScore+1)
	} 
	if (passwd.match(/(\d.*\d)/)) // [verified] at least two numbers
	{
		intScore = (intScore+1)
	} // SPECIAL CHAR
	if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character
	{
		intScore = (intScore+1)
	} 
	if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
	{
		intScore = (intScore+1)
	} 
	if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
	{
		intScore = (intScore+1)
	} // [Verified] Upper Letters, Lower Letters, numbers and special characters
	if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/))
	{
		intScore = (intScore+1)
	}
	return intScore;
}

function window_opener(url, width, height) {
   height = height ? height : 550;
   width = width ? width : 600;
   window.open(url,'_blank','alwaysRaised=yes,dependent=yes,height='+height+',width='+width+',menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
   return false;
}


function trim(str) {
     s = str.replace(/^(\s)*/, '');
     s = s.replace(/(\s)*$/, '');
     return s;
}


function number_format(num)
{
	num = '' + num;
	for (i=num.length; i>0; i-=3)
	{
		num = num.substr(0, i) + ' ' + num.substr(i);
	}
	return num;
}

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 setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	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() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : ';path=/' ) +		
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function getElementsByClassName(searchClass, node, tag)
{
	var classElements = new Array();
	if (node == null)
	{
		node = document;
	}
	if (tag == null)
	{
		tag = '*';
	}
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++)
	{
		if (pattern.test(els[i].className))
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function default_filter(col)
{
	if (document.getElementById(col) && document.getElementById(col).value==document.getElementById(col).defaultValue) 
	{
		document.getElementById(col).value = '';
	}
} 

function CreateBookmarkLinkorAddToFavourite(title, url) { 
	
	if (window.sidebar) { // Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) { // IE Favorite		
		window.external.AddFavorite( url, title); 
	}	else if(window.opera && window.print) { // Opera Hotlist		
		return true; 
	} 

} 

function CreateBookmarkLinkorAddToFavouriteLink(title, url) { 
	if (window.sidebar) {  
		document.write('<a href="#" onclick="javascript:CreateBookmarkLinkorAddToFavourite(\''+title+'\', \''+url+'\'); return false;">Legyen a Pistabá a könyvjelzőm!</a>');  
	} else if (window.external) {  
		document.write('<a href="#" onclick="javascript:this.style.behavior=\'url(#default#homepage)\'; this.setHomePage(\''+url+'\'); return false;">Legyen a Pistabá a kezdőlapom!</a>');   
	} else if (window.opera && window.print) {	   
		document.write('<a href="#" onclick="javascript:CreateBookmarkLinkorAddToFavourite(\''+title+'\', \''+url+'\'); return false;">Legyen a Pistabá a könyvjelzőm!</a>'); 
	} 
}

function show_hide(id)
{
	var field=document.getElementById(id);
	var link = document.getElementById('show_hide_link_'+id);
	if(field.style.display=='block')
	{
		if(link)
		{
			link.innerHTML = '+';
		}
		field.style.display='none';
	}
	else
	{
		if(link)
		{
			link.innerHTML = '-';
		}
		field.style.display='block';
	}
}

function clearSelect(select) {
	var select_options = select.options;
	for(var i=select_options.length-1; i>=0; i--) {
		select.removeChild(select.options[i]);
	}
}

function newTipus() {
	
	$('tipus_cont').innerHTML = '';
	//removeChild($('tipus'));
	
	var	sel = document.createElement('select'); 
	sel.setAttribute('name', 'tipus');
	sel.setAttribute('id', 'tipus');
	$('tipus_cont').appendChild(sel);
}
