// JavaScript Document

function zufall(max){
	var zahl = Math.round(Math.random() * max);
	return zahl;
}

function makeflash(vidId, width, height){
	flashcode  = '<iframe src="http://player.vimeo.com/video/'+vidId+'?title=0&amp;byline=0&amp;portrait=0" width="718" height="404" frameborder="0"></iframe>';
	return flashcode;
}

var userlang = navigator.language;
if (!userlang) var userlang = navigator.browserLanguage;
/*document.write(userlang);*/

if(userlang != 'de'){
	document.write('<script type="text/javascript" src="/layout/schuhplus/js/jquery.translate.min.js"></script>');
	function startTranslation(translang){
		$('body').translate('de', translang);
	}
}

$(document).ready(function() {
						   
	$(".articleList7ItemImg").mouseover(function (e) {
			$(this).parent().parent().css("z-index",100);
			$(this).parent().css("z-index",100);
    		$(this).parent().children(".sp_tooltip").show();
  	})
	$(".articleList7ItemImg").mouseout(function (e) {
			$(this).parent().parent().css("z-index",0);
			$(this).parent().css("z-index",0);
    		$(this).parent().children(".sp_tooltip").hide();
  	})

	$("#sp_single_right_Lists img[title]").tooltip({ predelay:500, position: 'bottom center'});

	$("#afterbasketoverlay").overlay({
		top:260,
		closeOnClick: true,
		load: true
	});

	$('.flashvid').html(function() { 
			vidId = $(this).attr("title");
			$(this).removeAttr("title");
			flashcode = makeflash(vidId, "718", "404");
			return flashcode;
		}
	);
	
	$('.faqvidlink').click(function() { 
			vidId = $(this).attr("rel");
			flashcode = makeflash(vidId, "718", "404");
			$('#faqsvid').html(flashcode);
			/*return false;*/

		}
	);

	$(window).bind("load", function() {
			$(".skim-me").skim();
	});

	// initialize scrollable for thumbs in single article
	$(".scrollable").scrollable();
	if ($('.items img').length > 4)
	{
		 $('.sp_single_left_Thumbs_next').removeClass('disabled');    
	}
	
	$(function() {
		$("div#sp_single_desc_outer ul.tabs").tabs("div#sp_single_desc_outer div.panes > div");
	});
	
	$(function() {
		$("div#faqs ul.tabs").tabs("div#faqs div.panes > div");
	});
	
	
	$("#sp_single_right_sizehint").overlay({
		target: '#sizevid_overlay',
		top:150,
		
		// when overlay is opened, insert swf
		onLoad: function() {
			$(".sizevid").html(makeflash('14178189', "718", "404"));
		},
		
		// when overlay is closed, unload swf
		onClose: function() {
			$(".sizevid").html(' ');
		}
	});
	
	$('.fadein img:gt(0)').hide();
	setInterval(function(){
		$('.fadein :first-child').fadeOut()
		.next('img').fadeIn()
		.end().appendTo('.fadein');
	}, 
	4000);
	
	if(userlang != 'de'){
		$(".translationbox").css('display', 'block');
	}

});
