if (window.attachEvent)
{
	// for handling class attachment for drop downs in IE
	window.attachEvent("onload", function() {
		var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" hover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}
	});
}

function pageinit()
{
	Pager.init();

	$('#search_query').focus(function(){
		if(this.value == this.defaultValue) this.value = '';
	}).blur(function(){
		if(this.value == '') this.value = this.defaultValue;
	});

}

var Pager = {
	init:function()
	{

		$('.items').each(function(){
			var LIs = $('li',this);
			var c = Math.round(this.scrollHeight / this.offsetHeight); // LIs.length;

			var ul = document.createElement('ul');
			ul.className = 'pager';
			for(var i=1;i<=c;i++)
			{
				var li = document.createElement('li');
				var a = document.createElement('a');
				a.href = '#';
				a.onclick = Pager.sel;
				if(i==1) a.className = 'current';
				a.appendChild(document.createTextNode(i));
				a.setAttribute('num', i);
				li.appendChild(a);
				ul.appendChild(li);

			}
			this.parentNode.insertBefore( ul, this.nextSibling);

		});
	},
	sel:function(evt)
	{
		$('.current', this.parentNode.parentNode).removeClass('current');
		$(this).addClass('current');
		var item = this.parentNode.parentNode.previousSibling;

		//item.scrollTop = (this.getAttribute('num') - 1)  * item.offsetHeight;
		var fx = new jQuery.fx(item, {duration:300, curAnim:{}}, 'scrollTop');
		fx.custom(item.scrollTop, (this.getAttribute('num') - 1)  * item.offsetHeight);

		return false;
	}
}

$(document).ready(pageinit);
