﻿var __images = new Array();var __curr = 0;var __newItems = new Array();var __currNewsItem = 0;
function __showNext() { $(__images[__curr]).fadeOut("slow"); __curr++; if (__curr >= __images.length) { __curr = 0; } $(__images[__curr]).fadeIn("slow"); setTimeout("__showNext()", 5000); } function __showNextNews() { $(__newItems[__currNewsItem]).fadeOut("slow"); __currNewsItem++; if (__currNewsItem >= __newItems.length) { __currNewsItem = 0; } $(__newItems[__currNewsItem]).fadeIn("slow"); setTimeout("__showNextNews()", 8000); }
String.prototype.endsWith = function(str)
{ return (this.match(str + "$") == str) }
$(document).ready(
	function()
	{
		// roundy corner stuff
		// $("h1.post-title").corner("5px");
		$("div#blog-area div.category-list").corner("10px");
		$("div#blog-area div.tag-cloud").corner("10px");
		$("h1.main-head").corner("bottom tr");
		$("h1.blog").corner();
		$("div.sub-nav").corner("10px");
		$("div.sub-nav a").each(function()
		{
			if (window.location.toString().endsWith($(this).attr('href')))
			{
				$(this).addClass("selected");
			}
			else
			{
				$(this).removeClass("selected");
			}
		});

		// Home Page Image Rotation Setup
		$("div#body div#images img").each(function() { __images.push($(this)); });
		$("div#body div#images img:first").css("display", "block");
		if (__images.length > 1) { setTimeout("__showNext()", 5000); }

		// Navigation Highlighting
		$("#nav a").each(function() { var location = window.location.href; location = location.substring(location.lastIndexOf('/')); if ($(this).attr('href') == location) { $(this).addClass("selected"); } else { $(this).removeClass("selected"); } });

		// Searchbar Functionality
		$("#searchterms").keyup(function(event) { if (event.keyCode == 13) { window.location.href = "/search/?q=" + $("#searchterms").attr("value"); } }).focus(function() { $(this).attr("value", ""); });
		$("#go-search").click(function() { window.location.href = "/search/?q=" + $("#searchterms").attr("value"); });

		// News Ticker Functionality
		$("div.headline:first").css("display", "block");
		var __headlineHeight = 0;
		$("div.headline").each(function() { if ($(this).height() > __headlineHeight) { __headlineHeight = $(this).height(); } __newItems.push($(this)); });
		__headlineHeight += 150;
		$("#headlines").height(__headlineHeight);
		if (__newItems.length > 1) { setTimeout("__showNextNews()", 8000); }

		var href = window.location.href;
		if (href.indexOf('/translate_c?') != -1)
		{
			$("li > span").each(
				function()
				{
					if ($(this).attr("onmouseout") != 'undefined')
					{
						$(this).attr("style", "margin:0px;padding:0px;");
					}
				}
			);
			$("span.google-src-text").attr("style", "margin:0px;padding:0px;");
		}
	}
);