var g_setLayerLink = false;

function open_layerlink(id,width,height)
{
	//var addr = id;
	var addr = '/script/LayerBlank_pid_' + id + '_b_t.htm';
	
//	document.cookie = id;
	
//	alert(addr);
//	alert(width);
//	alert(height);
	//addr = 'http://www.google.de';

//	window.alert($('#LayerPromotioncode').html());
//	($('#LayerPromotioncode').html('This existing content has been replaced with this content.');

//	alert($('#LayerPromotioncode'));

//$.ajax({
//  url: "test.html",
//  context: document.body,
//  success: function(){
    //$(this).addClass("done");
  //}
//});

// prüfen ob schon angehängt - dann nur öffnen

//cookie_id = Get_Cookie('id');
//alert($('#ContentLayer'));

	if (false)	
		{
			//$('#ContentLayer').fadeIn('slow');	
			//alert('hier');
		}
	else
		{
		$.get(addr, function(data) 
				{		
					$('body').append('<div id="ContentLayer" style="display:none;"><div id="ShowContent"><div id="ShowContentLayerClose"><a onclick="javascript:close_layerlink(\'ContentLayer\');" onMouseover="style.cursor=\'hand\';" onMouseout="this.style.cursor=\'\';" class="s_link" style="text-decoration:none;"><span class="s_text">x</span></a></div><div id="ShowContentLayer"></div></div></div>');
				  
					//$("html").css("overflow", "hidden");
					//$("html").scrollTop(this.pageY);
					
					//$('#ContentLayer').css('visibility', 'visible');						
					//$('#ContentLayer').css('display', 'block');				
					$('#ContentLayer').css('display', 'none');				
					$('#ContentLayer').css('position', 'fixed');				
					
					$('#ContentLayer').css('width', '100%');
					$('#ContentLayer').css('height', '100%');
					$('#ContentLayer').css('z-index', '10000');
					$('#ContentLayer').css('top', '0px');
					$('#ContentLayer').css('left', '0px');
					//$('#ContentLayer').css('top', top  + 'px');
					//$('#ContentLayer').css('left', '0px');		
					//$('#ContentLayer').css("top", ( $(window).height() - $('#ContentLayer').height() ) / 2+$(window).scrollTop() + "px");
					//$('#ContentLayer').css("left", ( $(window).width() - $('#ContentLayer').width() ) / 2+$(window).scrollLeft() + "px");
					
					$('#ContentLayer').css('text-align', 'center');			
					$('#ContentLayer').css('background-image', 'url(/images/background/000000.png)');
					//$('#ContentLayer').css('background-color', '#000000');
					
					$('#ShowContent').css('margin', 'auto');				
					$('#ShowContent').css('padding', '10px');				
					$('#ShowContent').css('text-align', 'left');			
					$('#ShowContent').css('position', 'relative');			
					$('#ShowContent').css('top', '40px');
					$('#ShowContent').css('width', width +'px');
					$('#ShowContent').css('height', height + 'px');
					$('#ShowContent').css('background-color', '#ffffff');
									
					$('#ShowContentLayerClose').css('position', 'relative');
					$('#ShowContentLayerClose').css('float', 'right');
					$('#ShowContentLayerClose').css('text-align', 'right');				
					$('#ShowContentLayerClose').css('width', '100%');				
					
					//data = utf8_decode(data);
					//alert(data);
					$('#ShowContentLayer').html(data);													
					$('#ContentLayer').fadeIn('slow');
				}, "html"
			);
			
			//$("a").click(function(e){
				//e.pageX; 
			//	var scrollTopPos = e.pageY;
					
			//	$("#ShowContentLayerClose").click(function(){
			//		$('#ContentLayer').fadeOut('fast', function() {
						//$("html").css("overflow", "auto");
						//$("html").scrollTop(scrollTopPos);
			//		});
			//	});
			//});			
		}
		
		//g_setLayerLink = true;
		//$("ContentLayer").ajaxComplete(function(event,request, settings){
		//   alert("<li>Request Complete.</li>");
		// });
		//Set_Cookie('id', id, 0);
		
//		$.wait = function( callback, seconds){
//		return window.setTimeout( callback, seconds * 1000 );
//		$.wait( function(){$('#ContentLayer').fadeIn('slow'); }, 5);
//		}

}

function close_layerlink(id,width,height)
{
	
	$('#ContentLayer').fadeOut('slow');
}

function open_internerlink_nw(url,w,h)
	{
	l = Math.round(screen.width/2)-Math.round(w/2);
	t = Math.round(screen.height/2)-Math.round(h/2);
	window.open(url,'','left='+l+',top='+t+',dependent=no,width='+w+',height='+h+',scrollbars=yes,status=no,toolbar=no,menubar=no');
	}

function changeimg(bildname,dateiname)
	{
	document.images[bildname].src=dateiname;
	}

function showpic(id,picture,width,height)
	{
	if (parseInt(width) < 2)
		{
		width  = parseInt(width) + 25;
		height = parseInt(height) + 25;
		}
	else
		{
		width	= 980
		height	= 680
		}
	window.open('/file/'+id+'_'+picture,'cmspicture'+id,'width='+(width)+',height='+(height)+',scrollbars=yes');
	}
	
function showpic_thumbs(bezeichnung,size) 
	{
	var wsize = size+180;
	var hsize = size+10;
	var adresse = '/thumb/'+bezeichnung+'_size_500_sizeby_max_path_abilder.jpg';
	var win = window.open(adresse,'zeige_bild','width='+wsize+'px,height='+hsize+'px,resizable=0,scrollbars=yes,screenX=100,screenY=250');
	win.focus();
	}
	
	
function showpic_thumbs_dennit(bezeichnung,sitzungsid,size) 
	{
	var wsize = size+100;
	var hsize = size+50;
	var adresse = 'http://www.dennit.de/articleimage/fitintostage/'+size+'/'+size+'/'+bezeichnung+'.jpg';
	var win = window.open(adresse,'zeige_bild','width='+wsize+',height='+hsize+',resizable=0,scrollbars=yes,screenX=100,screenY=250');
	win.focus();
	}
	
function showpic_thumbs_std(bezeichnung,size) 
	{
	var wsize = size+180;
	var hsize = size+10;
	var adresse = '/thumb/'+bezeichnung+'_size_500_sizeby_max.jpg';
	var win = window.open(adresse,'zeige_bild','width='+wsize+'px,height='+hsize+'px,resizable=0,scrollbars=yes,screenX=100,screenY=250');
	win.focus();
	}

	
function changeColor(name,color)
{
 element = document.getElementById(name);
 element.style.color = color;
}


function Set_Cookie( name, value, expires)
{
	var today = new Date();
	today.setTime( today.getTime() );

	if (expires)
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
}


function Get_Cookie( check_name ) {

	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );

		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

