$(document).ready(function() {
	var opera = false;
	if(navigator.userAgent.indexOf("Opera")!=-1){
		var versionindex=navigator.userAgent.indexOf("Opera")+6
		if (parseInt(navigator.userAgent.charAt(versionindex))>=8) {
			opera = true;
			setInterval("dropShadow", 2000);
		} 
	} 
	if(!opera) dropShadows(); // No shadows for bugged Opera. 

	$('div.forum-quote').hide();
	$('.forum-quote-handle p').click(function(){
		$(this).siblings('div.forum-quote').toggle();
	});

	var tabloc = location.href.indexOf('#');
	var curtab = '';
	if(tabloc > -1) curtab = location.href.substring(tabloc+1);
	else curtab = 'personal-info';


	/** Profile page stuff **/
	$('div#profile div.profile-content').not('[@rel="'+curtab+'"]').hide();
	$('div#profile div.profile-handle#'+curtab).addClass('active-tab');

	$('div#profile div.profile-handle').click(function() {
		curtab = $(this).attr('id');
		$('div#profile div.profile-handle').removeClass('active-tab');
		$(this).removeClass('inactive-tab');
		$(this).addClass('active-tab');

		$('div#profile div.profile-content').hide();
		$('div#profile div.profile-content[@rel="'+curtab+'"]').show();
	});

	/** Hide everything by default :> **/
	$('div.char-edit-form').hide();
	$('div.char-new-form').hide();
//	$('#subEvents').hide();
	$('.subEvents').hide();
	$('#subEvents-1').show();
	$('tr.hidden').hide();

	$('a.char-edit-link').click(function() {
			$('div.char-new-form').hide();
			$('div.char-edit-form').hide();
			$('div.char-edit-form#'+$(this).attr('id')).show();
	});

	$('a.char-new-link').click(function(){ 
		$('div.char-edit-form').hide();
		$('div.char-new-form').show();
	});


});

function dropShadows() {
    var elem = $('span.dropshadow, .profile-tooltip-text');
    $.each(elem, function() {
        var content = $(this).html();
        $(this).html('<span class="dropshadow-shadow"><span class="dropshadow-text">'+content+'</span>'+content+'</span>');
		if($(this).attr('class') == 'dropshadow link') $(this).children('.dropshadow-shadow').children('.dropshadow-text').addClass('link');

	});
}


function m_a_g_i_c(elem) {
	var file = $(elem).val();

	$(elem).siblings('input[@type="text"]').attr('value', file);
	
}


function varmistus(kysymys, redirect) {
        var vastaus = confirm(kysymys)
        if (vastaus) window.location = redirect;
}

