	var widgetPath='http://www.touropa.com/tp/countdown/layouts/';
	var constWoche=604800, constTag=86400, constStunde=3600, constMinute=60;
	var t_diff=0, resInterval=0;
				
	if (typeof (creationMode)=='undefined') {
		var saveOnload=window.onload;
		window.onload=function () {
			initCounter (counter);
			if (typeof (saveOnload)=='function') saveOnload ();
		}
	}
	
	var STR_PAD_RIGHT=0, STR_PAD_LEFT=1, STR_PAD_BOTH=2;	
	String.prototype.strpad = function () {
		var retValue=new String(this);
		switch (arguments.length) {
			case 0:	return (retValue); break;
			case 1: strPadChar=' '; intPadLength=arguments[0]; strPadPosition=STR_PAD_RIGHT; break;
			case 2: strPadChar=arguments[1].substr (0,1); intPadLength=arguments[0]; strPadPosition=STR_PAD_RIGHT; break;
			case 3: strPadChar=arguments[1].substr (0,1); intPadLength=arguments[0]; strPadPosition=arguments[2]; break;
		}

		switch (strPadPosition) {
			case 0: for (var dummy=this.length; dummy<intPadLength; dummy++) retValue+=strPadChar; break;
			case 1: for (var dummy=this.length; dummy<intPadLength; dummy++) retValue=strPadChar+retValue; break;
			case 2: for (var dummy=this.length; dummy<intPadLength; dummy+=2) { retValue+=strPadChar; if (retValue.length==intPadLength) break; retValue=strPadChar+retValue; } break;
		}

		return (retValue);
	}	
  
	function initCounter (counter) {
	
		if (document.getElementById ('t_uw').innerHTML.search (/touropa/)==-1) {
			var link=document.createElement ('DIV');
			with (link) {
				id='t_lnk';
				innerHTML='von <A href="http://www.big-systems.net/webshop" title="">BIG-SYSTEMS</A>';
			}
			document.getElementById ('t_uw').appendChild (link);
		}
  		
		if (typeof (creationMode)=='undefined') {
			var css=document.createElement ('link');
			with (css) {
				type='text/css';
				href=widgetPath+template+'_'+size+'.css';
				rel='stylesheet';
			}		
			document.getElementsByTagName ('head')[0].appendChild (css);
		}
	
		t_diff=counter-parseInt ((new Date ()).getTime ()/1000);
		if (resInterval) window.clearInterval (resInterval);
		resInterval=window.setInterval ('showCount ()', 1000);
	}
  
	function showCount () {
		t_diff--;
		if (t_diff<=0 && typeof (creationMode)=='undefined') {
			document.getElementById ('end_screen_ta').style.visibility='visible';
			document.getElementById ('count_screen').style.visibility='hidden';
			window.clearInterval (resInterval);
		} else if (t_diff<=0 && typeof (creationMode)!='undefined') {
			window.clearInterval (resInterval);
		} else {
			var t_diff_splitted=t_diff;
			var dummyStr;

			dummyStr=Math.floor (t_diff_splitted/constWoche)+'';
			document.getElementById ('t_wo').innerHTML=dummyStr.strpad (2, '0', STR_PAD_LEFT);
			t_diff_splitted%=constWoche;
			
			dummyStr=Math.floor (t_diff_splitted/constTag)+'';
			document.getElementById ('t_tag').innerHTML=dummyStr.strpad (2, '0', STR_PAD_LEFT);
			t_diff_splitted%=constTag;
			
			dummyStr=Math.floor (t_diff_splitted/constStunde)+'';
			document.getElementById ('t_std').innerHTML=dummyStr.strpad (2, '0', STR_PAD_LEFT);
			t_diff_splitted%=constStunde;
			
			dummyStr=Math.floor (t_diff_splitted/constMinute)+'';
			document.getElementById ('t_min').innerHTML=dummyStr.strpad (2, '0', STR_PAD_LEFT);
			t_diff_splitted%=constMinute;
			
			dummyStr=t_diff_splitted+'';
			document.getElementById ('t_sek').innerHTML=dummyStr.strpad (2, '0', STR_PAD_LEFT);
			
		}
	}
