(function($){$.fn.exist=function(){return this.length>0}})(jQuery);
(function($) {
    $.fn.reverse = function(selector) {
        var element = $(this);
        var newelement = $(selector);
        var html = element.html();
        var newhtml = newelement.html();
        element.html(newhtml);
        newelement.html(html);
    }
})(jQuery);

var $j = jQuery.noConflict();

var wnd;

function showwnd(url,wnd,width,height)
{
	return window.open(url,'',"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2));
}
function showChatWindow(userid)
{
    var width=600;
    var height=500;
    
    var wnd= window.open("",'chat_'+userid,"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2)+",toolbar=0,location=0,menubar=0,directories=0,resizable=0");
    
    if (wnd.closedchannel!=null) {
        //alert('Már van chat ablak nyitva ezzel a felhasználóval!');
        wnd.focus();
     } else {
        wnd.document.location.href="/chat.php?act=newchannel&userid="+userid;
        wnd.focus();
        //window.open("chat.php?act=newchannel&userid="+userid,'chat_'+userid,"width="+width+",height="+height+",left="+((screen.width-width)/2)+",top="+((screen.height-height)/2)+",toolbar=0,location=0,menubar=0,directories=0,resizable=0");
    }
}

function changeCheckBox(control,checked) {
    if (checked==2) {
        var val=document.getElementById(control).checked;
        if (val==true) val=false; else val=true;
    } else {
        val=(checked==0)?false:true;
    }

    document.getElementById(control).checked=val;
    document.getElementById(control+"_img").src="http://static.talalka.hu/new2/base/"+(val?"checkbox_on.gif":"checkbox_off.gif");
    
}

function changeCheckBox2(control)
{
    var ch = document.getElementById(control).checked;
    document.getElementById(control).checked = (ch)?false:true;
    document.getElementById(control+"_img").src="http://static.talalka.hu/"+((ch)?"checkbox_off.gif":"checkbox_on.gif");
}

function RefreshGemius()
{
   gemius_hit(pp_gemius_identifier.replace('USED_',''));
}


function reload_median() {
	console.log('reloadmedian_by_r_m');
	var same=Math.floor(Math.random()*1000000)+median_webaudit();
	//same=same+sameext;
	document.getElementById("median").innerHTML='<!-- Medián WebAudit Mellesleg Network Találka.hu 1/2 --><img style="position:absolute;top:-100px;left:-100px" src="http://audit.median.hu/cgi-bin/track.cgi?uc=11775870501153&dc=1&ui='+same+'" width="1" height="1">';
    RefreshGemius();
}

var usercards=new Array();
var activeUserCard=0;

function showUserCard(userid) {
	if (userid>0) {
		if (usercards[userid]!=null) {
			activeUserCard=userid;
			Element.update('usercardDiv',usercards[userid]);
			TagToTip('usercardDiv',COPYCONTENT,false);
			return;
		}
		$('usercardDiv').innerHTML=$('usercardWaiting').innerHTML;
		activeUserCard=userid;
		TagToTip('usercardDiv', COPYCONTENT, false);
	}
}

function showUserCard_Completed(response) {
	if (response!=null && response.responseXML!=null) {
		card=response.responseXML.getElementsByTagName("card")[0];
        
        if (card!=null) {
            userid=card.getElementsByTagName("userid")[0].firstChild.data;
            data=card.getElementsByTagName("data")[0].firstChild.data;

            if (userid!=null && data!=null) {
				usercards[userid]=data;

				if (activeUserCard==userid) {
					$('usercardDiv').innerHTML=data;
                    //$j('#usercardDiv').html(data);
//                    alert(data);
				}
            }
		}
	}
}

var popup_data=null;
/* Megjelenít egy popup ablakot */
function showPopup(url, width, height) {
    if (popup_data!=null) hidePopup();
    
    var dim=getWindowDimension();
    var scroll=window.pageYOffset ? window.pageYOffset : 
		document.documentElement ? document.documentElement.scrollTop : 
		document.body ? document.body.scrollTop : 0;
	var div=NewTag('div',document.body);
    div.style.position='absolute';
    div.style.top='0px';
    div.style.left='0px';
    div.style.width='100%';
    div.style.height=getDocumentHeight()+"px";
    div.style.zIndex=10000;
    div.style.background='black';
    SetOpac(div,60);

    var ifr=NewTag('iframe',document.body);
    ifr.style.position="absolute";
    ifr.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    ifr.style.left=Math.max(0,((dim.w-width)/2))+'px';
    ifr.style.zIndex=10001;
    ifr.style.width=(width-5)+'px';
    ifr.style.height=(height-5)+'px';
    
    var content=NewTag('div',document.body);
    content.style.position="absolute";
    content.style.top=Math.max(0,(scroll+(dim.h-height)/2))+'px';
    content.style.left=Math.max(0,((dim.w-width)/2))+'px';
    content.style.zIndex=10002;
    content.style.width=width+'px';
    content.style.height=height+'px';
    content.style.background='#503e1e';
    content.style.overflow='hidden';
    content.style.border="1px solid white";
    
    var content2=NewTag('div',content);
    content2.style.width=(width-14)+'px';
    content2.style.height=(height-14)+'px';
    content2.id="popupcontent";
    content2.style.background='white';
    content2.style.overflow='hidden';
    content2.style.margin="2px";
    content2.style.padding= '5px';
    
    popup_data={'backgrnd': div, 'iframe': ifr, 'content': content};
    
    new Ajax.Updater("popupcontent",url,{method: 'get',evalScripts: true});
    reload_median();
}

function hidePopup(callback,param) {
    if (popup_data!=null) {
        document.body.removeChild(popup_data.backgrnd);
        document.body.removeChild(popup_data.iframe);
        document.body.removeChild(popup_data.content);
        delete popup_data;
        popup_data=null;
    }
    if (callback!=null) callback(param);
}


function getWindowDimension() {
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        w = window.innerWidth;
        h = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        w = document.documentElement.clientWidth;
        h = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    return {w:w,h:h};
}

function getDocumentHeight() {
    var htmlheight = document.body.parentNode.scrollHeight; 
    var windowheight = window.innerHeight; 
    if ( htmlheight < windowheight ) {return windowheight;} 
    else {return htmlheight;} 
}

//DOM objektumkezelő függvények
function InsertBefore (pParent, pChild, pBefore)
{
    var a = new Array ();
    var c = pParent.firstChild;
    while (c!=null) {
        if (c == pBefore) break;
        c = c.nextSibling;
    }

    while (c!=null) {
        a[a.length] = c;
        c = c.nextSibling;
    }

    var i = 0;
    for (i = 0; i < a.length; i++) {
        pParent.removeChild(a[i]);
    }
    pParent.appendChild(pChild);
    for (i = 0; i < a.length; i++) {
        pParent.appendChild(a[i]);
    }

    delete a;
}

function RefreshChildren (pParent) {
    var a = new Array ();
    var c = pParent.firstChild;
    while (c!=null) {
        a[a.length] = c;
        c = c.nextSibling;
    }
    var i = 0;
    for (i = 0; i < a.length; i++) {
        pParent.removeChild(a[i]);
    }

    for (i = 0; i < a.length; i++) {
        pParent.appendChild(a[i]);
    }

    delete a;
}

function AddTag(pChild, pParent, pBefore) {
    if(pBefore != undefined) InsertBefore (pParent, pChild, pBefore);
    else pParent.appendChild(pChild);
}

function NewTag(id, pParent, pBefore) {
    var tag = document.createElement(id);
    if(pParent != undefined) AddTag(tag, pParent, pBefore);
    return tag;
}

function NewTextTag(text, pParent, pBefore) {
    var tag = document.createTextNode(text);
    if(pParent != undefined) AddTag(tag, pParent, pBefore);
    return tag;
}

function SetOpac (block,value) {
	block.style.opacity = value/100;
	block.style.filter = 'alpha(opacity=' + value + ')';
}


/* Megjelenít egy képet a képernyő közepén (a többit elsötétíti*/
function showPicture(url) {
    var dim=getWindowDimension();
    var scroll=window.pageYOffset ? window.pageYOffset :
		document.documentElement ? document.documentElement.scrollTop :
		document.body ? document.body.scrollTop : 0;
	var div=NewTag('div',document.body);
    div.style.position='absolute';
    div.style.top='0px';
    div.style.left='0px';
    div.style.width='100%';
    div.style.height=getDocumentHeight()+"px";
    div.style.zIndex=10000;
    div.style.background='black';
    SetOpac(div,60);

    var img=NewTag('img',document.body);
    img.src=url;
    img.style.position='absolute';
    var he=((dim.h-500)/dim.h/2)*100;
    var we=((dim.w-500)/dim.w/2)*100;
    img.style.top=(scroll+(dim.h-500)/2)+'px';
    img.style.left=((dim.w-500)/2)+'px';
    img.style.zIndex=10002;
    img.style.border="1px solid white";

    /*img.style.padding="1px";*/
    img.style.cursor="pointer";
    img.style.margin="auto";
    img.style.width="";
    img.style.height="";


    img.onclick=function() {
        document.body.removeChild(div);
        document.body.removeChild(this);
        document.body.removeChild(ifr);
    }

    img.onload=function() {
    	ifr.style.width=(img.width+2)+'px';
    	ifr.style.height=(img.height+2)+'px';
    	ifr.style.border="0px";
    	ifr.style.background="white";
    	//ifr.style.display="block";
    	img.style.border="1px solid white";
    }

    var ifr=NewTag('iframe',document.body);
    ifr.style.position="absolute";
    ifr.style.top=(scroll+(dim.h-500)/2)+'px';
    ifr.style.left=((dim.w-500)/2)+'px';
    ifr.style.zIndex=10001;
    ifr.style.width=img.width;
    ifr.style.height=img.height;

    //ifr.style.display="none";
    reload_median();
}


function  showPicture2(url)
 {
    var myAjax = new Ajax.Request( url, {method: 'post', onComplete: function(response){
        showPicture(response.responseText)
        }});

 }

/*Képgaléria*/
function openGalleryWithImage(imageid) {
	showwnd('/gallery.php?imageid='+imageid,'', 639,630);
}
function openGalleryWithFolder(folderid) {
	showwnd('/gallery.php?folderid='+folderid,'', 639,630);
}
/*
'style': {
            'position' : 'absolute'
            ,'width' : '100%'
            ,'height' : getDocumentHeight+'px'
            ,'background-color' : '#000000'
            ,'display' : 'none'
        }*/

function showAlert(onload_ok)
{
    var div = new Element('div',{
        id : 'alertPopupDiv'
    });
    div.setStyle({
        backgroundColor : '#fafefe'
        ,width : '100%'
        ,height : getDocumentHeight()+"px"
        ,position : 'absolute'
        ,top : 0
        ,left : 0
        ,zIndex : 9999
    });
    div.setOpacity(0.5);
    
    var div2 = new Element('div', {
        id : 'contentContainer'
        ,'class' : 'cf'
    });
    div2.setStyle({
        width: '100%'
        ,position: 'absolute'
        ,top:0
        ,left:0
        ,zIndex:10000
    });
    
    var content = new Element('div', {
        id : 'alertPopupContent'
        ,'class' : 'blog_commentitem'
    });
    content.setStyle({
        margin:"300px auto"
    });
    
    var header = new Element('div', {
        'class' : 'blog_commenttoprnd'
    });
    var footer = new Element('div', {
        'class' : 'blog_commentbottom'
    });
    //header.update('PRÉMIUM AKCIÓ!');
    
    var text = new Element('div', {
        'class' : 'cf'
    });
    
    
    text.setStyle({
         width: '584px'
        ,height: '73px'
        ,textAlign: 'justify'
        ,padding: '20px 20px 0px 20px'
    });
    text.update("A megújulás alkalmából van egy jó hírünk: újabb akcióval kedveskedünk Neked! <strong>Most bármennyi időre fizetsz elő, a dupláját írjuk jóvá az egyenlegeden, így 3 hónap helyett most 6 hónapot kapsz! Jól hangzik, nem?</strong> Akkor ugorj be hozzánk, nézz körül, fizess elő és indulhat a párvadászat!");
    
   
    
    
    var alertContainer = new Element('div', {
        id : 'alertContainer'
    });
    
    var closeLink = new Element('a', {
        href: 'javascript:void(0)'
    });
    closeLink.update("Bezár");
    closeLink.setStyle({
        marginLeft: '570px'
        ,marginBottom: '20px'
    });
    closeLink.observe('click', closePopup);
    
    content.insert(header);
    content.insert(text);
    content.insert(closeLink);
    content.insert(footer);
    div2.insert(content);
    //document.body.appendChild(div);
    //document.body.appendChild(div2);
    if(onload_ok)
    {
        $('body').insert(div);
        $('body').insert(div2);    
    }
    
    reload_median();
}

function closePopup(event)
{
    Element.remove('alertPopupDiv');
    Element.remove('contentContainer');
}

/*új függvények*/
function changeregionprofile()
{
    var regionprofid = arguments[0];
    //alert(arguments.length);
	$j("#regionidprof").val(regionprofid);
	
    $j.ajax({
        url: '/region.php',
        type: 'post',
        data:{
            'act' : 'simple2',
            'regionid' : regionprofid,  
            'size' : ((arguments.length>1)?arguments[1]:'180'),
            'rnd' : (new Date()).getTime()
        },
        success: function(msg)
        {
            $j('#regionprof').html(msg);
            //if(arguments.length>1) $j('#regionselect').css({'width':arguments[1]+'px'});
 //           $j('#regionselect').sSelect({ddMaxHeight: '300px'});
        }
    });
}
function changeregion()
{
    var regionid = arguments[0];
    //alert(arguments.length);
	document.searchform.regionid.value=regionid;
    $j.ajax({
        url: '/region.php',
        type: 'post',
        data:{
            'act' : 'simple',
            'regionid' : regionid,
            'size' : ((arguments.length>1)?arguments[1]:'180'),
            'rnd' : (new Date()).getTime()
        },
        success: function(msg)
        {
            $j('#region').html(msg);
            //if(arguments.length>1) $j('#regionselect').css({'width':arguments[1]+'px'});
 //           $j('#regionselect').sSelect({ddMaxHeight: '300px'});
        }
    });
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

var sizeToPx = new Array(0,"xx-small","small","medium","large","x-large","xx-large");



$j(document).ready(function(){
//        return;
        $j('*[tocufon]').each(function(index,item){
            if (typeof $j(item).attr("nolower") == "undefined") {
                var small = $j(item).html().toLowerCase();
                $j(item).html(small);
            }
            $j(item).css({'letter-spacing':'-1px'});
            //$j(item).children('a').css({'text-decoration':'none'});
            $j(item).children('a').hover().css('cssText','text-decoration: none !important');
            Cufon.replace($j(item),{fontFamily:'museo',fontSize:$j(item).attr('tocufon')});
        });
        //$j('*[onclick]').each(function(index,item){$j(item).css({'cursor':'pointer'});});
	//$j('#body').css({'display':''});
    }
);

function donicksearch() {
    if (document.getElementById("nick").value.length<2) {
        alert("A feltételben legalább két karaktert meg kell adni!");
        document.getElementById("nick").focus();
        return;
    }
    document.getElementById("nicksearch").submit();
}
//naire fgv-ek
function naire(n)
{
        var up=$j(n).parent();
        var result = $j(up).find('input:hidden').val();
        
        $j('#btn_save').attr("disabled", true);
        var isdivnaire = ($j(up).find('div').length>0)?true:false;
        if(isdivnaire)   //kérdést visz be
        {
            $j(up).find('div').replaceWith('<label class="label_naire">'+result+'</label>');
            var is_there_div_n = ($j('.questionnaire_table').find('div').length<1)?true:false;
            check_div(is_there_div_n);
        }
        else        //label
        {
            $j(up).find('label.label_naire').replaceWith('<div id="newrow" style="padding-left:15px;"><input type="text" value="'+result+'" style="width:400px; float:left;"/><input type="submit" id="btn_ok" style="display:none"/><a class="btn_ok2" id="ok_btn1" onclick="check_naire(this)"></a></div>');
            $j(up).find('div input[type~="text"]').focus();
            $j('div input[type~="text"]').keydown(function(event) {
                if (event.keyCode == '13') {
                    check_naire(this);
                }
            });
        }
}
function check_naire(n_a)
{
    var question=$j(n_a).parent().find('input').first().val();
    var question_parent=$j(n_a).parents().eq(1);
    
    try{
        if(question.length>40)
        {
            throw "Err1";
        }
        else if(question.length<1)
        {
            throw "Err2";
        }
        $j(question_parent).find('div').replaceWith('<label class="label_naire">'+question+'</label>');
        $j(question_parent).find('label.label_naire').html(question);
        $j(question_parent).find('input:hidden').val(question);
        var is_there_div = ($j('.questionnaire_table').find('div').length<1 && $j('#newrow').length<1)?true:false;
        
        check_div(is_there_div);
    }
    catch(er)
        {
        switch(er){
        case "Err1":
            alert("Túl hosszú kérdés!");
            break;
        case "Err2":
            alert("Nem adott meg kérdést!");
            break;
        }
        }
}

function question_prompt(b)
{
        var tr=$j(b).parents().eq(1);
        var nexttr=$j(tr).next();
        var result = $j(nexttr).find('input:hidden').val();
        var result1 = $j(nexttr).find('input').val();
        $j('#btn_save').attr("disabled", true);
        var isdiv = ($j(nexttr).find('div').length>0)?true:false;
        if(isdiv)   //kérdést visz be
        {
            $j(nexttr).find('div').replaceWith('<label class="defaultpurple">'+result1+'</label>');
            var is_there_div_q = ($j('.questionnaire_table').find('div').length<1 && $j('#newrow').length<1)?true:false;
            check_div(is_there_div_q);
        }
        else        //label
        {
            /*$j(nexttr).find('label').replaceWith('<div><input type="text" value="'+result+'" style="width:400px"/><input type="submit" id="btn_ok" style="display:none"/><span class="linkbox"><a class="btn_ok" id="ok_btn" onclick="check_question(this)" ></a></span></div>');*/
            $j(nexttr).find('label').replaceWith('<div><input type="text" value="'+result+'" style="width:500px"/><input type="submit" id="btn_ok" style="display:none"/><a class="btn_ok1" id="ok_btn1" onclick="check_question(this)" ></a></div>');
            $j(nexttr).find('div input[type~="text"]').focus();
            $j('div input[type~="text"]').keydown(function(event) {
                if (event.keyCode == '13') {
                    check_question(this);
                }
            });
        }
}
function check_question(q_a)
{
    var question=$j(q_a).parent().parent().find('input').first().val();
    var question_parent=$j(q_a).parents().eq(2);
    
    try{
        if(question.length>50)
        {
            throw "Err1";
        }
        else if(question.length<1)
        {
            throw "Err2";
        }
        $j(question_parent).find('div').replaceWith('<label class="defaultpurple">'+question+'</label>');
        $j(question_parent).find('label').html(question);
        $j(question_parent).find('input').val(question);
        var is_there_div = ($j('.questionnaire_table').find('div').length<1 && $j('#newrow').length<1)?true:false;
        check_div(is_there_div);
    }
    catch(er)
        {
        switch(er){
        case "Err1":
            alert("Túl hosszú kérdés!");
            break;
        case "Err2":
            alert("Nem adott meg kérdést!");
            break;
        }
        }
}
function answer_prompt(a)
{       
        var td=$j(a).parent();
        var uptd=$j(td).next();
        var answer_value=$j(uptd).find('input:hidden').val();
        var answer_value1=$j(uptd).find('input').val();
        $j('#btn_save').attr("disabled", true);
        var isdiv_a = ($j(uptd).find('div').length>0)?true:false;
        if(isdiv_a)   //kérdést visz be
        {
            $j(uptd).find('div').replaceWith('<label class="label_naire">'+answer_value1+'</label>');
            var are_there_div = ($j('.questionnaire_table').find('div').length<1  && $j('#newrow').length<1)?true:false;
            check_div(are_there_div);
        }
        else        //label
        {
            /*$j(uptd).find('label').replaceWith('<div><input type="text" value="'+answer_value+'" style="width:355px"/><input type="submit" id="btn_ok" style="display:none"/><span class="linkbox"><a class="btn_ok" id="ok_btn" onclick="check_answer(this)" ></a></span></div>');*/
            $j(uptd).find('label').replaceWith('<div><input type="text" value="'+answer_value+'" style="width:355px"/><input type="submit" id="btn_ok" style="display:none"/><a class="btn_ok1" id="ok_btn1" onclick="check_answer(this)" ></a></div>');
            $j(uptd).find('div input[type~="text"]').focus();
            $j('div input[type~="text"]').keydown(function(event) {
                if (event.keyCode == '13') {
                    check_answer(this);
                }
            });
            
        }
}
function check_answer(answ_a)
{
    
    var answer=$j(answ_a).parent().parent().find('input').first().val();
     var answer_parent=$j(answ_a).parents().eq(2);
    try{
        if(answer.length>50)
        {
            throw "Err1";
        }
        else if(answer.length<1)
        {
            throw "Err2";
        }
         $j(answer_parent).find('div').replaceWith('<label class="label_naire">'+answer+'</label>');
        $j(answer_parent).find('label').html(answer);
        $j(answer_parent).find('input:hidden').val(answer);
        var are_there_div_a = ($j('.questionnaire_table').find('div').length<1  && $j('#newrow').length<1)?true:false;
        check_div(are_there_div_a);
        
    }
    catch(er)
        {
        switch(er){
        case "Err1":
            alert("Túl hosszú válasz!");
            break;
        case "Err2":
            alert("Nem adott meg választ!");
            break;
        }
        }
}
function check_div(check_disabled)
{
    if (check_disabled)
        {
            $j('#btn_save').removeAttr("disabled");
        }
}
function hide_row(c)
{
    var up_parent = $j(c).parents().eq(1);
    var up_up_parent = $j(up_parent).parent();
    var up_child = $j(up_parent).next();
    $j(up_child).show();
    $j(up_parent).hide();
    $j(up_parent).find('input').attr("disabled", true);
    
    $j(up_up_parent).find('input:radio').first().attr("checked","checked");
}
function hide_row_edit(c)
{
    var up_parent = $j(c).parents().eq(1);
    var up_up_parent = $j(up_parent).parent();
    var up_child = $j(up_parent).next();
    $j(up_child).show();
    $j(up_parent).hide();
    $j(up_parent).find('input').attr("disabled", true);
    
    $j(up_up_parent).find('input:radio').first().attr("checked","checked");
}
function show_row(d)
{
    var up_show = $j(d).parent();
    var prev_show = $j(up_show).prev();
    $j(up_show).hide();
    $j(prev_show).show();
    $j(prev_show).find('input').removeAttr("disabled");
}
function save_questionnaire()
{
    var arr=$j('.questionnaire_table').find("input[type='hidden']:not(:disabled)");
    var visible_inputs = $j('.questionnaire_table').find("input[type='hidden']:not(:disabled)").length;
    var radio_checked=$j('.questionnaire_table').find('input:checked').length;
    var table_sum = $j('.questionnaire_table').length;
   
    var lathato_checked=$j('.lathatosag').find('input#visibility:checked').length;
    var lathato_radio=$j('.lathatosag').find('input[type="radio"]:checked:visible').length;
    var lathato_text=$j('.lathatosag').find('input[type="text"]:visible').length;
    var age_to = $j('.lathatosag').find('input[type="text"]:visible').last().val();
    var age_from = $j('.lathatosag').find('input[type="text"]:visible').first().val();
    
    var num=0;
    $j.each(arr, function(index, value) 
        { 
        var akarmi=$j(value).val();
        if (akarmi=="" || akarmi==" ") {
            $j(value).parent().find('label').first().removeClass('label_naire').removeClass('defaultpurple').addClass('naire_error_third').html('Nem töltötted ki!');
            $j(value).removeClass('naire_error_third');
            } else {num++;} 
        });
    if (visible_inputs==num && radio_checked==table_sum) 
    {
        var go=false;
        try{
            if(age_to>100 || age_from>100)
            {
                throw "Err1";
            }
            else if(age_from<0 || age_to<0)
            {
                throw "Err2";
            }
               go=true;
        }
        catch(er)
            {
            switch(er){
            case "Err1":
                alert("Túl idős!");
                break;
            case "Err2":
                alert("Túl fiatal!");
                break;
            }
        } 
        if (lathato_checked==1 || lathato_radio==1 && lathato_text==2 && go==true)
                {return true;}
            else {return false;}
        
    }
    else {return false;}
}
function valid_questionnaire()
    {
        var is_valid = $j('.naire_form').val().length;
        if (is_valid<1){$j('.naire_error').css("color", "red").html("Nem adtad meg a címet!");return false;}
        if (is_valid>40){$j('.naire_error').css("color","red").html("Túl hosszú címet adtál meg!");return false;}
        return true;
    }
function option_questionnaire(thisform)
    {
        var is_valid = $j('.naire_blue_background').find('select').val();
        if (is_valid<1){return false;}
        if (is_valid>5){return false;}
        return true;
    }
function option_filter(cnt, cnt_title)
    {
        var is_valid = $j('#filter_naire_form').find('#v5').val();
        var is_valid2 = $j('#filter_naire_form').find('#v6').val();
        if (is_valid2<0){return false;}
        if (is_valid2>cnt_title){return false;}
        if (is_valid<0){return false;}
        if (is_valid>cnt){return false;}
        return true;
    }
function check_empty_rows(){
    var arr1 = $j('.questionnaire_table').find('input#answ_check');
    $j.each(arr1, function(index, value) 
        { 
        hide_check_row(this);
    });
} 
function hide_check_row(c)
{
    var up_parent = $j(c).parents().eq(1);
    var up_up_parent = $j(up_parent).parent();
    var up_child = $j(up_parent).next();
    $j(up_child).show();
    $j(up_parent).hide();
    $j(up_parent).find('input').attr("disabled", true);
    /*$j('.questionnaire_table').find('input[name^="answ"]:disabled').attr("name", "teszt");*/
    
}
function areyousure(title)
{
    var r=confirm("Biztos, hogy törölni szeretnéd a(z) '"+title+"' című kérdőíved?");
    return r;
}
function rewrite()
{
    var rewrite=$j('.lathatosag').find('input:radio:checked').val();
    if (rewrite==0) {
        $j('.lathatosag').find('input:text').first().val('0');
        $j('.lathatosag').find('input:text').last().val('99');
    }
}
function save_saveview()
{
    var answers = $j('.questionnaire_table').find('input:radio:checked').length;
    var num_table = $j('.questionnaire_table').length;
    if (answers<num_table) {
        $j('#error').css('color','red').html("Nem válaszoltál az összes kérdésre!");
        return false;
        }
    return true;
}
function set_cookie(name, value, days)
{
    var today = new Date();
    var expire = new Date();
    var check_cookie= getCookie(name);
    if (check_cookie!=-1) value=-1;
    expire.setTime(today.getTime() + days*24*60*60);
    document.cookie = name + "=" + escape(value) + ";expires=" + expire.toGMTString();
} 
function getCookie(c_name)
{
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        }
      }
    return "";
}
function get_numUsers()
{
    var sex=$j('.visibility_set').find('input:radio:checked').val();
    var from=$j('#visib_from').val();
    var to=$j('#visib_to').val();
    if (from!="" && to!="") {
            new Ajax.Updater('num_users','/settings.php',{method: 'get', parameters: {act:'search', search_sex: sex, search_from:from, search_to: to}
            });
    }

}
function check_settings()
{
    var settings_from=parseInt($j('#visib_from').val());
    var settings_to=parseInt($j('#visib_to').val());

    if (jQuery("#visibility:checked").length==0) return true;
    if(settings_to>settings_from && settings_from>0 && settings_to<150){
            return true;
        } else {
            alert("A láthatósági beállításoknál a kor hibásan lett megadva!");
            return false;
        }
}

function rating(itemid, page)
{
    var sort=$j('.rate').find('input:radio:checked').val();
    new Ajax.Updater('rate_rows','/blog.php',{method: 'get', parameters: {act:'rating', itemid:itemid, page_rate:1,
                            rate:sort}
            });
}

function moderateforummessage(messageid) {
    jQuery.getJSON("/forum.php", {act:"mod", messageid:messageid}, function(data) {
        alert(data.msg);
    });
}

function moderateBlogComment(itemid, commentid) {
    jQuery.getJSON("blog_ajax.php", {act:"moderate", itemid:itemid, commentid:commentid}, function(data){
        if ( typeof data.html != "undefined" ) {
            $j("#comments"+itemid).html(data.html).show(200);
        }
    });
}

function openmenu(type) {
    jQuery("#menu_"+type).slideToggle(300);
    jQuery.post("domenu.php",{menutype:type});
}
