﻿var alertTimerId = 0;
var ActiveWindow = "";
var currentSlide = 0;

function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
function guid() {
    return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}


function Preloader() {
    this.IsProcessing = new Boolean(false);
    this.ScriptsLoaded = new Boolean(false);
    this.BeyondSpaceLoaded = new Boolean(false);
    this.AboutUsLoaded = new Boolean(false);
    this.HomePageLoaded = new Boolean(false);
    this.NumberClientPortfolios = new Number(0);
    this.ImagesLoaded = new Boolean(false);
    this.ThumbnailsLoaded = new Boolean(false);
    this.NiceFormsLoaded = new Boolean(false);
    this.ValidationLoaded = new Boolean(false);
    this.IsFullyLoaded = new Boolean(false);
    this.Images = new Array();
}

Preloader.instance = null;
Preloader.getInstance = function() {
    if (Preloader.instance == null) {
        Preloader.instance = new Preloader();
    }
    return Preloader.instance;
}


Preloader.prototype.AddImages = function(imagesrc) {
    this.Images.push(imagesrc);
}


Preloader.prototype.GetImages = function() {
    if (this.IsProcessing) {
        if (!this.ImagesLoaded) {
            var baseURL = $("#basehref1").attr('href');
            var allImgs = [];
            var k = 0;
            var arr = this.Images; //create array from regex obj
            $(arr).each(function() {
                allImgs[k] = new Image(); //new img obj
                allImgs[k].id = guid();
                allImgs[k].src = (this[0] == '/' || this.match('http://')) ? this : baseURL + this;     //set src either absolute or rel to css dir
                /*var isThisImgLoaded = false;
                $('#' + allImgs[k].id).attr('src', allImgs[k].src).load(function() {
                isThisImgLoaded = true;

                });*/
                k++;
            });
            /*if (allImgs.length == this.Images.length) {
            this.ImagesLoaded = true;
            }*/
        }
        this.ImagesLoaded = true;
        this.LoadThumbnails();
    }
}

Preloader.prototype.LoadImageQueue = function(array) {
    if (!this.IsProcessing) {
        this.IsProcessing = true;
        for (var i = 0; i < array.length; i++) {
            this.AddImages(array[i]);
        }

        this.GetImages();
    }
}

Preloader.prototype.LoadThumbnails = function() {
    if (this.IsProcessing) {
        if (!this.ThumbnailsLoaded) {
            var thumbs = loadThumbnailMouseOvers();
            if (thumbs) {
                this.ThumbnailsLoaded = true;
            }
        }
        this.LoadNiceForms();
    }
}

Preloader.prototype.LoadNiceForms = function() {
    if (this.IsProcessing) {
        if (!this.NiceFormsLoaded) {
            /*var existingLoadEvent = window.onload || function() { };
            var existingResizeEvent = window.onresize || function() { };
            window.onload = function() {
            existingLoadEvent();
            NFInit();
            };

            window.onresize = function() {
            if (resizeTest != document.documentElement.clientHeight) {
            existingResizeEvent();
            NFFix();
            }
            resizeTest = document.documentElement.clientHeight;
            };*/
            this.NiceFormsLoaded = true;
            this.LoadValidation();
        }
    }
}

Preloader.prototype.LoadValidation = function() {
    if (this.IsProcessing) {
        if (!this.ValidationLoaded) {
            /*$(document).ready(function() {
                $("#form1").validationEngine();
            });*/
            this.ValidationLoaded = true;
        }
    }

};


var preloaderObj = Preloader.getInstance();

function loadEasing() {

    jQuery(function($) {
        /**
        * Demo binding and preparation, no need to read this part
        */
        //borrowed from jQuery easing plugin
        //http://gsgd.co.uk/sandbox/jquery.easing.php
        $.easing.elasout = function(x, t, b, c, d) {
            var s = 1.70158; var p = 0; var a = c;
            if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
            if (a < Math.abs(c)) { a = c; var s = p / 4; }
            else var s = p / (2 * Math.PI) * Math.asin(c / a);
            return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
        };
        $.easing.easeOutBounce = function(x, t, b, c, d) {
            if ((t /= d) < (1 / 2.75)) {
                return c * (7.5625 * t * t) + b;
            } else if (t < (2 / 2.75)) {
                return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
            } else if (t < (2.5 / 2.75)) {
                return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
            } else {
                return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
            }
        };
        // back links
        $('a.back').click(function() {
            $(this).parents('div.pane').scrollTo(0, 800, { queue: true });
            $(this).parents('div.section').find('span.message').text(this.title);
            return false;
        });
        //just for the example, to stop the click on the links.
        $('ul.links').click(function(e) {
            e.preventDefault();
            var link = e.target;
            link.blur();
            if (link.title)
                $(this).parent().find('span.message').text(link.title);
        });

        // This one is important, many browsers don't reset scroll on refreshes
        // Reset all scrollable panes to (0,0)
        $('div.pane').scrollTo(0);
        // Reset the screen to (0,0)
        $.scrollTo(0);

        // TOC, shows how to scroll the whole window
        $('#toc a').click(function() {//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
            $.scrollTo(this.hash, 1500, { easing: 'elasout' });
            $(this.hash).find('span.message').text(this.title);
            return false;
        });

        // Target examples bindings
        // THIS DEMO IS NOT INTENDED TO SHOW HOW TO CODE IT
        // JUST THE MULTIPLE OPTIONS. THIS CODE IS UGLY.
        var $paneTarget = $('#pane-target');

        $('#relative-selector').click(function() {
            $paneTarget.stop().scrollTo('li:eq(14)', 800);
        });
        $('#jquery-object').click(function() {
            var $target = $paneTarget.find('li:eq(14)');
            $paneTarget.stop().scrollTo($target, 800);
        });
        $('#dom-element').click(function() {
            var target = $paneTarget.find('ul').get(0).childNodes[20];
            $paneTarget.stop().scrollTo(target, 800);
        });
        $('#absolute-number').click(function() {
            $paneTarget.stop().scrollTo(150, 800);
        });
        $('#absolute-number-hash').click(function() {
            $paneTarget.stop().scrollTo({ top: 800, left: 700 }, 800);
        });
        $('#absolute-position').click(function() {
            $paneTarget.stop().scrollTo('520px', 800);
        });
        $('#absolute-position-hash').click(function() {
            $paneTarget.stop().scrollTo({ top: '110px', left: '290px' }, 800);
        });
        $('#relative-position').click(function() {
            $paneTarget.stop().scrollTo('+=100', 500);
        });
        $('#relative-position-hash').click(function() {
            $paneTarget.stop().scrollTo({ top: '-=100px', left: '+=100' }, 500);
        });

        $('#percentage-position').click(function() {
            $paneTarget.stop().scrollTo('50%', 800);
        });

        // Options examples bindings, they will all scroll to the same place, with different options
        function reset_o() {//before each animation, reset to (0,0), skip this.
            $paneOptions.stop(true).attr({ scrollLeft: 0, scrollTop: 0 });
        };
        var $paneOptions = $('#pane-options');

        $('#options-no').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000);
        });
        $('#options-axis').click(function() {// only scroll horizontally
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { axis: 'x' });
        });
        $('#options-duration').click(function() {// it's the same as specifying it in the 2nd argument
            reset_o(); $paneOptions.scrollTo('li:eq(15)', { duration: 3000 });
        });
        $('#options-easing').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 2500, { easing: 'elasout' });
        });
        $('#options-margin').click(function() {//scroll to the "outer" position of the element
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { margin: true });
        });
        $('#options-offset').click(function() {//same as { top:-50, left:-50 }
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { offset: -50 });
        });
        $('#options-offset-hash').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { offset: { top: -5, left: -30} });
        });
        $('#options-over').click(function() {//same as { top:-50, left:-50 }
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { over: 0.5 });
        });
        $('#options-over-hash').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1000, { over: { top: 0.2, left: -0.5} });
        });
        $('#options-queue').click(function() {//in this case, having 'axis' as 'xy' or 'yx' matters.
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 2000, { queue: true });
        });
        $('#options-onAfter').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 2000, {
                onAfter: function() {
                    $('#options-message').text('Got there!');
                }
            });
        });
        // onAfterFirst exists only when queuing
        $('#options-onAfterFirst').click(function() {
            reset_o(); $paneOptions.scrollTo('li:eq(15)', 1600, {
                queue: true,
                onAfterFirst: function() {
                    $('#options-message').text('Got there horizontally!');
                },
                onAfter: function() {
                    $('#options-message').text('Got there vertically!');
                }
            });
        });
    });

}

function loadThumbnailMouseOvers() {


    $("div.clientDetailsWrapImageThumbnails ul li a img").each(function() {

        $(this).bind('mouseover', function() {

            activateThumbnailMouseOver($(this));

        });

    });

    $("#mousePictureFrame").bind('click', function() {
        loadPictureFrameClick();
    });

    return true;
}

function loadPictureFrameClick() {
    var assetId = $("#mousePictureFrame").attr('data-assetId');
    var assetSource = $("#mousePictureFrame").attr('data-assetSource');

    var bigPicFrame = assetId.replace("clientDetailsWrapImageThumbnails", "clientDetailsWrapImageMain");
    $("#" + bigPicFrame).attr({ 'src': assetSource });
}
function deActivateThumbnailMouseOver() {
    $("#mousePictureFrame").css({ 'top': '-500px', 'left': '-500px', 'display': 'none' });

}
function activateThumbnailMouseOver(element) {
    var x = $(element).offset().left - 3;
    var y = $(element).offset().top - 10;
    var left = x.toString() + "px";
    var top = y.toString() + "px";
    $("#mousePictureFrame").css({ 'top': top, 'left': left, 'display': 'block' });
    var assetId = $(element).parent().parent().parent().parent().attr('id');
    var assetSource = $(element).attr('src');
    $("#mousePictureFrame").attr({ 'data-assetId': assetId });
    $("#mousePictureFrame").attr({ 'data-assetSource': assetSource });
    loadPictureFrameClick();

}

function activateArrowMouseUp(element) {
    var x = $(element).offset().left + 100;
    var y = $(element).offset().top;
    var left = x.toString() + "px";
    var top = y.toString() + "px";
    $("#mouseArrowUp").css({ 'top': top, 'left': left, 'display': 'block' });


}
function deActivateArrowMouseUp() {
    $("#mouseArrowUp").css({ 'top': '-500px', 'left': '-500px', 'display': 'none' });

}

function activateArrowMouseDown(element) {
    var x = $(element).offset().left + 100;
    var y = $(element).offset().top;
    var left = x.toString() + "px";
    var top = y.toString() + "px";
    $("#mouseArrowDown").css({ 'top': top, 'left': left, 'display': 'block' });


}
function deActivateArrowMouseDown() {
    $("#mouseArrowDown").css({ 'top': '-500px', 'left': '-500px', 'display': 'none' });

}

function MouseOverGalleryItem(element) {
    $("#overlayClientInfo").show();
    var panelid = $(element).attr('panelid');
    $("#" + panelid).show();
}
function MouseOutGalleryItem(element) {
    $("#overlayClientInfo").hide();
    var panelid = $(element).attr('panelid');
    $("#" + panelid).hide();
}



function MoveTo(ContainerId, speed) {
    var $elem = $('#' + ContainerId);
    ActiveWindow = ContainerId;
    var isClient = $elem.hasClass('subclientWrap');
    if (ContainerId == "introContentWrap") {
        $.scrollTo($elem, speed, { easing: 'elasout', over: { top: -0.2} });
    }
    else if (ContainerId == "contactContentWrap") {
       $.scrollTo($elem, speed, { easing: 'elasout', over: { top: -0.1} });
    }
    /*else if (isClient) {
    $.scrollTo($elem, speed, { easing: 'easeOutBounce', over: { top: -0.05} });
    }*/
    else {
        $.scrollTo($elem, speed, { easing: 'elasout' });
    }
}

function initCaptchaImg() {
    var imgsrc = ["/images/delightful_elf.jpg",
                  "/images/eagle_eyes.jpg",
                  "/images/site/captcha/fat_busted.jpg",
                  "/images/glamour_puss.jpg",
                  "/images/gradient_boy.jpg",
                  "/images/monkey_nuts.jpg",
                  "/images/three_circles.jpg",
                  "/images/tigers_junction.jpg",
                  "/images/uber_spanner.jpg",
                  "/images/wild_bill.jpg",
                  "/images/winning_lemon.jpg"];
    var index = Math.floor(Math.random()*11);
    //alert(imgsrc[index]);
    
    $("div.captchaimage img").attr('src', imgsrc[index]);
}

function isRealPerson() {
    var isreal = false;
    var imgsrc = $("div.captchaimage img").attr('src');
    imgsrc = imgsrc.replace("/Images/site/captcha/", "");
    imgsrc = imgsrc.replace("/Images/", "");
    imgsrc = imgsrc.replace("/images/", "");
    imgsrc = imgsrc.replace(".jpg", "");
    var myArray = new Array();
    myArray = imgsrc.split("_");
    var myArray2 = new Array();
    myArray2 = $("#txtcaptcha").val().split(" ");
    if (myArray[0] == myArray2[0] && myArray[1] == myArray2[1]) {
        isreal = true;
    }
    return isreal;
}
function isValidField(id) {
    var isValid = false;
    var length = $("#" + id).val().length;
    if (length > 0) {
        isValid = true;
    }
    return isValid;
    
}
function SaveContactMessage() {
    $("#moleWrap").hide();
    var totalfilled = 0;
    if (isValidField('cfmessage')) {
        totalfilled += 1;
        $("#cfmessage").removeClass('contactFormFieldError');
    }
    else {
        $("#cfmessage").addClass('contactFormFieldError');
    }
    if (isValidField('cfemail')) {
        totalfilled += 1;
        $("#cfemail").removeClass('contactFormFieldError');
    }
    else {
        $("#cfemail").addClass('contactFormFieldError');
    }
    if (isValidField('cfname')) {
        totalfilled += 1;
        $("#cfname").removeClass('contactFormFieldError');
    }
    else {
        $("#cfname").addClass('contactFormFieldError');
    }
    if (isRealPerson()) {
        totalfilled += 1;
        $("#txtcaptcha").removeClass('contactFormFieldError');
    }
    else{
        $("#txtcaptcha").addClass('contactFormFieldError');
    }

    if (totalfilled < 4) {
        $("#moleWrap").show();
        MoveTo('moleWrapper', 2000);
    }
    else {
        $("#moleWrap").hide();
        var dataStr = "name=" + encodeURIComponent($("#cfname").val()) + "&company=" + encodeURIComponent($("#cfcompany").val()) + "&email=" + encodeURIComponent($("#cfemail").val());
        dataStr += "&phone=" + encodeURIComponent($("#cfphone").val()) + "&position=" + encodeURIComponent($("#cfposition").val()) + "&message=" + encodeURIComponent($("#cfmessage").val());


        if ($('#interestWebsiteDesign').is(':checked')) {
            dataStr += "&interestWebsiteDesign=true";
        }
        else {
            dataStr += "&interestWebsiteDesign=false";
        }
        if ($('#interestWebsiteDevelopment').is(':checked')) {
            dataStr += "&interestWebsiteDevelopment=true";
        }
        else {
            dataStr += "&interestWebsiteDevelopment=false";
        }
        if ($('#interestAppDevelopment').is(':checked')) {
            dataStr += "&interestAppDevelopment=true";
        }
        else {
            dataStr += "&interestAppDevelopment=false";
        }
        if ($('#interestGraphicDesign').is(':checked')) {
            dataStr += "&interestGraphicDesign=true";
        }
        else {
            dataStr += "&interestGraphicDesign=false";
        }
        if ($('#interestBranding').is(':checked')) {
            dataStr += "&interestBranding=true";
        }
        else {
            dataStr += "&interestBranding=false";
        }
        if ($('#interestSEO').is(':checked')) {
            dataStr += "&interestSEO=true";
        }
        else {
            dataStr += "&interestSEO=false";
        }
        if ($('#interestMarketing').is(':checked')) {
            dataStr += "&interestMarketing=true";
        }
        else {
            dataStr += "&interestMarketing=false";
        }
        if ($('#interestOther').is(':checked')) {
            dataStr += "&interestOther=true";
        }
        else {
            dataStr += "&interestOther=false";
        }
        if ($('#termsTrue').is(':checked')) {
            dataStr += "&termsTrue=true";
        }
        else {
            dataStr += "&termsTrue=false";
        }


        var req = $.ajax({
            type: "POST",
            url: "/MailHandler.ashx?op=savecontactmessage",
            data: dataStr,
            error: function(req, json) {

                alert(json);
            },
            success: function(html) {
                clearContactForm();

                //$("div.captcha").html('<h1 style="color:#ffffff font-size:20px !important;">Thank you for your message, we will get back to you as soon as possible.</h1>');
                $("#moleThankYouWrap").show();
                MoveTo('contactContentWrap', 2000);
                return;
            }
        });
    }
    
    
    
    
    

}

function changeImage(element) {
    var src = $(element).attr('src');

    if (src == "/images/btn_white_arrow.png") {
        src = "/images/btn_arrow_rollover.png";
        activateArrowMouseUp(element);
    }
    else if (src == "/images/btn_white_arrow_down.png") {
        src = "/images/btn_green_arrow_down.png";
        activateArrowMouseDown(element);
    }
    else if (src == "/images/btn_arrow_rollover.png") {
        src = "/images/btn_white_arrow.png";
        deActivateArrowMouseUp();
    }
    else if (src == "/images/btn_green_arrow_down.png") {
        src = "/images/btn_white_arrow_down.png";
        deActivateArrowMouseDown();
    }

    $(element).attr({ 'src': src });

}

function clearContactForm() {
    $("#cfname").val('');
    $("#cfcompany").val('');
    $("#cfemail").val('');
    $("#cfphone").val('');
    $("#cfposition").val('');
    $("#cfmessage").val('');
    $("#txtcaptcha").val('');
}

function LoadBeyondSpace() {
    $('#BeyondSpaceContainer').load("/SiteHandler.ashx?op=loadbeyondspace", function(response, status, xhr) {
        if (status == "success") {
            //$("#error").html(msg + xhr.status + " " + xhr.statusText);
            LoadAboutUs();
        }

    });
    //getData('BeyondSpaceContainer', '/ScriptService.asmx/GetControlHtml', '~/Controls/BeyondSpace.ascx');

}

function LoadAboutUs() {
    $('#AboutUsContainer').load("/SiteHandler.ashx?op=loadaboutuspanel", function(response, status, xhr) {
        if (status == "success") {
            preloaderObj = Preloader.getInstance();
            preloaderObj.AboutUsLoaded = true;
           
            LoadAboutHomeSeparator();
        }

    });

}

function LoadAboutHomeSeparator() {
    //getData('AboutHomeSeparatorContainer', '/ScriptService.asmx/GetControlHtml', '~/Controls/AboutHomeSeparatorPanel.ascx');
    preloaderObj = Preloader.getInstance();
    $('#AboutHomeSeparatorContainer').load("/SiteHandler.ashx?op=loadabouthomepanel", function(response, status, xhr) {
        if (status == "success") {
            preloaderObj = Preloader.getInstance();
            LoadHomepage();
        }

    });

}

function LoadHomepage() {
    preloaderObj = Preloader.getInstance();
    $('#HomepageContainer').load("/SiteHandler.ashx?op=loadhomepagepanel", function(response, status, xhr) {
        if (status == "success") {
            preloaderObj = Preloader.getInstance();
            preloaderObj.HomePageLoaded = true;
            Cufon.replace('h1', { fontFamily: 'VagRounded' });
            Cufon.replace('blockquote', { fontFamily: 'VagRounded' });
            Cufon.replace('h6', { fontFamily: 'stencil' });

            $(".jcolorbox").colorbox({ width: "765px", height: "640px", iframe: true });
            
            LoadMainPortfolio();
        }

    });
}

function LoadMainPortfolio() 
{
    preloaderObj = Preloader.getInstance();
    
    
    
    $('#MainPortfolioContainer').load("/SiteHandler.ashx?op=loadmainportfolio", function(response, status, xhr) {
        if (status == "success") {
            preloaderObj = Preloader.getInstance();
            Cufon.replace('h1', { fontFamily: 'VagRounded' });
            Cufon.replace('blockquote', { fontFamily: 'VagRounded' });
            LoadContact();
            //LoadSubPortfolios();
        }

    });
}

function LoadSubPortfolios() 
{
    preloaderObj = Preloader.getInstance();
    
    //alert('LoadSubPortfolios');

    //$("#SubPortfolioContainer").load("/SiteHandler.ashx?op=loadsubportfolio", function(response, status, xhr) 
    //{
    //    if (status == "success") 
        {
            preloaderObj = Preloader.getInstance();
            Cufon.replace('h1', { fontFamily: 'VagRounded' });
            Cufon.replace('blockquote', { fontFamily: 'VagRounded' });
            loadThumbnailMouseOvers();
            
            $("div.clientDetailsWrapContent ul").each(function() 
            {
                var counter = 0;
                $(this, "li").each(function() {
                    counter += 1;
                });
            });
            $("div.GalleryPreviewBox div").each(function() { $(this).show(); });
            loadCarousel();
            $("#overlaySignLoader").hide();
            $("div.GalleryPreviewButtonContainer").show();
            setTimeout(function() { TwitterFlyIn(); }, 5000);
        }
    //});


}

function LoadContact() 
{
    preloaderObj = Preloader.getInstance();
    
    alert('LoadContact');

    //$("#ContactContainer").load("/SiteHandler.ashx?op=loadcontact", function(response, status, xhr) {
    //if (status == "success") {
    preloaderObj = Preloader.getInstance();
    Cufon.replace('h1', { fontFamily: 'VagRounded' });
    Cufon.replace('blockquote', { fontFamily: 'VagRounded' });
    LoadBelowContact();
    //}
    //});
}

function LoadBelowContact() 
{
    preloaderObj = Preloader.getInstance();
    
    alert('LoadBelowContact');

    $("#BelowContactContainer").load("/SiteHandler.ashx?op=loadbelowcontact", function(response, status, xhr) {
        if (status == "success") {
            //loadCarousel();
            preloaderObj.IsProcessing = false;
            preloaderObj.IsFullyLoaded = true;

        }
    });
}

function loadCarousel() {
    $(".GalleryPreviewContainer").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        beforeStart: function() {

        },
        afterEnd: function(j) {

            var selector = j.selector;
            var array = new Array();
            array = selector.split('.');
            var slice = array[1];
            var currentslice = slice.replace("slice(", "");
            currentslice = currentslice.replace(")", "");
            updateGalleryPager(currentslice);
        }
    });

}

function updateGalleryPager(currentslice) {
    $("li.SelectedGalleryPage").each(function() {
        //$(this).addClass('GalleryPage');
        $(this).removeClass('SelectedGalleryPage');
    });
    $("#gallerypage" + currentslice).addClass('SelectedGalleryPage');
}

function TwitterFlyIn() {
    $("#TwitterWrapper").show();
    var pos = $("#" + ActiveWindow).offset();
    var width = $("#TwitterWrapper").width();

    //$("#TwitterWrapper").css('top', $("#" + ActiveWindow).height() / 2 - $("#TwitterWrapper").height() / 2);
    //$("#TwitterWrapper").css('left', $("#" + ActiveWindow).width() / 2 - $("#TwitterWrapper").width() / 2);
    //$("#TwitterWrapper").css({ "left": (pos.left + width) + "px", "top": pos.top + "px" });
    $("#TwitterWrapper").animate({ "top": pos.top + "px", "left": (pos.left + width) + "px" }, 2000, 'linear');
    //$("#TwitterWrapper").animate({ top: $(window).height() / 2 -$("#TwitterWrapper").height() / 2), left: $(window).width() / 2 - $("#TwitterWrapper").width() / 2}, 200, 'linear');

}

function TwitterFlyOut() {
    var pos = $("#" + ActiveWindow).offset();
    var width = $("#TwitterWrapper").width();

    $("#TwitterWrapper").animate({ "left": "-" + (pos.left + width) + "px","top":"-1500px" }, 1000, 'linear', function() { $("#TwitterWrapper").hide(); });

}

function TwitterFollowUs(obj, urlstr) {
    $.jqURL.loc(urlstr, { wintype: '_blank' });
}

function blockWindow() {
    $.blockUI('', { backgroundImage: 'url(/images/loading_animation.gif)' });
    //$('body').block('', { backgroundImage:'url(Images/site/loading_animation.gif)', backgroundRepeat: 'no-repeat', backgroundPosition: 'center', backgroundColor: '#00aeef', opacity: '1.00', width: '100%', height: '100%' });

}

function UnBlockWindow() {

    $("body").unblock();
    
    //alert('UnBlockWindow');

}

function alertTimerClickHandler() 
{
    preloaderObj = Preloader.getInstance();
    
    if (preloaderObj.IsFullyLoaded == true) 
    {
        clearTimeout(alertTimerId);
        loadEasing();
        //LoadMenu();
        MoveTo('introContentWrap', 1200);
        if(!$.browser.msie){
      		$("#overlayClientInfo").css("right","735px");
    	}
        UnBlockWindow();
        $("div.processingWindow").each(function() {
            $(this).hide();
        });
        
        setTimeout(function() {
            LoadSubPortfolios();
            
        },1000);
        
        

    }
    else {
        alertTimerId = setTimeout("alertTimerClickHandler()", 1000);

    }

}

function getData(destination, serviceURL, controlLocation) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: serviceURL,
        data: "{'controlLocation':'" + controlLocation + "'}",
        success:
   function(msg) {

       $('#' + destination).html(eval('(' + msg + ')').d)
   },
        error:
   function(XMLHttpRequest, textStatus, errorThrown) {
       alert("Error Occured!");
   }
    });
}


$(document).ready(function() 
{

$("#TwitterWrapper").hide();
    blockWindow();
    preloaderObj = Preloader.getInstance();
    preloaderObj.IsProcessing = true;
    preloaderObj.ScriptsLoaded = true;
    

    alertTimerClickHandler();
    
    //alert('here');

    //$(".jcolorbox").colorbox({ width: "740px", height: "80%", iframe: true });
//LoadBeyondSpace();
    
preloaderObj.IsProcessing = false;
preloaderObj.IsFullyLoaded = true;
setTimeout(function() { TwitterFlyIn(); }, 5000);
loadThumbnailMouseOvers();
$(".jcolorbox").colorbox({ width: "765px", height: "640px", iframe: true });
initCaptchaImg();

    //alert('here');

});
