var DialogOptions = 'center: yes; ' +
						  'resizable: no; ' +
						  'scroll: no; ' +
						  'status: no; ' +
						  'help: no; ' +
						  'minimize: yes; '

var WindowOption = 'toolbar=no, ' +
                   'location=no, ' +
                   'directories=no, ' +
                   'status=no, ' +
                   'scrollbars=no, '

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
                    
function OpenDialog(URL, DialogAruments, Width, Height, Modal)
{
	var Options = DialogOptions +
					  'dialogWidth: ' + Width + 'px; ' + 
					  'dialogHeight: ' + Height + 'px;'
	if (Modal)
		return window.showModalDialog(URL, DialogAruments, Options);
	else
		return window.showModelessDialog(URL, DialogAruments, Options);
}

function OpenWindow(URL, WindowName, Width, Height, Resizable)
{
	var Left = (screen.width - Width) / 2;
	var Top = (screen.height - Height) / 2;

	var Options = WindowOption +
					  'top=' + Top + ', ' + 
					  'left=' + Left + ', ' + 
					  'width=' + Width + ', ' + 
					  'height=' + Height;
	
	if (Resizable)
		Options = Options + ', resizable=yes;'
	else	
		Options = Options + ', resizable=no;'	
				  
	return window.open(URL, WindowName, Options);
}

function ResizeWindowByContentX(Dialog, Move)
{
	var Difference = document.body.scrollWidth - document.body.clientWidth;
	
	if (Dialog)
	{
		window.dialogWidth = (eval(window.dialogWidth.slice(0, window.dialogWidth.length - 2)) + Difference) + 'px';
		if (Move) window.dialogLeft = (eval(window.dialogLeft.slice(0, window.dialogLeft.length - 2)) - (Difference / 2)) + 'px';
	}
	else
	{
		window.resizeBy(Difference, 0);
		if (Move) window.moveBy(-1 * (Difference / 2), 0);
	}
}

function ResizeWindowByContentY(Dialog, Move)
{
	var Difference = document.body.scrollHeight - document.body.clientHeight;

	if (Dialog)
	{
		window.dialogHeight = (eval(window.dialogHeight.slice(0, window.dialogHeight.length - 2)) + Difference) + 'px';
		if (Move) window.dialogTop = (eval(window.dialogTop.slice(0, window.dialogTop.length - 2)) - (Difference / 2)) + 'px';
	}
	else
	{
		window.resizeBy(0, Difference);
		if (Move) window.moveBy(0, -1 * (Difference / 2));
	}
	
	return window.dialogHeight;
}

function ResizeWindowByContent(Dialog, Move)
{
	ResizeWindowByContentX(Dialog, Move);
	ResizeWindowByContentY(Dialog, Move);
}

function OpenPermissionError(RootPath)
{
	var URL = 'security/permission_error.aspx';
	var DialogAruments = null;	
	var Width = 250;
	var Height = 120;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}


function OpenPrintMainPage(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - content_url

	if (!Parameters[0]) Parameters[0]=0;
	var URL =  RootPath + 'print/index.aspx?content_url='+Parameters[0]; 
	var Options = 'center: yes; ' +
					  'resizable: yes; ' +
					  'scroll: no; ' +
				  	  'status: no; ' +
					  'help: no; ' +
					  'minimize: yes;' +
					  'maximize: yes;' +
					  'dialogWidth: 720px; ' + 
					  'dialogHeight: 500px;'
	return window.showModalDialog(URL, null, Options);		
}	


function OpenInfoPage(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Page Name

	if (!Parameters)
		Parameters = new Array();
		
	//for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
	//	 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	if (!Parameters[0]) Parameters[0] = 'info_pages/info1.htm';	 	
	
	var URL = Parameters[0]; 
	
	top.frames.MainFrame.document.location.href = URL;
}

function OpenMenuPage(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Page Name

	if (!Parameters)
		Parameters = new Array();
		
	//for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
	//	 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	if (!Parameters[0]) Parameters[0] = 'blank.htm';	 	
	
	var URL = Parameters[0]; 
	
	top.frames.main_frame.document.location.href = URL;
}
	
function OpenMain(Parameters, RootPath)
{
	//Parameters array indexes :
	//None
	
	var URL =  'main.aspx'; 
	
	var DialogAruments = null;	
	var Width = 780;
	var Height = 550;
	//return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
	return OpenWindow(RootPath + URL, 'main', Width, Height, true);
}	

	
function OpenFile(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - file_id

	if (!Parameters[0]) Parameters[0]=0;
	
	var URL =  'files/edit.aspx?file_id='+Parameters[0]; 
	
	var DialogAruments = null;	
	var Width = 760;
	var Height = 150; //536;
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
	//return OpenWindow(RootPath + URL, "Files", Width, Height, true);
}	

function OpenReportsList(Parameters, RootPath)
{
	var URL = 'reports/index.aspx';
	var DialogAruments = null;	
	var Width = 530;
	var Height = 583;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenMonthlyReport(Parameters, RootPath)
{
	var URL = 'monthly_report/index.aspx';
	var DialogAruments = null;	
	var Width = 725;
	var Height = 583;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenBlanksList(Parameters, RootPath)
{
	//var URL = 'files/reports/blanks/index.aspx';
	var URL = 'blanks/index.aspx';
	var DialogAruments = null;	
	var Width = 730;
	var Height = 473;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenComplaintsList(Parameters, RootPath)
{
	var URL = 'complaints/index.aspx';
	var DialogAruments = null;	
	var Width = 730;
	var Height = 485;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenComplaint(Parameters, RootPath)
{

	//Parameters array indexes :
	//0 - complaint_id
	
	if (!Parameters[0]) Parameters[0]=0;
	
	var URL = 'complaints/edit.aspx?complaint_id='+Parameters[0]; 
	var DialogAruments = null;	
	var Width = 600;
	var Height = 419;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenClient(Parameters, RootPath)
{

	//Parameters array indexes :
	//0 - client_id

	if (!Parameters[0]) Parameters[0]=0;
	
	var URL = 'clients/edit.aspx?client_id='+Parameters[0]; 
	var DialogAruments = null;	
	var Width = 625;
	var Height = 545;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenContact(Parameters, RootPath)
{

	//Parameters array indexes :
	//0 - contact_id
	//1 - client_id

	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'clients/contacts/edit.aspx?contact_id='+Parameters[0]+'&client_id='+Parameters[1]; 
	var DialogAruments = null;	
	var Width = 345;
	var Height = 470;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenMedia(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - media_id
	//1 - file_id

	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'medias/edit.aspx?media_id='+Parameters[0]+'&file_id='+Parameters[1]; 
	var DialogAruments = null;	
	var Width = 335;
	var Height = 408;
					
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenMedias(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - media_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'medias/index.aspx?media_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 720;
	var Height = 550;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenExpense(Parameters, RootPath)
{

	//Parameters array indexes :
	//0 - file_expense_id

	if (!Parameters) Parameters = new Array();
	if (!Parameters[0]) Parameters[0]=0;
	
	var URL = 'files/accounting/edit_expense.aspx?file_expense_id='+Parameters[0]; 
	var DialogAruments = null;	
	var Width = 355;
	var Height = 325;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenOfficeInvoice(Parameters, RootPath)
{

	//Parameters array indexes :
	//0 - office_invoice_id

	if (!Parameters) Parameters = new Array();
	if (!Parameters[0]) Parameters[0]=0;
	
	var URL = 'files/final/accounting/invoice_edit.aspx?office_invoice_id='+Parameters[0]; 
	var DialogAruments = null;	
	var Width = 355;
	var Height = 470;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}


function OpenTasks(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - task_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'tasks/index.aspx?task_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 760;
	var Height = 466;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenTask(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - file_id
	//1 - task_id
	//2 - show_open_file_button

	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 2; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '0';
	
	var URL = 'files/tasks/edit.aspx?task_id='+Parameters[1]+'&file_id='+Parameters[0]+'&open_file='+Parameters[2]; 
	var DialogAruments = null;	
	var Width = 465;
	var Height = 405;
					
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenGroups(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - group_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'groups/index.aspx?group_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 495;
	var Height = 478;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenFlags(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - flag_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'flags/index.aspx?flag_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 395;
	var Height = 455;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenCompanies(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - company_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'companies/index.aspx?company_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 425;
	var Height = 455;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenBranches(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - branch_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'branches/index.aspx?branch_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 525;
	var Height = 480;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenFileTypes(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - file_type_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'file_types/index.aspx?file_type_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 395;
	var Height = 455;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenClientTypes(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - client_type_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'client_types/index.aspx?client_type_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 395;
	var Height = 455;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenFiles(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - file_id

	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'files/index.aspx?file_id='+Parameters[1];
	var DialogAruments = Parameters[0];		
	var Width = 720;
	var Height = 550;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

//function OpenClients(Parameters, RootPath)
//{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - client_id
	//2 - Customers Only
	//3 - Client Type
//	if (!Parameters) Parameters = new Array();
//	for (var ParameterIndex = 1; ParameterIndex <= 3; ParameterIndex++)
//		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
//	var URL = 'clients/index.aspx?client_id='+Parameters[1]+'&customer='+Parameters[2]+'&client_type_id='+Parameters[3];
//	var DialogAruments = Parameters[0];		
//	var Width = 720;
//	var Height = 548;
				 
//	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
//}


function OpenClients(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - client_id
	//2 - Customers Only
	//3 - Client Type Id

	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 3; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'clients/index.aspx?client_id='+Parameters[1]+'&customer='+Parameters[2]+'&client_type_id='+Parameters[3];
	var DialogAruments = Parameters[0];		
	var Width = 720;
	var Height = 550;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenSurveyors(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - surveyor_id
	//2 - branch_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 2; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';

	var URL = 'surveyors/index.aspx?surveyor_id='+Parameters[1]+'&branch_id='+Parameters[2];
	var DialogAruments = Parameters[0];	
	var Width = 525;
	var Height = 480;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenDocumentTypes(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - document_type_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'document_types/index.aspx?document_type_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 450;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenTaskTypes(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - task_type_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'task_types/index.aspx?task_type_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 450;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenSuppliers(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - supplier_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'suppliers/index.aspx?supplier_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 518;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	


function OpenUsers(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - user_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';

	var URL = 'users/index.aspx?user_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 575;
	var Height = 480;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	


function OpenExpenseTypes(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - expense_type_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'expense_types/index.aspx?expense_type_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 450;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenSecurityLevels(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - SecurityLevelID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'security_levels/index.aspx?security_level_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 460;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenAccountingAccessLevels(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - AccountingAccessLevelID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'accounting_access_levels/index.aspx?accounting_access_level_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 380;
	var Height = 355;
			
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}	

function OpenCurrencies(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - Enable Select
	//1 - currency_id
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 1; ParameterIndex <= 1; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'currencies/index.aspx?group_id='+Parameters[1];
	var DialogAruments = Parameters[0];	
	var Width = 495;
	var Height = 389;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenInspectionDialog(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - FileID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'files/final/inspection/index.aspx?file_id='+Parameters[0];
	var DialogAruments = false;	
	var Width = 750;
	var Height = 423;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenInspectingDialog(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - FileID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'files/final/inspecting/index.aspx?file_id='+Parameters[0];
	var DialogAruments = false;	
	var Width = 750;
	var Height = 423;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenAccountingDialog(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - FileID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'files/final/accounting/index.aspx?file_id='+Parameters[0];
	var DialogAruments = false;	
	var Width = 770;
	var Height = 423;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenSendMailDialog(FileID, ToAddress, FromAddress, Subject, Message, Attachments, RootPath)
{
	
	var CountAttachments = 0;
	var URL = 'send_mail/index.aspx?file_id='+FileID+
								   '&mail_to='+ToAddress+
								   '&mail_from='+FromAddress+
								   '&mail_subject='+Subject+
								   '&mail_body='+Message;
	if (Attachments) 
	{
		for (var AttachmentIndex = 0; AttachmentIndex < Attachments.length; AttachmentIndex++)
		 if (Attachments[AttachmentIndex])
		 {
			CountAttachments++;
			URL = URL + '&path' + CountAttachments + '=' + Attachments[AttachmentIndex];
		 }
	}
	URL = URL + '&attachments_count=' + CountAttachments;
									   
	var DialogAruments = false;	
	var Width = 500;
	var Height = 383;
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

function OpenPDFDownload(Parameters, RootPath)
{
	//Parameters array indexes :
	//0 - MediaPath
	//1 - MediaFileName
	//2 - MediaDescription
	//3 - MediaTypeID
	
	if (!Parameters) Parameters = new Array();
	for (var ParameterIndex = 0; ParameterIndex <= 0; ParameterIndex++)
		 if (!Parameters[ParameterIndex]) Parameters[ParameterIndex] = '';
	
	var URL = 'client_site/create_pdf.aspx?file_path='+Parameters[0]+'&file_description='+Parameters[2];
	var DialogAruments = false;	
	var Width = 350;
	var Height = 150;
				 
	return OpenDialog(RootPath + URL, DialogAruments, Width, Height, true);
}

