var flashVersion = swfobject.getFlashPlayerVersion();
var YTurl = "http://www.youtube.com/watch?v=W8Bm2gTgcs0";

$.fn.autoNavWidth = function() {
	var browserOS = navigator.platform;
	var navWidth = jQuery(this).width();
	var navStyle = {
		'width' : ''+navWidth+'px',
		'margin' : '0 auto',
		'float' : 'none'
	}
	
	if ((navigator.platform.toLowerCase()) == "macppc" || "macintel" )  {
		var navStyle = {
			'width' : ''+(navWidth+16)+'px',
			'margin' : '0 auto',
			'float' : 'none'
		}
	}
	
	if ( jQuery(this).size()) {
		
		jQuery(this).css(navStyle);
	}

}
$(document).ready(function() {

	equalHeight($(".item p"));

	$(".home_widgets .widget:first").css("margin-left", "0");

	$(".footernav  li:last").css("border-right", "0");

	$(".navigation .alignleft:empty").hide();

	$(".navigation .alignright:empty").hide();

	$(".comment-nav .alignright:empty").hide();

	$(".comment-nav .alignleft:empty").hide();

	$(".navigation:empty").hide();

	$(".comment-nav:empty").hide();
	
	var currentPage = window.location;																			
	var postPage = $(".blogpost .comments").siblings("h2.title").children("a").attr("href");

	if (postPage != null) {
		$(".blogpost .comments").click(function() {
	
				window.location = postPage+"#respond"; 
				
		});
	}

	else {
		$(".blogpost .comments").wrap("<a href='#respond'/>");
	}
	
	$("#QuoteCycle").cycle({
		fx: 'fade',
		timeout: 6000,
		pause: true
	});
	
	$("#QuoteCycle").hover(
		function () {
			$("<div class='onPause'>Paused</div>").insertAfter(this);
		}, 
		function () {
			$("div.onPause").remove();
		}
	);
	

	$("#QuotesFull img:odd").removeClass("alignleft").addClass("alignright");
	
	// Setting up some variables to deal with flash detection and implementing the video

	
		$(".vidTrigger").each(function() {
			if (FlashDetect.installed) {
			
				var MPlayerUrl = "/mediaplayer/player.swf?wmode=transparent&file=/Katie.flv&controlbar=over&autostart=true&volume=45&bufferlength=5"
				$(this).attr({
					href: MPlayerUrl,
					target: "_blank"
				}).css({
					'outline' : 'none',
					'border-bottom' : 'medium none'
				});
			}
		});

	$("<div class='highslide-html-content' id='my-video'><div class='videoTip'><div class='tipInner'><!-- AddThis Button BEGIN --><div class='addthis_toolbox addthis_default_style'><a href='http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4ba7f55a15d96ff0' class='addthis_button_compact' addthis:url='http://www.youtube.com/watch?v=W8Bm2gTgcs0' style='color: #FFF!important;font-weight: bold;'>Share Video</a></div><script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4ba7f55a15d96ff0'></script><!-- AddThis Button END --></div></div><div class='highslide-header'></div><div class='highslide-body'></div><div class='highslide-foter'></div></div>").appendTo("body");
	
		$(".vidTrigger").click(function() {
			if (FlashDetect.installed) {

				return hs.htmlExpand(this, { objectType: 'swf', contentId: 'my-video', allowSizeReduction: true, slideshowGroup: null, width: 633, objectWidth: 633, objectHeight: 356, maincontentText: '<a href="'+YTurl+'" target="_blank">Watch the video on YouTube</a>', swfOptions: { version: '9', flashvars: { file: "/Katie.flv", bufferLength: "5", controlbar: "over", volume: "40", icons: "false", autostart: "true", mute: "false" }, params: { allowfullscreen: "true", allowscriptaccess: "always", wmode: "transparent" } }  } )
				pageTracker._trackPageview("/katietrailer");
			}
	 });
	
	$(".videoTip").hide();
	$("#my-video").each(function() {
		$(this).hover(
			function() {
				$(".highslide-controls").hide();												
				$(this).find(".videoTip").show();												
			},
			function() {
				$(".highslide-controls").hide();														
				$(this).find(".videoTip").hide();												
			}
		);
	});

	if ( $("#rpx_provider_wrap a.rpxnow").size() > 0) {
		$("#rpx_provider_wrap").hide();
		$("#rpx_provider_wrap").after("<div id='socButt' style='width: 150px; height: 50px; overflow: hodden; margin: 5px 0;'><a href='/wp-login.php' title='Facebook' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px -50px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>Facebook</a><a href='/wp-login.php' title='Twitter' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px -200px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>Twitter</a><a href='/wp-login.php' title='Google' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px -100px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>Google</a><a href='/wp-login.php' title='AOL' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px 0px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>AOL</a><a href='/wp-login.php' title='Yahoo!' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px -250px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>Yahoo!</a><a href='/wp-login.php' title='OpenID' class='rpxnow' style='display: block; background: url(/wp-content/themes/katie/images/social_buttons.png) no-repeat scroll 0px -150px; text-indent: -9999px; width: 150px; height: 50px; border-bottom: 0 none;'>OpenID</a></div>");
	}
	$("#socButt").cycle({
		fx: 'fade',
		timeout: 2000
	});
});



DD_roundies.addRule('blockquote, .comment-reply-link.qbutton a, blockquote,.comment-reply-link', '10px', true);

DD_roundies.addRule('#sidebarsearch div, .navigation a, .comment-nav a', '20px', true);

DD_roundies.addRule('.wp-caption,.portfnav a', '5px', true);

DD_roundies.addRule('.commentlist li', '10px', true);

Cufon.replace('#pagenav a', {

	textShadow: '1px 1px #747474'

});



Cufon.replace('h1');

Cufon.replace('.home_widgets .widget h3');

Cufon.replace('h5');

Cufon.replace('ul.sf-menu  li');

Cufon.replace('span.social');



function equalHeight(group) {

	tallest = 0;

	group.each(function() {

		thisHeight = $(this).height();

		if(thisHeight > tallest) {

			tallest = thisHeight;

		}

	});

	group.height(tallest);

}
