function showWaiting() {
	arrOffsets = document.viewport.getScrollOffsets();
	$('waitingDiv').setStyle({display: 'block', top: (arrOffsets['top']+100)});
}

function removeWaiting() {
	$('waitingDiv').setStyle({display: 'none'});
}

// ###############################################################################

function showTrans() {
	arrOffsets = document.viewport.getScrollOffsets();
	$('transDiv').setStyle({display: 'block', top: (arrOffsets['top'])});
}

function _removeTrans() {
	$('transDiv').setStyle({display: 'none'});
}

// ###############################################################################

function showIframe() {
	$('iframeDiv').setStyle({display: 'block', left: ((document.viewport.getWidth()-650)/2)});
	$('outerContainer').scrollTo();
	showTrans();
}

function _removeIframe() {
	$('iframeDiv').setStyle({display: 'none'});
}

// ###############################################################################

function reportError(transport) {
	initNotice(0, 'Fehler!', transport.responseText, false);
  //alert("Error: "+transport.responseText);
}

function reportSuccess(transport, f_blnReload) {
  showIframe();
  if (f_blnReload) location.reload();
}

function reportNone(transport, f_blnReload) {
  //alert("Error: "+transport.responseText);
  if (f_blnReload) location.reload();
}

// ###############################################################################

/**
* Login
*/
function _openIframe() {
	var container = 'iframeDiv';
	var url = './res/ajax/iframe.php';
	var ajax = new Ajax.Updater(container, url, {
		onCreate: function(transport) {showWaiting();},
		onFailure: function(transport) {reportError(transport);}, 
		onSuccess : function(transport) {reportSuccess(transport, false);}, 
		onComplete: function(transport) {removeWaiting();}
	});
}

var blnPreloaded = true;
function preloadIframe() {
	$.ajax({
		url: './res/ajax/iframe.php',
		cache: false,
		dataType: "html", 
		beforeSend: function(html){
			$('#iframeDiv').empty();
			//showWaiting(div);
		},
		success: function(html, status){
			//alert("Success: " + status);
			//$(div).append(html);
		},
		error: function(html, status) {
			//alert("Error: " + status);
		},
		complete: function(xhr, status) {
			//alert("Complete: " + status);
			if (status == "success") {
				$('#iframeDiv').append(xhr.responseText);
        //$('#iframeDiv').hide();
			}
			//removeWaiting(div);
		}
	});
}

function openIframe() {
	if (blnPreloaded) {
	  $('#iframeDiv').hide();
	  $('#iframeDiv').css('top','380px');
    $('#iframeDiv').fadeIn('slow');
  	blnPreloaded = false;
  }
	else openIframe_Reload();
}

function openIframe_Reload() {
	$.ajax({
		url: './res/ajax/iframe.php',
		cache: false,
		dataType: "html", 
		beforeSend: function(html){
			$('#iframeDiv').empty();
			//showWaiting(div);
		},
		success: function(html, status){
			//alert("Success: " + status);
			//$(div).append(html);
		},
		error: function(html, status) {
			//alert("Error: " + status);
		},
		complete: function(xhr, status) {
			//alert("Complete: " + status);
			if (status == "success") {
				$('#iframeDiv').hide().append(xhr.responseText).fadeIn('slow');
			}
			//removeWaiting(div);
		}
	});
}

function removeIframe() {
	$('#iframeDiv').hide();
}

function removeTrans() {
	$('#transDiv').hide();
}

// ###############################################################################

$(document).ready(function(){
	myOuterHeight = $('#outerContainer').height();
	$('#leftCol').css('height', myOuterHeight+'px');
	$('#middleCol').css('height', myOuterHeight+'px');
	
	$('#twitterContainer').css('cursor', 'pointer').click(function(){
		document.location.href = "./";
	});
  preloadIframe();
});

