// JavaScript Document

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

function makeflash(vidId, width, height){
	flashcode  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="iVideoPlayer" width="'+width+'" height="'+height+'" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	flashcode += '<param name="movie" value="http://weconda.plaspix-ivideo.de/ply/v01/iVideoPlayer002.swf"/>';
	flashcode += '<param name="quality" value="high"/>';
	flashcode += '<param name="wmode" value="opaque" />';
	flashcode += '<param name="allowScriptAccess" value="always"/>';
	flashcode += '<param name="allowFullScreen" value="true"/>';
	flashcode += '<param name="FlashVars" value="serverUrl=weconda.plaspix-ivideo.de&key='+vidId+'"/>';
	flashcode += '<embed src="http://weconda.plaspix-ivideo.de/ply/v01/iVideoPlayer002.swf"';
	flashcode += 'quality="high"';
	flashcode += 'width="'+width+'"';
	flashcode += 'height="'+height+'"';
	flashcode += 'name="iVideoPlayer"';
	flashcode += 'align="left"';
	flashcode += 'play="true"';
	flashcode += 'loop="false"';
	flashcode += 'FlashVars="serverUrl=weconda.plaspix-ivideo.de&key='+vidId+'"';
	flashcode += 'allowScriptAccess="sameDomain"';
	flashcode += 'type="application/x-shockwave-flash"';
	flashcode += 'allowFullScreen="true"';
	flashcode += 'wmode="transparent"';
	flashcode += 'pluginspage="http://www.adobe.com/go/getflashplayer"/>';
	flashcode += '</object>';
	return flashcode;
}


$(document).ready(function() {
	$("#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();
	
	$(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('00767f8e19f586122b802d748126635f2a19', "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);


});
