var FPortfolio = { objDiv: new Object, FP_Images: new Array(), FP_content: new Array(), FP_loading: new Object, FP_content_index: 0, FP_wrapper: new Object, FP_swapTimer: '', FP_fadeTimer: '', init: function(div_id){ this.objDiv = document.getElementById(div_id); if(this.objDiv){ var child_Divs = this.objDiv.getElementsByTagName('div'); for(i = 0; i < child_Divs.length; i++){ if(child_Divs[i].className == 'FP_wrapper') this.FP_wrapper = child_Divs[i]; if(child_Divs[i].className == 'FP_loading') this.FP_loading = child_Divs[i]; if(child_Divs[i].className == 'FP_content'){ child_Divs[i].style.visibility = 'hidden'; this.FP_content.push(child_Divs[i]); image = new Image(); image.src = child_Divs[i].getElementsByTagName('img')[0].src; this.FP_Images.push(image); } } this.showImages(); } }, setImages: function(){ for( i = 0; i < this.FP_content.length; i++ ){ } }, showImages: function(){ clearTimeout(this.FP_swapTimer); this.showWrapper(); if(this.FP_Images[this.FP_content_index].complete){ this.showImage(); }else{ this.showLoading(); this.FP_Images[this.FP_content_index].onload = function () { FPortfolio.showImage(); }; } }, showWrapper: function(){ opacity = 100; this.set_Opacity(opacity); this.FP_wrapper.style.visibility = 'visible'; }, showLoading: function(){ this.FP_loading.style.visibility = 'visible'; }, showImage: function(){ this.hideLoading(); this.hideImages(); this.FP_content[this.FP_content_index].style.visibility = 'visible'; this.fade_In(opacity); }, hideImages: function(){ for( i = 0; i < this.FP_content.length; i++ ){ this.FP_content[i].style.visibility = 'hidden'; } }, hideWrapper: function(){ opacity = 0; this.set_Opacity(opacity); this.FP_wrapper.style.visibility = 'hidden'; }, hideLoading: function(){ this.FP_loading.style.visibility = 'hidden'; }, set_Opacity: function(opacity){ if (this.FP_wrapper.style.MozOpacity!=null) { /* Mozilla's pre-CSS3 proprietary rule */ this.FP_wrapper.style.MozOpacity = (opacity/100)-.001; /* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */ } else if (this.FP_wrapper.style.opacity!=null) { /* CSS3 compatible */ this.FP_wrapper.style.opacity = (opacity/100)-.001; } else if (this.FP_wrapper.style.filter!=null) { /* IE's proprietary filter */ this.FP_wrapper.style.filter = "alpha(opacity="+opacity+")"; /* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */ } }, fade_In: function (opacity){ if (opacity > 0) { clearTimeout(this.FP_fadeTimer); this.set_Opacity(opacity); opacity = opacity - 5; if(opacity <=0){ this.hideWrapper(); this.FP_content_index++; if(this.FP_content_index >= this.FP_content.length) this.FP_content_index = 0; this.FP_swapTimer = setTimeout(function () { FPortfolio.showImages();}, 5000); }else{ this.FP_fadeTimer = setTimeout(function () { FPortfolio.fade_In(opacity);},50); } } } } var SwappingPhoneNo = { objContainer: new Object(), SwapImageSrc: new Array(), objSwapContainer: new Object(), objSwapper: new Object(), objImages: new Array(), images_height: 25, SwapInterval: '', init: function (div_id,images_arr){ this.objContainer = document.getElementById(div_id); this.objContainer.style.position = 'relative'; this.SwapImageSrc = images_arr; this.create_HTML(); }, create_HTML: function(){ this.objSwapContainer = document.createElement("div"); this.objSwapContainer.setAttribute("style", "position: absolute; top: 190px; left: 550px;width:298px;height:25px;overflow:hidden;"); this.objContainer.appendChild(this.objSwapContainer); this.objSwapper = document.createElement("div"); this.objSwapper.setAttribute("style", "width:298px;height:"+(this.SwapImageSrc.length * this.images_height)+"px;overflow:hidden;"); this.objSwapContainer.appendChild(this.objSwapper); this.objSwapper.style.marginTop = ( 0 - ( (this.SwapImageSrc.length-1) * this.images_height)) + 'px'; for(i = this.SwapImageSrc.length; i > 0; i--){ objImgDiv = document.createElement("div"); objImgDiv.setAttribute("style","width:298px;height:25px;overflow:hidden;"); objImg = new Image(); objImg.src = this.SwapImageSrc[i-1]; objImgDiv.appendChild(objImg); this.objImages.push(objImg); this.objSwapper.appendChild(objImgDiv); } this.startSwapping(); }, startSwapping: function (){ this.SwapInterval = setInterval( function() { SwappingPhoneNo.SwapImage(); } , 5000); }, SwapImage: function (){ if(parseInt(this.objSwapper.style.marginTop) < 0){ this.objSwapper.style.marginTop = (parseInt(this.objSwapper.style.marginTop) + 25) + 'px'; }else{ this.objSwapper.style.marginTop = ( 0 - ( (this.SwapImageSrc.length-1) * this.images_height)) + 'px'; } } }