function trim(str)//trim string
{
   return str.replace(/^\s+|\s+$/g,'');
}


$(function(){

//chat------------------
	/*		timestamp = 0;
			updateMsg();
			$("form#chatform").submit(function(){
				$.post("chat_backend.php",{
							message: $("#msg").val(),
							name: $("#author").val(),
							action: "postmsg",
							time: timestamp
						}, function(xml) {
					$("#msg").empty();
					addMessages(xml);
				});
				return false;
			});
		});
		function addMessages(xml) {
			if($("status",xml).text() == "2") return;
			timestamp = $("time",xml).text();
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#messagewindow").prepend("<b>"+$("author",message).text()+
											"</b>: "+$("text",message).text()+
											"<br />");
			});
		}
		function updateMsg() {
			$.post("chat_backend.php",{ time: timestamp }, function(xml) {
				$("#loading").remove();
				addMessages(xml);
			});
			setTimeout('updateMsg()', 4000);
		}
//chat--------------
*/


//ajax error
/*$("#messagewindow").ajaxError(function(event, request, settings){
   $(this).append("<li>Error requesting page " + settings.url + "</li>");
 });*/
/*
$(document).ajaxError(function(e, xhr, settings, exception) {
$("#messagewindow").append('<li>error in: ' + settings.url + ' \n'+'error:\n' + xhr.responseText + '</li>' );
}); 
*/
//



	
   $('.styleswitch').click(function()
      {
         switchStylestyle(this.getAttribute("rel"));
         return false;
      });
      var c = readCookie('style');
      if (c) switchStylestyle(c);
	
	
	
	})
	

	
   function switchStylestyle(styleName)
   {
      $('link[@rel*=style][title]').each(function(i)
      {
         this.disabled = true;
         if (this.getAttribute('title') == styleName) this.disabled = false;
      });
      createCookie('style', styleName, 365);
   }
	
	
	
	
	
function ShowStuff(id){
		$("div#"+id).show("slow");
		$("a#"+id+"_hide").show("slow");
}

function HideStuff(id){
		$("div#"+id).hide("slow");
		$("a#"+id+"_hide").hide("slow");	
}

	

