function couponClearDate(){
        $("#coupon_from").val("Nincs lejárat");
        $("#coupon_to").val("Nincs lejárat");
        $('#coupon_date').DatePickerClear();
}

function changeDateInput(nochecing){
        if($("#coupon_from").val().match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) && $("#coupon_to").val().match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/)){
                $('#coupon_date').DatePickerSetDate([$("#coupon_from").val(),$("#coupon_to").val()],true);
        }else if(nochecking!=NULL && nochecking!=false){
                if(!$("#coupon_from").val().match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/)){
                        $("#coupon_from").val("Nincs lejárat");
                }
                if(!$("#coupon_from").val().match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/)){
                        $("#coupon_to").val("Nincs lejárat");
                }
                alert("Hibás dátum formátum!");
        }
}

function addZero(num,length){
        num=num.toString();
        while(num.length<length){
                num='0'+num;
        }
        return num;
}

function fromToday(){
        var currentTime = new Date();
        var month = addZero(currentTime.getMonth() + 1,2);
        var day = addZero(currentTime.getDate(),2);
        var year = currentTime.getFullYear();
        $("#coupon_from").val(year + "-" + month + "-" + day);
        changeDateInput(true);
}
