
var SLIDE_CONTENT_OBJECTS=[];
var SLIDE_CONTENT_COUNTER=0;
var SC_ID_PREFIX='sc_';
var SLIDE_CONTENT_AUTO_BACK_TIMEOUT=1500;
function SlideContent_Create(oProps){
if(!oProps){
 oProps={};
}
SLIDE_CONTENT_COUNTER++;
oProps.id=SC_ID_PREFIX+SLIDE_CONTENT_COUNTER;
var oSlideContent=new SlideContent(oProps);
SLIDE_CONTENT_OBJECTS[oSlideContent.id]=oSlideContent;
return oSlideContent;
}
function SlideContent_GetById(sId){
return SLIDE_CONTENT_OBJECTS[sId];
}
function SlideContent(oProps){
var WINDOW_DIV_ID_SUFFIX='_windowDiv';
var CONTENT_DIV_ID_SUFFIX='_contentDiv';
var DIRECTION_FWD=1;
 var DIRECTION_BACK=2;
var iLastDirection=null;
this.initialized=false;
this.id=oProps.id;
this.inc=oProps.inc;
this.props=oProps;
this.contentLayer=null;
this.scrollObj=null;
this.speed=oProps.speed;
this.windowLayer=null;
this.applyElementForSlide=function(oDOMObject){
var CLONE_CHILD_OBJECTS=true;
var oCloned=oDOMObject.cloneNode(CLONE_CHILD_OBJECTS);
var oWindowDiv=document.createElement('DIV');
 var oContentDiv=document.createElement('DIV');
oWindowDiv.id=this.id+WINDOW_DIV_ID_SUFFIX;
 oWindowDiv.style.position='relative';
 oWindowDiv.style.width=this.props.width;
 oWindowDiv.style.height=this.props.height;
 oWindowDiv.style.overflow='hidden';
 oWindowDiv.style.zIndex=0;
oContentDiv.id=this.id+CONTENT_DIV_ID_SUFFIX;
 oContentDiv.style.position='absolute';
 oContentDiv.style.top=0;
 oContentDiv.style.left=0;
 oContentDiv.style.whiteSpace='nowrap';
 oContentDiv.style.zIndex=0;
oContentDiv.appendChild(oCloned);
 oWindowDiv.appendChild(oContentDiv);
var oParentNode=oDOMObject.parentNode;
oParentNode.replaceChild(oWindowDiv,oDOMObject);
}
this.backward=function(){
try{
 this.scrollObj.stop();
 iLastDirection=DIRECTION_BACK;
 this.scrollObj.left();
}
 catch(e){
}
}
this.forward=function(){
try{
 this.scrollObj.stop();
 iLastDirection=DIRECTION_FWD;
 this.scrollObj.right();
}
 catch(e){
}
}
this.getEndHtml=function(){
return '</div></div>';
}
this.getStartHtml=function(){
return '<div id = "' + this.id + WINDOW_DIV_ID_SUFFIX + '" style = "position:relative;width:' + this.props.width + '; height:' + this.props.height + ';overflow:hidden;z-index: 0;"><div id = "' + this.id + CONTENT_DIV_ID_SUFFIX + '" style = "position:relative;left:0; top:0;z-index: 0; white-space: nowrap;">';
}
this.init=function(){
if(!this.initialized){
this.windowLayer=new DynLayer(this.id+'_windowDiv');
 this.contentLayer=new DynLayer(this.id+'_contentDiv');
this.scrollObj=new LayerScroll(this.windowLayer,this.contentLayer,this.inc,this.speed);
if(!document.all){
 this.scrollObj.contentWidth=this.contentLayer.w;
 var oDummySpan=document.createElement('SPAN');
 oDummySpan.id='dummyspan';
 oDummySpan.innerHTML=document.getElementById(this.id+CONTENT_DIV_ID_SUFFIX).innerHTML;
 document.getElementById(this.id+CONTENT_DIV_ID_SUFFIX).innerHTML='';
 document.getElementById(this.id+CONTENT_DIV_ID_SUFFIX).appendChild(oDummySpan);
 this.scrollObj.offsetWidth=oDummySpan.offsetWidth-this.windowLayer.w;
}
this.contentLayer.onSlideEnd=HandleSlideEnd;
if(this.props.autoplay){
 this.forward();
}
}else{
return;
}
this.initialized=true;
}
this.stop=function(){
 this.scrollObj.stop();
}
function HandleSlideEnd(){
if(self.props.loop||(self.props.autobackward&&iLastDirection==DIRECTION_FWD)){
 if(iLastDirection==DIRECTION_FWD){
 window.setTimeout('SlideContent_GetById("' + self.id + '").backward()',SLIDE_CONTENT_AUTO_BACK_TIMEOUT);
}else{
 window.setTimeout('SlideContent_GetById("' + self.id + '").forward()',SLIDE_CONTENT_AUTO_BACK_TIMEOUT);
}
}
}
var self=this;
}