﻿
function OpenFromModule()
{
	CallTopFrame("OpenSelectedRecord", true);
}

function Open()
{
	try{
		CallTopFrame("OpenSelectedRecord");
	}catch(Exception)
	{
		setPointer('');
	}
}


function Delete()
{
	CallTopFrame("DeleteSelectedRecord");
}

function New()
{
	window.top.New();
}

function PrintAdvert(print)
{

	window.top.PrintSelectedAdvert("+print+");
}


function CallTopFrame(functionName,parameters)
{
	//Make sure the context menu is hidden
	//if (aspnm_activeContextMenu != null) aspnm_hideContext(false);
	
	//
	// Get the case id
	//
	var recordID = advertViewControl_clickedOnRecord;
	//
	// Store info from the top page in temporary variables
	//
	var tmpSelectedRecordID = window.top.selectedRecordID;
	var tmpSelectedRecordType = window.top.selectedRecordType;
	var tmpSelectedPageObject = window.top.selectedPageObject;
	
	//
	// Store info in the top page
	//
	window.top.selectedRecordID = recordID;
	window.top.selectedRecordType = window.top.selectedRecordType;
	window.top.selectedPageObject = this;
	//
	// Call a function in the top page
	//
	if(parameters)
	{
		eval("window.top."+functionName+";")
	}
	else
	{
		eval("window.top."+functionName+"();")
	}
	
	//
	// Store the original info back in the top page
	//
	window.top.selectedRecordID = tmpSelectedRecordID;
	window.top.selectedRecordType = tmpSelectedRecordType;
	window.top.selectedPageObject = tmpSelectedPageObject;
}

function printAdvert(print)
{
	CallTopFrame("PrintSelectedAdvert("+print+")",true);
}

