var showJoel = true;
var showJolina = true;
$(document).ready(function() {
	
	$('.menu-item').fitted();
	var options = {};
	$('#findUs').hide();
	$('#shareLink').click(function() {
			$( ".shareBox" ).toggle( 'blind', options, 800);
	});
	$('.shareBox').mouseleave(function() {
  		$('.shareBox').toggle( 'blind', options, 800);
	});
	$('#newslink').click(function() {
			$( '#newsbox' ).toggle(0);
	});
	$('#newsbox').click(function() {
			$( '#newsbox' ).toggle(0);
	});
	$('#newsboxinner').click(function(e) {
			e.stopPropagation();
	});	
	$('.toggleJoel').click(function() {
			$( '#findJoel' ).toggle('blind', options, 800);
			showJoel = changeText(this,showJoel); 
	});
	$('.toggleJolina').click(function() {
			$( '#findJolina' ).toggle('blind', options, 800);
			showJolina = changeText(this,showJolina); 
	});
	if( 
		navigator.userAgent.match(/Android/i) ||
		navigator.userAgent.match(/webOS/i) ||
		navigator.userAgent.match(/iPhone/i) ||
		navigator.userAgent.match(/iPad/i) ||
		navigator.userAgent.match(/iPod/i)
	 ){
	 	$('head').append('<link rel="stylesheet" type="text/css" media="all" href="/wp-content/themes/joeljolina/mobile.css"/>');
	}
	else{
	}


var i;
for (i in document.images) {
if (document.images[i].src) {
var imgSrc = document.images[i].src;
if (imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG') {
document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
}
}
}



});



function callback($i) {
var options = {};
setTimeout(function() {
			$($i).hide( 'blind', options, 800);
}, 15000 );
};

function changeText($i,$f) {
	if ( $f == true ) {
		$($i).text('Dölj karta');
		$f = false;
		return false;
	} else if ( $f == false ) {
		$($i).text('Visa karta');
		$f = true;
		return true;
	}
};
