
function popka(){
    var trg = window.open('', 'trg', 'menubar=0,location=0,scrollbars=0,toolbar=0,resizable=0,status=0,width=760,height=250,left=0,top=0');
    document.postlink.submit();
}

function popupka(link, name, settings){
    ujlink = window.open(link, name, settings);
}

function popkahozza(linkhozza, ablaknev){
    if (!window.focus) 
        return true;
    var href;
    if (typeof(linkhozza) == 'string') 
        href = linkhozza;
    else 
        href = linkhozza.href;
    window.open(href, ablaknev, 'width=700,height=670,scrollbars=yes');
    return false;
}


function uzimehet(tf){
    tf.submit();
    tf.m.value = '';
}

/**
 *
 */
var insertSmile = function(_t, _s, _id){
    if (typeof _id == 'undefined') {
        _id = 'field-hsz';
    }
    var e = document.getElementById(_id);
    var sm1 = [':)', ':(', ':I', ':D', ':B', ':P', ';)', ':x', ':M'];
	var ta = document.getElementById('field-hsz');
	var curspos = ta.selectionStart;
	if (!(curspos>=0)){
		curspos = getCursorPosition(ta);
	}
	var v = e.value;
    e.value = v.substring(0,curspos) + sm1[_s] + v.substring(curspos);
}
/**
 * @param {Object} oTextArea
 */
function getCursorPosition(oTextArea){
	oTextArea.focus();
	var iCurrentPos = oTextArea.value.length;
	var theCursor = document.selection.createRange().duplicate();
	var iSelectionLength = theCursor.text.length;
	while (theCursor.parentElement() == oTextArea && theCursor.move('character', 1)) {
		--iCurrentPos;
	}
	iStart = ++iCurrentPos;
	//iEnd = iStart + iSelectionLength;
	return iStart;
}
var uzike = function(){
	var j;
	if (typeof JSDATA == 'string') {
        j = Utilities.decode(JSDATA);
    }
	
	if (j && j.szavazo && j.szavazo[0][1]) {
	}
	else {
		alert('Csak regisztrált felhasználók szavazhatnak.');
	}
}

/**
 *
 */
var smcsere = function(_cls){
    if (typeof _cls == 'undefined') {
        _cls = 'tartalom';
    }
	
	var smbox = document.getElementById('smile-box');
	if (smbox) {
		smbox.style.visibility = 'visible';
	}
	
    var e = getElementsByClass(_cls, 'div');
    var img = ['<img src="../images/emotes/', '" alt="" border="0" />'];
    var sm = ['face-smile.gif', 'face-sad.gif', 'face-plain.gif', 'face-smile-big.gif', 'face-cool.gif', 'face-raspberry.gif', 'face-wink.gif', 'face-kiss.gif', 'face-monkey.gif'];
    var sm1 = [':\\)', ':\\(', ':I', ':D', ':B', ':P', ';\\)', ':x', ':M'];
    
    if (e && e.length > 0) {
        for (var i = 0; i < e.length; i++) {
            var str = e[i].innerHTML;
            for (var ii = 0; ii < sm1.length; ii++) {
                var re = new RegExp(sm1[ii].toLowerCase(), 'g');
                var k = img[0] + sm[ii] + img[1];
                str = str.replace(re, k);
                
                re = new RegExp(sm1[ii].toUpperCase(), 'g');
                str = str.replace(re, k);
            }
            
            e[i].innerHTML = str;
        }
    }
}
/**
 * @param {Object} name
 * @param {Object} tag
 */
var getElementsByClass = function(name, tag){
    var found = 0;
    var elems = new Array();
    if (tag) 
        var alltags = document.getElementsByTagName(tag);
    else 
        var alltags = document.getElementsByTagName("*");
    if (alltags) {
        for (i = 0; i < alltags.length; i++) {
            if (alltags[i].className == name) {
                elems[found++] = alltags[i];
            }
        }
    }
    return (elems);
}
/**
 * @param {Object} _v
 * @param {Object} _l
 */
var makeVoter = function(){
    var json;
    if (typeof JSDATA == 'string') {
        var json = Utilities.decode(JSDATA);
    }
    
    if (json && json.szavazo) {
        var d = json.szavazo;
        for (var i = 0; i < d.length; i++) {
            if (Utilities.get(d[i][0])) {
                new Voter({
                    contener: d[i][0],
                    number: 5,
                    nyuuz: {
                        szavazhat: d[i][1]
                    },
                    value: 0,
                    listeners: {
                        click: voterClick
                    }
                });
            }
        }
    }
}
/**
 * @param {Object} thisObj
 * @param {Object} _index
 */
var voterClick = function(thisObj, _index){
    if (!thisObj.nyuuz.szavazhat) {
        alert('Csak regisztrált felhasználók szavazhatnak.');
        return;
    }
    new Ajax({
        url: '../php/ertekel.php',
        method: 'POST',
        params: {
            kod: thisObj.contener.replace(/blog_szavazo/, ''),
            szavazat: _index
        },
        callback: function(_ss, _rr, _oo){
            voterClickCallback(thisObj, _ss, _rr, _oo);
        }
    });
}
/**
 * @param {Object} _ss
 * @param {Object} _rr
 * @param {Object} _oo
 */
var voterClickCallback = function(thisObj, _ss, _rr, _oo){
    if (_ss && _rr && _rr.responseText) {
        var v = eval('(' + _rr.responseText + ')');
        if (v.success) {
            var e = document.getElementById(thisObj.contener);
            var ee = document.getElementById(thisObj.contener.replace(/blog_szavazo/,'blog_szavazo_2'));
			
            if (e) {
                var m = '<img src="../images/star_s.gif" align="middle" border="0" alt="' + v.ertek + '" />&nbsp;&nbsp;';
                m += '' + v.ertek;
                if (v.db) {
                    m += '&nbsp;&nbsp;<span style="font-size:9px;">(' + v.db + ')</span>';
                }
				if (ee) {
					ee.innerHTML = '';
				}
                e.innerHTML = '';
                e.innerHTML = m;
            }
        }
        else {
            if (v && v.msg) {
                alert(v.msg);
            }
        }
    }
    else {
        alert('Hiba történt a szavás során. Próbáld meg újra.');
    }
}


/*


 function display(){


 rtime = etime - ctime;


 if (rtime > 60)


 m = parseInt(rtime / 60);


 else {


 m = 0;


 }


 s = parseInt(rtime - m * 60);


 if (s < 10) {


 s = "0" + s


 }


 //window.status=" :  "+m+":"+s;


 document.getElementById('idohely').innerHTML = " " + m + ":" + s;


 window.setTimeout("checktime()", 1000);


 }


 function settimes(ido){


 var time = new Date();


 hours = time.getHours();


 mins = time.getMinutes();


 secs = time.getSeconds();


 etime = hours * 3600 + mins * 60 + secs;


 etime += ido; //m�sodpercbe kell megadni


 checktime();


 }


 function checktime(){


 var time = new Date();


 hours = time.getHours();


 mins = time.getMinutes();


 secs = time.getSeconds();


 ctime = hours * 3600 + mins * 60 + secs


 if (ctime >= etime) {


 messageWindow();


 }


 else


 display(180);


 }


 function messageWindow(){


 //  var width="200", height="155";


 //  var left = (screen.width/2) - width/2;


 //  var top = (screen.height/2) - height/2;


 //  var styleStr = 'toolbar=no,titlebar=0,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;


 //  var msgWindow = window.open("../html/lejart.html","msgWindow", styleStr);


 //document.location.href="./lejart.html";


 document.location.href = '';


 }*/


