function xxlMarquee(args){
      	if(!args){
      		this.postNum		= 4;
      		this.changeSpeed 	= 6000;
      		this.imgHeight 	= 350;
				this.headlineWidth= 200;
				this.slideSpeed 	= this.changeSpeed / 16;
      	}else{
				this.postNum 		= (typeof args.postNum == 'undefined') ? 			4 			: args.postNum-1;
      		this.changeSpeed 	= (typeof args.changeSpeed == 'undefined') ? 	6000 		: args.changeSpeed;
      		this.imgHeight 	= (typeof args.imgHeight == 'undefined') ? 		350 		: args.imgHeight;
				this.headlineWidth= (typeof args.headlineWidth == 'undefined') ? 	200 		: args.headlineWidth;
				this.slideSpeed 	= (typeof args.slideSpeed == 'undefined') ? 		this.changeSpeed / 16 		: args.slideSpeed;
      	}

      	// define for local use
			postNum		= this.postNum;
      	changeSpeed = this.changeSpeed;
      	mgHeight = this.imgHeight;
			headlineWidth = this.headlineWidth
      	slideSpeed  = this.slideSpeed;
			distance = $("#image-container").height();
      }

	xxlMarquee.prototype.autoSlide = function(){	

		if( $("#image-container a:last").is(":visible") )
			nextLi = $("#image-container a:first");
		else 
			nextLi = $("#image-container a:visible").next("a"); 
			
		nextLi.show().css("top",distance*-1); // Show next li and move to top
		$("#marquee-nav .active").removeClass("active");
		var next = nextLi.attr("rel")
		$("#marquee-nav a[rel="+next+"]").addClass("active");
		
		$("#image-container a:visible").each(function(index){   // move visible slides down 
			var curPos = $(this).css("top");

			var nextPos = parseInt(curPos)+distance;
			$(this).animate({"top":nextPos},slideSpeed,function(){ 
				if( parseInt( $(this).css("top") ) == distance ){
					$(this).hide();
					$(this).css("top",distance*-1);
				}
			});
		})
		
		xxlMarquee.prototype.changeHeadline(next);
	}


	xxlMarquee.prototype.ManualSlide = function(next){
		$("#headline li").each(function(){ $(this).stop(true , true); })
		$("#image-container a").each(function(){ $(this).stop(true , true); })
		
		$("#image-container a.active").removeClass("active");
		$("#image-container a[rel="+next+"]").addClass("active");

		nextLi = $("#image-container a[rel="+next+"]"); 
		nextLi.show().css("top",distance*-1);

		// Stop all previous animations

		$("#image-container a:visible").each(function(){ // move visible slides down 

			var curPos = $(this).css("top");
			var nextPos = parseInt(curPos)+distance;

			$(this).animate({"top":nextPos},slideSpeed,function(){
				if( parseInt( $(this).css("top") ) == distance ){
					$(this).hide();
					$(this).css("top",distance*-1);
				}
			});
		})

		xxlMarquee.prototype.changeHeadline(next);

	}


xxlMarquee.prototype.changeHeadline = function(next){
  
	if (next == jsMarqueeData.length){
		var next = 0
	}

	var hlPos = headlineWidth*(-1);
	
	$("#headline li.active").animate({"left" : -213},slideSpeed/3,function(){
			$(this).hide().removeClass("active");
			$("#headline li[rel="+next+"]").animate({"left": "0px"},slideSpeed/3,function(){}).addClass("active").show();
	});
}


xxlMarquee.prototype.startInt = function (){slideInterval = window.setInterval("xxlMarquee.prototype.autoSlide();", changeSpeed);}
xxlMarquee.prototype.stopInt  = function (){window.clearInterval(slideInterval);}

xxlMarquee.prototype.init = function (){
	xxlMarquee.prototype.startInt();
	
	$("#image-container a").hide();
	$("#image-container a:first").show();
	$("#highlight-container").mouseover(function(){xxlMarquee.prototype.stopInt();})
	$("#highlight-container").mouseout(function(){xxlMarquee.prototype.startInt();});
	$("#marquee-nav a:first").addClass("active")
	$("#headline li").hide();
	$("#headline li:first").show().css("left","0px").addClass("active");

	// HOME FUNCTIONS
	$("#marquee-nav a").mouseover(
	
		function(){
			xxlMarquee.prototype.stopInt();
		
			if($(this).hasClass("active")){
				}else{
					xxlMarquee.prototype.ManualSlide($(this).attr("rel"))
					$("#marquee-nav a.active").removeClass("active");
					$(this).addClass("active");
				}
		})
}