﻿//This is used in conjunction with the HtmlHelper.Uploadify extension method.
function initUploadify(control, uploadUrl, baseUrl, fileExtensions, fileDescription, authenticationToken, errorFunction, completeFunction) {
    var options = {};

    options.script = uploadUrl;
    options.uploader = baseUrl + 'uploader.swf';
    options.cancelImg = baseUrl + 'cancel.png';
    //TODO: Make this an option?
    options.auto = true;
    options.scriptData = { AuthenticationToken: authenticationToken };
    options.fileExt = fileExtensions;
    options.fileDesc = fileDescription;

    if (errorFunction != null) {
        options.onError = errorFunction;
    }

    if (completeFunction != null) {
        options.onComplete = completeFunction;
    }

    control.fileUpload(options);
}

$(document).ready(function() {
    $('.flash').show();
    $('.flash').animate({ delay: 0 }, 1000).animate({ opacity: 0 }, 1000).animate({ paddingTop: '0px', paddingBottom: '0px', height: '0px' }, 0);
});

function ResizeFlashWrapperHeight(height) {

    // alert("Requested: " + height);

    if (height < 800 && height < $(window).height()) {
        height = 800;
    }

    // alert("Given: " + height);

    if (height > 4095) height = 4095;
    $('#flashWrapper').css("height", height + "px");
}

function ResizeFlashWrapperWidth(width) {
    $('#flashWrapper').css("width", width);
}

function ResizeLeftColumnHeight(height) {
    // alert('Resizing left column to ' + height);
    $('.column-left').css("height", height);
}

function UpdateGalleryStage() {
    var w = $(window).width();

    if (w < 955) { ResizeFlashWrapperWidth(955); }
    else { $('#flashWrapper').css("width", "100%"); }


}

function UpdateHomeStage() {
	        var w = $(window).width();
	        var h = $(window).height();
	        if (w < 955) { ResizeFlashWrapperWidth(955); }
	        else { $('#flashWrapper').css("width", "100%"); }
	        if (h < 570) { ResizeFlashWrapperHeight(570); }
	        else { $('#flashWrapper').css("height", "100%"); }

	    }

