/* SlideShow javascript object for dynamic images animated swapping */ function SlideShow( Name, WorkDiv, WorkDivWidth, WorkDivHeight, ImageOrder, Animation ) { // ********** Object Variables ********** // this.Name = Name; // Name of cycler MUST BE SAME WITH VARIABLE NAME WHICH HODS AN INSTANCE OF EACH OBJECT !!! this.Description = "Slideshow created by Wizard Solutions s.r.o. - Maros Zubko"; // Just description this.WorkDiv = WorkDiv; // Name of element in which this SlideShow will operate this.WorkDivWidth = WorkDivWidth; // Width in pixels this.WorkDivHeight = WorkDivHeight; // Height in pixels this.Images = new Array(); // Holds paths of individual pictures participating on slideshow this.Images_Width = new Array(); // Holds width for each image this.Images_Height = new Array(); // Holds height for each image this.Images_Descriptions = new Array(); // Description for each image this.ImageOrder = ImageOrder; // [ Ascending / Descending / Random ] this.Animation = Animation; // [ CrossFade, SlideIn ] this.CurrentImage = 0; // Holds image array index number of curently displayed image this.NextImage = 0; // Holds image array index number of next image in line this.Fg_ZIndex = 5; // Default Z-Index value of foreground image this.Bg_ZIndex = 0; // Z-Index value of background image this.AnimationTime = 2000; // How long one animation takes in miliseconds this.AnimationSteps = 100; // In how many steps is animation divided to this.ImageHangOn = 1000; // How long each image stay displayed on screen - time gap between two animations this.Running = false; // ********** Object Methods ********** // this.Check = function() // Check if all needed properties are set to correct values { var EverytingOK = true; if ( this.WorkDiv == "") EverytingOK = false; // Is WorkDiv selected ? // if ( document.getElementById( this.WorkDiv ) == null ) EverytingOK = false; // Is WorkDiv selected correctly ? if ( this.Images.length < 2 ) EverytingOK = false; // Has ImageList at least two images ? switch ( this.ImageOrder ) // Is image order set to one of allowed keywords ? { case "Ascending": case "Descending": case "Random": break; default : EverytingOK = false; } switch ( this.Animation ) // Is slide effect set to one of allowed keywords ? { case "CrossFade": case "SlideInRight": case "FadeIn": break; default : EverytingOK = false; } if ( ( this.SlideEffectSpeed < 0 ) || ( this.SlideEffectSpeed > 100 ) ) EverytingOK = false; return EverytingOK; } this.Initialize = function() { if ( this.Check() ) { this.CurrentImage = 0; this.GuessNextImage(); InnerHTML = ""; InnerHTML += "Background_Image"; InnerHTML += ""; document.getElementById( this.WorkDiv ).innerHTML = InnerHTML; return true; } else { alert('Error'); return false; } } this.ShowNextImage = function ( StartSlideShow ) { if ( StartSlideShow == true ) this.Running = true; else this.Running = false; this.SetImageSources(); switch ( this.Animation ) // Which slide effect to use { case "CrossFade":  var Source = document.getElementById ( this.Name+"_Image_1").src; if ( Source.substr( Source.length - this.Images[ this.CurrentImage ].length ) == this.Images[ this.CurrentImage ] ) // If _Image_1 is foreground currently for ( i = 0; i <= 100; i=i+Math.floor(100 / this.AnimationSteps) ) { setTimeout( "SetImageOpacity( '"+this.Name+"_Image_1'," +( 100 - i )+ " );", Math.round( this.AnimationTime * i / 100 ) ); setTimeout( "SetImageOpacity( '"+this.Name+"_Image_2'," +i+ " );", Math.round( this.AnimationTime * i / 100 ) ); } else for ( i = 0; i <= 100; i=i+Math.floor(100 / this.AnimationSteps) ) { setTimeout( "SetImageOpacity( '"+this.Name+"_Image_2'," +( 100 - i )+ " );", Math.round( this.AnimationTime * i / 100 ) ); setTimeout( "SetImageOpacity( '"+this.Name+"_Image_1'," +i+ " );", Math.round( this.AnimationTime * i / 100 ) ); } break; case "SlideInRight": var Source = document.getElementById ( this.Name+"_Image_1").src; SetImageOpacity( this.Name+"_Image_1", 100 ); SetImageOpacity( this.Name+"_Image_2", 100 ); if ( Source.substr( Source.length - this.Images[ this.CurrentImage ].length ) == this.Images[ this.CurrentImage ] ) // If _Image_1 is foreground currently for ( i = 0; i <= this.WorkDivWidth; i=i+Math.floor( this.WorkDivWidth / this.AnimationSteps) ) { document.getElementById ( this.Name+"_Image_2").style.right = this.WorkDivWidth + "px"; document.getElementById ( this.Name+"_Image_1").style.zIndex = this.Bg_ZIndex; document.getElementById ( this.Name+"_Image_2").style.zIndex = this.Fg_ZIndex; setTimeout( "document.getElementById( '" +this.Name+ "_Image_2').style.right = '" + (-1-i) + "px';", Math.round( this.AnimationTime * i / this.WorkDivWidth ) ); } else for ( i = 0; i <= this.WorkDivWidth; i=i+Math.floor( this.WorkDivWidth / this.AnimationSteps) ) { document.getElementById ( this.Name+"_Image_1").style.right = this.WorkDivWidth + "px"; document.getElementById ( this.Name+"_Image_2").style.zIndex = this.Bg_ZIndex; document.getElementById ( this.Name+"_Image_1").style.zIndex = this.Fg_ZIndex; setTimeout( "document.getElementById( '" +this.Name+ "_Image_1').style.right = '" + (-1-i) + "px';", Math.round( this.AnimationTime * i / this. WorkDivWidth ) ); } break; case "FadeIn": break; } // Switch images "after" Animation - it is not really after animation! this.CurrentImage = this.NextImage; // Swap bg image to current this.GuessNextImage(); setTimeout( this.Name+ ".ShowNextImage(true);", this.AnimationTime + this.ImageHangOn ); } this.AddImage = function ( ImageSrc, Description, Width, Height ) // Insert new image (description) to image list { if ( typeof( ImageSrc ) == "string" ) { this.Images.push( ImageSrc ); // Push new item to array if ( typeof( Description) == "string" ) this.Images_Descriptions[ this.Images.length-1 ] = Description; // Insert new image description for new Image if ( typeof( Width ) == "number" ) this.Images_Width[ this.Images.length-1 ] = Math.floor( Width ); // Insert new image custom wdth if ( typeof( Height ) == "number" ) this.Images_Height[ this.Images.length-1 ] = Math.floor( Height ); // Insert new image custom height return this.Images.length; // return number of images in list } else return false; // return false if image was not added } this.GuessNextImage = function() { switch ( this.ImageOrder ) // Set next image based on image order keyword { case "Ascending": this.NextImage = this.CurrentImage+1; break; case "Descending": this.NextImage = this.CurrentImage - 1; break; case "Random": this.NextImage = Math.floor( Math.random() * this.Images.length ); break; } // Two corrections for wrapping around image list if ( this.NextImage == -1 ) this.NextImage = this.Images.length-1; if ( this.NextImage == this.Images.length ) this.NextImage = 0; } this.SetImageSources = function() { var Source = document.getElementById ( this.Name+"_Image_1").src; if ( Source.substr( Source.length - this.Images[ this.CurrentImage ].length ) == this.Images[ this.CurrentImage ] ) // If _Image_1 is foreground currently var Bg_Image_Div = this.Name+"_Image_2"; else var Bg_Image_Div = this.Name+"_Image_1"; document.getElementById( Bg_Image_Div ).src = this.Images[ this.NextImage ]; if ( this.Images_Width[ this.NextImage ] != 0 ) document.getElementById( Bg_Image_Div ).style.width = this.Images_Width[ this.NextImage ] + "px"; else document.getElementById( Bg_Image_Div ).style.width = ""; if ( this.Images_Height[ this.NextImage ] != 0 ) document.getElementById( Bg_Image_Div ).style.height = this.Images_Height[ this.NextImage ] + "px"; else document.getElementById( Bg_Image_Div ).style.height = ""; } } function SetImageOpacity ( ImageId, Opacity ) // External function for changeing image(element) opacity { if ( document.getElementById( ImageId ) != null ) { var ImageStyle = document.getElementById( ImageId ).style; ImageStyle.opacity = (Opacity / 100); ImageStyle.MozOpacity = (Opacity / 100); ImageStyle.KhtmlOpacity = (Opacity / 100); ImageStyle.filter = "alpha(opacity=" + Opacity + ")"; if ( Opacity == 0 ) ImageStyle.display = "none"; else ImageStyle.display = "block"; } } Photo_Slideshow_1 = new SlideShow( "Photo_Slideshow_1", "Photo_Slideshow_1", 131, 153, "Ascending", "CrossFade" ); Photo_Slideshow_1.ImageHangOn = 7500; Photo_Slideshow_1.AnimationTime = 2500; Photo_Slideshow_1.AnimationSteps = 50; Photo_Slideshow_2 = new SlideShow( "Photo_Slideshow_2", "Photo_Slideshow_2", 131, 153, "Ascending", "CrossFade" ); Photo_Slideshow_2.ImageHangOn = 7500; Photo_Slideshow_2.AnimationTime = 2500; Photo_Slideshow_2.AnimationSteps = 50; Photo_Slideshow_3 = new SlideShow( "Photo_Slideshow_3", "Photo_Slideshow_3", 131, 153, "Ascending", "CrossFade" ); Photo_Slideshow_3.ImageHangOn = 7500; Photo_Slideshow_3.AnimationTime = 2500; Photo_Slideshow_3.AnimationSteps = 50; Photo_Slideshow_Adv = new SlideShow( "Photo_Slideshow_Adv", "Btn_Sipka", 86, 88, "Ascending", "CrossFade" ); Photo_Slideshow_Adv.ImageHangOn = 750; Photo_Slideshow_Adv.AnimationTime = 500; Photo_Slideshow_Adv.AnimationSteps = 25; Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/majakovsky den_2010.JPG', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/3.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/4.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/IMG_20111106_202842.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/IMG_20111106_203337.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/5.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/2.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/1.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/6.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/IMG_20111106_202448.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/TD_1.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/IMG_20111106_203743.jpg', '', 131, 153 );Photo_Slideshow_1.AddImage( '/Media/Slideshow/Group_1/badros_2.JPG', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/2.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/5.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/DMH_2011_2.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/4.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/3.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/badros_1.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/6.jpg', '', 131, 153 );Photo_Slideshow_2.AddImage( '/Media/Slideshow/Group_2/1.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/DMH_2011.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/nwxtteam_1.JPG', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/1.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/6.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/5.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/2.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/3.jpg', '', 131, 153 );Photo_Slideshow_3.AddImage( '/Media/Slideshow/Group_3/4.jpg', '', 131, 153 );setTimeout( "Photo_Slideshow_1.Initialize();", 4150); setTimeout( "Photo_Slideshow_1.ShowNextImage( true );", 5000); setTimeout( "Photo_Slideshow_2.Initialize();", 4250); setTimeout( "Photo_Slideshow_2.ShowNextImage( true );", 5750); setTimeout( "Photo_Slideshow_3.Initialize();", 4350); setTimeout( "Photo_Slideshow_3.ShowNextImage( true );", 6500); Photo_Slideshow_Adv.AddImage( '/Themes/Images/Sipka_2_percenta.png', '', 86, 88 ); //Photo_Slideshow_Adv.AddImage( '/Themes/Images/Arrow_Back.png', '', 86, 88 ); Photo_Slideshow_Adv.AddImage( '/Themes/Images/_Transparent1x1.png', '', 86, 88 ); setTimeout( "Photo_Slideshow_Adv.Initialize();", 100); setTimeout( "Photo_Slideshow_Adv.ShowNextImage( true );", 500);