// JavaScript Document
function preloader() 

{     // counter
     var i = 0;
	 var x = 0;

// rollover - change background image
if(!document.getElementById('thumbs')) return false;
var gallery = document.getElementById('thumbs');
var links = gallery.getElementsByTagName('a');
for (i=0; i<links.length; i++)
{	imageObj = new Image();	
	if(img = links[i].getAttribute('id'))
	{	imgid = img.substr(3);
		imageObj.src="photos/full/" + imgid + ".jpg";	// preload full size images
		imageObj.onLoad = x++;
		links[i].onmouseover = function()
		{	
			return showPic(this);	
		}
	}
}

function showPic(whichpic)
{	if(!document.getElementById('photo')) return true;
//	if(!whichpic.childNodes[0].getAttribute('id')) return true;
	if(source = whichpic.getAttribute('id'))
	{	source = source.substr(3);
		source = source + ".jpg";
		var bgimg1 = "background:#000000 url(photos/full/" + source + ") no-repeat top center;";
		var bgimg2 = "#000000 url(photos/full/" + source + ") no-repeat top center;";
		var main = document.getElementById('photo');
		main.setAttribute('style', bgimg1);
		main.style.background = bgimg2;
		var styled = main.getAttribute('style');
//		alert("main is now set to " + styled);
		return false;
	}
	else {	return true;	}
}

} 


window.onload = function () { 
   preloader(); 
   
} 

// JavaScript email encoder
// 1349718573
// This script is (C) Copyright 2004 Jim Tucek
// Leave these comments alone!  For more info, visit
// www.jracademy.com/~jtucek/email/ 

function choose(friendship,astonishment,bus) {
friendship += ' ';
var horse = friendship.length;
var hair = 0;
var box = '';
for(var rocket = 0; rocket < horse; rocket++) {
hair = 0;
while(friendship.charCodeAt(rocket) != 32) {
hair = hair * 10;
hair = hair + friendship.charCodeAt(rocket)-48;
rocket++;
}
box += String.fromCharCode(spread(hair,astonishment,bus));
}
parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+box;
}

function rise(crust,cost,debate) {
crust += ' ';
var money = crust.length;
var historian = 0;
for(var insect = 0; insect < money; insect++) {
historian = 0;
while(crust.charCodeAt(insect) != 32) {
historian = historian * 10;
historian = historian + crust.charCodeAt(insect)-48;
insect++;
}
//document.write('&');
//document.write('#');
//document.write(spread(historian,cost,debate));
document.write(String.fromCharCode(spread(historian,cost,debate)));
}
}

function spread(pencil,book,control) {
if (control % 2 == 0) {
mass = 1;
for(var same = 1; same <= control/2; same++) {
matter = (pencil*pencil) % book;
mass = (matter*mass) % book;
}
} else {
mass = pencil;
for(var dark = 1; dark <= control/2; dark++) {
matter = (pencil*pencil) % book;
mass = (matter*mass) % book;
}
}
return mass;
}

// JavaScript Document

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http = createRequestObject(); 

/* Function called to get the product categories list */
function getSport(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', 'get_events.php?action=get_sport&id=' 
			+ document.photo_upload.sports.selectedIndex);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleSport; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSport(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('list_events').innerHTML = response;
	}
}

