
function autoGaleryClass(cObject,cId){
	if(navigator.appName.indexOf('Explorer')!=-1) this.browserSpeed=1000;
	else this.browserSpeed=1000;
    this.objectKey=cObject;
    if(document.getElementById('galeryDynamicPictureSection_'+cId)==null) return;
    this.divObject=document.getElementById('galeryDynamicPictureSection_'+cId);
	if(this.divObject.getAttribute('isproduct')=='1'){
		this.sourceclass='html';
		this.imgs=new Array();
		var tmpImgs=this.divObject.getElementsByTagName('DIV');
		for(var ii in tmpImgs){
			if(tmpImgs[ii].className=='subdynamicdiv') this.imgs[this.imgs.length]=tmpImgs[ii];
		}
		eval("this.form=document.cartForm_"+cId+";");
		this.ajax=new AjaxClassCollection(this.form.action,"document.cartForm_"+cId,this.objectKey+'.ajax','');		
	}else{
		this.sourceclass='src';
		this.imgs=this.divObject.getElementsByTagName('IMG');
		eval("this.form=document.galeryForm_"+cId+";");
		this.ajax=new AjaxClassCollection(this.form.action,"document.galeryForm_"+cId,this.objectKey+'.ajax','');
	}
	this.object=this.imgs[0];
	this.object1=this.imgs[1];
	this.allPics=new Array();
	this.activePic=this.divObject.getAttribute('pictureA');
	this.lastPic=this.divObject.getAttribute('pictureB');

	this.timeOut=this.divObject.getAttribute('interval')*1000;
	this.opacity=0;
	this.changeSpeed=this.divObject.getAttribute('speed')*1/this.browserSpeed;
    this.object.ondblclick=new Function(this.objectKey+'.getPicture();');
    this.object1.ondblclick=new Function(this.objectKey+'.getPicture();');
	this.getPicture=function(){
		if(this.sourceclass=='html')
			this.ajax.runAjax('autoProductTransition','','&export=1&ajprid='+cId+'&action=autoProductTransition&ajitemId='+this.activePic+'',this.objectKey+'.pictureRecieved')
		else
			this.ajax.runAjax('autoPictureTransition','','&export=1&ajprid='+cId+'&action=autoPictureTransition&picId='+this.activePic+'',this.objectKey+'.pictureRecieved')
	}

    this.pictureRecieved=function(xmlHttpReq){
		if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200) {
			var returnText=xmlHttpReq.responseText;
            var tmpSpl=returnText.split("||");
            this.activePic=tmpSpl[0];
            if(this.lastPic!=this.activePic){
    			this.lastPic=this.activePic;
				if(this.sourceclass=='html') this.imgs[0].innerHTML=tmpSpl[1];
				else this.imgs[0].src=tmpSpl[1];
    			this.opacity=0;
    			this.pictureChangeProcess();
                return;
                
            }
            
            
            
			
			/*this.retXML=xmlHttpReq.responseXML;
			this.XML_mainParams=this.retXML.getElementsByTagName('submitFormTags')[0];
			this.flyElemInner=XML_getNodeValue('cartImage',this.XML_mainParams);
			this.flyToCart();*/			
		}
        
    }

	this.runPictureChange=function(){
		this.getPicture();
		if(this.lastPic!=this.activePic){
			this.lastPic=this.activePic;
			if(this.sourceclass=='html') this.object.innerHTML=this.allPics[this.activePic];
			else this.object.src=this.allPics[this.activePic];
			this.opacity=0;
			this.pictureChangeProcess();
			return;
		}else
		setTimeout(this.objectKey+".runPictureChange();",this.timeOut);
	}

	this.pictureChangeProcess=function(){
		this.opacity=this.opacity+this.changeSpeed;
		this.imgs[0].style.cssText='position:absolute;opacity:'+this.opacity+';filter:alpha(opacity='+(this.opacity*100)+');';
		this.imgs[1].style.cssText='position:absolute;opacity:'+(1-this.opacity)+';filter:alpha(opacity='+(100-this.opacity*100)+');';
		if(this.opacity<1){
			setTimeout(this.objectKey+".pictureChangeProcess();",1);
			return;
		}
		if(this.sourceclass=='html') this.imgs[1].innerHTML=this.imgs[0].innerHTML;
		else this.imgs[1].src=this.imgs[0].src;
		setTimeout(this.objectKey+".getPicture();",this.timeOut);

	}
	setTimeout(this.objectKey+".getPicture();",this.timeOut);
}
