var _carousel;

$(document).ready(function() {
    _carousel = $('#iphone_images').jCarouselLite({
        btnNext: ".next", 
        btnPrev: ".prev", 
        auto: 7000, 
        visible: 1,
        pauseOnHover: false
    });

    $('#notify-blackberry').click(function(e) {
        e.preventDefault();
        $('#platform-display').html('BlackBerry');
        $('#platform-display-2').html('BlackBerry');
        $('#notify-popup').modal();
    });
    
    $('#notify-android').click(function(e) {
        e.preventDefault();
        $('#notify-popup').modal();
    });
    
    $('#download-blackberry').click(function(e) {
        e.preventDefault();
        $('#platform-display').html('BlackBerry');
        $('#platform-display-2').html('BlackBerry');
        $('#download-popup').modal();
    });
    
    $('#download-android').click(function(e) {
        e.preventDefault();
        $('#platform-display').html('Android');
        $('#platform-display-2').html('Android');
        $('#notify-popup').modal();
    });

    $('#dlemail').keydown(function(e) {
        if (this.value=='your email address') { 
           this.value='';
        }
        this.style.color='#000000';
    });

    $('#other').keydown(function(e) {
        if (this.value=='please specify') { 
           this.value='';
        }
        this.style.color='#000000';
    });
    
    $('#notify-save').click(function(e) {
        var name = $('#platform:checked')[0].value;
        if (name == 'Other') {
           name = '';
        }
        $('#platform-display').html(name);
        $('#platform-display-2').html(name);
        $.ajax({
		    url: '/notify_submit/',
			data: $('#notify-form').serialize(),
		    type: 'POST',
		    dataType: 'json',
		    timeout: 10000,
		    error: function() {
		        $('#notify-step1').fadeOut(100, function() {
		           $('#notify-step2').fadeIn(100); 
		        });
		    },
		    success: function(result){
		        $('#notify-step1').fadeOut(100, function() {
		           $('#notify-step2').fadeIn(100); 
		        });
		    }
		});
    });
    
    $('#notify-cancel').click(function(e) {
        e.preventDefault();
        $.modal.close();
    });
    
    $('#notify-continue').click(function(e) {
        e.preventDefault();
        $.modal.close();
    });

    
    $('#download-save').click(function(e) {
        $.ajax({
		    url: '/download_submit/',
		    data: $('#download-form').serialize(),
		    type: 'POST',
		    dataType: 'json',
		    timeout: 10000,
		    error: function() {
		        $('#download-step1').fadeOut(100, function() {
		           $('#download-step2').fadeIn(100); 
		        });
		    },
		    success: function(result){
		        $('#download-step1').fadeOut(100, function() {
		           $('#download-step2').fadeIn(100); 
		        });
		    }
		});
    });
    
    $('#download-cancel').click(function(e) {
        e.preventDefault();
        $.modal.close();
    });
    
    $('#download-continue').click(function(e) {
        e.preventDefault();
        $.modal.close();
    });
});

