﻿"use strict";

var branding = {

    init: function () {
        base.subscribe('resize', branding.resize);
        $('.branding .contact-btn').bind(base.clickevent, base.contact);
        $('.branding .contact').each(function (i, o) {
            $('.contactform .inner').clone().appendTo($(o).html(''));
            $('.cancel', o).hide();
            $('.branding .contact-btn').hide();
        });
    },

    resize: function () {
        var p = $('.branding .photo');
		var t = $('.branding .stack .text').css({ width: '' });
		var l = $('.branding .stack .logo-container').css({ width: '' });
        if ((p.length > 0) && (t.length > 0)) {
			if (t.length > 1) {
				t.width(Math.max((Math.max($(t[0]).width(), $(t[1]).width()) - 40), 80));
            }
            if ($(p).offset().top < $(t).offset().top) {
                $(t).css({ textAlign: 'center' });
            }
            else {
                $(t).css({ textAlign: 'left' });
            }
		}
		if (l.length > 0) {
			if (l.length > 1) {
				l.width(Math.max($(l[0]).width(), $(l[1]).width()));
			}
		}
    }
};

$(branding.init);
 