
// EXTERNAL LINKS

$(document).ready(function()
{
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
});




// VALIDATION HIDE

$(document).ready(function()
{
	if (location.hostname == "mikemiles.com" || location.hostname == "www.mikemiles.com")
	{
		$("#validation").hide();
	}
});




// DATEPICKER

$(document).ready(function()
{
	var minutes = 1000 * 60;
	var hours = minutes * 60;
	var days = hours * 24;
	var years = days * 365;

	var fightDate = new Date($("#datefight").attr('title'));
	$("#datepicker").datepicker({
		inline: true,
		dateFormat: 'yy-mm-dd',
		dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
		firstDay: 1,
		defaultDate: fightDate
	});

	var now = new Date();
	var startDate = now.getTime();
	var endDate = fightDate.getTime();
	var diffDate = endDate - startDate;
	var daysUntil = Math.ceil(diffDate / days);
	var strEvent = $("#datefight").html();
	strDate = fightDate.toLocaleDateString().replace(/\//g, "-");
	$("#datefight").html("<p><label>" + daysUntil + "</label>" + "<em>Days Until</em><br/>" + strEvent + "</p>");
	$("#datefight").click(function(){location.href="index.php?p=coming";});
});




// CLASS SCHEDULES

$(document).ready(function()
{
	$(".gyms dd").hide();
	$(".gyms dd").eq(0).show();
	$(".gyms dt").click(function()
	{
		$(".gyms dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
});




// LINKS

$(document).ready(function()
{
	$("#links dd").hide();
	$("#links dt").click(function()
	{
		$("#links dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
});




// PROFILES

$(document).ready(function()
{
	$("#profile dd").hide();
	$("#profile dd").eq(0).show();
	$("#profile dt").click(function()
	{
		$("#profile dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
/*	$("#profile img").click(function()
	{
		$("#profile dd").show('slow');
		return false;
	}); */
});




// TESTIMONIALS

$(document).ready(function()
{
	$("#testimonials dd").hide();
	$("#testimonials dt").click(function()
	{
		$("#testimonials dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
/*	$("#profile img").click(function()
	{
		$("#profile dd").show('slow');
		return false;
	}); */
});




// QUOTES

$(document).ready(function()
{
	var quote = Math.floor(Math.random() * $("#quotes blockquote").size());
	$("#quotes blockquote").hide();
	$("#quotes blockquote + p").hide();
	$("#quotes blockquote").eq(quote).show();
	$("#quotes blockquote + p").eq(quote).show();
});




// COUNTRY

$(document).ready(function()
{
	var isoCountry = '';
	var imgCountry = '';
	$("div.coming, div.organization, #profile dl, div.red, div.blue").each(function(j) {
		obj = $(this);
		isoCountry = $(obj).attr("title");
		imgCountry = "url(images/country/" + isoCountry + ".gif)";
		obj.css("background-image", imgCountry);
	});
});




// CYCLE

$(document).ready(function()
{
	$("#cycle .cycleIMG").cycle(
	{
		fx: 'fade',
		pause: 1,
		after: onAfter,
		pager: '.cyclePAG',
		prev: '#cycleNAVp',
		next: '#cycleNAVn'
	});

	function onAfter(){
		$("#cycle .cycleALT").html(this.alt);
	}
});




// BEAUTYTIPS

$(document).ready(function()
{
	$(".btOrg").each(function(i)
	{
		var inputOrg = 'content/organizations.php div#' + $(this).html();
		$(this).bt(
		{
			ajaxPath: inputOrg,
			fill: '#222222',
			strokeStyle: '#333333',
			strokeWidth: 4,
			spikeGirth: 24,
			spikeLength: 36,
			cornerRadius: 8
		});
	});

	$(".btImg").each(function(j)
	{
		var inputSrc = $(this).attr('src');
		var imgWidth = $(this).attr('width') * 2;
		var imgHeight = $(this).attr('height') * 2;
		var srcInd = inputSrc.lastIndexOf('/');
		var strPath = inputSrc.substr(0, srcInd);
		var strFile = inputSrc.substr(srcInd);
		var outputImg = '<img src="' + strPath + '/bt/' + strFile + '" width="' + imgWidth + '" height="' + imgHeight + '"/>';
		$(this).bt( outputImg,
		{
			cssStyles: {width: 'auto'},
			fill: '#222222',
			strokeStyle: '#333333',
			strokeWidth: 4,
			spikeGirth: 24,
			spikeLength: 36,
			cornerRadius: 8
		});
	});

	$(".btPro").bt(
	{
		fill: '#222222',
		strokeStyle: '#333333',
		strokeWidth: 2,
		spikeGirth: 12,
		spikeLength: 18,
		cornerRadius: 4
	});
});




// ADDRESSES

$(document).ready(function()
{
	var calgarySE = '<address>Mike Miles MuayThai &amp; Kickboxing Ltd<br/>6041 - 6 Street SE<br/>Calgary, Alberta<br/>T2H 1L8<br/>Canada</address><address>403.244.8424 W<br/>403.244.7991 F</address><address><a href="mailto:mike@mikemiles.com">mike@mikemiles.com</a><br/><a href="mailto:sandra@mikemiles.com">sandra@mikemiles.com</a><br/><a href="mailto:scott@mikemiles.com">scott@mikemiles.com</a><br/><a href="mailto:shelley@mikemiles.com">shelley@mikemiles.com</a>';
	var calgaryNW = '<address>Mike Miles National Kickboxing NW<br/>25 - 7750 Ranchview Drive NW<br/>Calgary, Alberta<br/>T3G 1Y9<br/>Canada</address><address>403.208.1296 W<br/>403.208.1298 F</address><address><a href="mailto:mike@mikemiles.com">mike@mikemiles.com</a>';
	var cochrane = '<address>#6 - 118 1 Street West<br/>Cochrane, Alberta<br/>T4C 1A9<br/>Canada</address><address>403.851.1071 W</address><address><a href="mailto:christina@mikemiles.com">christina@mikemiles.com</a><br/><a href="mailto:bryan@mikemiles.com">bryan@mikemiles.com</a></address>';
	var edmonton = '<address>14839 - 118 Avenue NW<br/>Edmonton, Alberta<br/>T5L 2M7<br/>Canada</address><address>780.483.9235 W</address><address><a href="mailto:edmkick@telus.net">edmkick@telus.net</a></address>';
	$("div.address[title='calgarySE']").html(calgarySE);
	$("div.address[title='calgaryNW']").html(calgaryNW);
	$("div.address[title='cochrane']").html(cochrane);
	$("div.address[title='edmonton']").html(edmonton);
});