//
// Function to Delete a cookie
//
function DelCookie(sName)
{
  document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

//
// Function to Delete a cookie
//
function SetCookie(sName, sValue)
{
	var date = new Date();
	date.setFullYear(2199,1,1);
	document.cookie = sName + "=" + escape(sValue) + "; expires="+date.toUTCString()+";";
}

//
// Pops up a Modal Dialog containing "message", and return 
// Very Similar to the window.alert( message ), except that the 
// Ok button caption is customizable, the style is also cutomizable
// IMPORTANT NOTE: this currently works on ** INTERNET EXPLORER 5+ ONLY ** 
function CustomAlert( message, title, OkCaption, width, height, dialogURL )
{
	if( ! (navigator.appName.indexOf("Microsoft") >= 0) ) { alert( message ); return; };

	// Make sure height and width of dialog are ok.
	var w = parseInt( width );
	var h = parseInt( height );
	if ( isNaN( w ) ) w = 320; if( w < 320 ) w = 320;
	if ( w > screen.width ) w = screen.width;
	if ( isNaN( h ) ) h = 120; if( h < 120 ) h = 120;
	if ( h > screen.height ) h = screen.height;
	
	// Initialize URL
	var sURL = dialogURL ? dialogURL : "CustomDialog.html";
	
	// Initialize Arguments
	var vArguments = Array();
	vArguments["Message"] = message;
	vArguments["OkCaption"] = OkCaption;
	vArguments["Title"] = title;
	vArguments["DialogType"] = "Alert";
	
	// The width, height and other features of the dialog
	var sFeatures = "dialogHeight: "+h+"px; dialogWidth: "+w+"px; edge: Raised; center: yes; help: no; resizable: no; status: no; menu: no";
	
	// Open Dialog and Return 
	// (true if confirmed, false if not or if closed)
	window.showModalDialog(sURL, vArguments, sFeatures);
}


//
// Pops up a Modal Dialog containing "message", and return 
// Very Similar to the window.confirm( message ), except that the 
// Ok and Cancel buttons captions are customizable, the style is also cutomizable
// IMPORTANT NOTE: this currently works on ** INTERNET EXPLORER 5+ ONLY ** 
function CustomConfirm( message, YesCaption, NoCaption, title, width, height, dialogURL )
{
	if( ! (navigator.appName.indexOf("Microsoft") >= 0) ) return confirm( message );

	// Make sure height and width of dialog are ok.
	var w = parseInt( width );
	var h = parseInt( height );
	if ( isNaN( w ) ) w = 320; if( w < 320 ) w = 320;
	if ( w > screen.width ) w = screen.width;
	if ( isNaN( h ) ) h = 120; if( h < 120 ) h = 120;
	if ( h > screen.height ) h = screen.height;
	
	// Initialize URL
	var sURL = dialogURL ? dialogURL : "CustomDialog.html";
	
	// Initialize Arguments
	var vArguments = Array();
	vArguments["Message"] = message;
	vArguments["YesCaption"] = YesCaption;
	vArguments["NoCaption"] = NoCaption;
	vArguments["Title"] = title;
	vArguments["DialogType"] = "Confirm";
	
	// The width, height and other features of the dialog
	var sFeatures = "dialogHeight: "+h+"px; dialogWidth: "+w+"px; edge: Raised; center: yes; help: no; resizable: no; status: no; menu: no";
	
	// Open Dialog and Return 
	// (true if confirmed, false if not or if closed)
	var vReturnValue = window.showModalDialog(sURL, vArguments, sFeatures);
	return vReturnValue;
}


//Default Button
function SetDefaultButton(btnID, event)
{
	if(event.keyCode == 13)
	{
		event.returnValue = false;
		event.cancel = true;
		document.getElementById(btnID).click();
	}
}
