function StartOnLoad(funct) {
    //setup onload function
    if(typeof window.addEventListener != 'undefined')
    {
        //.. gecko, safari, konqueror and standard
        window.addEventListener('load', funct, false);
    }
    else if(typeof document.addEventListener != 'undefined')
    {
        //.. opera 
        document.addEventListener('load', funct, false);
    }
    else if(typeof window.attachEvent != 'undefined')
    {
        //.. win/ie
        window.attachEvent('onload', funct);
    }
    
    //** remove this condition to degrade older browsers
    else
    {
        //.. mac/ie5 and anything else that gets this far
        
        //if there's an existing onload function
        if(typeof window.onload == 'function')
        {
            //store it
            var existing = onload;
            
            //add new onload handler
            window.onload = function()
            {
                //call existing onload function
                existing();
                
                //call generic onload function
                funct();
            };
        }
        else
        {
            //setup onload function
            window.onload = funct;
        }
    }
}

var changeRegion=function(_rid,_select_text,_cont,_input,_action) {
		_rid=_rid || 1;
		_cont=_cont || 'regioncont';
		_input=_input || 'regioninput';
		_action=_action || '/region/getmultilinedata';
		_select_text || '- válassz -';
		$(_input).value=_rid==0?1:_rid;
		/*new Ajax.Updater(_cont,_action, {
			method: 'post',
			parameters: {regionid: _rid, profile_selector_text: _select_text}
		});*/
        jQuery.ajax({
            url: _action,
            type: 'POST',
            data: 'regionid='+_rid+'profile_selector_text='+_select_text,
            success: function(ret) {
                jQuery('#'+_cont).html(ret);
                fillDesignedSelect(true);
            }
        });
	};


var showwnd=function(url,width,height) {
		window.open(url,'',"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2)+",scrollbars=1");
	};



function Set_Cookie( 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 Tip() {tt_Tip(arguments, null);}
function UnTip() {tt_OpReHref();if (tt_aV[DURATION] < 0 && tt_iState & 2) {tt_tDurt.Timer("tt_HideInit()", - tt_aV[DURATION], true);} else if (!(tt_aV[STICKY] && tt_iState & 2)) {tt_HideInit();}}



var login_popup_state=false;
/**
 * belépő ablak
 */
function login_popup() {
    if(login_popup_state) {
        $('popup_bg_frame').remove();
        //$('login_popup_box_id').hide();
        $('login_popup_box_cnt_id').hide();

        $$('.flashcontent').each(Element.show);

        // el kell tüntetni az ablakot
    } else {
        // fel kell dobni az ablakot
        var h=$(document.body).getHeight();
        var w=$(document.body).getWidth();
        var bg=new Element('div',{id:'popup_bg_frame'});
        bg.setStyle({
             background:'#000'
            ,position:'absolute'
            ,left:'0px'
            ,top:'0px'
            ,width:w+'px'
            ,height:h+'px'
            ,zIndex:1000
        }).setOpacity(0.5);
        document.body.appendChild(bg);

        var dv=document.viewport.getDimensions();
        var so=document.viewport.getScrollOffsets();
        var box={width:570,height:360};
        var top=so.top+dv.height/2-box.height/2;
        var left=so.left+dv.width/2-box.width/2;
        
        //$('login_popup_box_id').setStyle({left:left+'px',top:top+'px'}).show();
        $('login_popup_box_cnt_id').setStyle({left:left+'px',top:top+'px'}).show();
        $$('.flashcontent').each(Element.hide);
    }
    login_popup_state=!login_popup_state;
}


function searcArtcile(_id) {
    location.href='/cikkek/kereses?search=#{search}'.interpolate({search: encodeURIComponent($F(_id))});
}






jQuery(document).ready(function() {
    fillDesignedSelect();
    
    jQuery('.invisible_checkbox').live('click', function() {
        jQuery(this).next('.designed_checkbox').toggleClass('designed_checkbox_selected');
    });
});

function selectOptionValue(obj) {
    var selected_option = jQuery(obj).children(':selected').html();
    jQuery(obj).next('span').html(selected_option);
}

function fillDesignedSelect(selected) {
    var first;
    
    if (typeof(selected)!='undefined' && selected==true) first = 'selected';
    else first = 'first';
    
    jQuery('.designed_select_container select').each(function(index, value) {
        var selected_option = jQuery(this).find('option:'+first).html();
        jQuery(this).next('span').html(selected_option);
    });
}

function showPopup(title, content) {
    var so = document.viewport.getScrollOffsets();
    var box_height = parseInt(jQuery('.karacsony_popup_wrapper').height());
    var karacsony_popup_wrapper_margintop = (so.top- box_height)/2;
    jQuery('.karacsony_popup .title2 h2').html(title);
    jQuery('.karacsony_popup .boxcontent .karacsony_popup_content').html(content);
    jQuery('.karacsony_popup_wrapper').css('margin-top', karacsony_popup_wrapper_margintop);
    jQuery('.karacsony_popup_overlay').show();
    jQuery('.karacsony_popup').show();
}

function closePopup() {
    jQuery('.karacsony_popup_overlay').hide();
    jQuery('.karacsony_popup').hide();
    jQuery('.karacsony_popup .title2 h2').html('');
    jQuery('.karacsony_popup .boxcontent .karacsony_popup_content').html('');
}
