
$(document).ready(function(){
   $("#Image21").attr({src:"/images/arrows/a5_01a.png"}); 
   $("#button1").click(function(){
     switchTab(1);
     $("#Image22").attr({src:"/images/arrows/a5_02.png"});
     $("#Image23").attr({src:"/images/arrows/a5_03.png"});
     $("#Image21").attr({src:"/images/arrows/a5_01a.png"});
   });
   $("#button2").click(function(){
     switchTab(2);
//      console.log('here1');
     $("#Image21").attr({src:"/images/arrows/a5_01.png"});
     $("#Image23").attr({src:"/images/arrows/a5_03.png"});
     $("#Image22").attr({src:"/images/arrows/a5_02a.png"});
//      console.log('here2');
    
   });
   $("#button3").click(function(){
     switchTab(3);
     $("#Image21").attr({src:"/images/arrows/a5_01.png"});
     $("#Image22").attr({src:"/images/arrows/a5_02.png"});
     $("#Image23").attr({src:"/images/arrows/a5_03a.png"});
   });

//     $("#rating").mouseover(function(){
//         
//         $("#rating").hide();
//         $("#rate").show();
//     });
//     
//     $("#rate").mouseout(function(){
//         $("#rating").show();
//         $("#rate").hide();
//     });
//

    

//    $("#changePassBtn").click(function(){
//         submitForm('changePassForm');
//    });

    $('#changePassForm').submit(function() {
        // now we're going to capture *all* the fields in the
        // form and submit it via ajax.

        // :input is a macro that grabs all input types, select boxes
        // textarea, etc.  Then I'm using the context of the form from
        // the initial '#contactForm' to narrow down our selector
        var inputs = [];
        $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
        })

        // now if I join our inputs using '&' we'll have a query string
        jQuery.ajax({
            data: inputs.join('&'),
            url: this.action,
            timeout: 2000,
            type:'post',
            error: function() {
                //console.log("Failed to submit");
        },
        success: function(r) {
            alert(r);
        }
    }) // checkout http://jquery.com/api for more syntax and options on this method.

    // re-test...
    // by default - we'll always return false so it doesn't redirect the user.
    return false;
})

//switchTab(1);
   
 });


var selTab = 1;
function switchTab(tab){
    if( tab != selTab ){
        //console.log(tab);
        //console.log(selTab);
        $("#tab" + selTab).hide('slow');
        $("#tab" + tab).show('slow');
        selTab = tab;
        //console.log("after click: "+selTab);
   }
}

function submitForm(){

    var inputs = [];
    $(':input', this).each(function() {
    inputs.push(this.name + '=' + escape(this.value));
    });

    jQuery.ajax({
    data: inputs.join('&'),
    url: this.action,
    timeout: 2000,
    error: function() {
        //console.log("Failed to submit");
    },
    success: function(r) {
        alert(r);
    }
    }) 

}

function rate(vote){
    
    for(i = vote; i <= rating ; i++){
        document.getElementById('r'+i).src = '/images/dots/d4_03.png';
    }
    
    for(i = vote; i > 0; i--){
        //alert('r'+vote);
        document.getElementById('r'+i).src = '/images/dots/d4_01.png';
    }
    
}

function unrate(vote){
    for(i = 1; i <= 5; i++){
        //alert('r'+vote);
        document.getElementById('r'+i).src = '/images/dots/d4_03.png';
    }
   
    rate(rating);
}