function makeform_post_id(id,value){

var div = '<div id="dialogalert" style="display: none;"><form name="postform" method="post"><input type="hidden" name="'+id+'" id="'+id+'" value="'+value+'" /></form></div>';
//alert(div);
$("body").append(div);

document.postform.submit();


}

function tallozas(root,placeid,valuetoid){

    $("#"+placeid).fileTree({ 
	root: root,    
	script: 'includes/jqueryFileTree.php',
	expandSpeed: 1000,
	collapseSpeed: 1000,
	multiFolder: false
    }, 
    function(file) {
	        //alert(file.replace(root,""));
	        $("#"+valuetoid).val(file.replace(root,""));
    });	
}


function gettel(){

    $("#telszam").hide();

    $.ajax({
	type: "POST",
	url: "/includes/ajax.php",
	data: "action=telefonszam",
	success: function(back){
	
	    $("#telszam").html(back);
	    $("#telszam").show(1000);
	
	}
    });

}

function emailtoredman(){

    var message=$("#contactmessage").val();

    $("#kapcs").hide(1000);

    $.ajax({
	type: "POST",
	url: "/includes/ajax.php",
	data: "action=message&message="+message,
	success: function(back){
	
	    $("#kapcs").html(back);
	    $("#kapcs").show(1000);
	
	}
    });


    

}

function eml(nev,domain,tld,clas,link){

    if (link){
	$("."+clas).html('<a href="mailto:'+nev+"@"+domain+"."+tld+'">'+nev+"@"+domain+"."+tld+'</a>');
    }
    else{
	$("."+clas).html(nev+"@"+domain+"."+tld);
    }

}


function popup(){

	var div = $('<div id="dialogalert" style="display: none;">').html('<p class="popuptext" id="popupcontent"><div id="ajaxloader" style="text-align: center"><img src="pic/loading.gif" style="margin-top: 100px;"></div></p>');
    $("body").append(div);

    $.ajax({
	type: "POST",
	url: "/includes/ajax.php",
	data: "action=contact",
	success: function(back){
	
	    $("#ajaxloader").remove();
	    $("#popupcontent").html(back);
	    dialog();
	
	}
    });

    
    	

}

function dialog(){

$.fx.speeds._default = 500;
    
	$("#dialogalert").dialog({
		width: 400,
		height: 380,
		bgiframe: true,
		resizable: false,
		modal: true,
		hide: "explode",
		title: 'Kapcsolat',
		overlay: {
			backgroundColor: '#000',
			opacity: 0.1
		},
		buttons: {
			ok: function() {
				$(this).dialog('close');
				
			}
		},
		close: function(event, ui) { $("#dialogalert").remove(); }

	});
	


}

function ujablak(x,y){

$.fx.speeds._default = 500;
    
	$("#dialogalert").dialog({
		width: x,
		height: y,
		bgiframe: true,
		resizable: false,
		modal: true,
		hide: "explode",
		title: 'Kapcsolat',
		overlay: {
			backgroundColor: '#000',
			opacity: 0.1
		},
		buttons: {
			ok: function() {
				$(this).dialog('close');
				
			}
		},
		close: function(event, ui) { $("#dialogalert").remove(); }

	});
	


}


function myalert(text,cim){

	if (cim="") cim="Figyelmeztetés";

	var div = $('<div id="dialogalert" style="display: none;">').html('<p class="dialogalert">'+ text +'</p>');
    $("body").append(div);
	$("#dialogalert").dialog({
		bgiframe: true,
		resizable: false,
		modal: true,
		title: cim, 
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: {
			Ok: function() {
				$(this).dialog('close');
				
			}
		},
		close: function(event, ui) { $("#dialogalert").remove(); }

	});
	
	

}

function myconfirm(text,funct){

	var div = $('<div id="dialogconfirm" style="display: none;">').html('<p class="dialogconfirm">'+ text +'</p>');
    $("body").append(div);
	$("#dialogconfirm").dialog({
		bgiframe: true,
		resizable: false,
		modal: true,
		title: 'Figyelmeztetés', 
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: {
			nem: function() {
				$(this).dialog('close');
				
			},
			igen: function() {
				$(this).dialog('close');
				eval(funct);
			
			}
			
		},
		close: function(event, ui) { $("#dialogconfirm").remove();}

	});
	
	

}

function trim( str ) {
	str = str.replace(/^\s+/, "");
	for( var i = str.length-1; i > 0; --i) {
		if( /\S/.test( str[i] ) ) {
			str = str.substring( 0, i+1 );
			break;
		}
	}
	return str;
}

function validemail(email) {
	
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) {
		return false;
	}
	else{
		return true;
	}
}

function validdomain(domain) {
	
	var filter = /^(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(domain)) {
		return false;
	}
	else{
		return true;
	}
}

/* hilite*/
jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};

jQuery.fn.removeHighlight = function() {
 return this.find("span.highlight").each(function() {
  this.parentNode.firstChild.nodeName;
  with (this.parentNode) {
   replaceChild(this.firstChild, this);
   normalize();
  }
 }).end();
};


/* hilite vége*/

function fitToContent(/* JQuery */text, /* Number */maxHeight) {
var adjustedHeight = text.height();
var relative_error = parseInt(text.attr('relative_error'));
if (!maxHeight || maxHeight > adjustedHeight) {
adjustedHeight = Math.max(text[0].scrollHeight, adjustedHeight);
if (maxHeight)
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if ((adjustedHeight - relative_error) > text.height()) {
text.css('height', (adjustedHeight - relative_error) + "px");
// chrome fix
if (text[0].scrollHeight != adjustedHeight) {
var relative = text[0].scrollHeight - adjustedHeight;
if (relative_error != relative) {
text.attr('relative_error', relative + relative_error);
}
}
}
}
}

function autoResizeText(/* Number */maxHeight) {
var resize = function() {
fitToContent($(this), maxHeight);
};
$("textarea").attr('relative_error', 0);
$("textarea").each(resize);
$("textarea").keyup(resize).keydown(resize);
}

/**
 * Cookie plugin
 *
*/
 
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


