/* JS DEFAULTS (override on a per-site basis) */

var Site = {
	fontSizes : { one:'75%', two:'85%', three:'95%', four:'105%' }
}

/* */

/* ONLOAD ACTIONS */
$(document).ready(function(){
		
	$(".placeholder").placehold();

	var findToggleContent = function(obj){
		return $(obj).siblings(".togglecontent").add($(obj).parent().siblings(".togglecontent"));
	}
	
	/* set up the toggle action on expandable lists */
	$(".expandable span.toggle").wrap("<a href='#' class='toggle'></a>");
	
	/* actions */
	$("a.toggle").toggle(function(){
		findToggleContent(this).slideDown();
		$(this).addClass("expanded");
	},function(){
		var THIS = this;
		findToggleContent(THIS).slideUp(function(){
			$(THIS).removeClass("expanded");
			$(THIS).blur();
		});
	})
	
	$("#sizeswitcher a").click(function(){
		var size = Site.fontSizes[$(this).attr("class")];
		$("body").css({"font-size":size});
		Site.cookie("fontSize",size);
		return false;
	})
	
	$("#bookmarking a").click(function(){
		window.open(($(this).attr("href")+'?url='+window.location.href),'bookmarking','toolbar=no,width=700,height=400');
		return false;
	})
	
	$(".jumper").change(function(){
		if (($(this).val() != null) && ($(this).val() != ""))
			window.location.href = $(this).val()
	})
	
   //- jQuery UI instantiations -------------------------------------------------------------- -->
   
   $(".xdate").datepicker({showButtonPanel: true,numberOfMonths: 1,dateFormat:"yy-mm-dd"});
})

/* COOKIE HANDLING */
Site.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;
    }
};
/* */

if(fontSize = Site.cookie("fontSize")){
	document.write('<style type="text/css">body{font-size:'+fontSize+'}</'+'style>');
}

document.write('<style type="text/css">.expandable .togglecontent{display:none}</'+'style>');