/* Aircraft Info Desk global Javascript library 
 * Author: Ingo Battis 
 */


/**************************************************************************************/
var $F = function(obj)
{
	return $(obj).val(); 
}

/**************************************************************************************/
function US_swapImage()
{
	$('#LAY_UserStatusImg').attr('src', $js_LAY_preToLayout+"AnHover.gif");
}


/**************************************************************************************/
function US_restoreImage()
{
	$('#LAY_UserStatusImg').attr('src', $js_LAY_preToLayout+"AnNormal.gif");
}


/**************************************************************************************/
function InfoWin($id)
{
	infoWin = window.open($js_SRV_websitePath+'infotext.php?_id='+$id,'','width=500,height=300,scrollbars,resizable');
	if (screen.width<=1024)
	{
		infoWin.moveTo(1,1);
		infoWin.focus();
	}
}


/**************************************************************************************/
function MemWindow($mid)
{
	memWindow = window.open($js_SRV_websitePath+'member/memberpopup.php?_mid='+$mid,'','width=400,height=300,scrollbars=0,resizable');
}


/**************************************************************************************/
function PriWindow(url)
{
	priWindow = window.open(url,'','width=800,height=600,scrollbars,resizable');
	priWindow.moveTo(1,1);
}


/**************************************************************************************/
function GLB_showNotepadWait()
{
	$('#notepadwait').css({'left' : 130});
	$('#notepadwait').css({'top' : $(window).scrollTop() + 200});
	document.notepadExec.submit();
	$('#notepadwait').show(); 
}


/**************************************************************************************/
function GLB_aidNewsInitDropIn() 
{
	if (LAY_aidNewsDropBoxXOffs > 0)
	{
		$('#dropbox').css({'left' : LAY_aidNewsDropBoxXOffs});
	}
	else 
	{
		$('#dropbox').css({'left' : ($(window).width() - $('#dropbox').width() + LAY_aidNewsDropBoxXOffs)});
	}
	$('#dropbox').css({'top' : (0 - $('#dropbox').height())});
	$('#dropbox').show(); 

	GLB_aidNewsDropIn();
}


/**************************************************************************************/
function GLB_aidNewsInitStatic() 
{
	if (LAY_aidNewsDropBoxXOffs > 0)
	{
		$('#dropbox').css({'left' : LAY_aidNewsDropBoxXOffs});
	}
	else 
	{
		$('#dropbox').css({'left' : ($(window).width() - $('#dropbox').width() + LAY_aidNewsDropBoxXOffs)});
	}
	$('#dropbox').show(); 

	aidNewsTimer = setTimeout("GLB_aidNewsDropIn()", 20000);
}


/**************************************************************************************/
function GLB_aidNewsDropIn()
{
	var pos = $('#dropbox').offset();

	if (pos.top < LAY_aidNewsDropBoxYOffs)
	{
		if ((pos.top + 10) > LAY_aidNewsDropBoxYOffs)
			$('#dropbox').css({'top' : LAY_aidNewsDropBoxYOffs});
		else
			$('#dropbox').css({'top' : (pos.top + LAY_aidNewsDropBoxYOffs)});
		aidNewsTimer = setTimeout("GLB_aidNewsDropIn()", 50);
	}
	else 
	{
	  clearTimeout(aidNewsTimer);
	  $('#dropboxcontent').css({'background-color': 'black'});
	  aidNewsTimer = setTimeout("GLB_aidNewsClearDropper()", 100);
	  aidNewsState = 2; 
	}
}


/**************************************************************************************/
function GLB_aidNewsClearDropper()
{
  if (aidNewsState == 2)
  {
  	aidNewsState--;
	  $('#dropboxcontent').css({'background-color': 'white'});
	  aidNewsTimer = setTimeout("GLB_aidNewsClearDropper()", 100);
  }
  else if (aidNewsState == 1)
  {
  	aidNewsState--;
	  $('#dropboxcontent').css({'background-color': 'black'});
	  aidNewsTimer = setTimeout("GLB_aidNewsClearDropper()", 100);
  }
  else 
  {
	  $('#dropboxcontent').css({'background-color': 'white'});
		aidNewsTimer = setTimeout("GLB_aidNewsDropIn()", 20000);
  }
}


/**************************************************************************************/
function GLB_autoComplete(searchField, selectField)
{
	var found = false;

	$(selectField+' option').each(function (index) {
		if ($(this).text().toUpperCase().indexOf($(searchField).val().toUpperCase()) == 0)
		{
			if (!found)
			{
				$(selectField).val($(this).val());
			}
			found=true; 
		}
	});
}

/**************************************************************************************/
GLB_DoubleSubmitCount = 0;
function GLB_CheckDoubleSubmit()
{
	GLB_DoubleSubmitCount++;
	if (GLB_DoubleSubmitCount == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/**************************************************************************************/
function GLB_submitShowProgressbar(formid)
{
	$('#LAY_progressbar').css({'left' : 130});
	$('#LAY_progressbar').css({'top' : $(window).scrollTop() + 200});
	$(formid).submit(); 
	$('#LAY_progressbar').show();
}

