function kcsscroller(){
	var scrollSpeed=50;
	var pause=7000;	
	var currentImage=0;//Image in array
	var activeImage=0;//gallery image
	var activeText=0;
	var hasText=false;
	var images=[];
	var sTimer=null;
	var simage=[];
	var stext=[];
	var textPanel;
	var textContent=[];
  var gallery;
  var ie;
  var width;
  var height;
  var tout;
  var hasControls=false;
  var controlPanel;
  var running;
  var transitionSpeed=1000;
  var imageSpeed=1;
  var textSpeed=1;
	
	function scrollImage(){		
		var lleft=0;
		var rleft=0;
		var ttop=0;
		var btop=0;
		var width;
		var calc=0;
		
		lleft=parseInt(simage[activeImage].style.left);
		rleft=parseInt(simage[activeImage^1].style.left);
		if(isNaN(lleft))
			lleft=0;
		if(isNaN(rleft))
			rleft=0;
		if(hasText){
			ttop=parseInt(stext[activeImage].style.top);
			btop=parseInt(stext[activeImage^1].style.top);
			if(isNaN(ttop))
				ttop=0;
			if(isNaN(btop))
				btop=0;

			ttop-=textSpeed;				
			btop-=textSpeed;
			
			//ttop=Math.ceil(ttop);
			//btop=Math.floor(btop);
		}
		
		lleft-=imageSpeed;
		rleft-=imageSpeed;
		
		//lleft=Math.ceil(lleft);
		//rleft=Math.floor(rleft);
		
		
		//alert(imageSpeed+" "+textSpeed);	
		if(lleft<(parseInt(gallery.style.width)*-1)){
			clearInterval(sTimer);
			currentImage++;
			
			if(currentImage>(images.length-1))
		    currentImage=0;
			
      simage[activeImage].src=images[currentImage]['image'].src;
      simage[activeImage].style.left=gallery.style.width;
      
      if(hasText){
      	stext[activeImage].innerHTML=images[currentImage]['text'];
      	stext[activeImage].style.top=gallery.style.height;
      }
      
      activeImage=activeImage^1;
      
      tout=setTimeout(startScroll,pause);
		} else {
			simage[activeImage].style.left=lleft+"px";
			simage[activeImage^1].style.left=rleft+"px";
			
			if(hasText){
				stext[activeImage].style.top=ttop+"px";
				stext[activeImage^1].style.top=btop+"px";
			}
		}
	}
		
	this.addImage=function(image,text){
		var details=[];
		var img=new Image();
		
		img.src=image;
		
		details['image']=img;
		details['text']=text;
		
		images.push(details);
	};
	
	
	function startScroll(){
		sTimer=setInterval(scrollImage,scrollSpeed);
	}
	
	function setupText(){
		textPanel=document.createElement('div');
  	textPanel.style.position="absolute";
  	textPanel.style.left="0px";
  	textPanel.style.width="150px";
  	textPanel.style.top="0px";
  	textPanel.style.height=gallery.style.height;
  	textPanel.style.zIndex="4";
  	if(ie)
    	textPanel.style.filter="alpha(opacity=70)";
  	else
  		textPanel.style.opacity="0.7";
  	
  	textPanel.style.backgroundColor="#BFDFFF";
  	textPanel.id="excerpt";
  	
  	textPanel.style.padding="10px";
  	stext[0]=document.createElement('div');
  	stext[0].className="excerpt_text";
  	stext[0].style.position="absolute";
  	
		stext[0].style.zIndex="5";
		stext[0].style.left="0px";
		stext[0].style.top="0px";
		stext[0].style.width="150px";
		stext[0].style.height=gallery.style.height;
		//stext[0].style.padding="10px";
		stext[0].innerHTML=images[0]['text'];
		
		stext[1]=document.createElement('div');
		stext[1].className="excerpt_text";
  	stext[1].style.position="absolute";
		stext[1].style.zIndex="5";
		stext[1].style.left="0px";
		//stext[1].style.padding="10px";
		stext[1].style.top=gallery.style.height;
		
		stext[1].style.width="150px";
		stext[1].style.height=gallery.style.height;  		
		stext[1].innerHTML=images[1]['text'];
		
		gallery.appendChild(textPanel);
		gallery.appendChild(stext[0]);
		gallery.appendChild(stext[1]);
	}	
		
	function setupControls(){
	  //gallery.onmouseover=this.showcontrols;
		var btn;
		
	  controlPanel=document.createElement("div");
	  controlPanel.style.position="absolute";
	  controlPanel.style.zIndex="6";

	  controlPanel.style.top=(height-25)+"px";
	  controlPanel.style.width=width+"px";
	  controlPanel.style.left="0px";
	  controlPanel.style.height="25px";
	  controlPanel.style.backgroundColor="#0066CC";
	  controlPanel.style.textAlign="center";
	  controlPanel.style.fontSize="14pt";
	   
	  btn=document.createElement("button");
	  btn.style.marginRight="5px";
	  if(!ie) {
	  	btn.type="button";
	  	btn.style.cursor="pointer";
	  } else
	  	btn.style.cursor="hand";
	  btn.id="stop";
	  btn.style.marginTop="2px";
	  btn.style.border="0px";
	  btn.style.width="35px";
	  btn.style.height="20px";
	  btn.innerHTML="&#9632;";
	  btn.style.fontSize="12pt";
	  btn.style.textAlign="center";
	  btn.style.backgroundColor="transparent";
	  btn.style.color="white";
	  btn.title="Pause";	  
	  btn.onmouseover=function(){	this.style.backgroundColor="orange"; };
	  btn.onmouseout=function(){this.style.backgroundColor="transparent"; };
	  btn.onclick=function(){
	    if(running){
	    	clearTimeout(tout);
	    	clearInterval(sTimer);
	    	this.innerHTML="&#9658;";
	    	running=false;
	    	btn.title="Play";
	    }else{
	    	clearTimeout(tout);
	    	clearInterval(sTimer);
	    	sTimer=setInterval(scrollImage,scrollSpeed);
	    	this.innerHTML="&#9632;";
	    	btn.title="Pause";
	    	running=true;
	    }
	  };
	  controlPanel.appendChild(btn);

	  controlPanel.style.fontSize="14pt";
	  gallery.appendChild(controlPanel);
	}
	
	this.start=function(element, w,h, withText, withControls){
		gallery=document.getElementById(element);
		pixelMove=1;
		running=true;
		width=w;
		height=h;
		gallery.style.width=width+"px";
		gallery.style.height=height+"px";
		
		ie=document.all ? true : false;
		
		simage[0]=document.createElement('img');
		simage[1]=document.createElement('img');
				
    gallery.appendChild(simage[0]);
    gallery.appendChild(simage[1]);
    
    simage[0].style.position="absolute";
		simage[0].style.zIndex="2";
		simage[0].style.left="0px";
		simage[0].style.top="0px";
    simage[0].src=images[0]['image'].src;
    
    simage[1].style.position="absolute";
		simage[1].style.zIndex="3";
		simage[1].style.left=width+"px";
		simage[1].style.top="0px";
    simage[1].src=images[1]['image'].src;
    hasText=withText;
    hasControls=withControls;
    if(hasText) setupText();
    if(hasControls) setupControls();
    imageSpeed=Math.ceil((width/transitionSpeed)*scrollSpeed);
    textSpeed=Math.ceil((height/transitionSpeed)*(scrollSpeed-(width/height)));
    
    //scrollSpeed=transitionSpeed;
    //alert(scrollSpeed);
    activeImage=0;
    currentImage=1;
		tout=setTimeout(startScroll,pause);
	};
}
