﻿function like (id,yesno){
	divnev = "likeline"+id;
	document.getElementById(divnev).innerHTML = "<div style='float:right; margin-right: 17px;'>Várj...</div>";
	$.ajax({
		type: "POST",
		url: "a_likes.php",
		data: "id="+id+"&yesno="+yesno,
		success: function(data, textStatus){
			document.getElementById(divnev).innerHTML=data;
		}
	});
}

$(document).ready(function(){
	$("#esemenydate").datepicker();
});

function HonapValtas(ev,honap) {
	$.ajax({
		type: "GET",
		url: "a_naptar.php",
		data: "ev="+ev+"&honap="+honap,
		success: function(data, textStatus){
			document.getElementById("Shonap").innerHTML=data;
		}
	}); 
}

function codeSimple (txtId, code, defText)
{

	codeInsert (txtId, "[" + code + "]", "[/" + code + "]", defText);

}



function codeParam (txtId, code, param, defText)
 {
	codeInsert (txtId, "[" + code + "=" + param + "]", "[/" + code + "]", defText);

}



function codeGetURL (txtId, code, msg){
	var url = prompt (msg, "http://");

	if (!url)
{

		document.getElementById(txtId).focus();

		return;
	}

	url = encodeURI(url).replace(/%25[0-9A-F][0-9A-F]/gi, decodeURIComponent);

	codeParam (txtId, code, url, (code == 'L' ? '[link]' : null));

}



function codeGetImg (txtId, code, msg)
{

	var url = prompt (msg, "http://");

	if (!url){

		document.getElementById(txtId).focus();

		return;

	}

	url = encodeURI(url).replace(/%25[0-9A-F][0-9A-F]/gi, decodeURIComponent);

	codeSimple (txtId, code, url, (code == 'L' ? '[img]' : null));

}



function codeSmiley (txtId, code)
{
	codeInsert (txtId, " " + code + " ", null, null);

}



function codeInsert (txtId, oTag, cTag, defText)
{

	var txt = document.getElementById(txtId);

	txt.focus();

	if (txt.selectionStart != undefined){

		// -- Firefox, Opera, Safari

		var sel_start = txt.selectionStart;

		var sel_end   = txt.selectionEnd;


		if (!cTag){

			txt.value = txt.value.substr(0, sel_start) + oTag + txt.value.substr(sel_end);

			txt.selectionStart = sel_start + oTag.length;

			txt.selectionEnd   = sel_start + oTag.length;

		}

		else{

			var selText = txt.value.substr(sel_start, sel_end - sel_start);

			if (!selText && defText) selText = defText;

			txt.value = txt.value.substr(0, sel_start) + oTag + selText + cTag + txt.value.substr(sel_end);

			txt.selectionStart = sel_start + oTag.length;

			txt.selectionEnd   = sel_start + oTag.length + selText.length;

		}

	}

	else if (document.selection){

		// -- IE

		var sel = document.selection.createRange();

		if (sel){

			if (!cTag) sel.text = oTag;

			else{

				var selText = sel.text;

				if (!selText && defText) selText = defText;

				var selLength = selText.replace(/\r\n/g, "\n").length;


				sel.text = oTag + selText + cTag;

				sel.moveStart ("character", -cTag.length - selLength);

				sel.moveEnd   ("character", -cTag.length);

			}

			sel.select();

		}

	}

} 

function keres(input,e) {
	if(e==1) {
		if(input.value=='') {
			input.id = 'input_keres';
			input.value='Keresés...';
		}
		else input.id='input_keres_nf';
	}
	else if(input.value=='Keresés...') input.value='';
}

