﻿$(document).ready(function () {

    // utility nav expand / collapse
    $("div.arrow-expand a").click(function () {
        $("div.utility-nav-collapsed").animate({ top: '-31px' }, 'fast');
        $("div.utility-nav-expanded").animate({ top: '1px' }, 'slow');
    });
    $("div.arrow-collapse a").click(function () {
        $("div.utility-nav-expanded").animate({ top: '-104px' }, 'fast');
        $("div.utility-nav-collapsed").animate({ top: '1px' }, 'slow');
    });

    // project nav expand / collapse
    var projectNavHeight = $("div#body-content div.right-column div.column.expanded").height();
    $("div#body-content div.right-column div.column.expanded p.nav-toggle a").click(function () {
        $("div#body-content div.right-column div.column.expanded").animate({ top: '-' + projectNavHeight }, 'fast');
        $("div#body-content div.right-column div.column.collapsed").animate({ top: "37px" }, 'slow');
    });
    $("div#body-content div.right-column div.column.collapsed p.nav-toggle a").click(function () {
        $("div#body-content div.right-column div.column.expanded").animate({ top: '0px' }, 'fast');
        $("div#body-content div.right-column div.column.collapsed").animate({ top: "-24px" }, 'slow');
    });

    $("div.footer-subscribe input.text").val("Email Address");
    $("div.footer-subscribe input.text").click(function () {
        if ($(this).val() == "Email Address")
            $(this).val("");
    });
    $("div.footer-subscribe input.text").blur(function () {
        if ($(this).val() == "")
            $(this).val("Email Address");
    });

    // stay connected text
    var strInput = "";
    $("div.stay-connected input.text").each(function () {
        switch ($(this).attr("class")) {
            case "text email":
                $(this).val("Email address");
                break;
            case "text cell":
                $(this).val("Cell # (for txts)");
                break;
            case "text zip":
                $(this).val("Zip");
                break;
        }
    });

    // work thumbnail hovers
    $("div.work-body-overview div.column").hover(function () {
        $(this).addClass("hover").css('z-index','1000').find("div.tooltip-wrapper").show();
    },
    function () {
        $(this).removeClass("hover").css('z-index', '10').find("div.tooltip-wrapper").hide();
    });

    $("div.side-bar-thumb-nav div.column").hover(function () {
        $(this).css('z-index', '1000').find("div.tooltip-wrapper").show();
    },
    function () {
        $(this).css('z-index', '10').find("div.tooltip-wrapper").hide();
    });

    // work detail cycle
    var rotator = $('div#work-viewer-slide-holder');
    $(rotator).cycle({
        fx: 'scrollHorz',
        timeout: 16000,
        speed: 750,
        prev: 'div#body-content div.work-body div.work-viewer div.work-viewer-tabs.previous',
        next: 'div#body-content div.work-body div.work-viewer div.work-viewer-tabs.next',
        after: onAfter
    });
    $("div#body-content div.work-body div.work-viewer div.work-viewer-nav ul li.pause").click(function () {
        $(rotator).cycle('pause');
    });
    $("div#body-content div.work-body div.work-viewer div.work-viewer-nav ul li.play").click(function () {
        $(rotator).cycle('resume');
        $(rotator).cycle('next');
    });
    $("div#body-content div.work-body div.work-viewer div.work-viewer-nav ul li.advance").click(function () {
        $(rotator).cycle('next');
    });
    $("div#body-content div.work-body div.work-viewer div.work-viewer-nav ul li.reverse").click(function () {
        $(rotator).cycle('prev');
    });
    function onAfter(curr, next, opts) {
        var counterText = 'Slide ' + (opts.currSlide + 1) + ' of ' + opts.slideCount;
        $('span#counter').html(counterText);
        $('span#work-caption').html(this.alt);
    }

    // file upload viewer
    $("div.column.file-upload-group input.file").change(function () {
        var Upload = $(this).val();
        //alert(Upload);
        //$("#container.contact-us div#body-content div.left-column div.column.file-upload input.text").val(Upload);
        $(this).siblings("input.text").val(Upload);
    });

    var fileCount = 2;
    var fileLimit = 3;
    var fileStr = "";

    // file upload multiple files displayer
    $("div.column.file-upload p a.multi-file").click(function () {
        if (fileCount <= fileLimit) {
            fileStr += '<div class="column file-upload-group">\r';
            fileStr += '<input type="text" class="text" name="file' + fileCount + '" />';
            fileStr += '<input type="image" class="button" src="/sites/untuck/images/BTN_upload.gif" style="width: 14px; height: 14px;" />';
            fileStr += '<input type="file" class="file" name="file' + fileCount + '" />';
            fileStr += '</div>';
            $("#file-upload-container").append(fileStr);
            fileCount++;
            fileStr = '';
        } else {
            $("div.column.file-upload p.multi-file").html('Sorry, our upload limit is ' + fileLimit + ' files.');
        }
        //$(this).parents().find("div.file-upload-container").slideDown();
    });




    /*$("div.work-body-overview div.thumbnail").qtip({
        content: $(this).attr('title'),
        show: 'mouseover',
        hide: 'mouseout',
        style: {
            color: '#65b6b3',
            border: 'none'
    },
    position: {
        corner: {
            target: 'rightTop',
            tooltip: 'bottomMiddle'
        }
    }

    });*/



});

function sumbitForm(form) {
    document.forms[form].submit();
    return false;
}
