function createImageContainer(mainContainer,divClassName)
{

	if (el=document.getElementById(mainContainer))
	{
		for (var i=0;i<(el=document.getElementsByTagName('img')).length;i++)
		{
			tmpDiv=document.createElement('div');
			tmpDiv.className=divClassName;
			tmpDiv.appendChild(el[i].cloneNode(false));
			el[i].parentNode.replaceChild(tmpDiv,el[i]);
		}
		
	}
}

function setHome()
{
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}

function decodeAddr(protectedAddr, domId, textAfterHover){
   var cleanAddr='';
   for(i=0; i < cleanAddr.length+1; i+=2){
      thisPiece=protectedAddr.substring(i,i+2);
      cleanAddr=cleanAddr.concat(thisPiece.charAt(1), thisPiece.charAt(0));
   }
   if(textAfterHover == 'decode'){
     textAfterHover = cleanAddr;
   }
   cleanAddr=textAfterHover.link('mailto:'+cleanAddr);
   document.getElementById(domId).innerHTML=cleanAddr;
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};

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 SEOUrlOnKeyUpFunction(s)
{
	document.getElementById('seourl_id').value=nameToSafeUniqueURL(s.value);	
}

function generateClearboxLinks(container,clearboxClassName)
{
	if (container && clearboxClassName && typeof(CB_Init)=='function')
	{		
		imgList=container.getElementsByTagName('img');
		for (var i=0;i<imgList.length;i++)
		{
			if (imgList[i].className.indexOf(clearboxClassName)>-1)
			{
				imgList[i].title='A nagyításhoz kattintson a képre!';
				aElement=document.createElement('a');
				aElement.className='c_l_e_a_r_b_o_x_link';
				aElement.setAttribute('href',imgList[i].src.replace('/resize/','/original/'));
				aElement.setAttribute('rel','clearbox');
				aElement.title='A nagyításhoz kattintson a képre!';
				imgList[i].parentNode.insertBefore(aElement,imgList[i]);
				aElement.appendChild(imgList[i]);
			}
		}
		
		CB_Init();
	}
}

function writeFlash(title, w, h) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.0.0" width="' + w + '" height="' + h + '" ID="sf" VIEWASTEXT>')
    document.write('  <param name="movie" value="' + title + '.swf" />')
    document.write('  <param name="quality" value="high" />')
    document.write('  <param name="wmode" value="transparent" />')
    document.write('  <param name="allowScriptAccess" value="always" />')
    document.write('  <param name="allowFullScreen" value="true" />')
    document.write('  <embed src="' + title + '.swf" quality="high" name="sf" allowScriptAccess="always" wmode="transparent" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed>')
    document.write('</object>')
}
