﻿/*
www.webdevelopercv.com
Copyright (c) 2010 Evgeny Neumerzhitskiy.
Please feel free to use any part of my code. If you put a reference to me I would be grateful, but it's not required.*/
/// <reference path="jquery-1.4.2.min.js"/>

// implement JSON.stringify and JSON.parse. Code is taken from http://www.JSON.org/json2.js
if (!this.JSON) { this.JSON = {}; }
(function() {
    function f(n) { return n < 10 ? '0' + n : n; }
    if (typeof Date.prototype.toJSON !== 'function') {
        Date.prototype.toJSON = function(key) {
            return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
        }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(key) { return this.valueOf(); };
    }
    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }, rep; function quote(string) { escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function(a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; }
    function str(key, holder) {
        var i, k, v, length, mind = gap, partial, value = holder[key]; if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); }
        if (typeof rep === 'function') { value = rep.call(holder, key, value); }
        switch (typeof value) {
            case 'string': return quote(value); case 'number': return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': if (!value) { return 'null'; }
                gap += indent; partial = []; if (Object.prototype.toString.apply(value) === '[object Array]') {
                    length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; }
                    v = partial.length === 0 ? '[]' : gap ? '[\n' + gap +
partial.join(',\n' + gap) + '\n' +
mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v;
                }
                if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { k = rep[i]; if (typeof k === 'string') { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } else { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } }
                v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v;
        }
    }
    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function(value, replacer, space) {
            var i; gap = ''; indent = ''; if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } } else if (typeof space === 'string') { indent = space; }
            rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); }
            return str('', { '': value });
        };
    }
    if (typeof JSON.parse !== 'function') {
        JSON.parse = function(text, reviver) {
            var j; function walk(holder, key) {
                var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } }
                return reviver.call(holder, key, value);
            }
            text = String(text); cx.lastIndex = 0; if (cx.test(text)) {
                text = text.replace(cx, function(a) {
                    return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }
            if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { j = eval('(' + text + ')'); return typeof reviver === 'function' ? walk({ '': j }, '') : j; }
            throw new SyntaxError('JSON.parse');
        };
    }
} ());

var ftc_obb = {
    isAdmin: false,
    compareObjects: function (obj1, obj2) {
        var t1 = typeof (obj1);
        var t2 = typeof (obj2);
        if (t1 !== t2) {
            return false;
        }
        if (t1 != "object" || obj1 === null) {
            return obj1 === obj2;
        }
        else {
            if (obj1.constructor == Array && obj2.constructor != Array) {
                return false;
            }
            // recurse array or object
            var n1, v1, v2;
            for (n1 in obj1) {
                if (obj1.hasOwnProperty(n1)) {
                    v1 = obj1[n1]; t1 = typeof (v1);
                    if (!(n1 in obj2)) {
                        return false;
                    }
                    v2 = obj2[n1];
                    t2 = typeof (v2);

                    if (t1 !== t2) {
                        return false;
                    }
                    if (t1 != "object" || v1 === null) {
                        if (v1 !== v2) {
                            return false;
                        }
                    }
                    else {
                        if (ftc_obb.compareObjects(v1, v2) === false) {
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    },
    mySearchObjectInArray: function (array, propertyName, propertyValue) {
        for (var iIndex = 0; iIndex < array.length; iIndex++) {
            if (array[iIndex][propertyName] == propertyValue) {
                return array[iIndex];
            }
        }
        return null;
    },
    padNumber: function (number, length) {
        var str = '' + number;
        while (str.length < length) {
            str = '0' + str;
        }

        return str;
    },
    parseTextBoxInt: function ($textbox, fieldName, numberFrom, numberTo, errorMsgFunc) {
        var textboxEntered = $textbox.val();
        var errorMessage = null;
        if (textboxEntered) {
            if (!/^[0-9]+$/.test(textboxEntered)) {
                errorMessage = "Please enter valid " + fieldName;
            }
        } else {
            errorMessage = "Please enter " + fieldName;
        }
        textboxEntered = parseInt(textboxEntered,10);
        if (textboxEntered <= numberFrom || textboxEntered > numberTo) {
            errorMessage = "The '" + fieldName + "' value should be between " + numberFrom + " and " + numberTo;
        }
        if (errorMessage !== null) {
            $textbox.addClass('input-validation-error').focus();
            errorMsgFunc(errorMessage);
            return { valid: false };
        }
        return { valid: true, value: textboxEntered };
    },
    parseTextBoxFloat: function ($textBox, fieldName, numberFrom, numberTo, errorMsgFunc) {
        var textboxEntered = $textBox.val();
        var errorMessage = null;
        if (textboxEntered) {
            if (isNaN(textboxEntered)) {
                errorMessage = "Please enter valid " + fieldName;
            }
        } else {
            errorMessage = "Please enter " + fieldName;
        }
        textboxEntered = parseFloat(textboxEntered);

        if (textboxEntered < numberFrom || textboxEntered > numberTo) {
            errorMessage = "The '" + fieldName + "' value should be between " + numberFrom + " and " + numberTo;
        }
        if (errorMessage !== null) {
            $textbox.addClass('input-validation-error').focus();
            errorMsgFunc(errorMessage);
            return { valid: false };
        }
        return { valid: true, value: textboxEntered };
    },
    encodeHTML: function (text) {
        var textneu = text.replace(/&/, "&amp;");
        textneu = textneu.replace(/</, "&lt;");
        textneu = textneu.replace(/>/, "&gt;");
        textneu = textneu.replace(/\r\n/, "<br>");
        textneu = textneu.replace(/\n/, "<br>");
        textneu = textneu.replace(/\r/, "<br>");
        return (textneu);
    },
    popupMessage: null,
    popupMsgCloseTimerID: null,
    repTav: [114, 97, 46, 113, 107, 105, 106, 64, 116, 101, 109, 111, 110, 117, 108, 121, 104, 32],
    umboriagest: function (stringFrom) {
        var stringReturn = '';
        for (var i = 0; i < stringFrom.length; i++) {
            var character = stringFrom.charAt(i);
            var lowered = character.toLowerCase();
            var index = jQuery.inArray(lowered.charCodeAt(0), ftc_obb.repTav);
            if (index != -1) {
                if (index % 2 === 0) {
                    index++;
                } else {
                    index--;
                }
                var characterFinal = String.fromCharCode(ftc_obb.repTav[index]);
                if (lowered != character) {
                    characterFinal = characterFinal.toUpperCase();
                }
                stringReturn += characterFinal;
            } else {

                stringReturn += character;
            }
        }
        return stringReturn;
    },
    kufmjfkyoearusftaqcmo: function kufmjfkyoearusftaqcmo() {
        var funcName = arguments.callee.toString();
        funcName = funcName.substr('function '.length);
        funcName = funcName.substr(0, funcName.indexOf('('));
        var friendlyName = ftc_obb.umboriagest(funcName);
        $(this).html(friendlyName).attr('href', ftc_obb.umboriagest('orkyem:') + friendlyName);
    },
    ftcProtocol: null,
    roundPrice: function (num) {//rounds a number to 2 decimals
        return Math.round(num * 100) / 100;
    },
    preloadImages: function () {
        for (var i = 0; i < arguments.length; i++) {
            jQuery("<img>").attr("src", "/images/" + arguments[i]);
        }
    },
    showPopupMessageNow: function (msg) {
        ftc_obb.popupMessage = msg;
        ftc_obb.showPopupMessage();
    },
    showPopupMessage: function () {
        if (ftc_obb.popupMessage === null) {
            return;
        }
        $("body").children(".popupMessage").remove();
        if (ftc_obb.popupMsgCloseTimerID !== null) {
            clearTimeout(ftc_obb.popupMsgCloseTimerID);
        }
        var $popupMessage = $("<div class='popupMessage'>" + ftc_obb.popupMessage + "</div>");
        $("body").append($popupMessage);
        var left = ($(window).width() - $popupMessage.outerWidth(true)) / 2;
        $popupMessage.css("left", left + "px");
        $popupMessage.fadeIn('normal', function () {
            ftc_obb.fixIEFadeIn(this);
            ftc_obb.popupMsgCloseTimerID = setTimeout("$('body').children('.popupMessage').fadeOut('slow');", 3000);
        });
    },
    emptyStringIfNull: function (str) {
        if (str === null) {
            return "";
        }
        return str;
    },    
    getIEVersionNumber: function () {
        var ua = navigator.userAgent;
        var MSIEOffset = ua.indexOf("MSIE ");

        if (MSIEOffset == -1) {
            return 0;
        } else {
            return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
        }
    },
    fixIEFadeIn: function (element) {//the function fixes the 'edgy text' after fadeIn in IE 7 and 6
        if (ftc_obb.getIEVersionNumber() > 4) {
            if (element === undefined) {
                element = this;
            }
            element.style.removeAttribute("filter");
        }
    },
    submitForm: function (submitForm, funcSuccess, funcOnSubmit) {
        var $submitForm = $(submitForm);
        $submitForm.data('submitFormFuncSuccess', funcSuccess);
        $submitForm.data('submitFormFuncOnSubmit', funcOnSubmit);
        $submitForm.submit(function (funcSuccess) {
            if ($(".ajaxLoading").is(":visible")) {
                return false;
            }
            var $submitForm = $(this);
            var onSubmitFunction = $submitForm.data('submitFormFuncOnSubmit');
            if (onSubmitFunction !== undefined) {
                if (!onSubmitFunction($submitForm)) {
                    return false;
                }
            }

            $(".ajaxLoading").show();
            $("input[type='submit'], input[type='button']").attr("disabled", "disabled");
            $submitForm.find(".field-validation-message").slideUp('fast', function () { $(this).remove(); });
            $submitForm.find(".validation-summary-errors").html('').slideUp('fast');
            $submitForm.find(".input-validation-error").each(function () { $(this).removeClass('input-validation-error'); });
            $submitForm.ajaxError(function (e, xhr, settings, exception) {
                $submitForm = $(this);
                $submitForm.unbind('ajaxError');
                $(".ajaxLoading").hide();
                $("input[type='submit'], input[type='button']").removeAttr("disabled");
                $submitForm.find(".validation-summary-errors").append('<div>Failed to connect to web site. Please retry. Error description: ' + xhr.statusText + '</div>').slideDown();
                if ($(window).scrollTop() > 100) {
                    $('html,body').animate({ scrollTop: 0 }, 500);
                }
            });
            $.post($submitForm.attr('action'), $submitForm.serialize(), function (result) {
                var jsonResult = result;
                if (!jsonResult.Valid || !$submitForm.hasClass('doNotHideLoadingOnSuccess')) {
                    $(".ajaxLoading").hide();
                    $("input[type='submit'], input[type='button']").removeAttr("disabled");
                }
                if (jsonResult.Valid) {
                    var submitSuccessFunction = $submitForm.data('submitFormFuncSuccess');
                    if (submitSuccessFunction !== undefined && submitSuccessFunction !== null) {
                        submitSuccessFunction($submitForm, jsonResult);
                    }
                    if ($submitForm.hasClass('closeDlgOnSuccess')) {
                        ftc_obb.closeDialog();
                    }
                } else {
                    var validationMessagePrefix = "&laquo;";
                    if ($submitForm.parents('.dialog, .orderSlide, #sendMessageContainer').length > 0) {
                        validationMessagePrefix = "^";
                    }
                    var vInt = 0;
                    for (var key in jsonResult.errors) {
                        if (jsonResult.errors.hasOwnProperty(key)) {
                            var $field = $("#" + key);
                            if ($field.length === 0) {
                                $submitForm.find(".validation-summary-errors").hide().append("<div>" + jsonResult.errors[key] + '</div>');
                            } else {
                                $field.addClass('input-validation-error').after("<div class='field-validation-message' style='display:none'>" + validationMessagePrefix + "&nbsp;" + jsonResult.errors[key] + "</div>");
                                if (vInt === 0) {
                                    $field.focus().select();
                                }
                                vInt++;
                            }
                        }
                    }

                    if ($(".validation-summary-errors div").length > 0) {
                        $(".validation-summary-errors").slideDown('normal');
                        if ($(window).scrollTop() > 100) {
                            $('html,body').animate({ scrollTop: 0 }, 500);
                        }
                    }
                    $(".field-validation-message").slideDown('normal');
                }
            });
            return false;
        });
    },
    closeDialog: function () {
        var $dlg = $(".dialog");
        var dlgHeight = $dlg.height();
        $dlg.animate({ top: $(window).scrollTop() - dlgHeight }, 500, null, function () {
            var $element = $(this).find('.dialogContent > div');
            $element.hide();
            $(this).replaceWith($element);
        });
        ftc_obb.showOverlay(false);
    },
    showDialog: function (elementId, title) {
        var $dialogElement = $("#" + elementId);
        $dialogElement.wrap("<div class='dialogContent'></div>");
        var $dialogContent = $dialogElement.parent();
        $dialogContent.wrap("<div class='dialog'></div>");
        var $dialog = $dialogContent.parent();
        $dialogElement.show();
        var $dialogTitle = $("<div class='dialogTitle'>" + title + "</div>");
        $dialog.prepend($dialogTitle);
        $dialog.find(".dlgClose").click(function () {
            $(this).unbind('click');
            ftc_obb.closeDialog();
        });

        var dlgWidth = $dialog.width();
        var dlgHeight = $dialog.height();
        $dialogTitle.css("width", dlgWidth - 10 + "px");

        var dlgTop = Math.floor(($(window).height() - dlgHeight) / 2 + $(window).scrollTop());
        var dlgLeft = Math.floor(($(window).width() - dlgWidth) / 2 + $(window).scrollLeft());

        ftc_obb.showOverlay();
        $dialog.css({ left: dlgLeft, top: $(window).scrollTop() - dlgHeight });
        $dialog.show().animate({ top: dlgTop }, 500);
    },
    showOverlay: function (show) {
        var $overlay = $("#overlay");
        if (show === undefined || show) {
            var vHeight = document.body.clientHeight;
            if (vHeight < screen.height) {
                vHeight = screen.height;
            }
            $overlay.css({ height: vHeight + "px" });
            $overlay.show().css({ opacity: 0 }).fadeTo('slow', 1);
        } else {
            $overlay.fadeTo('slow', 0, function () { $(this).hide(); });
        }
    },
    equalize: function () {
        var vSameHeightObjects = [];
        var $sameHeightElements = $(".heightEqualize");
        var maxHeight = 0;
        for (var iIndex0 = 0; iIndex0 < $sameHeightElements.length; iIndex0++) {
            var oElement0 = $sameHeightElements[iIndex0];
            if (oElement0.offsetHeight > maxHeight) {
                maxHeight = oElement0.offsetHeight;
            }
        }
        for (var iIndex = 0; iIndex < $sameHeightElements.length; iIndex++) {
            var oElement = $sameHeightElements[iIndex];
            oElement.style.height = maxHeight + 'px';
        }
    },
    getCaptionInsideElementValue: function ($element) {
        if ($element.val() == $element.data("fieldText")) {
            return "";
        } else {
            return $element.val();
        }
    },
    $headerPromotionExpireArea: null,
    discountCountdownExpirationDate: null,
    updateDiscountCountdown: function () {
        if (ftc_obb.discountCountdownExpirationDate === null || ftc_obb.$headerPromotionExpireArea === null) {
            return;
        }
        var secondsRemaining = (ftc_obb.discountCountdownExpirationDate.getTime() - (new Date()).getTime()) / 1000;
        if (secondsRemaining <= 0) {
            ftc_obb.$headerPromotionExpireArea.children("#promotionBannerText").html('Promotion Ended');
            ftc_obb.$headerPromotionExpireArea.children("#promotionBannerCountdown").hide();
            return;
        }

        var daysRemaning = Math.floor(secondsRemaining / 60 / 60 / 24);
        var hoursRemaining = Math.floor((secondsRemaining / 60 / 60) - daysRemaning * 24);
        var minutesRemaining = Math.floor((secondsRemaining / 60) - daysRemaning * 24 * 60 - hoursRemaining * 60);
        secondsRemaining = Math.floor((secondsRemaining) - daysRemaning * 24 * 60 * 60 - hoursRemaining * 60 * 60 - minutesRemaining * 60);

        var countdownText = " ";
        if (daysRemaning >= 0) {
            countdownText += daysRemaning + " Day";
            if (daysRemaning > 1 || daysRemaning === 0) {
                countdownText += "s";
            }
        }
        countdownText += " " + hoursRemaining + ":" + ftc_obb.padNumber(minutesRemaining, 2) + ":" + ftc_obb.padNumber(secondsRemaining, 2);
        ftc_obb.$headerPromotionExpireArea.children("#promotionBannerCountdown").html(countdownText);
        setTimeout("ftc_obb.updateDiscountCountdown()", 1000);
    },
    showTooltip: function ($icon) {
        var $tooltip = $icon.prev();
        var $tooltipContent = $tooltip;
        if (!$tooltip.hasClass('dialogBg')) {
            $tooltip = $("<div class='dialogBg'><div class='dlgBgArrowRight'></div><div class='dialogBgContent'><div class='dlgBgArrowLeft'></div><div class='t'></div></div><div class='b'><div></div></div></div>");
            $tooltip.find(".t").after($tooltipContent.show());
            $tooltip = $icon.before($tooltip).prev();
        }
        $tooltipContent = $tooltip.find(".ftcTooltipBg");
        //run the onShow function if specified
        if ($tooltipContent[0].id !== null && typeof (tooltipBgOnShow) != "undefined" && $tooltipContent[0].id in tooltipBgOnShow) {
            var funcOnShow = tooltipBgOnShow[$tooltipContent[0].id];
            if (funcOnShow($tooltipContent) === false) {
                return;
            }
        }
        var tooltipInBody = false; //true if tootip is in body element
        if ($tooltipContent.hasClass("moveToBody")) {
            tooltipInBody = true;
            $tooltip = $("body").append($tooltip).children(".dialogBg:last");
        }
        //fix the width for old IE
        if (ftc_obb.getIEVersionNumber() > 4 && ftc_obb.getIEVersionNumber() < 8) {
            if (ftc_obb.getIEVersionNumber() < 7) {
                $tooltip.css("width", $tooltipContent.width() + "px");
            }
            $tooltip.find(".b").css("width", $tooltip.width() + "px");
        }
        //position the tooltip
        var vPositionToTheRight = $icon.offset().left < ($(window).width() / 2);
        var iconWidth = $icon.width();
        var iconPosition = tooltipInBody ? $icon.offset() : $icon.position();
        var tooltipHeight = $tooltip.outerHeight(true);

        var horizontalIndent = 28;
        var verticalIndent = 10;
        var arrowTopIndent = 7;
        var tooltipBottomAbsolute = $icon.offset().top + verticalIndent + tooltipHeight;
        var moveUp = tooltipBottomAbsolute - $(window).height() - $(window).scrollTop() + 1;
        if (moveUp < 0) {
            moveUp = 0;
        } else {
            if (moveUp > tooltipHeight - 60) {
                moveUp = tooltipHeight - 60;
                if (moveUp < 0) {
                    moveUp = 0;
                }
            }
            verticalIndent -= moveUp;
            arrowTopIndent += moveUp;
        }


        if (vPositionToTheRight) {
            $tooltip.find(".dlgBgArrowRight").hide();
            $tooltip.find(".dlgBgArrowLeft").css("top", arrowTopIndent + "px").show();
            $tooltip.css({ left: (iconPosition.left + iconWidth + horizontalIndent) + "px", top: (iconPosition.top + verticalIndent) + "px" }).show();
        } else {
            $tooltip.find(".dlgBgArrowLeft").hide();
            $tooltip.find(".dlgBgArrowRight").css("top", arrowTopIndent + "px").show();
            $tooltip.show().css({ left: (iconPosition.left - horizontalIndent - $tooltip.outerWidth(true)) + "px", top: (iconPosition.top + verticalIndent) + "px" });
        }
        if (ftc_obb.getIEVersionNumber() == 6) {//fixing a 'select over an absolute positioned element' bug in IE6                
            var iframeStyles = {
                width: $tooltip.outerWidth(true) + 'px',
                height: $tooltip.outerHeight() + 'px',
                top: $tooltip.position().top + 'px',
                left: $tooltip.position().left + 'px'
            };
            $tooltip.before($("<iframe style='border: 0; position:absolute;' src='javascript:false;' />").css(iframeStyles));
        }
    },
    hideTooltip: function ($icon) {
        var $tooltip = $("body").children(".dialogBg:last");
        if ($tooltip.length > 0) {
            if (ftc_obb.getIEVersionNumber() == 6) {
                $tooltip.prev("iframe").remove();
            }
            $icon.before($tooltip);
        }
        $tooltip = $icon.prev();
        if (ftc_obb.getIEVersionNumber() == 6) {
            $tooltip.prev("iframe").remove();
        }
        $tooltip.hide();
    },
    init: function () {
        var dateStart = new Date();
        $(".confirmDelete").click(function () {
            return confirm("Are you sure you want to delete this item?");
        });
        $("table tr:even").addClass("alt");
        $(".menu a[href]").not("[href]").addClass("disabled");
        $("a.calculator").click(function () {
            ft_calc.showDialog(true);
            return false;
        });

        $("a.Cmuercehot").mouseenter(function () {
            $(this).unbind('mouseenter').each(ftc_obb.kufmjfkyoearusftaqcmo);
        });

        if ($("#imageLiveChat").height() != 20) {
            $("#imageLiveChat").load(function () {
                var vHeight = $(this).height();
                if (vHeight != 20)//the chat is online
                {
                    $("#headerLinkChat").addClass("chatOn");
                }
            });
        }

        $("a.liveChatLink").click(function () {
            window.open('http://livechat.boldchat.com/aid/' + boldChatFTC.accountId + '/bc.chat?cwdid=' + boldChatFTC.chatWindowId + '&wdid=' + boldChatFTC.websiteId + '&url=' + escape(document.location.href), 'Chat' + boldChatFTC.chatWindowName, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');
            return false;
        });

        ftc_obb.showPopupMessage();

        ftc_feedback.init();

        $(".captionInside").each(function () {
            var $element = $(this);
            $element.data("fieldText", $element.val())
            .addClass('gray')
            .focus(function () {
                var $element = $(this);
                if ($element.val() == $element.data("fieldText")) {
                    $element.val("").removeClass('gray');
                }
            }).blur(function () {
                var $element = $(this);
                if ($.trim($element.val()) == "") {
                    $element.val($element.data("fieldText")).addClass('gray');
                }
            });
        });

        $("a#editContentShorcut").hover(function () {
            $(this).stop().css({ opacity: 0.3 }).animate({ "right": "0", "opacity": "1" }, 200);
        }, function () {
            var rightAnimation = "-13px";
            if (ftc_obb.getIEVersionNumber() > 4 && ftc_obb.getIEVersionNumber() < 7) {
                rightAnimation = "0";
            }
            $(this).stop().animate({ "right": rightAnimation, "opacity": "0.3" }, 200);
        });

        $(".ftcTooltipBg + *").hover(function () { ftc_obb.showTooltip($(this)); }, function () { ftc_obb.hideTooltip($(this)); });

        ftc_obb.$headerPromotionExpireArea = $("#headerPromotionExpireArea");
        try {
            var headerBannerSrc = ftc_obb.$headerPromotionExpireArea.parent().find("img").attr("alt");
            var expireRegExp = /\(exp ([^)]*)\)/;
            var parseResult = expireRegExp.exec(headerBannerSrc);
            if (parseResult !== null && parseResult.length == 2) {
                var expirationDate = parseResult[1].split('-');
                if (expirationDate.length == 3) {
                    ftc_obb.$headerPromotionExpireArea.fadeIn('normal', ftc_obb.fixIEFadeIn);
                    ftc_obb.discountCountdownExpirationDate = new Date(expirationDate[2], expirationDate[0] - 1, expirationDate[1]);
                    ftc_obb.updateDiscountCountdown();
                }
            }
        }
        catch (ex) {
        }

        var executionTime = new Date() - dateStart;
    }
};

var ftc_slider = {
    $outer: null,
    $image: null,
    $link: null,
    $slider: null,
    $image1: null,
    $image2: null,
    $link1: null,
    $link2: null,
    imageHeight: 350,
    slideChangeInterval: 10000,
    slideChangeSpeed: 2000,
    currentSlideIndex: 0,
    slideChangeTimerID: null,
    imageLoaded: function() {
        ftc_slider.$slider.hide();
        ftc_slider.$link.show();
        ftc_slider.prepareNextSlide();
    },
    image2Loaded: function() {
        ftc_slider.slideChangeTimerID = setTimeout('ftc_slider.changeSlide();', ftc_slider.slideChangeInterval);
    },
    changeSlide: function() {
        ftc_slider.slideChangeTimerID = null;
        ftc_slider.$slider.css("top", "0").show().animate({ top: -ftc_slider.imageHeight + "px" }, ftc_slider.slideChangeSpeed, null,
                    function() {
                        ftc_slider.$link.hide().attr('href', ftcSliderImageLinks[ftc_slider.currentSlideIndex]);
                        ftc_slider.$image.attr('src', ftcSliderImages[ftc_slider.currentSlideIndex]);
                    });
    },
    prepareNextSlide: function() {
        if (ftc_slider.slideChangeTimerID !== null) {
            //slide change timer already started
            return;
        }

        if (ftcSliderImages.length == 1) {
            //there is only one slide - no need to change it
            return;
        }

        ftc_slider.$image1.attr('src', ftcSliderImages[ftc_slider.currentSlideIndex]);
        ftc_slider.$link1.attr('href', ftcSliderImageLinks[ftc_slider.currentSlideIndex]);
        ftc_slider.currentSlideIndex++;
        if (ftc_slider.currentSlideIndex > ftcSliderImages.length - 1) {
            ftc_slider.currentSlideIndex = 0;
        }
        ftc_slider.$image2.attr('src', ftcSliderImages[ftc_slider.currentSlideIndex]);
        ftc_slider.$link2.attr('href', ftcSliderImageLinks[ftc_slider.currentSlideIndex]);
    },
    init: function() {
        ftc_slider.$outer = $("#sliderOuter");
        if (ftc_slider.$outer.length === 0) {
            return; //there is no slider on this page
        }
        ftc_slider.$image = ftc_slider.$outer.find("#sliderImage");
        ftc_slider.$slider = ftc_slider.$outer.find("#slider");

        ftc_slider.$link = ftc_slider.$outer.find("#sliderLink");
        ftc_slider.$link1 = ftc_slider.$slider.find("#sliderLink1");
        ftc_slider.$link2 = ftc_slider.$slider.find("#sliderLink2");

        ftc_slider.$image1 = ftc_slider.$slider.find("#sliderImage1");
        ftc_slider.$link2.append($("<img id='sliderImage2' class='sliderImage' alt='Film Transfer Slider Image 2' />"));
        ftc_slider.$image2 = ftc_slider.$slider.find("#sliderImage2");


        if (typeof (ftcSliderImages) == "undefined" || ftcSliderImages === undefined || ftcSliderImages === null || ftcSliderImages.length < 1) {
            return;
        }
        if (typeof (ftcSliderImageLinks) == "undefined" || ftcSliderImageLinks === undefined || ftcSliderImageLinks === null || ftcSliderImageLinks.length != ftcSliderImages.length) {
            return;
        }

        if (ftc_obb.getIEVersionNumber() > 4 && ftc_obb.getIEVersionNumber() < 7) {
            //fix the cursor and background flickering in IE6
            try {
                document.execCommand('BackgroundImageCache', false, true);
            }
            catch (ex) {
            }
        }
        ftc_slider.$image2.load(ftc_slider.image2Loaded);
        if (typeof (vFirstSliderImageLoaded) != "undefined" && vFirstSliderImageLoaded) {
            ftc_slider.imageLoaded();
        }
        ftc_slider.$image.load(ftc_slider.imageLoaded);
    }
};
var ft_calc = {
    $calculator: null,
    $calculatorResults: null,
    totalFootage: 0,
    isFootage8mm: true,
    selectedFilms: {}, //object contains the film types chosen by customer  
    filmTypes:
    [
        {
            id: 'calc8mm',
            type: '8mm / Super 8mm',
            footage:
            [
               '3"/50ft',
               '4"/100ft',
               '5"/200ft',
               '6"/300ft',
               '7"/400ft'
            ],
            feetToHours: 800,
            totalFeet: 0
        },
        {
            id: 'calc16mm',
            type: '16mm',
            footage:
            [
               '3"/50ft',
               '4"/100ft',
               '5"/200ft',
               '6"/300ft',
               '7"/400ft',
               '9"/600ft',
               '10"/800ft',
               '12"/1200ft',
               '16"/1600ft'
            ],
            feetToHours: 1500,
            totalFeet: 0
        }
    ],
    getDataForFilmID: function (filmID) {
        for (var key in ft_calc.filmTypes) {
            if (ft_calc.filmTypes[key].id == filmID) {
                return ft_calc.filmTypes[key];
            }
        }
        return null;
    },
    addClear: function ($ctrl) {
        $ctrl.append($("<div class='clear'></div>"));
    },
    getFilmIdFromControl: function ($ctrl, suffix) {
        return $ctrl.attr('id').replace(suffix, '');
    },
    showErrorMessage: function (msg) {
        ft_calc.hideResults();
        ft_calc.$calculator.children("#calcWarningMessage").html(msg).show();
    },
    hideErrorMessage: function () {
        ft_calc.$calculator.children("#calcWarningMessage").hide();
    },
    showResults: function () {
        ft_calc.$calculatorResults.show();
    },
    hideResults: function () {
        ft_calc.$calculatorResults.hide();
    },
    calculate: function () {
        ft_calc.isValid = true;
        for (var iIndex0 in ft_calc.filmTypes) {
            if (ft_calc.filmTypes.hasOwnProperty(iIndex0)) {
                ft_calc.filmTypes[iIndex0].totalFeet = 0;
            }
        }
        var $reelSizes = ft_calc.$calculator.children("#reelSizes");
        var $inputArea = ft_calc.$calculator.children("#calcInputArea");
        var filmHours = 0; //total film hours
        ft_calc.totalFootage = 0;
        ft_calc.selectedFilms = {};

        for (var iIndex in ft_calc.filmTypes) {
            if (ft_calc.filmTypes.hasOwnProperty(iIndex)) {
                var filmData = ft_calc.filmTypes[iIndex];
                if (!$inputArea.find("#" + filmData.id + "_select_type")[0].checked) {
                    continue;
                }
                var $filmTypesArea = $reelSizes.find("#" + filmData.id + "_film_types'");
                var $checkboxes = $filmTypesArea.find("input[type='checkbox']:checked");
                for (var iCheckbox = 0; iCheckbox < $checkboxes.length; iCheckbox++) {
                    var checkbox = $checkboxes[iCheckbox];
                    var $textBox = $(checkbox).parent().find("input[type='text']");
                    var fieldName = 'footage';
                    var maxValue = 999999;
                    if (checkbox.value != 'custom') {
                        fieldName = 'films quantity';
                        maxValue = 999;
                    }
                    var footageParsed = ftc_obb.parseTextBoxInt($textBox, fieldName, 0, maxValue, ft_calc.showErrorMessage);

                    if (!footageParsed.valid) {
                        ft_calc.totalFootage = 0;
                        return;
                    }
                    if (checkbox.value != 'custom') {
                        filmData.totalFeet += footageParsed.value * parseInt(checkbox.value, 10);
                    } else {
                        filmData.totalFeet += footageParsed.value;
                    }

                    if (ft_calc.calculateForOrder()) {
                        var selectedFilm = {};
                        if (!(filmData.type in ft_calc.selectedFilms)) {
                            ft_calc.selectedFilms[filmData.type] = selectedFilm;
                        } else {
                            selectedFilm = ft_calc.selectedFilms[filmData.type];
                        }
                        if (checkbox.value == 'custom') {
                            selectedFilm.custom = {
                                "qty": footageParsed.value,
                                "name": "Custom"
                            };
                        } else {
                            selectedFilm[parseInt(checkbox.value, 10)] = {
                                "qty": footageParsed.value,
                                "name": checkbox.nextSibling.nodeValue
                            };
                        }
                    }
                }
                filmHours += filmData.totalFeet / filmData.feetToHours;
                ft_calc.totalFootage += filmData.totalFeet;
                if (filmData.totalFeet > 0) {
                    ft_calc.isFootage8mm = filmData.id == 'calc8mm';
                }
            }
        }
        $reelSizes.find('.input-validation-error').removeClass('input-validation-error');
        ft_calc.hideErrorMessage();

        if (filmHours === 0) {
            ft_calc.hideResults();
            return;
        }
        //show results
        var timeText = '';
        if (Math.floor(filmHours) > 0) {
            timeText += Math.floor(filmHours) + " hour";
            if (Math.floor(filmHours) > 1) {
                timeText += "s";
            }
        }
        var minutes = Math.round((filmHours - Math.floor(filmHours)) * 60);
        if (minutes > 0) {
            timeText += " " + minutes + " minute";
            if (minutes > 1) {
                timeText += "s";
            }
        } else {
            if (Math.floor(filmHours) === 0) {
                timeText += "Less than a minute";
            }
        }

        ft_calc.$calculatorResults.find("#calculatorTotalFootage").html(ft_calc.totalFootage);
        ft_calc.$calculatorResults.find("#calculatorTotalTime").html(timeText);
        ft_calc.$calculatorResults.find("#calculatorData").html(parseFloat((filmHours * 62).toFixed(1)));
        ft_calc.showResults();
    },
    addFilmControls: function () {
        var $inputArea = ft_calc.$calculator.children("#calcInputArea");
        var $reelSizes = ft_calc.$calculator.children("#reelSizes");
        for (var iIndex in ft_calc.filmTypes) {
            if (ft_calc.filmTypes.hasOwnProperty(iIndex)) {
                var filmData = ft_calc.filmTypes[iIndex];
                var $filmColumn = $("<div class='calculatorFilmColumn' id='" + filmData.id + "_column'></div>");
                $inputArea.append($filmColumn);
                var $reelSizeColumn = $("<div class='calculatorFilmColumn' id='" + filmData.id + "_reel_size_column'></div>");
                $reelSizes.append($reelSizeColumn);
                var $select_type = $("<input type='checkbox' id='" + filmData.id + "_select_type' />");
                $filmColumn.append($("<div>" + filmData.type + "</div>").prepend($select_type));
                $select_type.click(function () {
                    var filmID = ft_calc.getFilmIdFromControl($(this), '_select_type');
                    var $reelSizeColumn = $reelSizes.find("#" + filmID + "_reel_size_column");
                    var $filmTypes = $reelSizeColumn.find("#" + filmID + "_film_types");
                    if (this.checked) {
                        if ($filmTypes.length === 0) {
                            //show film types
                            $filmTypes = $("<div id='" + filmID + "_film_types' style='display:none'></div>");
                            $reelSizeColumn.append($filmTypes);
                            var filmData = ft_calc.getDataForFilmID(filmID);
                            //add all footage types
                            for (var footageID in filmData.footage) {
                                if (filmData.footage.hasOwnProperty(footageID)) {
                                    var footageText = filmData.footage[footageID];
                                    var footageNumber = parseInt(/[0-9]+ft/.exec(footageText)[0].replace("ft", ""), 10);
                                    var $footageCheckbox = $("<input type='checkbox' value='" + footageNumber + "' />");
                                    var $qtyTextbox = $("<input type='text' value='1'/>");
                                    $qtyTextbox.keyup(ft_calc.calculate);
                                    $filmTypes.append($("<div class='calcReelSizeRow'>" + footageText + "</div>").prepend($footageCheckbox).append($("<span class='calcFootageQty' style='visibility:hidden'>Qty:</span>").append($qtyTextbox)));
                                    $footageCheckbox.click(function () {
                                        //show/hide the quantity field
                                        var $qtyTextbox = $(this).parent().children('.calcFootageQty');
                                        if (this.checked) {
                                            $qtyTextbox.css("visibility", "visible");
                                        } else {
                                            $qtyTextbox.css("visibility", "hidden");
                                        }
                                        ft_calc.calculate();
                                    });
                                }
                            }
                            //add custom footage checkbox
                            var $customFootageCheckbox = $("<input type='checkbox' value='custom' />");
                            var $customFootageTextbox = $("<input type='text' value='5000'/>");
                            $customFootageTextbox.keyup(ft_calc.calculate);
                            $filmTypes.append($("<div>Custom</div>").prepend($customFootageCheckbox).append($("<span class='calcFootageCustom' style='visibility:hidden'>ft</span>").prepend($customFootageTextbox)));
                            $customFootageCheckbox.click(function () {
                                //show/hide the quantity field
                                var $customFootageTextbox = $(this).parent().children('.calcFootageCustom');
                                if (this.checked) {
                                    $customFootageTextbox.css("visibility", "visible");
                                } else {
                                    $customFootageTextbox.css("visibility", "hidden");
                                }
                                ft_calc.calculate();
                            });
                        }

                        ft_calc.$calculator.children("#calcInstructionsReelSizes:hidden").show();

                        //hide the controls from the other film type
                        var filmTypeToHide = "calc8mm";
                        if (filmID == "calc8mm") {
                            filmTypeToHide = "calc16mm";
                        }
                        var $filmTypesToHide = $reelSizes.find("#" + filmTypeToHide + "_film_types");
                        ft_calc.$calculator.find("#" + filmTypeToHide + "_select_type").removeAttr("checked");
                        $filmTypesToHide.hide('fast');

                        $filmTypes.show('fast');
                        ft_calc.calculate();
                    } else {
                        //hide film types
                        $filmTypes.hide('fast');
                        ft_calc.calculate();
                    }
                });
            }
        }
    },
    showDialog: function (show) {
        if (show === undefined) {
            show = true;
        }
        if (ft_calc.$calculator === null) {
            ft_calc.init();
        }
        if (show) {
            if (ft_calc.$calculator.is(":visible")) {
                return;
            }
            var calcWidth = ft_calc.$calculator.width();
            var calcHeight = ft_calc.$calculator.height();

            var calcTop = $(window).scrollTop() + 23;
            var calcLeft = Math.floor(($(window).width() - calcWidth) / 2 + $(window).scrollLeft());

            ftc_obb.showOverlay();
            ft_calc.$calculator.css({ left: calcLeft, top: $(window).scrollTop() - calcHeight });
            ft_calc.$calculator.show().animate({ top: calcTop }, 500);
        } else {
            var calcHeight1 = ft_calc.$calculator.height();
            ft_calc.$calculator.animate({ top: $(window).scrollTop() - calcHeight1 }, 500, null, function () { $(this).hide(); });
            ftc_obb.showOverlay(false);
        }
    },
    //returns true if the calculator was opened on the order page
    calculateForOrder: function () {
        return (typeof (ftc_order) !== 'undefined' && ftc_order.$totalFootage !== null);
    },
    closeCalculator: function () {
        if (ft_calc.calculateForOrder() && ft_calc.totalFootage > 0) {
            //calculator was opened from Order page - paste the film footage to order
            ftc_order.$totalFootage.val(ft_calc.totalFootage);
            var typeValue = '16mm';
            if (ft_calc.isFootage8mm) {
                typeValue = '8mm';
            }
            ftc_order.$orderOptions.find("#filmTypeArea input[type='radio'][value='" + typeValue + "']").attr("checked", "checked");
            ftc_order.selectedFilms = ft_calc.selectedFilms;
            ftc_order.calculateOrderPrice(false, true);
        }
        ft_calc.showDialog(false);
    },
    init: function () {
        ft_calc.$calculator = $("#calculator");
        ft_calc.$calculatorResults = ft_calc.$calculator.children("#calculatorResults");
        ft_calc.$calculator.find("#calculatorButtonClose").click(ft_calc.closeCalculator);
        ft_calc.addFilmControls();
    }
};

/* The slider on the side bar showing customer feedback */
var ftc_feedback = {
    $widget: null,
    $window: null,
    $slider: null,
    $slides: null,
    currentSlideNo: 1,
    numberOfSlides: 1,
    animationSpeed: 250,
    sliderWidth: 180,
    changeSlide: function() {
        if (ftc_feedback.currentSlideNo < 0 || ftc_feedback.currentSlideNo > ftc_feedback.numberOfSlides) {
            ftc_feedback.currentSlideNo = 0;
        }
        $slideToShow = $(ftc_feedback.$slides[ftc_feedback.currentSlideNo - 1]);
        ftc_feedback.$window.height($slideToShow.outerHeight());
        ftc_feedback.$slider.animate({ "left": -$slideToShow.position().left }, ftc_feedback.animationSpeed);
    },
    init: function() {
        ftc_feedback.$widget = $("#customerFeedback");
        ftc_feedback.$window = ftc_feedback.$widget.find(".window");
        ftc_feedback.$slider = ftc_feedback.$window.children(".slider");
        ftc_feedback.$slides = ftc_feedback.$slider.children(".slide");
        ftc_feedback.$slides.sort(function() { return 0.5 - Math.random(); });
        ftc_feedback.$slider.children().remove();
        ftc_feedback.$slides.appendTo(ftc_feedback.$slider);

        ftc_feedback.numberOfSlides = ftc_feedback.$slides.length;
        if (ftc_feedback.numberOfSlides < 1) {
            return;
        }

        ftc_feedback.$slider.css({ "width": (ftc_feedback.numberOfSlides * ftc_feedback.sliderWidth) + "px" });

        var firstSlideHeight = $(ftc_feedback.$slides[0]).outerHeight();
        ftc_feedback.$window.css({ "height": firstSlideHeight + "px" });

        ftc_feedback.$widget.children(".switch").click(function() {
            if (this.id == 'feedbackLeft') {
                ftc_feedback.currentSlideNo -= 1;
            } else {
                ftc_feedback.currentSlideNo += 1;
            }
            if (ftc_feedback.currentSlideNo < 1) {
                ftc_feedback.currentSlideNo = ftc_feedback.numberOfSlides;
            }
            if (ftc_feedback.currentSlideNo > ftc_feedback.numberOfSlides) {
                ftc_feedback.currentSlideNo = 1;
            }
            ftc_feedback.changeSlide();
            return false;
        });
    }
};

var ftc_contact = {
    $msgForm: null,
    init: function() {
        ftc_contact.$msgForm = $("#sendMessageForm");
        if (ftc_contact.$msgForm.length === 0) {
            //there is no message form on this page
            return;
        }        

        ftc_contact.$msgForm.find("#sendMessageBtn").click(function() {
            ftc_contact.$msgForm.submit();
            return false;
        });
        ftc_obb.submitForm("#sendMessageForm", function($form, jsonResult) {
            ftc_contact.$msgForm.hide('fast');
            $("#messageSentSuccess").show('fast', ftc_obb.fixIEFadeIn);
        });
    }
};

ftc_orderDetails = {
    statusMaterialsShippedToClient: null,
    statusOrderCancelled: null,
    statusPartiallyRefunded: null,
    selectedFilms: undefined,
    init: function() {
        $("#UPSTrackingIDArea").toggle($("#newOrderStatus :selected").val() == ftc_orderDetails.statusMaterialsShippedToClient);
        $("#newOrderStatus").change(function() {
            if ($(this).children(":selected").val() == ftc_orderDetails.statusMaterialsShippedToClient) {
                $("#UPSTrackingIDArea").slideDown('fast');
            } else {
                $("#UPSTrackingIDArea").slideUp('fast');
            }
        });
        $("#PartialRefundArea").toggle($("#newOrderStatus :selected").val() == ftc_orderDetails.statusPartiallyRefunded);
        $("#newOrderStatus").change(function() {
            if ($(this).children(":selected").val() == ftc_orderDetails.statusPartiallyRefunded) {
                $("#PartialRefundArea").slideDown('fast');
            } else {
                $("#PartialRefundArea").slideUp('fast');
            }
        });
        $("#viewUPSShippingStatus").click(function() {
            $("#getUPSStatusForm").fadeIn(ftc_obb.fixIEFadeIn);
            $("#getUPSStatusForm").submit();
            return false;
        });
        $("#changeStatus").click(function() {
            ftc_obb.showDialog("changeStatusDlg", "Change Order Status");
            return false;
        });
        ftc_obb.submitForm("#changeStatusForm,#getUPSStatusForm,#changeOrderNotesForm", function($form, jsonResult) {
            switch ($form.attr('id')) {
                case 'changeStatusForm':
                    location.reload(true);
                    break;
                case 'getUPSStatusForm':
                    if ("ShippingStatusHTML" in jsonResult.Data) {
                        $("#getUPSStatusForm").slideUp('fast');
                        $("#viewUPSShippingStatus").fadeOut('fast');
                        $("#UPSShippingStatusHTML").html(jsonResult.Data.ShippingStatusHTML);
                        $("#UPSShippingStatusArea").slideDown('fast');
                    }
                    break;
                case 'changeOrderNotesForm':
                    location.reload(true);
                    break;
            }
        }, function($form) {
            if ($form.find("#newOrderStatus option:selected").val() == ftc_orderDetails.statusOrderCancelled) {
                return confirm("Are you sure you want cancel the order and make a refund?");
            }
            return true;
        });

        $("#linkAddOrderNotes, #linkChangeOrderNotes").click(function() {
            ftc_obb.showDialog("changeOrderNotesDlg", "Change Order Notes");
            return false;
        });
        if (typeof (ftc_orderDetails.selectedFilms) != 'undefined') {
            var $selectedFilmsArea = $("#selectedFilmsArea");
            var selectedReelsTable = "";
            for (var filmType in ftc_orderDetails.selectedFilms) {
                if (ftc_orderDetails.selectedFilms.hasOwnProperty(filmType)) {                                    
                    selectedReelsTable += "<div><table class='centered verticalMiddle'>";
                    selectedReelsTable += "<tr><th colspan='2'>" + filmType + "</th></tr>";
                    var selectedFilmsType = ftc_orderDetails.selectedFilms[filmType];
                    for (var reelType in selectedFilmsType) {
                        if (selectedFilmsType.hasOwnProperty(reelType)) {                                                    
                            var selectedReelType = selectedFilmsType[reelType];
                            var selectedReelsQty = selectedReelType.qty + " reel";
                            if (selectedReelType.qty > 1) {
                                selectedReelsQty += "s";
                            }
                            if (reelType == "custom") {
                                selectedReelsQty = selectedReelType.qty + " ft";
                            }
                            selectedReelsTable += "<tr><th>" + selectedReelType.name + "</th><td>" + selectedReelsQty + "</td></tr>";
                        }
                    }

                    selectedReelsTable += "</table></div>";
                }
            }

            $selectedFilmsArea.children("#selectedFilmsData").html(selectedReelsTable);
            $selectedFilmsArea.slideDown('fast');
        }
    }
};
boldChatFTC = {
    accountId: "4776194380006802248",
    websiteId: "2042801725507865689",
    chatWindowId: "430702061631974289",
    invitationId: "2373960614748422481",
    chatButtonId: "2046844969958208691",//id of the custom button that contains two images. This button is needed to determine if the chat operator is online. (to turn off/on the 'LIVE chat' link on the web site header)
    chatWindowName: "6623430682862183552"
};

ftc_obb.ftcProtocol=(("https:" == document.location.protocol) ? "https://" : "http://");  

ftc_obb.preloadImages("calc_bg.png", "bullet2.gif", "bullet-selected2.gif", "loading.gif", "dialog-bg.png", "dialog-bg-arrow-left.png", "dialog-bg-arrow-right.png");

if (ftc_obb.getIEVersionNumber() > 4 && ftc_obb.getIEVersionNumber() < 7) {
    ftc_obb.preloadImages("dialog-bg.gif", "dialog-bg-arrow-left.gif", "dialog-bg-arrow-right.gif");
}

$(function() {
    ftc_obb.init();
    ftc_slider.init();
    ftc_contact.init();
});