// JavaScript Document
var lastObj;
$(document).ready(function(){
	$( ".button").button();
	$("input,textarea,select").focus(function () {
		if (lastObj) {
			lastObj.animate({backgroundColor:'#F4F4F4'},'slow');
		}
		if ($(this).attr('type')!="submit") {
	      	$(this).parents('li').animate({backgroundColor:'#FFf7c0'},'slow');
			lastObj=$(this).parents('li');
		}
	});
	$('a.modal').bind('click', function() {
		var popURL = $(this).attr('href')
		var popTitle= $(this).attr('title')
		var popWide=$(this).attr('width')
		if (popTitle=="") {
			popTitle="Kaosweaver";
		}
		if (isNaN(popWide)) {
			popWide=500
		}
		
	
		$( "#dialog-modal" ).load(popURL).dialog({
			modal: true,
			width:Number(popWide),
			title:popTitle,
			position: ['center',100]
		});
		return false;
	
	});
	$("#q").DefaultValue("Search...");
	$("p.download_add").hover(function(){
		$(this).removeClass("download_add")
		$(this).addClass("download_add_over")
	}, function() {
		$(this).removeClass("download_add_over")
		$(this).addClass("download_add")

	});
	$("p.download_new").hover(function(){
		$(this).removeClass("download_new")
		$(this).addClass("download_new_over")
	}, function() {
		$(this).removeClass("download_new_over")
		$(this).addClass("download_new")

	});
	$("p.download_normal").hover(function(){
		$(this).removeClass("download_normal")
		$(this).addClass("download_normal_over")
	}, function() {
		$(this).removeClass("download_normal_over")
		$(this).addClass("download_normal")

	});
	$("p.download_update").hover(function(){
		$(this).removeClass("download_update")
		$(this).addClass("download_update_over")
	}, function() {
		$(this).removeClass("download_update_over")
		$(this).addClass("download_update")

	});
   setTimeout(function(){
	  $("p.resultmessage, p.errormessage").slideUp("slow");
	}, 4000);

});
$.fn.preload = function() {
    this.each(function(){
        $('<img/>')[0].src = this;
    });
}
