

function changeContents(layerId, moveLength, direction, delay) {

   var This = this;

   this.obj = $('#' + layerId)[0];
   this.length = $('#' + layerId).find('>li').length;
   this.moveLength = moveLength;
   this.direction = direction;
   this.delay = delay;
   this.timer = null;

   this.obj.onmouseover = function () { if(This.delay) window.clearInterval(This.timer); }
   this.obj.onmouseout = function () { if(This.delay) This.timer = window.setInterval(function () { eval('This.move' + ((This.direction=='prev')?'Prev':'Next') + '();'); } , This.delay); }

   if((direction=='prev')&&moveLength&&delay) this.movePrev();
   if((direction=='next')&&moveLength&&delay) this.moveNext();

}

changeContents.prototype.getFirstChild = function(obj) {   

   var fObj = obj.firstChild;   

   while(fObj.nodeType!=1) fObj = fObj.nextSibling;     

   return fObj;   

}

changeContents.prototype.getLastChild = function(obj) {   

   var lObj = obj.lastChild;   

   while(lObj.nodeType!=1) lObj = lObj.previousSibling;   
  
   return lObj;   

}

changeContents.prototype.movePrev = function() {   
   
   var This = this;

   if(this.length>this.moveLength) {   

    if((this.delay&&this.timer)||(!this.delay&&!this.timer)) {

     var saveObj = this.getLastChild(this.obj);   
     this.obj.removeChild(this.getLastChild(this.obj));   
     this.obj.insertBefore(saveObj, this.getFirstChild(this.obj));   

	}

   }  
   
   if(this.delay&&(this.timer==null)) this.timer = window.setInterval(function () { This.movePrev(); } , this.delay);

}   

changeContents.prototype.moveNext = function() {   
     
   var This = this;

   if(this.length>this.moveLength) {   

    if((this.delay&&this.timer)||(!this.delay&&!this.timer)) {

     var saveObj = this.getFirstChild(this.obj);   
     this.obj.removeChild(this.getFirstChild(this.obj));   
     this.obj.appendChild(saveObj);   

	}

   }

   if(this.delay&&(this.timer==null)) this.timer = window.setInterval(function () { This.moveNext(); } , this.delay);
   
}  


function recpieFlashLoad(layerId, filePath, width, height) {

   var html = '', flashVars = '';
   if(!width) width = 0; 
   if(!height) height = 0;

   if(filePath.indexOf('?')>0) {

	flashVars = filePath.substring(filePath.indexOf('?')+1, filePath.length);
    filePath = filePath.split('?')[0];

   }

   html += '<object  id="' + layerId + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="' + width + 'px" height="' + height + 'px">';  
   html += '<param name="allowScriptAccess" value="always" />';
   html += '<param name="movie" value="' + filePath + '" />';
   html += '<param name="flashvars" value="' + flashVars + '" />';
   html += '<param name="quality" value="hight" />';
   html += '<param name="wmode" value="transparent" />'; 
   html += '<param name="bgcolor" value="#ffffff" />';
   html += '<embed name="' + layerId + '" src="' + filePath + '" flashvars="' + flashVars + '" quality="hight" wmode="transparent" bgcolor="#ffffff" width="' + width + 'px" height="' + height + 'px" allowScriptAccess="always" showLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
   html += '</object>';

   if($('#' + layerId).html()==null) documentWrite(html);
   else $('#' + layerId).html(html).attr('class', '');

   $('#' + layerId).css({'position': 'absolute', 'z-index': '1000', 'marginLeft': '-30px', 'width': '950px', 'height': '500px'});
   $('.visual').css('height', '440px');

}
