var extSlider = function(conf){
    conf = conf == undefined ? new Array() : conf;
       
    conf.transIn = conf.transIn == undefined ? 'r' : conf.transIn;
    conf.transOut = conf.transOut == undefined ? 'l' : conf.transOut; 
    conf.contentId 	= conf.contentId 		== undefined ? 'box-content':conf.contentId;
    conf.sliderClass 	= conf.sliderClass == undefined ? 'content-slider':conf.sliderClass;
    conf.ocjenaPath = conf.ocjenaPath == undefined ? '/tpl/karlovacko/korner/res/images/' : conf.ocjenaPath;
    conf.longdesc = conf.longdesc == undefined ? '/' : conf.longdesc;
        
    this.conf = conf;
    //this.init();
};

extSlider.prototype = {
	
    init:function(){
		this.connText = new Ext.data.Connection();	
    	this.boxContent = Ext.get(this.conf.contentId);
    	this.runningContent = null;
    	this.activeContent = this.boxContent.child('div.'+this.conf.sliderClass);
    	this.trIn = this.conf.transIn;
    	this.trOut = this.conf.transOut;
    },
    clearRunningContent:function(){
    	this.runningContent = null;
    },
    cbLoadContent:function(options, bSuccess, response) {
    	if(this.runningContent) { this.runningContent.stopFx(); }            
		if(this.activeContent) { this.activeContent.slideOut(this.trOut, {duration:.35, remove:true}); }
        
        var json = Ext.util.JSON.decode(response.responseText);
        
        KarlovackoKlubUkupnaOcjenaBuilder(this.conf.ocjenaPath, json.rating, 'klub_ukupna_ocjena', true, 1,'UkupnaOcjena', this.conf.longdesc);
        if (document.getElementById('klub_tvoja_ocjena')) {
        	KarlovackoKlubUkupnaOcjenaBuilder(this.conf.ocjenaPath, json.myVote, 'klub_tvoja_ocjena', json.myVote > 0 ? true : false, json.imageId,'TvojaOcjena', this.conf.longdesc);
        }

        document.getElementById("klub_autor").innerHTML = json.autor;
        document.getElementById("karlovacko_klub_ocjena_h3").innerHTML = json.name;
        document.getElementById('formPosaljiFotku').image_id.value = json.imageId;

        var s = response;
		s.el = new Ext.Element(document.createElement('div'));
		s.el.addClass(this.conf.sliderClass);		
		s.el.enableDisplayMode();            
		s.el.update(json.image);
		s.el.appendTo(this.boxContent);
		s.el.slideIn(this.trIn, {callback: this.clearRunningContent, duration:.35});
		this.runningContent = s.el;
		this.activeContent = s.el;				
		return true;
    },
    loadLeft:function(url) {
   		this.process = true;
    	this.trIn = this.conf.transIn;
    	this.trOut = this.conf.transOut;
    	this.connText.request({ url: url, method: 'GET', callback: this.cbLoadContent, scope: this });
    },
    loadRight:function(url) {
   		this.process = true;
    	this.trIn = this.conf.transOut;
    	this.trOut = this.conf.transIn;
    	this.connText.request({ url: url, method: 'GET', callback: this.cbLoadContent, scope: this });
    }
};
