$(document).ready(function() {

	// vymazání textu v hledacím inputu
	/*inputHelpText('input[name=q]','test basic hledani');

	inputHelpText('input[name=jmeno]','test basic jmeno');
	inputHelpText('input[name=username]','test partners jmeno');
	inputHelpText('input[name=firstname]','test kontakt jmeno');

	inputHelpText('input[name=password]','test partners heslo');

	inputHelpText('input[name=prijmeni]','test basic prijmeni');
	inputHelpText('input[name=lastname]','test kontakt prijmeni');

	inputHelpText('input[name=email]','test basic email');
	inputHelpText('input[name=emailaddress1]','test kontakt email');

	inputHelpText('input[name=telephone1]','test kontakt telefon');*/

	inputHelpText('textarea[name=description]',LABELS['vyplňte svůj dotaz']);

	//inputHelpText('input[name=evTermin]',LABELS['format_datumu_prohlidka']);
//	inputHelpText('input[name=FlatSizeFrom]','test byty od');
//	inputHelpText('input[name=FlatSizeTo]','test byty do');
	

//oznaceni vsech check boxu - FlatSearch.phtml	



if ($("#page #selectCheckBox").length){
	$("#selectCheckBox a").attr('href', 'javascript:void(0)').css('display', 'inline');
	$("#selectCheckBox a#selectAll").click(function(event) {
		event.preventDefault();
		
		$("table.flats input:checkbox").attr('checked', 'checked');
	});
	$("#selectCheckBox a#deleteAll").click(function(event) {
		event.preventDefault();
		$("table.flats input:checkbox").attr('checked', '');
	});
}
	
}); //eo document ready

// vymazání textu v hledacím inputu
function inputHelpText(selector, defaultValue){
    
    var searchFocusedClass = 'focused';
	$(selector).addClass('red');

    // Input s heslem - nelze přeepisoval attr "value", vyrobíme náhradní­ input s type="text"
    if($(selector).attr('type') == 'password'){
        var fakePassInput = '<input id="password-clear" class="fi-text" type="text" value="' + defaultValue + '" autocomplete="off">'
        $(selector).hide().after(fakePassInput);
    
        $('#password-clear').focus(function(){
            $(this).hide();                                   
            $(selector).show().trigger('focus');
        });
       
        $(selector).blur(function(){
            if($(this).val() == ''){
                $(this).hide();
                $('#password-clear').show();
            }
        });
    }
    // Klasický input
    else {
        $(selector).each(function() {
            if($.trim(this.value) == ''){
                this.value = defaultValue;
            }
        });
       
        $(selector).focus(function(){
            if(this.value == defaultValue){
                this.value = '';
				$(this).removeClass('red');
                $(this).parent().addClass(searchFocusedClass);
            }
        });
       
        $(selector).blur(function(){
            if($.trim(this.value) == ''){
                this.value = defaultValue;
                $(this).addClass('red')
				$(this).parent().removeClass(searchFocusedClass);
            }
        });
    }
}

