﻿// JScript File

//A timer will be fired in 10 seconds to call getNextImage()
var c_interval = 10000;
window.setTimeout("getNextImage()", c_interval);

function getNextImage()
{
    //Send the request to server with the current image url as the argument
    //CallServer(document.getElementById("ctl00_ContentPlaceHolder1_photo").src, "");
}
          
function ReceiveServerData(rValue)
{
    //Receive server's response of a string rValue, which is prepared in the server's function
    //GetCallbackResult()
    var wds = rValue.split(";");
    //Assign the transition effect
//    if (document.getElementById("ctl00_ContentPlaceHolder1_photo").filters) 
//    {
//        document.getElementById("ctl00_ContentPlaceHolder1_photo").style.filter = wds[1];
//    }
//    else
//    {
//       // var opacity = (opacity == 100)?99.999:opacity;
//        document.getElementById("ctl00_ContentPlaceHolder1_photo").style.MozOpacity = 99.999/100;
//    }
    //Preload the image file from server.  When finishing download, imageLoaded function will be called
    //with the img object as the argument                           
    var img  = new Image();
    img.onload = function(){ imageLoaded(this); }
    img.onerror = function(){ imageError(this); }
    img.onabort = function(){ imageError(this); }
    img.src = wds[0];                                            
}
function imageError(img)
{
    //If image download errors occur, this function will be called.
    window.setTimeout("getNextImage()", 1000);
}
function imageLoaded(img)
{
//    var photo = document.getElementById("ctl00_ContentPlaceHolder1_photo");   //Find the image control object
//    if (document.getElementById("ctl00_ContentPlaceHolder1_photo").filters) 
//    {
//        photo.filters[0].apply();                       //Apply the transition effect
//        photo.filters[0].play();                        //Play the effect and display the new image
//    }
//    photo.src = img.src;                            //Assign the image to the image control
//    
//    window.setTimeout("getNextImage()", c_interval);//Initiate the next request
}

function SlideEffect(Anthemimg)
{

    if(Anthemimg=='ctoa')
    {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgCallToAction");
         if (imgctl.filters) 
        {           
            imgctl.style.filter = "progid:DXImageTransform.Microsoft.Iris(irisstyle='SQUARE', motion='out')";
            //"progid:DXImageTransform.Microsoft.Stretch(Duration=1,stretchStyle='push')";
           //imgctl.style.filter = GetNextTransition();
            imgctl.filters[0].apply();    //Apply the transition effect
            imgctl.filters[0].play();     //Play the effect and display the new image
        }
        else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
            imgctl.style.MozOpacity = 99.999/100;
        }
    }
    else if(Anthemimg=='advert')
    {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgAdverts");
        if (imgctl.filters) 
        {
            imgctl.style.filter = "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=20, Duration=10, Enabled=false)";
           //  imgctl.style.filter = GetNextTransition();
            imgctl.filters[0].apply();    //Apply the transition effect
            imgctl.filters[0].play();     //Play the effect and display the new image            
        }
        else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
            imgctl.style.MozOpacity = 99.999/100;
        }
    }
    else if(Anthemimg=='logo')
    {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgLogo");
        if (imgctl.filters) 
        {
            imgctl.style.filter = "progid:DXImageTransform.Microsoft.Stretch(Duration=0.43,stretchStyle='spin')";
            imgctl.filters[0].apply();    //Apply the transition effect
            imgctl.filters[0].play();     //Play the effect and display the new image
        }
        else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
            imgctl.style.MozOpacity = 99.999/100;
        }
    }
    //document.getElementById("ctl00_ContentPlaceHolder1_photo").src = img.src;   
}
function NoSlideEffect(Anthemimg)
{   
    if(Anthemimg=='ctoa')
    {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgCallToAction");
         if (imgctl.filters) 
        {
            imgctl.style.filter = "";
        }
        else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
           // imgctl.style.MozOpacity = 99.999/100;
        }
    }
    else if(Anthemimg=='advert')
   {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgAdverts");
        if (imgctl.filters) 
        {
            imgctl.style.filter = "";
        }
        else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
           // imgctl.style.MozOpacity = 99.999/100;
        }
    }
    else if(Anthemimg=='logo')
    {
        var imgctl=document.getElementById("ctl00_ContentPlaceHolder1_imgLogo");
        if (imgctl.filters) 
        {
        imgctl.style.filter="";
        }
         else
        {
           // var opacity = (opacity == 100)?99.999:opacity;
           // imgctl.style.MozOpacity = 99.999/100;
        }
    }
}
function GetNextTransition()
    {
        //Randomly pick a transition effect.  Note some of the effects only work in IE.
      //  int n = (int)((new Random().NextDouble()) * 5);
        var rnd_no = Math.round(5 * (Math.random()));
       // alert( rnd_no);
        switch (rnd_no)
        {
            case 0:
            case 1:
                rnd_no = Math.round(22 * Math.random());
                return "revealTrans(duration=2,transition=" + rnd_no + ")";
            case 2:
            case 3:
                    rnd_no = Math.round(8 * Math.random());
                    switch (rnd_no)
                    {
                        case 0:
                            return "progid:DXImageTransform.Microsoft.RandomDissolve(Duration=0.45)";
                        case 1:
                            return "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=20, Duration=2, Enabled=false)";
                        case 2:
                            return "progid:DXImageTransform.Microsoft.RadialWipe(Duration=0.45,wipeStyle='clock')";
                        case 3:
                            return "progid:DXImageTransform.Microsoft.Wheel(Duration=0.45,spokes=4)";
                        case 4:
                            return "progid:DXImageTransform.Microsoft.Stretch(Duration=0.4,stretchStyle='spin')";
                        default:
                            return "progid:DXImageTransform.Microsoft.Stretch(Duration=0.45,stretchStyle='push')";
                    }
              default:
                return "blendTrans(duration=2)";
        }
    }
    
   
