var imgno=0;  //imageno which is currenly showing in imageshow
var images = new Array(); //hold images when loaded
var pause=0; //when pause=0 it is not paused
//var buttonno=0;  //button no which is active now with the showing image it is


//function to preload images
function loadhalogenimageshow()
{     // counter
      var i = 0;
     // create object
     imageObj = new Image();
     // set image list
    // images = new Array();
     window.images[0]="assets/images/imageshow/is1.jpg";
     window.images[1]="assets/images/imageshow/is2.jpg";
     window.images[2]="assets/images/imageshow/is3.jpg";
     window.images[3]="assets/images/imageshow/is4.jpg";
     window.images[4]="assets/images/imageshow/is5.jpg";
     window.images[5]="assets/images/imageshow/is6.jpg";
     //5 is no of images
     // start preloading
     for(i=0; i<=5; i++)
     {
          imageObj.src=window.images[i];
         
         // document.getElementById('image_show_main').src= imageObj.src;
     }
 $('#image_show').animate({
    opacity: 0}, 200, function() {
   animateImageshow(0);
  });


    
}

//this function is called automatically when page loads and run the image show
function animateImageshow(imno)
{// testObj.style.opacity = value/10;
//	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
if(window.pause==0)
    {
        changeimage(imno);

  //document.getElementById('image_show').innerHTML= '<img style="" id="image_show_main" src="'+window.images[imgno]+'" width="901" height="380"/>';
  fadeoutimage();
  //setTimeout("fadeoutimage()",650);
 // document.getElementById('image_show_main').filters.alpha.opacity=20;
  if(imno<5)  //6 is no of images
   {
    imno++;
    window.imgno=imno;
   }
   else
       {imno=0;
        window.imgno=imno;
       }

 setTimeout("if(window.pause!=1){fadeimage();}",7050);   //it will check if pause is not clicked then change image
 setTimeout("animateImageshow("+imno+")",8000);
    
  }
else
   {
      // fadeoutimage();
       return;
   }
} //function animateimageshow() ends

function changeimage(imgno)  //will change image and other related things
{//new_button="button"+imgno+"-hover";
 //alert(new_button);
//change the button 
for(i=0;i<5;i++)//4 is total no of images
    {
        new_button="button"+i;
       if(i==imgno)
      { document.getElementById(new_button).style.background='maroon';
        
       }
       else
           {
               document.getElementById(new_button).style.background='';
           }
    }
//change button ends

document.getElementById('image_show').innerHTML= '<img style="" id="image_show_main" src="'+window.images[imgno]+'" width="901" height="380"/>';
//document.getElementById()
    
}
function fadeoutimage()
{
    $('#image_show').animate({
    opacity: 1 }, 1000, function() {
    // Animation complete.
  });

}
function fadeimage()
{
    $('#image_show').animate({
    opacity: 0 }, 1000, function() {
    // Animation complete.
  });

}


//this function is called when direct image button is clicked
function setimage(imno)
{window.pause=1;
   fadeimage();
    //fadeimage();
    setTimeout(" changeimage("+imno+")",1050);
  // changeimage(imno);
    //document.getElementById('image_show').innerHTML= '<img id="image_show_main" src="'+window.images[imno]+'" width="901" height="380"/>';
fadeoutimage();

}

//this function is called when next, prev or pause is clicked. wt=1 means next
function setnpimage(wt)
{ document.getElementById('pause').innerHTML=">";
   if(wt==1)
    {window.pause=1;
        if(window.imgno<3&&window.imgno>=0)//4 here total no of images
            {
             window.imgno++;
            }
         else
         { window.imgno=0;
         }
           fadeimage();
           setTimeout(" changeimage("+window.imgno+")",1050);
           fadeoutimage();
     }
   else if(wt==-1)
     {
         window.pause=1;
         if(window.imgno>0&&window.imgno<=3)//3+1 toatal no of images
          { window.imgno--;

          }
        else
        {window.imgno=3; //1 is total no of images
        }

       fadeimage();
       setTimeout(" changeimage("+window.imgno+")",1050);
       fadeoutimage();
   }
  else if(wt==0)
      {//if already pause
          if(window.pause==1)
          {
             window.pause=0;
             $('#image_show').animate({
             opacity: 0}, 200, function() {
             animateImageshow(window.imgno);
               });
          }
          else
              {window.pause=1;
               animateImageshow(window.imgno);
              }


     
      }
    
}//function setupnpimage ends

