/*
 *
 * Copyright (c) 2006 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
 
/*
 * A basic news ticker
 *
 * @name     newsticker (or newsTicker)
 * @param    delay      Delay (in milliseconds) between iterations. Default 4 seconds (4000ms)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $("#news").newsticker(); // or jQuery("#news").newsticker(5000);
 *
 */
jQuery.fn.newsTicker = jQuery.fn.newsticker = function(delay)
{
	return this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			delay = delay || 10000;
			var self = this;
			self.items = jQuery("li", self);
			// hide all items (except first one)
			self.items.not(":eq(0)").hide().end();
			// current item
			self.currentitem = 0;
			var doTick = function()
			{
				jQuery.newsticker(self);
			}
			setInterval(doTick,delay);
		}
	)
	.addClass("newsticker")
	.hover(
		function()
		{
			// pause if hovered over
			this.pause = true;
		},
		function()
		{
			// unpause when not hovered over
			this.pause = false;
		}
	);
}
jQuery.newsticker = function(el)
{
	// return if hovered over
	if(el.pause) return;
	// hide current item
	jQuery(el.items[el.currentitem]).fadeOut("slow",
		function()
		{
			jQuery(this).hide();
			// move to next item and show
			el.currentitem = ++el.currentitem % (el.items.size());
			jQuery(el.items[el.currentitem]).fadeIn("slow");
		}
	);
}

function search_form_safari() {
	document.write('<input type="search" name="query" value="Search..." results="5" onfocus="if (this.value==\'Search...\') this.value=\'\'" onblur="this.value=\'Search...\'" />');
}
function search_form_others() {
	document.write('<span class="sbox_l"></span>');
	document.write('<span class="sbox">');
	document.write('<input type="search" id="srch_fld" name="query" value="Search..." autosave="applestyle_srch" results="5" onfocus="if (this.value==\'Search...\') this.value=\'\'" onblur="this.value=\'Search...\'" onkeyup="applesearch.onChange(\'srch_fld\',\'srch_clear\')" />');
	document.write('</span>');
	document.write('<span class="sbox_r" id="srch_clear"></span>');
}

function show_news_fade() {
$.get(
	"http://www.informatux.com/xpetitions/news.html", {}, function(data)
	{
		$("#news").append(data).find("ul").newsTicker();
	}
)
document.write('<div id="news"></div>');
}
