$(function(){

    // Slider
    $("#BJ_amount").val('€ ' + 0);
    $('#BJ').slider({
            range: "min",
            value: 1,
            min: 0,
            max: 75000,
            slide: function(event, ui) {
                    $("#BJ_amount").val('€ ' + ui.value);

            }
    });
    //$("#amount").val('$' + $("#slider-range-min").slider("value"));

    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
            function() {$(this).addClass('ui-state-hover');},
            function() {$(this).removeClass('ui-state-hover');}
    );

});

$(function(){

    // Slider
    $("#BJP_amount").val('€ ' + 0);
    $('#BJP').slider({
            range: "min",
            value: 1,
            min: 0,
            max: 75000,
            slide: function(event, ui) {
                    $("#BJP_amount").val('€ ' + ui.value);

            }
    });
    //$("#amount").val('$' + $("#slider-range-min").slider("value"));

    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
            function() {$(this).addClass('ui-state-hover');},
            function() {$(this).removeClass('ui-state-hover');}
    );

});

$(function(){

    // Slider
    $("#EG_amount").val('€ ' + 0);
    $('#EG').slider({
            range: "min",
            value: 1,
            min: 0,
            max: 75000,
            slide: function(event, ui) {
                    $("#EG_amount").val('€ ' + ui.value);

            }
    });
    //$("#amount").val('$' + $("#slider-range-min").slider("value"));

    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
            function() {$(this).addClass('ui-state-hover');},
            function() {$(this).removeClass('ui-state-hover');}
    );

});

/* ------ CALCULATOR ------ */


var str1 = document.getElementById('BJ_amount');
var str2 = "-";
//function con(str1, str2, idx)
function con()
{
    str1.disabled = "false";

var str3 = str1.value.substring(0, idx-1) + str2 + str1.value.substring(idx-1, str1.length);

alert(str3);
//alert('i am called');
}

var total = 0;

$(document).ready(function(){

    $('#calc .total').val('€ ' + 0 + ',-');

    $(".ui-slider-handle").mouseup(function() {
        calculateTotal();
    }).mouseleave(function() {

        
    }).focusout(function() {
        calculateTotal();
    });
});


var textbox1 = "";
var textbox2 = "";
var textbox3 = "";

var tmp = "";
var tmp2 = "";
var tmp3 = "";

var value1 = 0;
var value2 = 0;
var value3 = 0;

$(document).ready(function(){
    // on focus
    $('#BJ_amount').focusin(function(){
       // saves value of text
       textbox1 = $('#BJ_amount').val();

       // clear textbox
       $('#BJ_amount').val("");

    });

    $('#BJ_amount').focusout(function(){
        // return value if textbox is empty on focusout
        if($('#BJ_amount').val() == ''){
            $('#BJ_amount').val(textbox1);
        }

        else{
            // display value with € sign.
            tmp = $('#BJ_amount').val();
            $('#BJ_amount').val('€ ' + tmp);
        }
         calculateTotal();
    });

    // on focus

    $('#BJP_amount').focusin(function(){
       // saves value of text
       textbox1 = $('#BJP_amount').val();

       // clear textbox
       $('#BJP_amount').val("");

    });

    $('#BJP_amount').focusout(function(){
        // return value if textbox is empty on focusout
        if($('#BJP_amount').val() == ''){
            $('#BJP_amount').val(textbox1);
        }

        else{
            // display value with € sign.
            tmp = $('#BJP_amount').val();
            $('#BJP_amount').val('€ ' + tmp);
        }
         calculateTotal();
    });

    // on focus
    $('#EG_amount').focusin(function(){
       // saves value of text
       textbox1 = $('#EG_amount').val();

       // clear textbox
       $('#EG_amount').val("");

    });

    $('#EG_amount').focusout(function(){
        // return value if textbox is empty on focusout
        if($('#EG_amount').val() == ''){
            $('#EG_amount').val(textbox1);
        }

        else{
            // display value with € sign.
            tmp = $('#EG_amount').val();
            $('#EG_amount').val('€ ' + tmp);
        }
         calculateTotal();
    });

    /*$('#BJ_amount').keyup(function(){
        var str1 = $('#BJ_amount').val();
        //alert(str1);

        var num1 = str1.substr(1);

        //alert(num1);
    });*/

    $('#BJ_amount').keyup(function(e){
        if(e.keyCode == 13) {
            //alert('Enter key was pressed.');
            calculateTotal();
        }
    });

    $('#BJP_amount').keyup(function(e){
        if(e.keyCode == 13) {
            //alert('Enter key was pressed.');
            calculateTotal();
        }
    });

    $('#EG_amount').keyup(function(e){
        if(e.keyCode == 13) {
            //alert('Enter key was pressed.');
            calculateTotal();
        }
    });
});






// FUNCTION for Input Text
/*
$(document).ready(function(){
    $('#BJ_amount').keypress(function(){
       calculateTotal();
    });
    $('#BJP_amount').keypress(function(){
       calculateTotal();
    });
    $('#EG_amount').keypress(function(){
        calculateTotal();
    });
});
*/

function calculateTotal(){
    var strBJamount;
    var strBJPamount;
    var strEGamount;

    var BJamount = 0;
    var BJPamount = 0;
    var EGamount = 0;

    var total = 0;
    //      con();
    strBJamount = $('#BJ_amount').val().toString();
    strBJPamount = $('#BJP_amount').val().toString();
    strEGamount = $('#EG_amount').val().toString();

    BJamount = parseInt(strBJamount.replace('€ ', ''));
    BJPamount = parseInt(strBJPamount.replace('€ ', ''));
    EGamount = parseInt(strEGamount.replace('€ ', ''));

    total = ((BJamount + BJPamount) * 5) + EGamount;
    strTotal = total.toString().toCurrecyFormated();


    $('#calc .total').val('€ ' + strTotal);
}




//total.toString().toCurrecyFormatted();




