var Piercer = {
  
  
        initialize: function (){

          getImagePiercing();
        }


  };

var Animation = {
  timer: '',
  listImage: [],
  loop:0,
  delayTime: 8000,
  currentItem: '',
  play: function(){
  
       if(this.loop < this.listImage.length){
	       this.currentItem = this.listImage[this.loop];
		       
		   document.getElementById('pierceDisplayer').innerHTML = document.getElementById(this.currentItem).innerHTML;

		   this.loop +=1;
		   this.timer = setTimeout("Animation.play()",this.delayTime);
	   } 
	   else
	     {
		 
	       clearTimeout(this.timer);
	      Animation.initialize();

	     }

  },

  pause: function(){

    clearTimeout(this.timer);
this.delayTime = 100000000000;

    },

  extend: function(){
      this.delayTime = 10000;
  },
  initialize: function(){

     var loop=0;
     
     
     for(loop=0;loop<document.getElementById('imageContainer').getElementsByTagName("div").length;loop++)
           this.listImage[loop] = "image"+(loop+1);

	   this.loop = 0;


           this.play();
  }
  
};

  
var site_url = window.location.protocol+'//'+window.location.hostname+'/';
var getPiercer = getHTTPObject(); // We create the HTTP Object
/* ----------------------------------------------------------------------------------  AJAX SIDE */
       function process_getPiercer()
          {
             if(getPiercer.readyState == 4)
                {
                   if(getPiercer.status==200)
                      {
                                   document.getElementById('imageContainer').innerHTML = getPiercer.responseText;
                                   Animation.initialize();

                      }


               }

           }
        function getImagePiercing()
          {

	      getPiercer.open("GET",site_url+"includes/indexPiercerLoader.php", true);
              getPiercer.onreadystatechange = process_getPiercer;
              getPiercer.send(null);
          }

function getHTTPObject()
 {
  var xmlhttp;

  if(window.XMLHttpRequest){  xmlhttp = new XMLHttpRequest();  }
  else
     if (window.ActiveXObject)
           {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 if (!xmlhttp){ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
           }
  return xmlhttp;
}
