/*JS Jquery*/
//Global Variables
var images = new Array();
var count = 0 
var banner_id;
var img_width;
var img_height;
var over = false;
var delay_time; 
var ease;

function jq_banner(id,delay,easing){
	delay_time = delay*1000;
	ease = easing;
	banner_id = id;
	img_width = $('#'+banner_id+' div img').width();
	img_height = $('#'+banner_id+' div img').height();
	$('#'+banner_id).css({
		width : img_width+'px',
		height : img_height+'px',
		overflow : 'hidden'
	})  
	$('#'+banner_id+' div').children().each(function(){ 
		images.push($(this).attr('src'));
	})
	$('#'+banner_id+' div').children().remove()
	$('#'+banner_id+' div').append('<img src="'+images[0]+'" />');
	
	$('#'+banner_id).mouseover(function(){
		if (easing){
			over = true;
			}else{
			over = false; 
			}
	})
	
	$('#'+banner_id).mouseout(function(){
		over = false;
	})
	
	if(ease == false){
		b_animate();
	}else{
		setInterval('b_animate()',delay_time);
	}
}

function b_animate(){
	if(!over){
		var w_div = img_width*3 
		
		$('#'+banner_id+' div').css('width',w_div+'px'); 
		
		count++;
		
		if(count == images.length){
			count = 0;
		}
		
		$('#'+banner_id+' div').append('<img src="'+images[count]+'" />');
		
		var pos = -img_width;
		
		if(ease == false){
			$('#'+banner_id+' div').animate({
				'margin-left': pos+'px',
			},delay_time,"linear",function(){
				reset_b();
				b_animate();
			})
			
		}else{
			$('#'+banner_id+' div').animate({
				'margin-left': pos+'px',
			},(delay_time-(delay_time/3)),"swing",function(){
				reset_b()
			})
		}
	}
	
}


function reset_b(){
	$('#'+banner_id+' div').children(':first').remove();
	$('#'+banner_id+' div').css('margin-left','0px');	
}

