// ===============================================================
// showDialog(displayText)
// function gets two variables:
// displayText as string and dialogType as string,
// it displays a modal dialog with the displayText and
// there are three forms of dialog depending on
// the dialogType string:
// 'question' will display a question with 'yes' and 'no' 
//           buttons, it will return 1 or 0. 
// 'inform' will display an information message and 
//          will return 0.
// 'input' will display a text box for input and 
//         will return the input string or 0 if it's empty.
// the function uses the file  dialog.asp located in 
// 'includes' folder as the dialog window.
function showDialog(displayText,dialogType)
{	
	
    // checking the input variables:
	if (typeof displayText == "undefined" || typeof dialogType == "undefined")
	{
	   alert("Javascript function showDialog() Error - function has to get 2 variables.")
	   return
	}
    dialogType = dialogType.toLowerCase()
	// checking the dialogType string:
	// (must be 'question' , 'inform' or 'input'
	if (dialogType!="question" && dialogType!="inform" && dialogType!="input")
	{
	   alert("Javascript function showDialog() Error - dialogType value incorrect.")
	   return
	}
	// checking the displayText string 
	// (can't be empty)
	if (displayText.length==0)
	{
	   alert("Javascript function showDialog() Error - displayText value can't be empty.")
	   return
	}	
	if(window.ActiveXObject) /// This is Internet Explorer browser:
	{
			
			// setting the features of the dialog box:
			/////////////////////////////////////////
			var dialogHeight = "165";
			var dialogWidth = "348";
			var scroll = "no";
			var resizable = "no";
			var help = "no";
			var status = "0";
			var dialogFeatures = "";
			var returnVal = 0;
			dialogFeatures = "dialogHeight:" + dialogHeight + "px";
			dialogFeatures += ";dialogWidth:" + dialogWidth + "px"; 
			dialogFeatures += ";scroll:" + scroll;
			dialogFeatures += ";help:" + help; 
			dialogFeatures += ";resizable:" + resizable;
			dialogFeatures += ";status:" + status;
			dialogFeatures += ";unadorned:no"
			/////////////////////////////////////////
			// opening the dialog box and getting the 
			// returned value:
			returnVal = window.showModalDialog(FLIX_PATH + "/js/modalDialog/dialog.asp?dt="+dialogType+"&t="+displayText,window,dialogFeatures);
	}
	else /// Other browser:
	{
		if(dialogType=="question")
			returnVal = confirm(displayText)
		else if(dialogType=="inform")	
		{
			alert(displayText)
			returnVal = 0
			
		}
		else if(dialogType=="input")
			returnVal = prompt(displayText)
	
	}
	/////////////////////////////////////////
	// in any case, the returned value of this function 
	// will be 0, 1 or a string (not empty)
	if(typeof returnVal == "undefined" || returnVal == "")
		return 0;
	else
		return returnVal;	
}

