$(document).ready(function() {

$('#index-email').live('click', function(e) {
    if ( e.button == 2 && ( this.value == 'E-mail cím' || this.value == 'Az e-mail cím mező kitöltése kötelező!' || this.value == 'Hibás e-mail formátum!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});
$('#index-email').live('mousedown', function(event) {
    if ( event.button == 2 && ( this.value == 'E-mail cím' || this.value == 'Az e-mail cím mező kitöltése kötelező!' || this.value == 'Hibás e-mail formátum!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});

$('#index-comment').live('click', function(e) {
    if ( e.button == 2 && ( this.value == 'Megjegyzés' || this.value == 'A megjegyzés mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});
$('#index-comment').live('mousedown', function(e) {
    if ( e.button == 2 && ( this.value == 'Megjegyzés' || this.value == 'A megjegyzés mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});

$('#index-name').live('click', function(e) {
    if ( e.button == 2 && ( this.value == 'Ajánlatkérő neve' || this.value == 'Az ajánlatkérő neve mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});
$('#index-name').live('mousedown', function(e) {
    if ( e.button == 2 && ( this.value == 'Ajánlatkérő neve' || this.value == 'Az ajánlatkérő neve mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});

$('#index-phone').live('click', function(e) {
    if ( e.button == 2 && ( this.value == 'Telefonszáma' || this.value == 'A telefonszáma neve mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});
$('#index-phone').live('mousedown', function(e) {
    if ( e.button == 2 && ( this.value == 'Telefonszáma' || this.value == 'A telefonszáma neve mező kitöltése kötelező!' ) ) {
        this.value = ''
        this.style.color = '#D7CD9E';
    }
});

// Lábléc űrlap eseményeinek kezelése
    function setSelectionRangeX(input, selectionStart, selectionEnd) {
    // IE
        if (input.createTextRange) {
            var range = input.createTextRange();
            range.collapse(true);
            range.moveEnd('character', selectionEnd);
            range.moveStart('character', selectionStart);
            range.select();
    // real browsers :)
        } else if (input.setSelectionRange) {
            input.focus();
            input.setSelectionRange(selectionStart, selectionEnd);
        }
    }
    $("#index-email").focus(function() {
        if( this.value == 'E-mail cím' || this.value == 'Az e-mail cím mező kitöltése kötelező!' || this.value == 'Hibás e-mail formátum!' ) {
            this.style.color = '#3b3f17';
            setSelectionRangeX(this, 0, 0);
        }
    });
    $("#index-email").keypress(function() {
        if( this.value == 'E-mail cím' || this.value == 'Az e-mail cím mező kitöltése kötelező!' || this.value == 'Hibás e-mail formátum!' ) {
            this.value = '';
            this.style.color = '#D7CD9E';
        }
    });
    $("#index-email").blur(function() {
        this.style.color = '#D7CD9E';
        if( this.value == '' ) this.value = 'E-mail cím';
    });

    $("#index-comment").focus(function() {
        if( this.value == 'Megjegyzés' || this.value == 'A megjegyzés mező kitöltése kötelező!' ) {
            this.style.color = '#3b3f17';
            setSelectionRangeX(this, 0, 0);
        }
    });
    $("#index-comment").keypress(function() {
        if( this.value == 'Megjegyzés' || this.value == 'A megjegyzés mező kitöltése kötelező!' ) {
            this.value = '';
            this.style.color = '#D7CD9E';
        }
    });
    $("#index-comment").blur(function() {
        this.style.color = '#D7CD9E';
        if( this.value == '' ) this.value = 'Megjegyzés';
    });

    $("#index-name").focus(function() {
        if( this.value == 'Ajánlatkérő neve' || this.value == 'Az ajánlatkérő neve mező kitöltése kötelező!' ) {
            this.style.color = '#3b3f17';
            setSelectionRangeX(this, 0, 0);
        }
    });
    $("#index-name").keypress(function() {
        if( this.value == 'Ajánlatkérő neve' || this.value == 'Az ajánlatkérő neve mező kitöltése kötelező!' ) {
            this.value = '';
            this.style.color = '#D7CD9E';
        }
    });
    $("#index-name").blur(function() {
        this.style.color = '#D7CD9E';
        if( this.value == '' ) this.value = 'Ajánlatkérő neve';
    });

    $("#index-phone").focus(function() {
        if( this.value == 'Telefonszáma' || this.value == 'A telefonszáma neve mező kitöltése kötelező!' ) {
            this.style.color = '#3b3f17';
            setSelectionRangeX(this, 0, 0);
        }
    });
    $("#index-phone").keypress(function() {
        if( this.value == 'Telefonszáma' || this.value == 'A telefonszáma neve mező kitöltése kötelező!' ) {
            this.value = '';
            this.style.color = '#D7CD9E';
        }
    });
    $("#index-phone").blur(function() {
        this.style.color = '#D7CD9E';
        if( this.value == '' ) this.value = 'Telefonszáma';
    });

});

