// JavaScript Document
function getBanner(banner_id,blog_url,position_id) {
     //alert(blog_url);
    //generate the parameter for the php script
    var data = "action=my_banner_action&banner_id=" + banner_id + "&position_id=" + position_id;;
	//alert(data);
    jQuery.ajax({
        //url: "/banner-loader.php",
		url: blog_url+"/wp-admin/admin-ajax.php",
        type: "POST",       
        data: data,    
        cache: false,
        success: function (response) { 
         
            //add the content retrieved from ajax and put it in the #content div
			//alert(response);
			//$('#banner-div-content').html("");
            //$('#banner-div-content').html(response);
			$('#slides').html("");
            $('#slides').html(response);
            //display the body with fadeIn transition
            //$('#demo1').fadeIn('slow');
			//$('#demo1').hide();
			
            //animateBanner(); //Function is exist on header.php
			if(banner_id==''){
				clearInterval( $("#slides").data("interval")); //To clear the previous instance
			}
			//$(function(){
			//alert('success');
			
			$('#slides').slides({

				preload: true,
				preloadImage: blog_url+'/wp-content/themes/imre2011/images/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true,
				start: banner_id == '' ? parseInt(position_id)+1 : 1, //Start from the next of the thumbnail clicked
				animationStart: function(current){
					
					$('.caption').animate({
						bottom:-35
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}
			});
		//});
			
			//$('#demo1').show();
        },
		error:function (xhr, ajaxOptions, thrownError){
                    alert(xhr.statusText);
                    alert(thrownError);
        }     
    });
	
}
