
// EXTERNAL LINKS

$(document).ready(function()
{
//	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
	$("a[href^=http://]").attr("target","_blank");
});




// VALIDATION HIDE

$(document).ready(function()
{
	if (location.hostname == "shelleyatdelphi.com" || location.hostname == "www.shelleyatdelphi.com")
	{
		$("#validation").hide();
	}
});




// SIDEBAR

$(document).ready(function()
{
	$("#sidebar dd").hide();
	var showThis = Math.floor(Math.random()*($("#sidebar dd").size()));
	$("#sidebar dd:eq(" + (showThis) + ")").show();
	$("#sidebar dt").mouseover(function()
	{
		$("#sidebar dd").hide('fast');
		$(this).next().toggle('slow');
		return false;
	});
	$("#sidebar h2:last").mouseover(function()
	{
		$("#sidebar dd").show('slow');
		return false;
	});
});




// ADDRESS

$(document).ready(function()
{
	var shelley = '<address>Shelley At Delphi<br/>6041 - 6 Street SE<br/>Calgary, Alberta<br/>T2H 1L8<br/>Canada</address><address>403.244.8424 W<br/>403.938.1008 F</address><address><a href="mailto:shelley@shelleyatdelphi.com">shelley@shelleyatdelphi.com</a>';
	$("div.address[title='shelley']").html(shelley);
});




// DATEPICKER

$(document).ready(function()
{
	var minutes = 1000 * 60;
	var hours = minutes * 60;
	var days = hours * 24;
	var years = days * 365;

	var fightDate = new Date($("#dateevent").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 = $("#dateevent").html();
	strDate = fightDate.toLocaleDateString().replace(/\//g, "-");
	$("#dateevent").html("<p><label>" + daysUntil + "</label>" + "<em>Days Until</em><br/>" + strEvent + "</p>");
	$("#dateevent").click(function(){location.href="index.php?p=events";});
});




// 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();
});




// DROPCAPS

$(document).ready(function()
{
	$("div.a p:first-child").text(function(){
		return 'A' + ($(this).text());
	});
	$("div.q p:first-child").text(function(){
		return 'Q' + ($(this).text());
	});
	$("div.t p:first-child").text(function(){
		return 'T' + ($(this).text());
	});
});




// BEAUTYTIPS

$(document).ready(function()
{
	$(".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
		});
	});
});




// INNERFADE

$(document).ready(function()
{
	$('#testimonials').innerfade({
		speed: 'slow',
		timeout: 12000,
		type: 'random_start',
		containerheight: 'auto'
	});
});
