﻿/*
* Fix height for equal height columns http://www.webdevelopers.eu/jquery/fixheight/demo
*/
(function($) { $.fn.fixHeight = function() { var row = 0; function fhResize(siblings, maxSize) { if (!siblings.length) return siblings; row++; var col = 1; return siblings.height(maxSize).attr('class', function(idx, old) { return old.replace(/(^| )fh(Col|Row)[0-9]+( |$)/, ' '); }).addClass(function() { return 'fhRow' + row + ' fhCol' + col++; }); } this.each(function() { var offset = 0, maxSize = 0, siblings = $(), row = 0; $(this).children().height('auto').each(function() { var $this = $(this); if (offset != $this.position().top) { fhResize(siblings, maxSize); maxSize = $this.height(); offset = $this.position().top; siblings = $(); } else { if (maxSize < $this.height()) maxSize = $this.height(); } siblings = siblings.add($this); }); fhResize(siblings, maxSize); }); return this; } })(jQuery);
/*
* jQuery Textarea Characters Counter Plugin
* Examples and documentation at: http://roy-jin.appspot.com/jsp/textareaCounter.jsp
* Copyright (c) 2010 Roy Jin
* Version: 1.0.0 (11-JUN-2010)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*Contact: http://royjin.wufoo.com/forms/z7x4a9/
* Requires: jQuery v1.4.2 or later
*/
(function ($) {
    $.fn.textareaCount = function (options) {
        var defaults = { maxCharacterSize: -1, textFontSize: '10px', textColor: '#000000', textFamily: 'Tahoma,sans-serif', textAlign: 'right', warningColor: '#FF0000', warningNumber: 20, isCharacterCount: true, isWordCount: false }; var options = $.extend(defaults, options); var container = $(this); if (options.maxCharacterSize < 0) { return; }
        $("<div class='charleft'> </div>").insertAfter(container); var charLeftCss = { 'font-size': options.textFontSize, 'font-family': options.textFamily, 'color': options.textColor, 'text-align': options.textAlign, 'width': container.width() }; var charLeftInfo = getNextCharLeftInformation(container); charLeftInfo.css(charLeftCss); container.bind('paste', function (event) { setTimeout(function () { limitTextAreaByCharacterCount(); }, 10); }); container.bind('keyup', function (event) { limitTextAreaByCharacterCount(); }); function getNextCharLeftInformation(container) { return container.next('.charleft'); }
        function limitTextAreaByCharacterCount() {
            var content = container.val(); var contentLength = content.length; var resultString = ''; if (options.isCharacterCount) {
                if (contentLength >= options.maxCharacterSize) { content = content.substring(0, options.maxCharacterSize); }
                var count = 0; for (var i = 0; i < contentLength; i++) { if (content.charAt(i) == '\n') { count++; } }
                var systemmaxCharacterSize = 0; var strOS = navigator.appVersion; if (strOS.toLowerCase().indexOf('win') != -1) { systemmaxCharacterSize = options.maxCharacterSize - count; } else { systemmaxCharacterSize = options.maxCharacterSize }
                if (contentLength > systemmaxCharacterSize) { var originalScrollTopPosition = this.scrollTop; container.val(content.substring(0, systemmaxCharacterSize)); this.scrollTop = originalScrollTopPosition; }
                if (systemmaxCharacterSize - contentLength <= options.warningNumber) { charLeftInfo.css({ "color": options.warningColor }); } else { charLeftInfo.css({ "color": options.textColor }); }
                resultString = 'Characters: '
                if (strOS.toLowerCase().indexOf('win') != -1) { resultString += (container.val().length + count) + "/" + options.maxCharacterSize } else { resultString += container.val().length + "/" + options.maxCharacterSize } 
            }
            if (options.isWordCount) { var word_count = countWord(getCleanedWordString(container.val())); resultString += ' Words: ' + word_count; }
            charLeftInfo.html(resultString);
        }
        function getCleanedWordString(content) { var fullStr = content + " "; var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi; var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, ""); var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi; var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " "); var splitString = cleanedStr.split(" "); return splitString; }
        function countWord(cleanedWordString) { var word_count = cleanedWordString.length - 1; return word_count; } 
    };
})(jQuery);
//Shuffle Arrays
(function ($) { $.shuffle = function (arr) { for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); return arr; } })(jQuery);
//TextShadows
(function ($) {
    $.fn.textShadow = function (option) {
        if (!$.browser.msie) return; var IE6 = $.browser.version < 7; return this.each(function () {
            var el = $(this); var shadow = el.textShadowParse(this.currentStyle["text-shadow"]); shadow = $.extend(shadow, option); el.textShadowRemove(); if (shadow.x == 0 && shadow.y == 0 && shadow.radius == 0) return; if (el.css("position") == "static") { el.css({ position: "relative" }); }
            el.css({ zIndex: "0" }); if (IE6) { el.css({ zoom: "1" }); }
            var span = document.createElement("span"); $(span).addClass("jQueryTextShadow"); $(span).html(el.html()); $(span).css({ padding: this.currentStyle["padding"], width: el.width(), position: "absolute", zIndex: "-1", color: shadow.color != null ? shadow.color : el.css("color"), left: (-parseInt(shadow.radius) + parseInt(shadow.x)) + "px", top: (-parseInt(shadow.radius) + parseInt(shadow.y)) + "px" }); if (shadow.radius != 0) { if (shadow.opacity != null) { $(span).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelradius=" + parseInt(shadow.radius) + ", enabled='true', makeShadow='true', ShadowOpacity=" + shadow.opacity + ")"); } else { $(span).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelradius=" + parseInt(shadow.radius) + ", enabled='true')"); } }
            el.append(span);
        });
    }; $.fn.textShadowParse = function (value) {
        value = String(value).replace(/^\s+|\s+$/gi, '').replace(/\s*!\s*important/i, '').replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3/$4)').replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3)')
        var shadow = { x: 0, y: 0, radius: 0, color: null }; if (value.length > 1 || value[0].toLowerCase() != 'none') {
            value = value.replace(/\//g, ','); var color; if (value.match(/(\#[0-9a-f]{6}|\#[0-9a-f]{3}|(rgb|hsb)a?\([^\)]*\)|\b[a-z]+\b)/i) && (color = RegExp.$1)) { shadow.color = color.replace(/^\s+/, ''); value = value.replace(shadow.color, ''); }
            value = value.replace(/^\s+|\s+$/g, '').split(/\s+/).map(function (item) { return (item || '').replace(/^0[a-z]*$/, '') ? item : 0; }); switch (value.length)
            { case 1: shadow.x = shadow.y = value[0]; break; case 2: shadow.x = value[0]; shadow.y = value[1]; break; case 3: shadow.x = value[0]; shadow.y = value[1]; shadow.radius = value[2]; break; }
            if ((!shadow.x && !shadow.y && !shadow.radius) || shadow.color == 'transparent') { shadow.x = shadow.y = shadow.radius = 0; shadow.color = null; } 
        }
        return shadow;
    }; $.fn.textShadowRemove = function () { if (!$.browser.msie) return; return this.each(function () { $(this).children("span.jQueryTextShadow").remove(); }); };
})(jQuery); if (typeof Array.prototype.map == 'undefined') {
    Array.prototype.map = function (fnc) {
        var a = new Array(this.length); for (var i = 0; i < this.length; i++) { a[i] = fnc(this[i]); }
        return a;
    } 
}
