var GL_Style = "normalStyle";
var WebPartElementID = "MSO_ContentTable";

//setSizeStyle();
disableTDTitles();

// --------------------------------------------------------------------------------
function RadEditorLoad(editor, args)  
{  
   var contentArea = editor.get_contentArea();  
   contentArea.style.className= "Tekst";
}  


var fontSizes = function() 
{
	var NORMAL = 1;
	var LARGE = 2;
	var XLARGE = 3;
	
	/*
	 * Voeg hier te vergroten / verkleinen CSS klassen toe 
	 */
	var fontStylesNormal = ["Tekst", "Subtitel", "Titel", "ms-standardheader ms-WPTitle", "item bulletnews", "Voettekst", "ms-WPBorder"];
	var fontStylesLarge = ["TekstLarge", "SubtitelLarge", "TitelLarge", "ms-standardheader ms-WPTitleLarge", "item bulletnewsLarge", "VoettekstLarge", "ms-WPBorderLarge"];
	var fontStylesXLarge = ["TekstXLarge", "SubtitelXLarge", "TitelXLarge", "ms-standardheader ms-WPTitleXLarge", "item bulletnewsXLarge", "VoettekstXLarge", "ms-WPBorderXLarge"];
	
	this.getAllItems = function() 
	{
		return document.getElementsByTagName("*");
	};
	
	this.getElementNo = function (aArray,value) {
		for (var i=0; i < aArray.length; i++) {
			if (aArray[i] === value) {
				return i;
			}
		}
		return -1;
	};
	
	this.changeFontSize = function(toSize)
	{
		switch (toSize) 
		{
			case NORMAL:
				to = fontStylesNormal;
				from1 = fontStylesLarge;
				from2 = fontStylesXLarge;
				break;
			case LARGE:
				to = fontStylesLarge;
				from1 = fontStylesNormal;
				from2 = fontStylesXLarge;
				break;
			case XLARGE:
				to = fontStylesXLarge;
				from1 = fontStylesNormal;
				from2 = fontStylesLarge;			
				break;
		}
		var items = this.getAllItems();
		for (var idx=0; idx < items.length; idx++) 
		{
			if (items[idx].className) 
			{	
				styleNo = this.getElementNo(from1, items[idx].className);
				if (styleNo != -1) 
				{
					items[idx].className = to[styleNo];
				} 
				else
				{
					styleNo = this.getElementNo(from2, items[idx].className);
					if (styleNo != -1) 
					{
						items[idx].className = to[styleNo];
					}
				}
			}
		}
	};
	
	this.setNormal = function()
	{
		return this.changeFontSize(NORMAL);
	};
	
	this.setLarge = function()
	{
		return this.changeFontSize(LARGE);
	};	
	
	this.setXLarge = function()
	{
		return this.changeFontSize(XLARGE);
	};
};

function setFontSize(style)
{
   switch (style)
   {
      case "xx-largeStyle":
          styleID = "xx-largeStyle";
          break;
      case "x-largeStyle":
         styleID = "x-largeStyle";
         break;
      case "largeStyle":
          styleID = "largeStyle";
          break;
      case "normalStyle":
          styleID = "normalStyle";
          break;
      default:
          styleID = "normalStyle";
          break;
   }
   setCookie("fontSize", styleID, getExpDate(365, 0, 0));
   setSizeStyle();
}

// Input values:
// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// Input value:
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  if (dc == "" || dc == null)
     return (GL_Style);
  else
  {
     var prefix = name + "=";
     var begin = dc.indexOf("; " + prefix);
     if (begin == -1) {
       begin = dc.indexOf(prefix);
       if (begin != 0) return null;
     } else
       begin += 2;
     var end = document.cookie.indexOf(";", begin);
     if (end == -1)
       end = dc.length;
     return unescape(dc.substring(begin + prefix.length, end));
   }
}

function getExpDate(days, hours, minutes)
{
   var expDate = new Date();
   if (typeof days == "number" && typeof hours == "number" && typeof minutes == "number"  )
   {
       expDate.setDate(expDate.getDate() + parseInt(days));
       expDate.setHours(expDate.getHours() + parseInt(hours));
       expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
       return expDate.toGMTString();
   }
}

// Input values:
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        "; path=/" + 
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    GL_Style = value;
    return(true);
}

function setSizeStyle()
{
	if (document.getElementById)
	{
		var styleIDs = ["normalStyle", "largeStyle", "x-largeStyle", "xx-largeStyle"];
		var idx;
		var styleCookie = getCookie("fontSize");
		if (styleCookie == "" || styleCookie == null) {
			styleCookie = "normalStyle";
			setCookie("fontSize", styleCookie, getExpDate(365, 0, 0));
		}
		var fs = new fontSizes();
		switch (styleCookie) {
		case "normalStyle":
			fs.setNormal();
			setLinkItemStyle("fontSizeNormal");
			break;
		case "largeStyle":
			fs.setLarge();
			setLinkItemStyle("fontSizeLarge");
			break;
		case "x-largeStyle":
			fs.setXLarge();
			setLinkItemStyle("fontSizeXLarge");
			break;
		default:
			fs.setNormal();
			break;
		}
	}
}

function setLinkItemStyle(linkItemId) {
	var linkItem = document.getElementById("fontSizeNormal");
	if (linkItem) {
		linkItem.style.borderBottom = "2px solid white";
	}
	var linkItem = document.getElementById("fontSizeLarge");
	if (linkItem) {
		linkItem.style.borderBottom = "2px solid white";
	}
	var linkItem = document.getElementById("fontSizeXLarge");
	if (linkItem) {
		linkItem.style.borderBottom = "2px solid white";
	}
	var linkItem = document.getElementById(linkItemId);
	if (linkItem) {
		linkItem.style.borderBottom = "2px solid #1AB6F2";
	}

}


// Change default class editor 
function OnClientLoad(editor, args) {
	if (editor.get_text() == "") {
		editor.set_html("<span class=\"Tekst\"> </span>");
	}
}

// Name.dll fix - Dit lost de vervelende melding in Internet Explorer op wanneer de site van buiten benaderd wordt...
function ProcessDefaultOnLoad(onLoadFunctionNames)
{
	ProcessPNGImages();
	UpdateAccessibilityUI();
		
	//** We comment out the offending ootb function
	//** and leave the rest of the functions as they were
	//ProcessImn();
	for (var i=0; i < onLoadFunctionNames.length; i++)
	{
		var expr="if(typeof("+onLoadFunctionNames[i]+")=='function'){"+onLoadFunctionNames[i]+"();}";
		eval(expr);
	}
	if (typeof(_spUseDefaultFocus)!="undefined")
		DefaultFocus();
}	



// Javascript to set page title
function setPageTitle() {
  var firstFolder = document.URL.split("//")[1].split("/")[1];
  var docTitle = "SDW ";
  switch (firstFolder) {
    case "Pages":
       docTitle += "SDW Zorgvuldig met zorg";
       break;
    case "UwZorgvraag":
       docTitle += "Uw Zorgvraag";
       break;
    case "ZelfZorgAanvragen":
       docTitle += "Zelf Zorg Aanvragen";
       break;
    case "WerkenBijSDW":
       docTitle += "Werken Bij SDW";
       break;
    case "OverSDW":
       docTitle += "Over SDW";
       break;
    case "SDWInBedrijf":
       docTitle += "In Bedrijf";
       break;
    default:
       docTitle += "Overige informatie";
       break;
    }
  document.title = docTitle;
}


function printpages()
{
	var bolWebPartFound = false;
	if (document.getElementById != null)
	{
		//Create html to print in new window
		var PrintingHTML = '\n<BODY>\n';
		//Take data from Head Tag
		if (document.getElementsByTagName != null)
		{
			var HeadData= document.getElementsByTagName("BODY");
			if (HeadData.length > 0)
			PrintingHTML += HeadData[0].innerHTML;
		}
		PrintingHTML += '\n</BODY>\n\n';
		var WebPartData=document.getElementById(WebPartElementID).innerHTML;
		if (WebPartData != null)
		{
			//PrintingHTML += WebPartData.innerHTML;
			bolWebPartFound = true;
		}
		else
		{
			bolWebPartFound = false;
			alert ('Cannot Find Web Part');
		}
	}
	PrintingHTML += '\n\n';
	if (bolWebPartFound)
	{
		var PrintingWindow = window.open("about:blank","","toolbar,width=800,height=600,scrollbars,resizable,menubar");
		PrintingWindow.document.open();
		var WebPartData1 ='<HTML><Head>';

		var webdata = document.getElementById(WebPartElementID).innerHTML;
		var data = document.getElementsByTagName('Link');
		data.rel='stylesheet';
		for(webdata in data)
		{
	 		var c = data[webdata];
	 		if(c.href!="undefined")
	 		{
	    			WebPartData1 +="<link rel = 'stylesheet' href='"+c.href+"' type='text/css'/>";
	 		}
		}
	
		var aArray = new   Array();
		aArray = WebPartData.split('id=WebPartWPQ');
		var i=0;
		var itemName;
		for(i=0; i<aArray.length; i++)
		{
			var itemContent = aArray[i].toString();
			var itemID = itemContent.substring(0,1);
	            	try
	            	{
	                	if(parseInt(itemID) > 0)
	               		{
	                    		var elem = document.getElementById("WebPartWPQ" + itemID.toString());
	                    		var imageID = "ctl00_m_g_" + elem.WebPartID + "_image1";
	                    		imageID = imageID.replace(/-/g,'_');
            	       			if(document.getElementById(imageID) != null)
            	       			{
            	       				itemName =imageID;
            	       			}
	                	}
	            	}
	            	catch(e)
	            	{
			}
		}
		//-->WebPartData1 +="</Head><Body>"+WebPartData+"</Body></HTML>";
		WebPartData1 +=WebPartData;
		PrintingWindow.document.write(WebPartData1);
		PrintingWindow.document.close();
		PrintingWindow.focus();
		//-->PrintingWindow.document.getElementById(itemName).style.display="none";
		PrintingWindow.print();
	}
}

// Copyright 2008 Darren Johnstone (http://darrenjohnstone.net)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

function SPAPI_Core()
{
    this.createXMLHttpRequest = function()
    {
        if (typeof XMLHttpRequest != "undefined") 
        {
            return new XMLHttpRequest();
        } 
        else if (typeof ActiveXObject != "undefined") 
        {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } 
        else 
        {
            throw new Error("XMLHttpRequest not supported");
        }
    }
    
    this.executeRequest = function(serviceUrl, action, packet, params)
    {
        var oXMLHttpRequest = this.createXMLHttpRequest();
        var result = null;
        var resultName;
        
        oXMLHttpRequest.open("POST", serviceUrl, false);
        oXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 
        oXMLHttpRequest.setRequestHeader("SOAPAction", action);
        
        if (params != null)
        {
            for (var i=0; i < params.length; i++)
            {
                packet = packet.replace('{' + i.toString() + '}', (params[i] == null ? '' : params[i]));
            }
        }
        
        oXMLHttpRequest.send(packet);
        
        resultName = action.substring(action.lastIndexOf('/') + 1) + 'Result';
        var resBatch;
        var status;
        var statusText;
        
        status = oXMLHttpRequest.status;
        statusText = oXMLHttpRequest.statusText;
        
        if (status == 200)
        {
            // Check for SharePoint error code
            resBatch = oXMLHttpRequest.responseXML.getElementsByTagName(resultName);
            
            var codeEl = oXMLHttpRequest.responseXML.getElementsByTagName('ErrorCode');
            
            if (codeEl != null && codeEl.length > 0)
            {
                var spStatus = parseInt(codeEl[0].childNodes[0].nodeValue);
                
                if (spStatus != 0)
                {
                    status = 0-spStatus; // Note we make this -ve to prevent confusion with the HTTP code
                    
                    var messageEl = oXMLHttpRequest.responseXML.getElementsByTagName('ErrorText');
                    if (messageEl != null && messageEl.length >= 0)
                    {
                        statusText = messageEl[0].childNodes[0].nodeValue;
                    }
                }
            }
        }
            
        result = {
        status : status,
        statusText : statusText,
        responseXML : oXMLHttpRequest.responseXML,
        responseText : oXMLHttpRequest.responseText,
        resultNode : (resBatch == null || resBatch.length == 0 ? null : resBatch[0])
        };
        
        return result;
    }
}

function SPAPI_Lists(baseUrl)
{
    this.core = new SPAPI_Core();
    this.serviceUrl = baseUrl + '/_vti_bin/lists.asmx';
    
    /* List template IDs */
    this.LIST_ID_ADMIN_TASKS        = 1200    // Administrator tasks list 
    this.LIST_ID_ANNOUNCEMENTS      = 104     // Announcements list 
    this.LIST_ID_BLOG_CATEGORIES    = 303     // Blog Categories list 
    this.LIST_ID_BLOG_COMMENTS      = 302     // Blog Comments list 
    this.LIST_ID_BLOG_POSTS         = 301     // Blog Posts list 
    this.LIST_ID_CONTACTS           = 105     // Contacts list 
    this.LIST_ID_CUSTOM_GRID        = 120     // Custom grid for a list 
    this.LIST_ID_CUSTOM_WORKFLOW    = 118     // Custom Workflow Process 
    this.LIST_ID_DATA_CONNECTIONS   = 130     // Data Connection library 
    this.LIST_ID_SATA_SOURCES       = 110     // Data sources 
    this.LIST_ID_DISCUSSION_BORAD   = 108     // Discussion board 
    this.LIST_ID_DOCUMENT_LIBRARY   = 101     // Document library 
    this.LIST_ID_EVENTS             = 106     // Events list 
    this.LIST_ID_GANTT_TASKS        = 150     // Gantt Tasks list 
    this.LIST_ID_GENERIC            = 100     // Generic list 
    this.LIST_ID_ISSUE_TRACKING     = 1100    // Issue tracking 
    this.LIST_ID_LINKS              = 103     // Links list 
    this.LIST_ID_LIST_TEMPLATE      = 114     // List template gallery 
    this.LIST_ID_MASTER_PAGE        = 116     // Master pages gallery 
    this.LIST_ID_MEETING_AGENDA     = 201     // Meeting Agenda list 
    this.LIST_ID_MEETING_ATTENDEES  = 202     // Meeting Attendees list 
    this.LIST_ID_MEETING_DECISIONS  = 204     // Meeting Decisions list 
    this.LIST_ID_MEETING_OBJECTIVES = 207     // Meeting Objectives list 
    this.LIST_ID_MEETING_SERIES     = 200     // Meeting Series list 
    this.LIST_ID_MEETING_TEXT_BOX   = 210     // Meeting text box 
    this.LIST_ID_MEETING_TTB        = 211     // Meeting Things To Bring list 
    this.LIST_ID_MEETING_WS_PAGES   = 212     // Meeting Workspace Pages list 
    this.LIST_ID_NO_CODE_WORKLOFWS  = 117     // No-Code Workflows 
    this.LIST_ID_PERSONAL_DOCLIB    = 2002    // Personal document library 
    this.LIST_ID_PICTURE_LIBRARY    = 109     // Picture library 
    this.LIST_ID_PORTAL_SITE_LIST   = 300     // Portal Sites list 
    this.LIST_ID_PRIVATE_DOCLIB     = 2003    // Private document library
    this.LIST_ID_SITE_TEMPLATES     = 111     // Site template gallery 
    this.LIST_ID_SURVEY             = 102     // Survey 
    this.LIST_ID_TASKS              = 107     // Tasks list 
    this.LIST_ID_USER_INFO          = 112     // User Information list 
    this.LIST_ID_WEB_PARTS          = 113     // Web Part gallery 
    this.LIST_ID_WIKI_PAGES         = 119     // Wiki Page library 
    this.LIST_ID_WORKFLOW_HISTORY   = 140     // Workflow History 
    this.LIST_ID_XML_FORMS          = 115     // XML Form library 
    /*-------------------*/
    
    this.addAttachment = function(listName, listItemID, fileName, attachment)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/AddAttachment';
		var params = [listName, listItemID, fileName, attachment];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddAttachment xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><listItemID>{1}</listItemID><fileName>{2}</fileName><attachment>{3}</attachment></AddAttachment></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.addDiscussionBoardItem = function(listName, message)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/AddDiscussionBoardItem';
		var params = [listName, message];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddDiscussionBoardItem xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><message>{1}</message></AddDiscussionBoardItem></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.addList = function(listName, description, templateID)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/AddList';
		var params = [listName, description, templateID];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddList xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><description>{1}</description><templateID>{2}</templateID></AddList></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.addListFromFeature = function(listName, description, featureID, templateID)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/AddListFromFeature';
		var params = [listName, description, featureID, templateID];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddListFromFeature xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><description>{1}</description><featureID>{2}</featureID><templateID>{3}</templateID></AddListFromFeature></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.applyContentTypeToList = function(webUrl, contentTypeId, listName)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/ApplyContentTypeToList';
		var params = [webUrl, contentTypeId, listName];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ApplyContentTypeToList xmlns="http://schemas.microsoft.com/sharepoint/soap/"><webUrl>{0}</webUrl><contentTypeId>{1}</contentTypeId><listName>{2}</listName></ApplyContentTypeToList></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.checkInFile = function(pageUrl, comment, checkinType)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/CheckInFile';
		var params = [pageUrl, comment, checkinType];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><CheckInFile xmlns="http://schemas.microsoft.com/sharepoint/soap/"><pageUrl>{0}</pageUrl><comment>{1}</comment><CheckinType>{2}</CheckinType></CheckInFile></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.checkOutFile = function(pageUrl, checkoutToLocal, lastmodified)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/CheckOutFile';
		var params = [pageUrl, checkoutToLocal, lastmodified];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/"><pageUrl>{0}</pageUrl><checkoutToLocal>{1}</checkoutToLocal><lastmodified>{2}</lastmodified></CheckOutFile></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.createContentType = function(listName, displayName, parentType, fields, contentTypeProperties, addToView)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/CreateContentType';
		var params = [listName, displayName, parentType, fields, contentTypeProperties, addToView];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><CreateContentType xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><displayName>{1}</displayName><parentType>{2}</parentType><fields>{3}</fields><contentTypeProperties>{4}</contentTypeProperties><addToView>{5}</addToView></CreateContentType></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.deleteAttachment = function(listName, listItemID, url)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/DeleteAttachment';
		var params = [listName, listItemID, url];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><DeleteAttachment xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><listItemID>{1}</listItemID><url>{2}</url></DeleteAttachment></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.deleteContentType = function(listName, contentTypeId)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/DeleteContentType';
		var params = [listName, contentTypeId];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><DeleteContentType xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId></DeleteContentType></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.deleteContentTypeXmlDocument = function(listName, contentTypeId, documentUri)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/DeleteContentTypeXmlDocument';
		var params = [listName, contentTypeId, documentUri];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><DeleteContentTypeXmlDocument xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId><documentUri>{2}</documentUri></DeleteContentTypeXmlDocument></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.deleteList = function(listName)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/DeleteList';
		var params = [listName];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><DeleteList xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName></DeleteList></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getAttachmentCollection = function(listName, listItemID)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetAttachmentCollection';
		var params = [listName, listItemID];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetAttachmentCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><listItemID>{1}</listItemID></GetAttachmentCollection></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getList = function(listName)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetList';
		var params = [listName];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName></GetList></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListAndView = function(listName, viewName)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListAndView';
		var params = [listName, viewName];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListAndView xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><viewName>{1}</viewName></GetListAndView></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListCollection = function()
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListCollection';
		var params = [];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" /></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListContentType = function(listName, contentTypeId)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListContentType';
		var params = [listName, contentTypeId];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListContentType xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId></GetListContentType></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListContentTypes = function(listName, contentTypeId)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListContentTypes';
		var params = [listName, contentTypeId];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListContentTypes xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId></GetListContentTypes></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}

	this.getListItemChanges = function(listName, viewFields, since, contains)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListItemChanges';
		var params = [listName, viewFields, since, contains];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListItemChanges xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><viewFields>{1}</viewFields><since>{2}</since><contains>{3}</contains></GetListItemChanges></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListItemChangesSinceToken = function(listName, viewName, query, viewFields, rowLimit, queryOptions, changeToken, contains)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListItemChangesSinceToken';
		var params = [listName, viewName, query, viewFields, rowLimit, queryOptions, changeToken, contains];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListItemChangesSinceToken xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><viewName>{1}</viewName><query>{2}</query><viewFields>{3}</viewFields><rowLimit>{4}</rowLimit><queryOptions>{5}</queryOptions><changeToken>{6}</changeToken><contains>{7}</contains></GetListItemChangesSinceToken></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getListItems = function(listName, viewName, query, viewFields, rowLimit, queryOptions, webID)
	{
	    if (queryOptions == null || queryOptions == '') queryOptions = '<QueryOptions/>';
	    
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetListItems';
		var params = [listName, viewName, query, viewFields, rowLimit, queryOptions, webID];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><viewName>{1}</viewName><query>{2}</query><viewFields>{3}</viewFields><rowLimit>{4}</rowLimit><queryOptions>{5}</queryOptions><webID>{6}</webID></GetListItems></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.getVersionCollection = function(strlistID, strlistItemID, strFieldName)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/GetVersionCollection';
		var params = [strlistID, strlistItemID, strFieldName];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetVersionCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"><strlistID>{0}</strlistID><strlistItemID>{1}</strlistItemID><strFieldName>{2}</strFieldName></GetVersionCollection></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.undoCheckOut = function(pageUrl)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UndoCheckOut';
		var params = [pageUrl];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UndoCheckOut xmlns="http://schemas.microsoft.com/sharepoint/soap/"><pageUrl>{0}</pageUrl></UndoCheckOut></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.updateContentType = function(listName, contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields, addToView)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UpdateContentType';
		var params = [listName, contentTypeId, contentTypeProperties, newFields, updateFields, deleteFields, addToView];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UpdateContentType xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId><contentTypeProperties>{2}</contentTypeProperties><newFields>{3}</newFields><updateFields>{4}</updateFields><deleteFields>{5}</deleteFields><addToView>{6}</addToView></UpdateContentType></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.updateContentTypeXmlDocument = function(listName, contentTypeId, newDocument)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UpdateContentTypeXmlDocument';
		var params = [listName, contentTypeId, newDocument];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UpdateContentTypeXmlDocument xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId><newDocument>{2}</newDocument></UpdateContentTypeXmlDocument></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.updateContentTypeXmlDocument = function(listName, contentTypeId, newDocument)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UpdateContentTypeXmlDocument';
		var params = [listName, contentTypeId, newDocument];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UpdateContentTypeXmlDocument xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><contentTypeId>{1}</contentTypeId><newDocument>{2}</newDocument></UpdateContentTypeXmlDocument></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.updateList = function(listName, listProperties, newFields, updateFields, deleteFields, listVersion)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UpdateList';
		var params = [listName, listProperties, newFields, updateFields, deleteFields, listVersion];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UpdateList xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><listProperties>{1}</listProperties><newFields>{2}</newFields><updateFields>{3}</updateFields><deleteFields>{4}</deleteFields><listVersion>{5}</listVersion></UpdateList></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
	this.updateListItems = function(listName, updates)
	{
		var action = 'http://schemas.microsoft.com/sharepoint/soap/UpdateListItems';
		var params = [listName, updates];
		var packet = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>{0}</listName><updates>{1}</updates></UpdateListItems></soap:Body></soap:Envelope>';

		return this.core.executeRequest(this.serviceUrl, action, packet, params);
	}
	
    this.callUpdateListItems = function(listName, fields, command, rootFolder)
	{
	    var batch;
	    var itemArray;
	    
	    batch = "<Batch OnError='Continue'"
	    
	    if (rootFolder != null)
	    {
	        batch += " RootFolder='" + rootFolder + "'";
	    }
	    
	    batch += ">";
	    
	    if (fields.constructor != Array)
	    {
	        itemArray = [ fields ];
	    }
	    else
	    {
	        itemArray = fields;
	    }
	    
	    for (var i=0; i<itemArray.length; i++)
	    {
	        batch += "<Method ID='1' Cmd='" + command + "'>";
    	    
	        for (att in itemArray[i])
	        {
	            batch += "<Field Name='" + att + "'><![CDATA[" + itemArray[i][att] + "]]></Field>";
	        }
    	    
	        batch += "</Method>";
	    }
	    
	    batch += "</Batch>";
	    
	    return this.updateListItems(listName, batch);
	}
	
	this.quickAddListItem = function(listName, fields, rootFolder)
	{
	    return this.callUpdateListItems(listName, fields, "New", rootFolder);
	}
	
    this.quickUpdateListItem = function(listName, fields)
	{
	    return this.callUpdateListItems(listName, fields, "Update");
	}
	
	this.quickDeleteListItem = function(listName, itemIds)
	{
	    var idFields = [ ];
	    
	    if (itemIds.constructor == Array)
	    {
	        for (var i=0; i<itemIds.length; i++)
	        {
	            idFields.push( { ID: itemIds[i] } );
	        }
	    }
	    else
	    {
	        idFields = [ { ID: itemIds } ];
	    }
	    
	    return this.callUpdateListItems(listName, idFields, "Delete");
	}
	
	this.callFolderUpdate = function(listName, folderName, command, rootFolder)
	{
	    var batch;
	    
	    batch = "<Batch OnError='Continue'"
	    
	    if (rootFolder != null)
	    {
	        batch += " RootFolder='" + rootFolder + "'";
	    }
	    
	    batch += ">";
	    
        batch += "<Method ID='1' Cmd='" + command + "'>"
        +"<Field Name='FSObjType'>1</Field>"
        +"<Field Name='BaseName'>" + folderName + "</Field>"
        +"</Method>"
        +"</Batch>";
        
	    return this.updateListItems(listName, batch);
	}
	
	this.createFolder = function(listName, folderName, rootFolder)
	{
	    return this.callFolderUpdate(listName, folderName, "New", rootFolder);
	}
}


function DBRepopulateList(controlName,siteName,lookupListName,lookupViewName,textField,valueField) 
{ 
	// -- retrieve the list for the elements 
	var listEl = document.getElementsByName(controlName);
	if(listEl.length>0) { 
		// -- emptying the control
		listEl(0).innerHTML = ""; 
		
		// -- query the SPList
		var lists = new SPAPI_Lists(siteName);
		var items = lists.getListItems(lookupListName,lookupViewName);
		
		// -- function to retrieve node values 
		var getNodeValue = function(element,cNode) {
			if (element.getAttributeNode(cNode)) {
				return element.getAttributeNode(cNode).value;
			} else {
				return "";
			}
		};
		
		// -- response 200 (HTTP Status code) = list retrieved in a proper way 
		if (items.status == 200) {
			var rows = items.responseXML.getElementsByTagName('z:row');
			for (var i=0; i<rows.length; i++) {
				var element=rows[i];
				var optionText = getNodeValue(element, textField);
				var optionValue = getNodeValue(element,valueField);
				var opt = document.createElement("OPTION"); 
				listEl(0).options.add(opt); 
				opt.innerText = optionText; 
				opt.value = optionValue; 
			}
		} else {
			alert('Er is een fout opgetreden: ' + items.statusText);
		}	
	} 
} 

function disableTDTitles() {
	var allTD = document.getElementsByTagName("td");
	for (var i=0; i<allTD.length; i++) {
		if (allTD[i].title) {
			allTD[i].title = "";
		}
	}
}

setSizeStyle();