﻿// Timetable function

//Main parameters description
//containerID - the ID of the parent element. Can't be null or empty 
//URL - the URL string of the time table to load provided by time table developer's personal, like: http://<host>[:port]/[virtual directories/]<page name>.<page extension>. Can't be null or empty
//contextID - the ID of the instance from time table is being load, provided by time table developer's personal. Can't be null, empty or less than 1;

//Additional parameters description
//searchText - the search string time table will load by default when time table is being loaded for the first time.
//DisplayDoctorSearch - true/false, set if the doctors search by the doctor's surname panel is shown. False by default.
//DisplayPaymentTypes - true/false, set if the panel with payment types is shown. True by default.
//DisplaySearchHeader - true/false, set if the search result text in the time table head will be shown. False by default.
//DisplayInstanceName - true/false, set if instance name text will be shown in the pages head. False by default.
//DisplayInstancePhones - true/false, set if instance contact phones will be shown in the pages head. False by default.
//DisplaySpecialistHeader - true/false, set if the specialists title in the detailed time table head will be shown. False by default.
//DisplaySpecialistName - true/false, set if the specialist name text will be shown in the detailed timetable head. True by default.
//AvailabilityFilter - the position of AvailabilityFilter in the time table for loading by default when time table is being loaded for the first time.
//DaysAmount - set the amount of days to be shown at the one time in the time table (should be corrected in depence of width of the placeholder) 7 by default.

function Timetable(containerID, URL, contextID, parameters)
{
    if (containerID == null || containerID == "" || URL == null || URL == "" || contextID == null || parseInt(contextID) < 1) return;
    var obj = document.getElementById(containerID);
    if (obj == null) return;
	var srcobj = document.createElement("iframe");
	srcobj.width = obj.style.width;
	srcobj.height = obj.style.height;
	srcobj.frameBorder = 0;
	parameters = parameters.replace(/\s*;\s*/g,"&").replace(/\s*:\s*/g,"=");
	if (parameters.substring(parameters.length-1) == "&") parameters = parameters.substring(0,parameters.length-1);
	srcobj.src = URL+"?contextID="+contextID+"&"+parameters;
	obj.appendChild(srcobj);
}
