// JavaScript Document

function $(id) {
	return document.getElementById(id);	
}

function pageRecommend(what) {
	newWindow = open(ptr + '/recommend/'+what, "newWindow", 'width=375,height=580,left='+(screen.width/2-150)+',top='+(screen.height/2-150));
}

function lineupToggleDescription (icon) {
	var container = document.getElementById('description_' + icon);	
	var arrow = document.getElementById('arrow_' + icon);	
	if (container.style.display == 'none') {
		container.style.display = 'block';
		arrow.src = ptr + '/../global/images/page/arrow_white_down.png';
	}
	else {
		container.style.display = 'none';
		arrow.src = ptr + '/../global/images/page/arrow_white.png';
	}
}

function pageLightviewVideo(video, video_width, video_height) {
	var video_content = '<div id="mediaspace"></div>';
	new lightviewClass({close_type: 'img', style: {width: video_width + 'px', height: video_height + 'px'}}, video_content); 
	
	  var so = new SWFObject(ptr + '/../global/movies/jwplayer-5.4/player.swf', 'mpl', video_width, video_height, '9', '#000000');
	  so.addParam('allowfullscreen','true');
	  so.addParam('allowscriptaccess','always');
	  so.addParam('wmode','opaque');
	  so.addVariable('file', ptr + '/../global/movies/' + video);
	  so.addVariable('controlbar','over');
	  so.addVariable('autostart','true');
	  so.write('mediaspace');
	
} 
function pageLightviewLeafthrough() {
	var leafthrough_content = '<iframe src="' + ptr + '/../global/blaetterkatalog/index.html" style="width:800px; height:600px;" frameborder="0"  allowtransparency="true"/>';
	new lightviewClass({close_type: 'text', style: {width: '800px', height: '600px'}}, leafthrough_content); 
}

var slider_ext = false;
function slider(container_id, orig_width, ext_width, options) {
	var effect = new Effect.Class(options);
	var container = document.getElementById(container_id);
	var delta_width = ext_width - orig_width;
	var cur_width = parseInt(container.style.width);
	var target_width;
	var action = '';
	if (cur_width <= orig_width + delta_width / 2) {
		target_width = ext_width - cur_width; 
		slider_ext = true;
	}
	else {
		target_width = - cur_width + orig_width; 
		slider_ext = false;
	}
	effect.transform = function(pos) {
		container.style.width = cur_width + Math.round(target_width * pos) + 'px'; 
	}
	effect.init();
}

function langbar_slider(ext_width) {
	slider('menu_langbar', 0, ext_width, {duration: 0.5, transition: 'log'});
}
