$(document).ready(function() {
	$('#user-login-form #edit-name').siblings('label').html('u:');
	$('#user-login-form #edit-pass').siblings('label').html('p:');
	$('#user-login-form ul li.first > a').html('<strong>Trainer recruitment</strong> (sign up)');

	$('#primary > ul.menu > li').hover( function() {
		$(this).children('ul').show();
	}, function() {
		$(this).children('ul').hide();
	});
	
	$('#primary > ul.menu > li > ul > li').hover( function() {
		$(this).addClass('active');
	}, function() {
		$(this).removeClass('active');
	});

	$('div.bio').hide();
	$('#bio-neighbor').show();
	
	$('a.visit, a.share').html('');
	
	$('#primary > ul.menu > li.leaf.last > a').attr('target', '_blank');

	
	// flash check / quicktime replace
	
	var requiredMajorVersion = 8;
	var requiredMinorVersion = 0;
	var requiredRevision = 0;
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if (!hasReqestedVersion) {
		var quicktimeURL;
		$('embed').each( function(i) {
			quicktimeURL = $(this).attr('id');
			$(this).replaceWith('<embed src="http://afterjudgment.com/podcast/qtposter.png" href="' + quicktimeURL + '" type="video/x-m4v" target="myself" scale="1" />');
		} );
		$('object.audioPlayer').each( function(i) {
			quicktimeURL = $(this).attr('id');
			$(this).replaceWith('<embed style="height: 30px; width: 512px; margin 0 auto" height="30" src="http://afterjudgment.com/podcast/audioposter.png" href="' + quicktimeURL + '" type="audio/x-mp3" target="myself" scale="1" />');
		} );
		if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
			$('p.vidDesc a, #homeVidDesc a').css('display', 'none');
		}
	}
});

function ajBio(character) {
	$('div.bio').hide();
	$('#bio-' + character).show();
}

function switchB4Vid(character, blipID) {
	$('#bio-' + character).children('div.embed').html('<embed src="http://blip.tv/play/' + blipID + '?brandname=afterjudgment.com&brandlink=http%3A//afterjudgment.com/&lightcolor=0x557722&backcolor=0x00000&frontcolor=0xCCCCCC&showguidebutton=false" type="application/x-shockwave-flash" width="500" height="312" allowscriptaccess="always" allowfullscreen="true"></embed>');
}

function addBookmark() {
	var url = 'http://afterjudgment.com';
	var title = 'After Judgment Web Series';
	
    var agent = navigator.userAgent.toLowerCase();
	var control = "CTRL";

    if (agent.indexOf('mac') != -1) 		{	control = 'Command';	}
	if (agent.indexOf('webkit') != -1) 		{ 	agent = 'webkit';		}
	if (agent.indexOf('konqueror') != -1) 	{	agent = 'konqueror';	}
	
	// IE
    if (window.external) {
        window.external.AddFavorite(url, title);

	// Webkit / Safari
    } else if (agent == 'webkit') {
      alert('Press '+ control + ' + D to bookmark After Judgment.');

	// Firefox
	} else if (window.sidebar) {
		window.sidebar.addPanel(title, url, '');

	// Opera
    } else if (window.opera && window.print) {
		return true;

	// Konqueror
    } else if (agent == 'konqueror') {
      alert('Press '+ control + ' + B to bookmark After Judgment.');

	// Misc
    } else {
      alert('Sorry, bookmark creation failed. Please bookmark After Judgment manually.');
    }
}

function postcard() {
	window.open('http://afterjudgment.com/aj/sites/all/themes/ajgrey/share.php','Send a Postcard | After Judgment','menubar=no,width=700,height=450,toolbar=no,scrollbars=no,status=no,location=no,directories=no,resizable=yes');
}


