function getColor(f) {
   var color = new Array (
	'0x0078b4',
	'0x99c9e1'
   );

   if (f!='') {
   	  //alert(f);
	if (f == 'yellow') {
		 color = new Array (
			'0xf9ba66',
			'0xfde3c2'
		 );
	}
	if (f == 'blue') {
		 color = new Array (
			'0x0078b4',
			'0x99c9e1'
		);
	}
	if (f == 'green') {
		 color = new Array (
			'0x556c60',
			'0xaabcb3'
		 );
	}

   }	
	return(color);
}


function runVorschau() {			
	//SNIP
	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
	     && typeof document.documentElement.clientWidth !=
	     'undefined' && document.documentElement.clientWidth != 0)
	 {
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	//alert('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
	//SNAP
	
	var flashwidth=830;
	var flashheight=635;
	
	var targetwidth=parseInt(viewportwidth*0.95);
	targetheight=parseInt(targetwidth*flashheight/flashwidth);
	
	if(targetheight>(viewportheight*0.95)) {
		targetheight=parseInt(viewportheight*0.95);
		targetwidth=parseInt(targetheight*flashwidth/flashheight);
		//alert("by height");
	} else {
		//alert("by width");
	}
	/*
	marginheight=parseInt(((viewportheight-targetheight)/2)*1.2); //
	marginwidth= parseInt(((viewportwidth -targetwidth )/2));
	
	if(viewportwidth<1000) marginwidth+=parseInt((1000-viewportwidth)/2);
	if(viewportwidth>1000) marginwidth=0;
	
	if(viewportheight<850) marginheight+=parseInt((850-viewportheight)/2);
	*/
	
	
	var flashvars = {};
	var urlparams=document.location.search.split("&");
	//alert(urlparams);
	
	var auftakt=urlparams[1].split("=");
	auftakt=auftakt[1];
	
	var color=urlparams[2].split("=");
	color=color[1];
	
	
	color=getColor(color);
	
	if(auftakt=='rechts') auftakt='right';
	else auftakt='left';

	//alert(color+" auftakt:"+auftakt);
	
	
	flashvars._color = color[0];
	flashvars._color2 = color[1];
	flashvars.start_pos =auftakt;
	var params = {};
	params.menu = "false";
	params.quality = "best";
	params.scale = "noscale";
	params.salign = "tl";
	params.wmode = "window";
	params.allowscriptaccess = "always"; // sameDomain
	params.allowFullScreen="true";
	params.bgcolor = "363636"; 
	var attributes = {};
	
	var c=0;
	var log='';
	var swf='';
	while(urlparams.length>c) {
		//log+=(c+'='+urlparams[c]+"..");
		zwi=urlparams[c].split("=");
		if(zwi[0]=='swf' || zwi[0]=='?swf') swf=zwi[1];
		c++;
	}
	//alert(log+"!!"+swf);
	
	swfobject.embedSWF(swf, "myAlternativeContent", ""+targetwidth, ""+targetheight, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

function closeApi() {
	parent.$.fn.colorbox.close();
}

$(document).ready(function() {
		runVorschau();
});
