﻿//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
** Common java script stuff
**
** $Created: 2007-07-23 12:36 $
** $URL: svn://Server/daLugoWeb/daLugoWeb/www.dalugo.com/js/Common.js $
** $Author: thomas_liljetoft $
** $Date: 2007-06-28 12:41:44 +0200 (Thu, 28 Jun 2007) $
** $Revision: 1983 $
** $ID: $
**
******************************************************************************************************************************/
//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function DoAction( action )
{
	document.getElementById( 'Form' ).Action.value = action;
	document.getElementById( 'Form' ).submit();
}
function DoActionGoTo( action, gotomarker )
{
	document.getElementById( 'Form' ).Action.value = action;
	document.getElementById( 'Form' ).GoToMarker.value = gotomarker;
	document.getElementById( 'Form' ).submit();
}


//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function DoIdAction( id, action )
{
	document.getElementById( 'Form' ).Id.value = id;
	document.getElementById( 'Form' ).Action.value = action;
	document.getElementById( 'Form' ).submit();
}
function DoId2ActionGoTo( id, action, gotomarker )
{
	document.getElementById( 'Form' ).Id2.value = id;
	document.getElementById( 'Form' ).Action.value = action;
	document.getElementById( 'Form' ).GoToMarker.value = gotomarker;
	document.getElementById( 'Form' ).submit();
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function ConfirmAction( action, what )
{
	var bOk = confirm( what );
	if( bOk )
	{
		document.getElementById( 'Form' ).Action.value = action;
		document.getElementById( 'Form' ).submit();
	}
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function ConfirmIdAction( Id, action, what )
{
	var bOk = confirm( what );
	if( bOk )
	{
		document.getElementById( 'Form' ).Id.value = Id;
		document.getElementById( 'Form' ).Action.value = action;
		document.getElementById( 'Form' ).submit();
	}
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function DoActionOnCRLFEvent( event, action )
{
	var keynum;

	if( window.event ) // IE
	{
		keynum = event.keyCode;
	}
	else if( event.which ) // Netscape/Firefox/Opera
	{
		keynum = event.which;
	}

	if( keynum == 13 )
	{
		document.getElementById( 'Form' ).Action.value = action;
		document.getElementById( 'Form' ).submit();
	}
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function MaxChars()
{
	if( document.getElementById( 'Form' ).Comment.value.length > 300 )
	{
		document.getElementById( 'Form' ).Comment.value = document.getElementById( 'Form' ).Comment.value.substr( 0, 300 );
	}
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function RemoveList( id )
{
	document.getElementById( 'Form' ).Action.value = "RemoveList";
	document.getElementById( 'Form' ).ListId.value = id;
	document.getElementById( 'Form' ).submit();
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function AddList( id )
{
	document.getElementById( 'Form' ).Action.value = "AddList";
	document.getElementById( 'Form' ).ListId.value = id;
	document.getElementById( 'Form' ).submit();
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function RemoveAllList( id )
{
	document.getElementById( 'Form' ).Action.value = "RemoveAllList";
	document.getElementById( 'Form' ).ListId.value = id;
	document.getElementById( 'Form' ).submit();
}

//-----------------------------------------------------------------------------------------------------------------------------
/******************************************************************************************************************************
**
**/
function AddAllList( id )
{
	document.getElementById( 'Form' ).Action.value = "AddAllList";
	document.getElementById( 'Form' ).ListId.value = id;
	document.getElementById( 'Form' ).submit();
}

function CalcMenuCost()
{
	var admission = new Number( document.getElementById( 'Form' ).AdmissionFee.value );
	var food = new Number( document.getElementById( 'Form' ).FoodFee.value );
	document.getElementById( 'Form' ).CompanyTotal.value = admission + food;
	document.getElementById( 'Form' ).Total.value = admission + food;
}

function CheckIfNumeric( inp )
{
	var num = inp.value;
	if( num.length > 0 )
	{
		var keynum = num.charAt( num.length - 1 );
		if( keynum < '0' || keynum > '9' )
		{
			inp.value = num.substr( 0, num.length - 1 );
		}
	}
}
