function calculate(a, b, c) {
	d = (a + b) * c;
	return d;
}
function translate(inpValue) {

}

var urlParams = {}; (function() { var e, a = /\+/g, r = /([^&;=]+)=?([^&;]*)/g, d = function(s) { return decodeURIComponent(s.replace(a, " ")); }, q = window.location.search.substring(1); while (e = r.exec(q)) urlParams[d(e[1])] = d(e[2]); })();
$(document).ready(function() {
	$('body').css('visibility', 'visible');
	var first = 0;
	var speed = 700;
	var pause = 3500;
	var urlParams = {};
	(function() {
		var e,
			a = /\+/g,
			r = /([^&;=]+)=?([^&;]*)/g,
			d = function(s) { return decodeURIComponent(s.replace(a, " ")); },
			q = window.location.search.substring(1);
//        alert(q);
		while (e = r.exec(q))
			urlParams[d(e[1])] = d(e[2]);
	})();

	function removeFirst() {
		first = $('ul#listticker li:first').html();
		$('ul#listticker li:first')
			.animate({ opacity: 0 }, speed)
			.fadeOut('slow', function() { $(this).remove(); });
		addLast(first);
	}

	function addLast(first) {
		last = '<li style="display:none">' + first + '</li>';
		$('ul#listticker').append(last)
		$('ul#listticker li:last')
			.animate({ opacity: 1 }, speed)
			.fadeIn('slow')
	}

	interval = setInterval(removeFirst, pause);
	var adcarousel = {
		'default1': {
			0: { 'altImage': 'img/Brooks.jpg', 'height': '100', 'width': '230' },
			1: { 'altImage': 'img/casio.jpg', 'height': '48', 'width': '230' },
			2: { 'altImage': 'img/mizuno.jpg', 'height': '100', 'width': '230' },
			3: { 'altImage': 'img/hbfrotating.gif', 'height': '85', 'width': '230' },
			4: { 'altImage': 'img/shotz.jpg', 'height': '96', 'width': '230' },
			5: { 'altImage': 'img/Asics 2006.jpg', 'height': '73', 'width': '230' },
			6: { 'altImage': 'img/polar.jpg', 'height': '64', 'width': '230' },
			7: { 'altImage': 'img/parmelia.jpg', 'height': '61', 'width': '230' },
			8: { 'altImage': 'img/runnersworld.jpg', 'height': '42', 'width': '230' },
			9: { 'altImage': 'img/Kids2009logo.jpg', 'height': '100', 'width': '230' }
		}
	};
	var pos = 0;
	var maxpos = 9;
	$(".adrotate img").eq(1).everyTime(5000, 'mitimer1', function() {
		$(this).slideToggle("slow");
		this.setAttribute('src', adcarousel['default1'][pos]['altImage']);
		this.setAttribute('height', adcarousel['default1'][pos]['height']);
		this.setAttribute('width', adcarousel['default1'][pos]['width']);
		$(this).slideToggle("slow");
		if (pos < maxpos)
			pos++;
		else
			pos = 0;
	});
	var pos = 0;
	var maxpos = 9;
	$(".adrotate img").eq(3).everyTime(5000, 'mitimer1', function() {
		$(this).slideToggle("slow");
		this.setAttribute('src', adcarousel['default1'][pos]['altImage']);
		this.setAttribute('height', adcarousel['default1'][pos]['height']);
		this.setAttribute('width', adcarousel['default1'][pos]['width']);
		$(this).slideToggle("slow");
		if (pos < maxpos)
			pos++;
		else
			pos = 0;
	});
	$("ul#ticker01").liScroll();
	if ("target" in urlParams) {
		if (urlParams["target"] == "membership") {
			$("#container > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast' }, selected: 1 });
		}
		else {
			$("#container > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast' }, selected: 4 });
		}
	}
	else {
		$("#container > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast' }, selected: 4 });

	}
//    $("#container > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast' }, selected: 4 });
	$("#resultscontainer > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
	$("#programmecontainer > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
	$("#previewscontainer > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
	$("#FunRunsContainer > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
	$("#photoscontainer > ul").tabs({ fx: { opacity: 'toggle', duration: 'fast'} });
	$(".accordion2 h2").eq(0).addClass("active");
	$(".accordion2 p").eq(0).show();
	$(".accordion2 h2").eq(2).addClass("active");
	$(".accordion2 p").eq(2).show();
	$(".accordion2 h2").eq(9).addClass("active");
	$(".accordion2 p").eq(9).show();
	$(".accordion2 h2").click(function() {
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h2").removeClass("active");
	}); 
	$(".tickertapelink").click(function() {
		var mainTabs = $("#container > ul");
		var subTabs = $("#FunRunsContainer > ul");
		var hrefattr = this['href'];
		var tabtoget = 0;
		var acctoget = 0;
		if (hrefattr.match("Marathon$") == "Marathon") {
			tabtoget = 2;
			acctoget = 16;
		}
		if (hrefattr.match("Challenge$") == "Challenge") {
			tabtoget = 0;
			acctoget = 12;
		}
		if (hrefattr.match("HalfMarathon$") == "HalfMarathon") {
			tabtoget = 1;
			acctoget = 13;
		}
		var accordionh2 = $(".accordion2 h2").eq(acctoget);
		mainTabs.tabs('select', 11);
		subTabs.tabs('select', tabtoget);
		if (!accordionh2.hasClass('active')) {
			accordionh2.next("p").slideToggle("slow")
			.siblings("p:visible").slideUp("slow");
			accordionh2.toggleClass("active");
			accordionh2.siblings("h2").removeClass("active");
		}
		return false;
	})
	var viewport = {
		o: function() {
			if (self.innerHeight) {
				this.pageYOffset = self.pageYOffset;
				this.pageXOffset = self.pageXOffset;
				this.innerHeight = self.innerHeight;
				this.innerWidth = self.innerWidth;
			} else if (document.documentElement && document.documentElement.clientHeight) {
				this.pageYOffset = document.documentElement.scrollTop;
				this.pageXOffset = document.documentElement.scrollLeft;
				this.innerHeight = document.documentElement.clientHeight;
				this.innerWidth = document.documentElement.clientWidth;
			} else if (document.body) {
				this.pageYOffset = document.body.scrollTop;
				this.pageXOffset = document.body.scrollLeft;
				this.innerHeight = document.body.clientHeight;
				this.innerWidth = document.body.clientWidth;
			}
			return this;
		},
		init: function(el) {
			$(el).css("left", 50);
			$(el).css("top", Math.round(viewport.o().innerHeight / 2) + viewport.o().pageYOffset - Math.round($(el).height() / 2) + 10);
            $(el).css("z-index",999);
		}
	};
	var lastHeight;
	var lastWidth;
	$("img.floatoverimage").hover(
		function() {
			$(".simple_popup_div").remove();
			var strSimple = "<div class='simple_popup_div'><div class='simple_popup_inner'>";
			strSimple += "<img src='" + this.getAttribute('src') + "' alt='" + this.getAttribute('alt') + "'></img>";
			strSimple += "</div></div>";
			$("body").append(strSimple);
			viewport.init(".simple_popup_div");
			return false;
		},
		function() {
			$(".simple_popup_div").remove();
		}
	);
	var firstphoto = true;
	$('li > a[href="#Photos"]').click(function() {
		/*if(firstphoto) {
		FOTO.Slider.reload('Christchurch2009');
		FOTO.Slider.preloadImages('Christchurch2009');
		FOTO.Slider.enableSlideshow('Christchurch2009');
		firstphoto=false;
		} */
		if (firstphoto) {
			var container = $('#40Miler2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='40Miler2010.html' ></iframe>");
			firstphoto = false;
		}
		return true;
	});
	var firstFriendship2009 = true;
	$('li > a[href="#Friendship2009Pane"]').click(function() {
		if (firstFriendship2009) {
			var container = $('#Friendship2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='Friendship2009.html' ></iframe>");
			firstFriendship2009 = false;
		}
		return true;
	});
	var firstMatildaBay2009 = true;
	$('li > a[href="#MatildaBay2009Pane"]').click(function() {
		if (firstMatildaBay2009) {
			var container = $('#MatildaBay2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='MatildaBay2009.html' ></iframe>");
			firstMatildaBay2009 = false;
		}
		return true;
	});
	var firstNewYearsEveRace = true;
	$('li > a[href="#NewYearsEveRacePane"]').click(function() {
		if (firstNewYearsEveRace) {
			var container = $('#NewYearsEveRacePane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='NewYearsEveRace.html' ></iframe>");
			firstNewYearsEveRace = false;
		}
		return true;
	});
	var firstPointWalter2009 = true;
	$('li > a[href="#PointWalter2009Pane"]').click(function() {
		if (firstPointWalter2009) {
			var container = $('#PointWalter2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='PointWalter2009.html' ></iframe>");
			firstPointWalter2009 = false;
		}
		return true;
	});
	var firstSwanTwilight2009 = true;
	$('li > a[href="#SwanTwilight2009Pane"]').click(function() {
		if (firstSwanTwilight2009) {
			var container = $('#SwanTwilight2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='SwanTwilight2009.html' ></iframe>");
			firstSwanTwilight2009 = false;
		}
		return true;
	});
	var firstNeilHawkins2009 = true;
	$('li > a[href="#NeilHawkins2009Pane"]').click(function() {
		if (firstNeilHawkins2009) {
			var container = $('#NeilHawkins2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='NeilHawkins2009.html' ></iframe>");
			firstNeilHawkins2009 = false;
		}
		return true;
	});
	var firstDarlingtonHalf2009 = true;
	$('li > a[href="#DarlingtonHalf2009Pane"]').click(function() {
		if (firstDarlingtonHalf2009) {
			var container = $('#DarlingtonHalf2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='DarlingtonHalf2009.html' ></iframe>");
			firstDarlingtonHalf2009 = false;
		}
		return true;
	});
	var firstKingOfTheMountain2009 = true;
	$('li > a[href="#KingOfTheMountain2009Pane"]').click(function() {
		if (firstKingOfTheMountain2009) {
			var container = $('#KingOfTheMountain2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='KingOfTheMountain2009.html' ></iframe>");
			firstKingOfTheMountain2009 = false;
		}
		return true;
	});
	var firstKingOfTheMountain2010 = true;
	$('li > a[href="#KingOfTheMountain2010Pane"]').click(function() {
		if (firstKingOfTheMountain2010) {
			var container = $('#KingOfTheMountain2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='KingOfTheMountain2010.html' ></iframe>");
			firstKingOfTheMountain2010 = false;
		}
		return true;
	});
	var firstPancakeRun2009 = true;
	$('li > a[href="#PancakeRun2009Pane"]').click(function() {
		if (firstPancakeRun2009) {
			var container = $('#PancakeRun2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='PancakeRun2009.html' ></iframe>");
			firstPancakeRun2009 = false;
		}
		return true;
	});
	var firstChristchurch2010 = true;
	$('li > a[href="#Christchurch2010Pane"]').click(function() {
		if (firstChristchurch2010) {
			var container = $('#Christchurch2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='Christchurch2010.html' ></iframe>");
			firstChristchurch2010 = false;
		}
		return true;
	});
	var firstChristchurch2009 = true;
	$('li > a[href="#Christchurch2009Pane"]').click(function() {
		if (firstChristchurch2009) {
			var container = $('#Christchurch2009Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='Christchurch2009.html' ></iframe>");
			firstChristchurch2009 = false;
		}
		return true;
	});
	var firstLakeGwelup2010 = true;
	$('li > a[href="#LakeGwelup2010Pane"]').click(function() {
		if (firstLakeGwelup2010) {
			var container = $('#LakeGwelup2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='LakeGwelup2010.html' ></iframe>");
			firstLakeGwelup2010 = false;
		}
		return true;
	});
	var firstBoldPark2010 = true;
	$('li > a[href="#BoldPark2010Pane"]').click(function() {
		if (firstBoldPark2010) {
			var container = $('#BoldPark2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='BoldPark2010.html' ></iframe>");
			firstBoldPark2010 = false;
		}
		return true;
	});
	var firstDeepwater2010 = true;
	$('li > a[href="#Deepwater2010Pane"]').click(function() {
		if (firstDeepwater2010) {
			var container = $('#Deepwater2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='Deepwater2010.html' ></iframe>");
			firstDeepwater2010 = false;
		}
		return true;
	});
	var firstJohnGilmour2010 = true;
	$('li > a[href="#JohnGilmour2010Pane"]').click(function() {
		if (firstJohnGilmour2010) {
			var container = $('#JohnGilmour2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='JohnGilmour2010.html' ></iframe>");
			firstJohnGilmour2010 = false;
		}
		return true;
	});
	var firstPancake2010 = true;
	$('li > a[href="#Pancake2010Pane"]').click(function() {
		if (firstPancake2010) {
			var container = $('#Pancake2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='Pancake2010.html' ></iframe>");
			firstPancake2010 = false;
		}
		return true;
	});
	var firstBookLaunch2010 = true;
	$('li > a[href="#BookLaunch2010Pane"]').click(function() {
		if (firstBookLaunch2010) {
			var container = $('#BookLaunch2010Pane');
			container.append("<iframe align='middle' border='0' height='600' width='100%' src='BookLaunch2010.html' ></iframe>");
			firstBookLaunch2010 = false;
		}
		return true;
	});
	var firstParlouf2010 = true;
	$('li > a[href="#Parlouf2010Pane"]').click(function() {
	if (firstParlouf2010) {
		var container = $('#Parlouf2010Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='Parlouf2010.html' ></iframe>");
		firstParlouf2010 = false;
		}
		return true;
	});
    var firstChristchurch2011 = true;
	$('li > a[href="#Christchurch2011Pane"]').click(function() {
	if (firstChristchurch2011) {
		var container = $('#Christchurch2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='Christchurch2011.html' ></iframe>");
		firstChristchurch2011 = false;
		}
		return true;
	});  
    var firstBurswoodTwilight2011 = true;
	$('li > a[href="#BurswoodTwilight2011Pane"]').click(function() {
	if (firstBurswoodTwilight2011) {
		var container = $('#BurswoodTwilight2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='BurswoodTwilight2011.html' ></iframe>");
		firstBurswoodTwilight2011 = false;
		}
		return true;
	});  
    var firstDarlingtonHalf2011 = true;
	$('li > a[href="#DarlingtonHalf2011Pane"]').click(function() {
	if (firstDarlingtonHalf2011) {
		var container = $('#DarlingtonHalf2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='DarlingtonHalf2011.html' ></iframe>");
		firstDarlingtonHalf2011 = false;
		}
		return true;
	}); 
    var firstMtHelena40miler2011 = true;
	$('li > a[href="#MtHelena40miler2011Pane"]').click(function() {
	if (firstMtHelena40miler2011) {
		var container = $('#MtHelena40miler2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='MtHelena40miler2011.html' ></iframe>");
		firstMtHelena40miler2011 = false;
		}
		return true;
	}); 

    var firstPerth32TenKm2011 = true;
	$('li > a[href="#Perth32TenKm2011Pane"]').click(function() {
	if (firstPerth32TenKm2011) {
		var container = $('#Perth32TenKm2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='Perth32TenKm2011.html' ></iframe>");
		firstPerth32TenKm2011 = false;
		}
		return true;
	}); 
    var firstNeilHawkins2011 = true;
	$('li > a[href="#NeilHawkins2011Pane"]').click(function() {
	if (firstNeilHawkins2011) {
		var container = $('#NeilHawkins2011Pane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='NeilHawkins2011.html' ></iframe>");
		firstNeilHawkins2011 = false;
		}
		return true;
	}); 
    var first2011KidsMarathon = true;
	$('li > a[href="#2011KidsMarathonPane"]').click(function() {
	if (first2011KidsMarathon) {
		var container = $('#2011KidsMarathonPane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='2011KidsMarathon.html' ></iframe>");
		first2011KidsMarathon = false;
		}
		return true;
	}); 
    var first2011PerthMarathon = true;
	$('li > a[href="#2011PerthMarathonPane"]').click(function() {
	if (first2011PerthMarathon) {
		var container = $('#2011PerthMarathonPane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='2011PerthMarathon.html' ></iframe>");
		first2011PerthMarathon = false;
		}
		return true;
	}); 
   var first2011WomensClassic = true;
	$('li > a[href="#2011WomensClassicPane"]').click(function() {
	if (first2011WomensClassic) {
		var container = $('#2011WomensClassicPane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='2011WomensClassic.html' ></iframe>");
		first2011WomensClassic = false;
		}
		return true;
	}); 
    var first2011RunForGold = true;
	$('li > a[href="#2011RunForGoldPane"]').click(function() {
	if (first2011WomensClassic) {
		var container = $('#2011RunForGoldPane');
		container.append("<iframe align='middle' border='0' height='600' width='100%' src='2011RunForGold.html' ></iframe>");
		first2011RunForGold = false;
		}
		return true;
	});
	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {

		//Cancel the link behavior   
		e.preventDefault();
		//Get the A tag   
		var id = $(this).attr('href');

		//Get the screen height and width   
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();

		//Set heigth and width to mask to fill up the whole screen   
		$('#mask').css({ 'width': maskWidth, 'height': maskHeight });

		//transition effect        
		$('#mask').fadeIn(1000);
		$('#mask').fadeTo("slow", 0.8);

		//Get the window height and width   
		var winH = $(window).height();
		var winW = $(window).width();

		//Set the popup window to center   
		$(id).css('top', winH / 2 - $(id).height() / 2);
		$(id).css('left', winW / 2 - $(id).width() / 2);

		//transition effect   
		$(id).fadeIn(2000);

	});

	//if close button is clicked
	$('.window .close').click(function(e) {
		e.preventDefault();
		$('#mask, .window').hide();
	});

	//if mask is clicked
	$('#mask').click(function() {
		$(this).hide();
		$('.window').hide();
	});
	$('body').css('visibility', 'visible');
	$('body').fadeIn(2000);
});
