﻿$.fn.cycle.defaults.timeout = 9000;
$(function() {
    // run the code in the markup!
    $('.imageGallery pre').each(function() {
        eval($(this).text());
    });
});
$(function() {
    $('#breadcrumbsWhiteContainer').corner("bottom");
    $('#subpageContent').corner();
});

$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#mainGallery a').hide();
  $('#contactContainer').hide();
 $(".showContact").click(function() { 
    $("#contactContainer").toggle("slide", { 
        direction: "up",
        easing: "easeOutBounce"
    }, 1300); 
});
});
function scrollToTop() {
    var $target = $(this.hash);
    $target = $target.length && $target
    var targetOffset = $target.offset().top;
    $('html,body').animate({scrollTop: targetOffset}, 1000);
}
    
var currentImage = 1;

function swapPortfolioItem(dir) {	    
    if (dir == "left") {	        
        //set the current image
        if (currentImage > 1) {
            document.getElementById("PortfolioDisplayImage").src = "";
            //swap the image to the loader for a second
            document.getElementById("PortfolioDisplayImage").src = "/assets/themes/default/images/ajax-loader.gif";
            currentImage = currentImage - 1;
            if (currentImage == 1) {
                document.getElementById("portfolioLeftButton").style.backgroundImage = "url(/assets/themes/default/images/btnPortfolioNone.gif)";
            }
            else {
                document.getElementById("portfolioRightButton").style.backgroundImage = "url(/assets/themes/default/images/btnPortfolioRight.gif)";
            }
            setTimeout("doTheChange()", 500);
        }
        else {
            //don't do the change but swap out the button image
            currentImage = 1;	            
        }
    }
    else if (dir == "right") {
        //set the current image
        if (currentImage < itemTotal) {
            document.getElementById("PortfolioDisplayImage").src = "";
            //swap the image to the loader for a second
            document.getElementById("PortfolioDisplayImage").src = "/assets/themes/default/images/ajax-loader.gif";
            currentImage = currentImage + 1;
            if (currentImage == itemTotal) {
                document.getElementById("portfolioRightButton").style.backgroundImage = "url(/assets/themes/default/images/btnPortfolioNone.gif)";
            }
            else {
                document.getElementById("portfolioLeftButton").style.backgroundImage = "url(/assets/themes/default/images/btnPortfolioLeft.gif)";
            }
            setTimeout("doTheChange()", 500);
        }
        else {
            //don't do the change
            document.getElementById("portfolioRightButton").style.backgroundImage = "url(/assets/themes/default/images/btnPortfolioNone.gif)";
            currentImage = itemTotal;
        }
    }
}
function doTheChange() {
        //get the new image based on the database value
        var newImage = document.getElementById("PortfolioImage" + currentImage).innerHTML;
        //get the new link based on the database value
        var newLink = document.getElementById("PortfolioLink" + currentImage).innerHTML;
        //get the new title based on the database value
        var newTitle = document.getElementById("PortfolioTitle" + currentImage).innerHTML;
        //set the new link
        document.getElementById("PortfolioLink").href = "/portfolio/portfolio-display.aspx?portfolio_id=" + newLink; 
        //set the new image
        document.getElementById("PortfolioDisplayImage").src = "/ImageItems/portfolio/thumbs/" + newImage;
        //set the new title
        document.getElementById("portfolioTitle").innerHTML = newTitle;
}

// START FONTSIZE FUNCTIONS
var fontsize = 11;

function getFontSize(userFont) {
if (userFont == null) {
fontsize = userFont;
}
else {
fontsize = userFont;
} 
document.getElementById("subpageText").style.fontSize = fontsize + "px";
}

function resetFont() {
fontsize = 11;
ajaxFontSize();
document.getElementById("subpageText").style.fontSize = fontsize + "px";
}
function enlarge() {
if (fontsize == 14) {
}
else {
fontsize = fontsize + 1;
} 
ajaxFontSize();
document.getElementById("subpageText").style.fontSize = fontsize + "px";
}
function shrink() {
if (fontsize == 8) {
}
else {
fontsize = fontsize - 1;
} 
ajaxFontSize();
document.getElementById("subpageText").style.fontSize = fontsize + "px";
}
//END FONTSIZE FUNCTIONS