﻿//New js file for the homepage slide show

function preloader() 
{
try
{
    var  varUrls;
   // var  varImages;
    if(document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txturls"))
    {
      varUrls = document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txturls").innerHTML;
      varImages =  varUrls.split(",");
     }
     // counter     
      var i = 0;
      var j=0;
     // create object   
       imageObj = new Image();
     // set image list     
     var  images1 = new Array();    
     // start preloading    	
     
     for(j=0; j<=varImages.length; j++)     
     {       
        images1[j]= varImages[j];
     }
   for(i=0; i<=varImages.length; i++)     
   {       
        imageObj.src=images1[i];    
   }
}
catch(err){}
} 

function GetDetails()
{

//preloader();


if(document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txturls"))
{
 
urls=document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txturls").innerHTML;
images= urls.split(",");
}

if(document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txtKicker"))
{
 kickers = document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txtKicker").innerHTML;
 PhotoKicker=kickers.split("~");
}
//Muzafar
if(document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txtImageIds"))
{
 ids = document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_txtImageIds").innerHTML;
PhotoIDS = ids.split("~");

}
timeDelay=setTimeout("slideshow_automatic()",2000);    
}


function Changecur(id)
{

document.getElementById(id).style.cursor = 'pointer';
}

//To play the slide show automatic
function slideshow_automatic()
{ 
try
{
running=true;
   
     
    if (num<tphoto-1)
     {
   
       num++;
       current++;
       timeDelay=setTimeout("slideshow_automatic()",4000); 
       
       
       if(browserName == "Netscape")
       { 
          
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current;
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        
       }
       else
       {
       image_effects();
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       
     
     }
       
     else if (num==tphoto-1) 
     {
       
       num=0;
       current=1;  
         
       //sets the timer value to 4 seconds,we can create a timing loop by using the setTimeout method
       timeDelay=setTimeout("slideshow_automatic()",4000); 
       
       if(browserName == "Netscape")
       {       
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current;
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       else
       {
    
       image_effects();
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
        document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
     }
     }
     catch(errr)
     {
          
     
     }
   }  
   
//To play and pause the slideshow   
function Pause_image()
{
if(running)
{
running=false;
window.clearTimeout(timeDelay);
timeDelay =0;
document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_imgPauseBottom").src="http://www.hindustantimes.com/homepage/images/slidePlay.gif";
}
else
{
timeDelay=setTimeout("slideshow_automatic()",4000); 
document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_imgPauseBottom").src="http://www.hindustantimes.com/homepage/images/slidepause.gif";
}
}

//To set the next image url
function next_image()
{ 

running=true;
Pause_image();
    
    if (num<tphoto)
    {
    
   
        num++;
        current++;
            
       
       if(browserName == "Netscape")
       {
       
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current;
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       else
       {
       image_effects();
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       
       }
       

    }
    
    if (num==tphoto) 
    {
    num=0;
    current=1;  
   
    //set the SRC attribute to let the browser load the preloaded images 
   
    if(browserName == "Netscape")
    {
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current;
    document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
    document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
    }
    else
    {
     image_effects();
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
    document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
    document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
    document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       
    }
     
        
    }
   
} 
   
 //To set the previous image url  
function previous_image()
{   
running=true;
Pause_image();
    if (num>0)
    {      
     
       num--;      
       current--;  
       
       if(browserName == "Netscape")
       {
          
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current; 
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       else
       {
       image_effects();    
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
           
       }
     
       
     }
   
    else if (num==0)
    {  //if first image is displayed
       num=tphoto; 
       current=tphoto; 
       num--;       
       
       if(browserName == "Netscape")
       {       
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").src=images[num];
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").textContent=current;
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num]; 
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       else
       {
       image_effects();
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblcurrent").innerText=current;
       document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_lblKicker").innerHTML=PhotoKicker[num];
       document.getElementById("hypRedirect").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
        document.getElementById("hypImage").href="http://www.hindustantimes.com/photos-news/photo-story-news/"+categ+"/Article4.aspx";
       }
       
                            
       
       //current++;       
                          
    } 
    
    
 
  
}   
  
  
  function image_effects()
{

   //set the transition to the number selected in the list
 document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").style.filter ="progid:DXImageTransform.Microsoft.Fade(duration=1,overlap=1.0)"
 document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").filters[0].Apply();
 document.getElementById("ctl00_ContentPlaceHolder1_TopMultimediaChunk1_ctl00_photo").filters[0].Play();

  
}



               
                   
