$.fn.bulletsCarousel2 = function(options) {  

         var  defaults = {  
             idContainer: 'mainBulletContainer',  
             idContent: 'mainBulletContent',  
             leftButton: 'leftButton' ,
			 rightButton: 'rightButton',
			 bulletList: 'bulletContainer',		 
			 timer: false,
			 time: 8500
           },  
          vars = $.extend({}, defaults, options);  
		  
if( $("#"+vars.idContainer).length > 0) {
	
	var ende = ".png";
	if(typeof document.body.style.maxHeight === "undefined")
	ende = ".gif";
	
	//variable declaration
	var i=0; //-used as a counter
	var bullet = 1; //-keep track of which bullet we are using. Right now we are at bullet : 1
 	var myTimeout; //time for auto-scroll
	//sanity check: We must count how many list items there are in our vars.idContent div.
	var listSize = $("#"+vars.idContent + " ul li").size();

	//if our list size is for any reason smaller(!) or equal to Zero, then we bestow invisibilty upon our navigational buttons.
	//Reason: they are not to be pressed and yield no results.
	if(listSize <= 0)
	{
		$(vars.leftButton).css("display", "none");
		$(vars.rightButton).css("display", "none");
		return false; 
		//ending the function no reason to keep active code
	}    
      
    
	//we otherwise proceed.
	//we are to create a list that will be autofilled with bullet items. These lie within our custom css.

	$("div."+vars.bulletList).append('<ul class="serialList">');
	
	for(i=1;i<=listSize;i++) { 
		$("div."+vars.bulletList+" ul.serialList").append("<li><div class='bullet'></div></li>"); 
		if(i==listSize) $("div."+vars.bulletList).append("</ul>");
		
		
		//$("div#homePageRight").append('<div class="HomePageWidget" ><img src='+$("div#"+vars.idContent+" ul li:nth-child("+i+") div.imageurl").html()  +' /></div>');
		
	}
	
	$("div#mainSlider").css("margin-left", (440-$("div#mainSlider").width()) );

	//Populate our Container with the first child of the list and set the first bullet as active!
	document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child(1) div.content").html();
	Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
	
	$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child(1) div.link").html() );
	$("div#MasterWidget").append('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
	
	
	// first bullet is active!
	$("div."+vars.bulletList+" ul.serialList li:nth-child(1) div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
	$("div."+vars.rightButton).click( function() {
					vars.time = 90000;
					if(bullet<listSize) {
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");	
						bullet++;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();	
						
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );		
	$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
	
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove(); });
						
						
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}
					else if(bullet==listSize) {
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");
						bullet=1;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
						
						$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
						
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove(); });

						
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}
					//if(vars.timer==true)
	   				//myTimeout = setTimeout(callBack, vars.time); 
		});
	///////////////////////////////////////////////////////////////////////////////
		$("div."+vars.leftButton).click( function() {
					vars.time = 90000;
					//we show the fadeout effect and
					//$("#"+vars.idContainer).stop(true,true).fadeOut();
					//document.getElementById(vars.idContainer).innerHTML = "";
					
					//bullet = bullet + 1; Since we are moving towards the next bullet.
					// yet if we are currently at the last bullet (listSize) then we have to return to bullet:1
					if(bullet>1) {
						if(typeof document.body.style.maxHeight === "undefined")
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet.gif)");
						else
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");	
						bullet--;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
						$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove(); });
						
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});

Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");

						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}
					else if(bullet==1) {
						if(typeof document.body.style.maxHeight === "undefined")
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet.gif)");
						else
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");
						bullet=listSize;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
						$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove(); });
						
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}
					//if(vars.timer==true)
	   				//myTimeout = setTimeout(callBack, vars.time); 			
		});
	////////////////////////////////////MAIN BULLETS//////////////////////////////////////////////
	$("div."+vars.bulletList+" ul.serialList li").click( function() {
																  vars.time = 90000;
			//$("#"+vars.idContainer).stop(true,true).fadeOut();
			if(typeof document.body.style.maxHeight === "undefined")
			$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet.gif)");
			else
			$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");
			bullet  = $(this).index()+1;
						
			$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
			document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
			$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
			$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove(); });
			
			
			$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
			//$("div#homePageRight").css("background-image", "url("+$("#"+vars.idContent + " ul li:nth-child("+bullet+") div.imageurl").html()+")"  );
			
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
			//$("#"+vars.idContainer).stop(true,true).fadeIn();
			
			//if(vars.timer==true)
	   		//myTimeout = setTimeout(callBack, vars.time); 
		});		
	
	}	
	/////////////////////////////////////////////////////////////////////////////////////////////
	

	/////////////////////////////////

		
		
function callBack() { 
					//$("#"+vars.idContainer).stop(true,true).fadeOut();
					//document.getElementById(vars.idContainer).innerHTML = "";
					
					//bullet = bullet + 1; Since we are moving towards the next bullet.
					// yet if we are currently at the last bullet (listSize) then we have to return to bullet:1
					if(bullet<listSize) {
						if(typeof document.body.style.maxHeight === "undefined")
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet.gif)");
						else
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");	
						bullet++;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
						$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove();   });
						
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}
					else if(bullet==listSize) {
						if(typeof document.body.style.maxHeight === "undefined")
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet.gif)");
						else
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet"+ende+")");
						bullet=1;
						document.getElementById(vars.idContainer).innerHTML = $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.content").html();
						$("div#MasterWidget").prepend('<div class="HomePageWidget"><img src="'+$("div#"+vars.idContent+' ul li:nth-child('+bullet+') div.imageurl img').attr("src")+'" /></div>');
						$("div.HomePageWidget:eq(1)").fadeOut(1800, function() { $(this).remove();  });
						
						$("a.frontpageLink").attr("href", $("#"+vars.idContent + " ul li:nth-child("+bullet+") div.link").html() );	
						//$("div#homePageRight").css("background-image", "url("+$("#"+vars.idContent + " ul li:nth-child("+bullet+") div.imageurl").html()+")"  );
						
Cufon.replace('h2', {	
	fontFamily: 'HelveticaNeueLt',
	hover: true
});
Cufon.replace('h4', {	
	fontFamily: 'HelveticaNeueLtCond',
	hover: true
});
						
						$("div."+vars.bulletList+" ul.serialList li:nth-child("+bullet+") div.bullet").css("background-image", "url(fileadmin/templates/images/bullet-active"+ende+")");
						//$("#"+vars.idContainer).stop(true,true).fadeIn();
					}						  
						myTimeout = setTimeout(callBack, vars.time);
			}


	if(vars.timer==true)
	   myTimeout = setTimeout(callBack, vars.time); 

}
