﻿function loadPortfolio(loadtype) {
    $("#scroller").html('<li></li>');
    $('#arrow_indicator').hide(500);
    $('#outer_container').css('left', '-450px');
    $('.menu').slideToggle();
    $('.wrapper').fadeIn('slow', function () {
        $('#container').fadeIn('slow', function () {
            $('#closeIcon').show();
        });
    });

    $.get("loadportfolio.aspx", { type: loadtype }, function (data) {
        $("#scroller").html(data);
    })
  .complete(function () { calculateULWidth(); });
}

function loadHome() {
    $('.wrapper').fadeOut('fast');
    $('#container').fadeOut('slow');
    $('#closeIcon').hide();
    $("#scroller").html('<li></li>');
    $('.menu').slideToggle();
    $('#arrow_indicator').show(500);
    $('#outer_container').css('left', '-350px');
}

function picloaded(id) {
    $('#' + id).fadeIn(500);
}

function calculateULWidth() {
    var ul_width = 0;
    var ul_len = $("#scroller").children().length;
    for (var i = 1; i <= ul_len; i++) {
        ul_width += $("#scroller li:nth-child(" + i + ")").width();
    }
    ul_width += 30;
    $("#scroller").css("width", ul_width);
}

var timeoutHandle;
function loadtheme() {
    var theme = new Array();
    theme[0] = "includes/theme/boxing/boxing.css";
    theme[1] = "includes/theme/fashion/fashion.css";
    theme[2] = "includes/theme/islam/islam.css";
    theme[3] = "includes/theme/joker/joker.css";
    theme[4] = "includes/theme/kashmir/kashmir.css";
    theme[5] = "includes/theme/medical/medical.css";
    theme[6] = "includes/theme/mugshot/mugshot.css";
    theme[7] = "includes/theme/restless/restless.css";
    theme[8] = "includes/theme/sports/sports.css";

    var image = new Array();
    image[0] = "includes/theme/boxing/atif-boxing.jpg";
    image[1] = "includes/theme/fashion/atif-fashion.jpg";
    image[2] = "includes/theme/islam/atif-Islam.jpg";
    image[3] = "includes/theme/joker/atif-joker.jpg";
    image[4] = "includes/theme/kashmir/atif-kashmir.jpg";
    image[5] = "includes/theme/medical/atif-medical.jpg";
    image[6] = "includes/theme/mugshot/atif-mugshot.jpg";
    image[7] = "includes/theme/restless/atif-restless.jpg";
    image[8] = "includes/theme/sports/atif-sports.jpg";

    //$preloader.fadeIn("fast"); //show preloader
    var id = Math.floor(Math.random() * 9);
    $("#atifcss").attr("href", theme[id]);
    //$("#tempImage").attr("src", image[id]);
    timeoutHandle = window.setTimeout("loadtheme()", 90000);
}
