if(window["gExternalisering_Loaded"] != true)
{
	window["gExternalisering_Loaded"] = true;
	
	var g_externalising_doExecute = true;
	
	function externalisering_SavePosition(objects)
	{
		if(!g_externalising_doExecute)
			return;
		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&x"+(i+1)+"="+(parseInt(objects[i].offsetLeft)-parseInt(objects[i].getAttribute('margin_left'))+1);
				savestring+="&y"+(i+1)+"="+(parseInt(objects[i].offsetTop)-parseInt(objects[i].getAttribute('margin_top'))+1);
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
//				Trace(objects[i].offsetLeft);
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_position.cfm","dbgdiv",savestring);
	}
	

	function externalisering_SaveSizeSetActualSize(objects)
	{
		if(!g_externalising_doExecute)
			return;
		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				var container = document.getElementById(objects[i].getAttribute('mainTD'));
				
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_size_actual.cfm","dbgdiv",savestring,"document.location = document.location;");
	}


	function externalisering_SaveSize(objects)
	{
		if(!g_externalising_doExecute)
			return;
		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				var container = document.getElementById(objects[i].getAttribute('mainTD'));
				
				savestring+="&width"+(i+1)+"="+container.offsetWidth;
				savestring+="&height"+(i+1)+"="+container.offsetHeight;
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_size.cfm","dbgdiv",savestring);
	}
	
	function externalisering_SaveZIndex(objects)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&zindex"+(i+1)+"="+objects[i].style.zIndex;
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_zindex.cfm","dbgdiv",savestring);
	}

	function externalisering_SaveLockedSize(objects)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&locked_size"+(i+1)+"="+objects[i].getAttribute('locked_size');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_locked_size.cfm","dbgdiv",savestring);
	}

	function externalisering_SaveLockedPosition(objects)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&locked_position"+(i+1)+"="+objects[i].getAttribute('locked_position');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_save_locked_position.cfm","dbgdiv",savestring);
	}

	function externalisering_DeleteForms(objects)
	{
		if(!g_externalising_doExecute)
			return;
		

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items;
		if(items)
		{
			ajaxpage(syspath+"/_system/ajax/ajax_delete_forms.cfm","dbgdiv",savestring,'document.location=document.location;');
			g_externalising_doExecute = false;
		}
	}

	function externalisering_CreateTemplate(objects,templatename,collectionid)
	{
		if(!g_externalising_doExecute)
			return;
		if(templatename == '')
			return;
		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		savestring += "&formcount="+items+'&templatename='+templatename+'&collectionid='+collectionid;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_create_quicktemplate.cfm","dbgdiv",savestring,'document.location=document.location;');
	}

	function externalisering_SetClipboard(objects)
	{
		if(!g_externalising_doExecute)
			return;
		var tmpDiv = document.createElement('div');
		
		
		var savestring = "";
		var items = 0;
		
		var minX = 99999;
		var minY = 99999;
		var maxX = 0;
		var maxY = 0;
		
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				tmpDiv.appendChild(objects[i].cloneNode(true));
				
				minX = Math.min(minX,objects[i].offsetLeft);
				minY = Math.min(minY,objects[i].offsetTop);
				maxX = Math.max(maxX,objects[i].offsetLeft+objects[i].offsetWidth);
				maxY = Math.max(maxY,objects[i].offsetTop+objects[i].offsetHeight);
				
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
			}
		}
		
		for(var i = 0; i < tmpDiv.childNodes.length; i++)
		{
			tmpDiv.childNodes[i].setAttribute('mainTD','');
			tmpDiv.childNodes[i].setAttribute('locked_size','');
			tmpDiv.childNodes[i].setAttribute('locked_position','');
			tmpDiv.childNodes[i].setAttribute('component_type','');
			tmpDiv.childNodes[i].setAttribute('onDblClick','');
			tmpDiv.childNodes[i].setAttribute('onMouseDown','');
			tmpDiv.childNodes[i].setAttribute('onDblClick','');
			tmpDiv.childNodes[i].setAttribute('onclick','');
			tmpDiv.childNodes[i].setAttribute('editmode','');
			tmpDiv.childNodes[i].setAttribute('oncontextmenu','');
			tmpDiv.childNodes[i].setAttribute('DnDType','');
			tmpDiv.childNodes[i].setAttribute('DnDId','');
			tmpDiv.childNodes[i].setAttribute('name','');
			tmpDiv.childNodes[i].setAttribute('ondragover','');
			tmpDiv.childNodes[i].setAttribute('ondrop','');
			tmpDiv.childNodes[i].setAttribute('view_count','');
			tmpDiv.childNodes[i].setAttribute('formnr','');
			tmpDiv.childNodes[i].setAttribute('xmlfile','');
			tmpDiv.childNodes[i].setAttribute('path','');
			tmpDiv.childNodes[i].style.top = (parseInt(tmpDiv.childNodes[i].style.top)-minY)+'px';
			tmpDiv.childNodes[i].style.left = (parseInt(tmpDiv.childNodes[i].style.left)-minX)+'px';
		}
		savestring += "&formcount="+items+'&width='+(maxX-minX)+'&height='+(maxY-minY)+'&html='+encodeURIComponent(tmpDiv.innerHTML);
		tmpDiv = null;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_clipboard_set.cfm","dbgdiv",savestring);
	}


	function externalisering_SetDatasource(objects,type,field,property)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&formid"+(i+1)+"="+objects[i].getAttribute('formnr');
				savestring+="&datasource_type"+(i+1)+"="+type;
				savestring+="&datasource_field"+(i+1)+"="+field;
				savestring+="&datasource_property"+(i+1)+"="+property;
			}
		}
		savestring += "&formcount="+items;
		if(items)
			ajaxpage(syspath+"/_system/ajax/ajax_set_datasource.cfm","dbgdiv",savestring,'document.location=document.location;');
	}


	function externalisering_SetComponentAttributeByGUID(guid,key,value,oncomplete)
	{
		var arr = new Array();
		arr.push(forms_GetFormByGuid(guid));
		externalisering_SetComponentAttribute(arr,key,value,oncomplete);
	}
	
	function externalisering_SetComponentAttribute(objects,key,value,oncomplete)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			//if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&guid"+(i+1)+"="+encodeURIComponent(objects[i].getAttribute('guid'));
				
				if(key.pop != undefined)
					savestring+="&key"+(i+1)+"="+encodeURIComponent(key[i]);
				else
					savestring+="&key"+(i+1)+"="+encodeURIComponent(key);
					
				if(value.pop != undefined)
					savestring+="&value"+(i+1)+"="+encodeURIComponent(value[i]);
				else
					savestring+="&value"+(i+1)+"="+encodeURIComponent(value);
			}
		}
		savestring += "&formcount="+items;
		savestring += '&params='+encodeURIComponent(window['params']);
		if(items)
		{
			if(!oncomplete)
				oncomplete="document.location=document.location";
			ajaxpage(syspath+"/_system/ajax/ajax_update_component_attribute.cfm","dbgdiv",savestring,oncomplete);
		}
	}
/*
	function externalisering_SetFormAttribute(objects,key,value,oncomplete)
	{
		var arr=new Array();
		var obj=new Object();
		obj[key]=value;
		arr.push(obj);
		externalisering_SetFormAttributes(objects,arr,oncomplete);
		
	}
	function externalisering_SetFormAttributes(objects,aKey,oncomplete)
	{
		if(!g_externalising_doExecute)
			return;

		var savestring = "";
		var items = 0;
		for(var i = 0; i < objects.length; i++)
		{
			//if(objects[i].getAttribute('editmode') == 1)
			{
				items++;
				savestring+="&xmlpath"+(i+1)+"="+objects[i].getAttribute('path');
				savestring+="&xmlfile"+(i+1)+"="+objects[i].getAttribute('xmlfile');
				savestring+="&guid"+(i+1)+"="+encodeURIComponent(objects[i].getAttribute('guid'));
				savestring+="&key"+(i+1)+"="+encodeURIComponent(key);
				savestring+="&value"+(i+1)+"="+encodeURIComponent(value);
			}
		}
		savestring += "&formcount="+items;
		savestring += '&params='+encodeURIComponent(window['params']);
		if(items)
		{
			if(!oncomplete)
				oncomplete="document.location=document.location";
			ajaxpage(syspath+"/_system/ajax/ajax_update_form_attribute.cfm","dbgdiv",savestring,oncomplete);
		}
	}*/




}