// alert ('1 '+document.documentElement.clientHeight+' 2 '+document.documentElement.offsetHeight);
$(document).ready(function(){
/*    $(".header_menus img").kep_cserelo();
    $("input.mehet_gomb").kep_cserelo();*/
//    $(".reszletes_input, #es_varos").alap_ertek().key_read();
//    $(".gyorskereso_cont input").alap_ertek();
	$(".input_csere").alap_ertek();
	$(".hideOnload").slideUp(1500);
});

$.fn.kep_cserelo = function()
    {
	this.each(
		function()
		{
		    var src_tmp = $(this).attr('src');
		    var ext = src_tmp.substring(src_tmp.length-4,src_tmp.length);
		    src_tmp = src_tmp.substring(0,src_tmp.length-4);
		    var src_off = src_tmp+ext;
		    var src_on = src_tmp+'on'+ext;
		    preload(src_on);
		    $(this).hover(function(){
			$(this).attr({src: src_on});
			},function(){
			$(this).attr({src: src_off});
			});
		}
	);
		
	return this;

    }

$.fn.alap_ertek = function() {
	this.each(
		function() {
			if ( typeof($(this).attr('title')) == "undefined" || $(this).attr('title') == '' ) {
				$(this).attr('title',$(this).val());
			}
//		$(this).attr({title: $(this).val()});
//		alert($(this).attr('title'));
			$(this).focus( function() {
				if ($(this).val() == $(this).attr('title'))
				$(this).val('');
		    });
			$(this).blur(function() {
				if ($(this).val() == '') {
					$(this).val($(this).attr('title'));
				}
			});
		});
	return this;    
}

function preload(srcs) {
    var img = new Image();
	img.onload = function () {
	return true;
	};
	img.onerror = function () {
	    return false;
	}
    img.src = srcs;
    }

function streachPicDiv(cid,h) {
	//var h = $('#ceg_adat_'+cid).height();
	//h -= 15;
	h += "px";
	//alert(cid + ' '+h+$('#ceg_adat_'+cid).siblings('.data_row').height());
	//alert(cid + ' '+h);
	//$('#ceg_kepek_'+cid).css({ border: "1px solid red"});
	//$('#ceg_kepek_'+cid).animate({ height: "30px"});
}

function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
//alert('encode '+str);
    var ret = str;

    ret = ret.toString();
    ret = encodeURIComponent(ret);
//	var mr;
//	mr = ret;
	ret = ret.replace(/\+/g,'%2B');
    ret = ret.replace(/%20/g, '+');
//alert(ret);
    return ret;
}