/*
	24.05.2007, mJ:	subscribe
	
	21.07.2008, mJ:	more cookie functions from 
					http://www.quirksmode.org/js/cookies.html

	21.02.2010, mJ:	allg tabs-Initialisierungen hier
	
	14.01.2011, mJ:	decodeURIComponent override
*/

_decodeURIComponent = decodeURIComponent;

decodeURIComponent = function ( arg )
//	override globally because jquery.jquery uses it
//	and decodeURIComponent fails on iso chars
{
	try {
		return _decodeURIComponent( arg );	
	} catch( err ) {
		return unescape( arg );				
	}
};


var	popUp;

function openPopUp( url, windowname, WIDTH, HEIGHT )
{
	var x;
	var y;

	if( popUp && !popUp.closed ) 
		popUp.close();

	if( document.all ) {
    	x = window.screenLeft;
		y = window.screenTop;
	} else {
		x = window.screenX;
		y = window.screenY;
	}


	x = Math.round( (screen.availWidth - WIDTH) / 2 ) ;
	y = Math.round( (screen.availHeight - HEIGHT) / 2 );

	popUp = window.open( url, windowname,'width='+WIDTH+',height='+HEIGHT+',top='+y+',left='+x+',resizable=yes,scrollbars=no' );
	return false;
}


function openScrollPopUp( url, windowname, WIDTH, HEIGHT )
{
	var x;
	var y;

	if( popUp && !popUp.closed ) 
		popUp.close();

	if( document.all ) {
    	x = window.screenLeft;
		y = window.screenTop;
	} else {
		x = window.screenX;
		y = window.screenY;
	}


	x = Math.round( (screen.availWidth - WIDTH) / 2 ) ;
	y = Math.round( (screen.availHeight - HEIGHT) / 2 );

	popUp = window.open( url, windowname,'width='+WIDTH+',height='+HEIGHT+',top='+y+',left='+x+',resizable=yes,scrollbars=yes' );
	return false;
}

function select_language_id( language_id )
{
	createCookie( 'LANGUAGE_ID', language_id, 365 );
	window.location.reload();
}


// preliminary cookie-functions

function GetCookie( t_cookie_name )
{
		var t_cookies = document.cookie;

		t_cookies = t_cookies.split( ";" );

		var i = 0;
		while( i < t_cookies.length ) {
				var t_cookie = t_cookies[ i ];

				t_cookie = t_cookie.split( "=" );

				if ( Trim( t_cookie[ 0 ] ) == t_cookie_name ) {
						return( t_cookie[ 1 ] );
				}
				i++;
		}

		return -1;
}

function SetCookie( t_cookie_name, p_value )
{
		var t_expires = new Date();

		t_expires.setTime( t_expires.getTime() + (365 * 24 * 60 * 60 * 1000));

		document.cookie = t_cookie_name + "=" + p_value + "; expires=" + t_expires.toUTCString() + ";";
}


var subscribeWin = 0;

function subscribe( form, url )
{
	if( form.email.value == '' ) {
		alert( "Please enter your e-mail address!" );
		return false;
	}

	if( subscribeWin && !subscribeWin.closed )
		subscribeWin.close();

	if( document.all ) {
    	var x = window.screenLeft;
		var y = window.screenTop;
	} else {
		var x = window.screenX;
		var y = window.screenY;
	}

	var WIDTH  = 1024;
	var HEIGHT = 450;

	var x = Math.round( (screen.availWidth - WIDTH) / 2) ;
	var y = Math.round( (screen.availHeight - HEIGHT) / 2);

	var arg = form.email.value;

	subscribeWin = window.open( url + '?BUTTON=1&email='+arg, 'subscription',
				'width='+WIDTH+',height='+HEIGHT+',top='+y+',left='+x+',resizable=yes,scrollbars=no' );

	return false;
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



$(document).ready(
	function()
	{
		$( ".tabs" ).tabs( {
// 			fx: { opacity: 'toggle', duration: 'fast' } 
		} );
	}
);

