/*
--------------------------------------------------------------------------------
|	MODULE				: WM
|	FILENAME			: Common03
|	FUNCTION			: Common JavaScript Functions for WM Web Module
|	PARAMETERS			: None
|	AUTHOR				: Bobby Kotzev
|	DATE				: 6/6/01
--------------------------------------------------------------------------------
|	MODIFICATIONS:
|
|	04/18/2002			: Rossen Totev
|						  Added Title to ImageButtons
|
--------------------------------------------------------------------------------
*/


//--------------------------------------------------------------------------------
// Returns Random String, which is attached to all the url's as random parameter in 
// order to bypas proxy and local chaches of the pages.
//--------------------------------------------------------------------------------
function RandomFactor()
{
  return Math.round(Math.random() *1000000000);
}
		
function ImageButton(Name, Caption, OnClickEvent, btnWidth, CaptionImage, TopOffset, Title)
{
  var def = "'default';";
  document.write('<button type="button" name="' +Name+ '" id="' +Name +'" onClick="javascript: if(!this.disabled) ' +OnClickEvent +'" style="width:' +btnWidth +'; height:' +Math.min(btnWidth, 24) +'; background-repeat: no-repeat; font-weight:bold; " ' + (Title ? 'title = "' + Title + '"': '') + '>' +
					 (CaptionImage ? '<img id="' + Name + '_captionimage" src="' +CaptionImage +'">' : '') +         
					  Caption +
				  '</button>');

  var btn = document.all(Name);
  btn.style.pixelWidth = btnWidth;
      
  return btn;
}

//--------------------------------------------------------------------------------
// Returns the html code for creating a button with the passed parameters
//--------------------------------------------------------------------------------
function ImageButtonHTML(Name, Caption, OnClickEvent, btnWidth, CaptionImage, TopOffset, Title)
{
  var def = "'default';";
  return '<button type="button" name="' +Name+ '" id="' +Name +'" onClick="javascript: if(!this.disabled) ' +OnClickEvent +'" style="width:' +btnWidth +'; height:' +Math.min(btnWidth, 24) +'; background-repeat: no-repeat; font-weight:bold; " ' + (Title ? 'title = "' + Title + '"': '') + '>' +
					 (CaptionImage ? '<img id="' + Name + '_captionimage" src="' +CaptionImage +'">' : '') +         
					  Caption +
				  '</button>';
}

//--------------------------------------------------------------------------------
// Changes the disabled status of a button together with its image
//--------------------------------------------------------------------------------
function btnDisable(btn, IsDisabled)
{
  btn.disabled = IsDisabled;  
}

