$(document).ready(function(){
	//browser compliant way of rendering a list of links to look inline with pipes
	$("ul.inline_links li:not(:first-child)").prepend("| ");//add pipes to inline lists
	
	//if empty left sidebar, hide the containers so that left sidebar doesn't look ugly
	if (!$("#zz2_QuickLaunchMenu").html()) {
		$("#PlaceHolderLeftNavBar").hide();
		$("#sidebar_extra_div1").hide();		
	}

	//hide WSS Design Console if not in edit mode
	if (!$("#WSSDesignConsole table tr").html()) {
		$("#WSSDesignConsole").hide();
	}
	
	//made arkansas h2 into a link
	$("#arkansasgov_link").click(function(){
		window.location='http://www.arkansas.gov';
	});
	
	//add default value to home google search mini textbox
	$("#google_search_mini_home input.gm_searchbox").val("Search Agency Website").click(function(){ $(this).val(''); });

	//add default value to back google search mini textbox	
	if ($("input.gsTextbox").val())
		$("#google_search_mini_back input.gm_searchbox").val($("input.gsTextbox").val());
	else
		$("#google_search_mini_back input.gm_searchbox").val("Search Agency Website")
		
	$("#google_search_mini_back input.gm_searchbox").click(function(){ $(this).val(''); });
	
	//add WebPartID as a class to all elements with WebpartID attribute so that we can 
	//style webpart instances by their GUID which is now a class in each webpart
	$("[WebPartID]").each(function(){ $(this).addClass($(this).attr('WebPartID')); });

	//Crop the Flickr Gallery thumbs
	$(".fg_containerGallery .fg_linkbutton, .fg_containerAlbum .fg_linkbutton").thumbs();
	
	//Show the Flickr Gallery container when the page is loaded
	$(".fg_containerGallery, .fg_containerAlbum, .fg_containerPhoto").show().css('display','block');
	
	
	$("#increase_font").click(function(){
		$('p,div,span,h1,h2,h3,h4,h5,h6,td,th,a,li,table').each(function(){
		
	    	var matches = $(this).css('font-size').match(/^(\d+)([^\d]+)$/);
		
			var font_size = matches[1];
			var font_unit = matches[2];
			
			font_size++;
			
			$(this).css('font-size', font_size+font_unit);
		});
	});
	
	$("#decrease_font").click(function(){
		$('p,div,span,h1,h2,h3,h4,h5,h6,td,th,a,li,table').each(function(){
		
	    	var matches = $(this).css('font-size').match(/^(\d+)([^\d]+)$/);
		
			var font_size = matches[1];
			var font_unit = matches[2];
			
			font_size--;
			
			$(this).css('font-size', font_size+font_unit);
		});
	});
});


function showTodaysDate(){
	var d=new Date();
	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	document.write(weekday[d.getDay()] + " | ");
	document.write((d.getMonth()+1) + ".");
	document.write(d.getDate() + ".");
	document.write(d.getFullYear());
}

function disable_stylesheets(){
	for(i=0;i<document.styleSheets.length;i++){
		void(document.styleSheets.item(i).disabled=true);
	}
}


/*
 *
 * Copyright (c) 2006 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */

/*
 * Converts image and link elements to thumbnails
 *
 * @name     jThumb
 * @author   Joan Piedra (http://www.joanpiedra.com)
 * @example  $("a.thumb, img.thumb").thumbs();
 *
 */
jQuery.fn.thumbs = function()
{
	return this.wrap('<div class="thumb-img"><div class="thumb-inner">' + '</div><div class="thumb-strip"></div><div class="thumb-zoom"></div></div>');
}

/*
 * Absolute positions the image in the middle of the thumbnail frame
 *
 * @name     jThumbImg
 * @author   Joan Piedra (http://www.joanpiedra.com)
 * @example  $("a.thumb img, img.thumb").thumbsImg();
 *
 */
jQuery.fn.thumbsImg = function()
{
	return this.each(
		function()
		{
			jQuery(this).css('position','absolute');
			jQuery(this).left( '-' + ( parseInt( $(this).width() ) / 2 ) + 'px' );
			jQuery(this).top( '-' + ( parseInt( $(this).height() ) / 2 ) + 'px' );
			jQuery(this).css('margin-left', '50%' );
			jQuery(this).css('margin-top', '50%' );
		}
	)
}