$(function() {

	resizeColumns();

});
function resizeColumns() {
    var h=$('#body-left').height()+90;
    if ($('#body-center').height()>h)
        h= $('#body-center').height();
    if ($('#body-right-blank').height()>h)
        h= $('#body-right-blank').height();
    
    if($('#body-left').height()<h)
        $('#body-left').height(h);
}
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


/* -------------------------------------------------- *
 * ToggleVal 2.1
 * Updated: 1/16/09
 * -------------------------------------------------- *
 * Author: Aaron Kuzemchak
 * URL: http://aaronkuzemchak.com/
 * Copyright: 2008-2009 Aaron Kuzemchak
 * License: MIT License
** -------------------------------------------------- */

(function($) {
	$.fn.toggleVal = function(theOptions) {
		// check whether we want real options, or to destroy functionality
		if(!theOptions || typeof(theOptions) == "object") {
			theOptions = $.extend({
				focusClass: "tv-focused", // class during focus
				changedClass: "tv-changed", // class after focus
				populateFrom: "default", // choose from: default, label, custom, or alt
				text: null, // text to use in conjunction with populateFrom: custom
				removeLabels: false // remove labels associated with the fields
			}, theOptions);
		}
		else if(typeof(theOptions) == "string" && theOptions.toLowerCase() == "destroy") {
			var destroy = true;
		}
		
		return this.each(function() {
			// unbind everything if we're destroying, and stop executing the script
			if(destroy) {
				$(this).unbind("focus.toggleval").unbind("blur.toggleval").removeData("defText");
				return false;
			}
			
			// define our variables
			var defText = "";
			
			// let's populate the text, if not default
			switch(theOptions.populateFrom) {
				case "alt":
					defText = $(this).attr("alt");
					$(this).val(defText);
					break;
				case "label":
					defText = $("label[for='" + $(this).attr("id") + "']").text();
					$(this).val(defText);
					break;
				case "custom":
					defText = theOptions.text;
					$(this).val(defText);
					break;
				default:
					defText = $(this).val();
			}
			
			// let's give this field a special class, so we can identify it later
			// also, we'll give it a data attribute, which will help jQuery remember what the default value is
			$(this).addClass("toggleval").data("defText", defText);
			
			// now that fields are populated, let's remove the labels if applicable
			if(theOptions.removeLabels == true) { $("label[for='" + $(this).attr("id") + "']").remove(); }
			
			// on to the good stuff... the focus and blur actions
			$(this).bind("focus.toggleval", function() {
				if($(this).val() == $(this).data("defText")) { $(this).val(""); }
				
				// add the focusClass, remove changedClass
				$(this).addClass(theOptions.focusClass).removeClass(theOptions.changedClass);
			}).bind("blur.toggleval", function() {
				if($(this).val() == "") { $(this).val($(this).data("defText")); }
				
				// remove focusClass, add changedClass if, well, different
				$(this).removeClass(theOptions.focusClass);
				if($(this).val() != $(this).data("defText")) { $(this).addClass(theOptions.changedClass); }
					else { $(this).removeClass(theOptions.changedClass); }
			});
		});
	};
})(jQuery);
