img_url = 'http://ts.clients.squiz.co.uk/__data/assets/image/0008/40202/ajax-loader.gif'
ajax_url = 'http://ts.clients.squiz.co.uk/mp3_test/ajax'

jQuery(document).ready(function() {
	jQuery('a[title="mp3"]').click(function() {
                confirmation(this)
		return false
	})
})

function confirmation(e) {
        jQuery('body').append('<div id="cover_surface"></div>')

        jQuery('#cover_surface').css({
           position: 'fixed',
           backgroundColor: '#000', 
           top: 0, 
           left: 0, 
           height: jQuery(document).height(), 
           width: jQuery(document).width(),
           opacity: 0.5, 
           display: 'none'
        })

        //jQuery("#cover_surface").fade(1000)

        jQuery('body').append('<div id="confirmation_box"></div>')
        
        jQuery('#confirmation_box').css({
           position: 'fixed',
           backgroundColor: '#FFF', 
           top: jQuery(document).height()/2 - 200, 
           left: jQuery(document).width()/2 - 300, 
           height: '300px', 
           width: '600px', 
           border: '2px solid #000', 
           display: 'none'
        })

        jQuery("#confirmation_box").append('<p><img src="'+img_url+'"/> Please Wait...</p>')        
        jQuery("#confirmation_box").show(1000)
         
        jQuery.ajax({
           url: ajax_url,
           cache: false,
           success: function(html){
                       jQuery("#confirmation_box > p:eq(0)").remove()
                       jQuery("#confirmation_box").append(html)
                       jQuery("#agree").click(function() {agree(e)})
                       jQuery("#disagree").click(function() {disagree()})
                    }
        });    
}

function agree(e) {
    jQuery("#confirmation_box").remove()
    jQuery("#cover_surface").remove()
    window.location = e.href
}

function disagree() {
    jQuery("#confirmation_box").remove()
    jQuery("#cover_surface").remove()
}