<!--

$(document).ready(function()
{
	$('#loadingPage').hide();

	$('#loadingPage').ajaxStart(function() {
			$(this).show();
			$('#content').html("");
	}).ajaxStop(function() {
			$(this).fadeOut('slow').$(this).hide();
	});
	
	$('#scrollit').click(function() {
		var divOffset = $('#content').offset().top;
		var pOffset = $('#content #topofpage').offset().top;
		var pScroll = (pOffset - divOffset) - 10;
		$('#content').animate({scrollTop: '+=' + pScroll + 'px'}, 1000, 'bounceout');
	});
	
	jQuery.fn.extend({
	  scrollhere : function(div, speed) {
		return this.each(function() {
			var scrolltohere = ($(this).offset().top - $(div).offset().top) - 20;
			$(div).animate({scrollTop: '+=' + scrolltohere + 'px'}, speed, 'easeout');
		});
	  }
	});

});

function submitMail()
{
		$.post("AJAX-mail.php",{				
			name: $("#name").val(),
			message: $("#message").val(),
			subject: $("#subject").val(),
			email: $("#email").val()
			}, function() {$('#content').html("<h1>Mail form</h1><div class=\"textcontainer\" style=\"width:304px;\"><p>Thank you. Your message has been sent.</p></div>");return false;});
}


window.onload=function()
{        
	if ( $('div#preload').is(':visible') )
	{
		$('div#preload').fadeOut('slow');
	}
}

function getpage(pageName)
{
	$.each( ["news","music","misc","links","about","mail","dos"], function(i, n){
		$("#"+n).removeClass("current");
	});
	$("#"+pageName).addClass("current");
	
	var loading = new Array(
		'<img src="grafik/bruce_lee-bruce.gif" width="32" height="42" alt="Bruce Lee">',
		'<img src="grafik/bruce_lee-ninja.gif" width="32" height="38" alt="Ninja">',
		'<img src="grafik/bruce_lee-yamo.gif" width="32" height="42" alt="Yamo">');
	
	var texts = new Array(
		'please wait','','','','ZZzzzz','The name is Baud....., James Baud.','','','','Unable to locate Coffee',';o)','','','','(o:','just a second','','','');
	
	var loadingphotos = loading.length;
	var whichPhoto=Math.round(Math.random()*(loadingphotos-1));
	
	var loadingtexts = texts.length;
	var whichText=Math.round(Math.random()*(loadingtexts-1));
	
	$("div#loadingPhoto").html(loading[whichPhoto]+'<div class="wait">'+texts[whichText]+'</div>');
	
	$("div#content").load("AJAX-"+pageName+".php","", function()
	{
		urchinTracker("AJAX-"+pageName+".php");
	});
}

function bounceout(div) {
	$("div#read"+div).hide();
	$("div#text"+div).slideDown({duration: 1000, easing: "backout"});
}

function playmusic(filename) {
	$("#musicplayer").html('<div class="playmp3">'+filename+'.mp3</div>');
	$(".playmp3").jmp3();
}

function scrolldiv(filename) {
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+'\n'; }
  } if (errors) alert('Please fill out:\n'+errors);
  document.MM_returnValue = (errors == '');
}

//-->