<?xml version="1.0" encoding="UTF-8"?>
<rmml>

<composition name="rnmc_stdIntegration" class="rnmc_stdMediaGroup">
<script><![CDATA[

// ======================================================================
// 			настройки
// ======================================================================
//	перемешивать объекты на старте
	this.randomOnStart = false; //true;	
//	возврат объекта на исходную позицию при перетаскивании за пределы зоны
	this.return = true;

//	скорость движения
	this.flowdelta = 15;

//	границы таскания
	this.minDraggingBoundX = 0;
	this.maxDraggingBoundX = Player.module.scenes.width;
	this.minDraggingBoundY = 0;
	this.maxDraggingBoundY = Player.module.scenes.height;

//	зона для объекта Integration
	this.targetID = null;
	this.targetEnabled = true;

//	чувствительность по умолчанию
	this.sensitivity = 20;

//	точка регистрации таскаемых объектов при отпускании мышки
	this.regPointType = "LEFT_TOP";
//	this.regPointType = "CENTER";
//	this.regPointType = "MOUSE";

//	массив стартовых позиций
	this.startPlaces = new Array();
//	массив ттаскаемых объектов
	this.inegration = null;

// количество оставшихся объектов, которые необходимо расставить
	this.dragObjectsRemaining = 0;

	function initFromNode(srcNode, useDelayLoad){
		var xmlNode = null;
		var xmlAttributeMap = null;
		var xmlAttribute = null;
		this.targetObj = new Array();
		this.buttons = new Array();	
		this.integration = new Array();

		xmlAttributeMap = srcNode.attributes;
		if (xmlAttributeMap){
			xmlAttribute = xmlAttributeMap.getNamedItem("id");
			if (xmlAttribute != null && xmlAttribute.specified){
				this.id = xmlAttribute.value;
			}
			xmlAttribute = xmlAttributeMap.getNamedItem("visible");
			if (xmlAttribute != null && xmlAttribute.specified){
				if(xmlAttribute.value.toLowerCase() == "true")
					this.visibility = OBJECT_VISIBILITY_TRUE;
				else if(xmlAttribute.value.toLowerCase() == "false")
					this.visibility = OBJECT_VISIBILITY_FALSE;
			}
			xmlAttribute = xmlAttributeMap.getNamedItem("enabled");
			if (xmlAttribute != null && xmlAttribute.specified
			&& xmlAttribute.value.toLowerCase() == "false")
				this.disabled = true;
		}

		this.loadChildsObject(srcNode)

		for(var i = 0; i < this.childObjects.length; i++){
		//	создаем массив кнопок, т.к. они не таскаются по определению
			if(this.childObjects[i].type == "rnmc_stdButton")
				this.buttons.push(this.childObjects[i]);
			else{
			//	создаем массив таскаемых объектов
				this.childObjects[i].objectState = DRAGOBJECT_STATE_BEFORESTART;
			//	добавляем копии таскаемых объектов, если нужно (параметр quantity)
				if(this.childObjects[i].quantity > 1)
					for(var j = 1; j < this.childObjects[i].quantity; j++)
						this.childObjects[i].copies[j].objectState = DRAGOBJECT_STATE_BEFORESTART;
				this.integration.push(this.childObjects[i]);
			}
		}

		xmlNode = srcNode.firstChild;

		while(xmlNode){

			if(xmlNode.nodeName == "param"){

			// разбор стандартных настроек
				this.parseParamNode(xmlNode);

			// разбор специфичных настроек
				xmlAttributeMap = xmlNode.attributes;
				if (xmlAttributeMap){
					xmlAttribute =  xmlAttributeMap.getNamedItem("random");
					if (xmlAttribute != null && xmlAttribute.specified){
						if(xmlAttribute.value.toLowerCase() == "true"){
							this.randomOnStart = true;
						} else if (xmlAttribute.value.toLowerCase() == "false"){
							this.randomOnStart = false;
						}
					};
					xmlAttribute =  xmlAttributeMap.getNamedItem("return");
					if (xmlAttribute != null && xmlAttribute.specified){
						if(xmlAttribute.value.toLowerCase() == "true"){
							this.return = true;
						} else if (xmlAttribute.value.toLowerCase() == "false"){
							this.return = false;
						}
					};
				//	точка регистрации таскаемых объектов при отпускании мышки
					xmlAttribute =  xmlAttributeMap.getNamedItem("regPoint");
					if (xmlAttribute != null && xmlAttribute.specified){
						this.regPointType = xmlAttribute.value;
					};
				}
			} else if(xmlNode.nodeName == "actions"){
				this.parseActionsNode(xmlNode);

				this.onAllObjectsPlacedActions =
					scene.Utils.parseActionsNode(xmlNode, "onAllObjectsPlaced");
				this.onPlacedRightActions =
					scene.Utils.parseActionsNode(xmlNode, "onPlacedRight");
				this.onPlacedWrongActions =
					scene.Utils.parseActionsNode(xmlNode, "onPlacedWrong");
				this.onEnterTargetActions =
					scene.Utils.parseActionsNode(xmlNode, "onEnterTarget");
				this.onLeaveTargetActions =
					scene.Utils.parseActionsNode(xmlNode, "onLeaveTarget");
			} else if(xmlNode.nodeName == "effects"){
				this.parseEffectsNode(xmlNode);
			} else if(xmlNode.nodeName == "objectives"){
				this.parseObjectivesNode(xmlNode);
			} else if(xmlNode.nodeName == "conditions"){
				var conditionNode = xmlNode.firstChild;
				while(conditionNode){
					if(conditionNode.nodeName == "condition"){
						this.parseConditionNode(conditionNode);
					}
					conditionNode = conditionNode.nextSibling;
				}
				this.parseConditionNode(xmlNode);
			} else if(xmlNode.nodeName == "properties"){
				this.parsePropertiesNode(xmlNode);

			//цель
			} else if(xmlNode.nodeName == "target"){
				xmlAttributeMap = xmlNode.attributes;
				if (xmlAttributeMap){
					xmlAttribute = xmlAttributeMap.getNamedItem("id");
					if (xmlAttribute != null && xmlAttribute.specified)
						this.targetID = xmlAttribute.value;
					xmlAttribute = xmlAttributeMap.getNamedItem("enabled");
					if (xmlAttribute != null && xmlAttribute.specified
						&& xmlAttribute.value == "false")
						this.targetEnabled = false;
				}

				this.loadChildsObject(xmlNode);

				if(this.childObjects[this.childObjects.length-1]){
					this.targetObj = this.childObjects[this.childObjects.length-1];
					this.targetObj.target = true;
				}

				var rollNode = xmlNode.firstChild;
				while(rollNode){
					if(rollNode.nodeName == "rollovermenu")
						this.targetObj.parseRolloverMenuNode(rollNode);
					rollNode = rollNode.nextSibling;
				}

			//	исзодные позиции таскаемых объектов
			} else if(xmlNode.nodeName == "startplaces"){
				var startPlaceNode = xmlNode.firstChild;

				while(startPlaceNode){
					if(startPlaceNode.nodeName == "place"){
						var startPlaceX = 0;
	 					var startPlaceY = 0;
						var startPlaceWidth = 0;
						var startPlaceHeight = 0;
						var startPlaceSensitivity = 30;
						var quantity = 1;
						xmlAttributeMap = startPlaceNode.attributes;
						if (xmlAttributeMap){
							xmlAttribute =  xmlAttributeMap.getNamedItem("x");
							if (xmlAttribute != null && xmlAttribute.specified){
								startPlaceX = parseInt(xmlAttribute.value);
							};
							xmlAttribute =  xmlAttributeMap.getNamedItem("y");
							if (xmlAttribute != null && xmlAttribute.specified){
								startPlaceY = parseInt(xmlAttribute.value);
							};
							xmlAttribute =  xmlAttributeMap.getNamedItem("width");
							if (xmlAttribute != null && xmlAttribute.specified){
								startPlaceWidth = parseInt(xmlAttribute.value);
							};
							xmlAttribute =  xmlAttributeMap.getNamedItem("height");
							if (xmlAttribute != null && xmlAttribute.specified){
								startPlaceHeight = parseInt(xmlAttribute.value);
							};
							xmlAttribute =  xmlAttributeMap.getNamedItem("quantity");
							if (xmlAttribute != null && xmlAttribute.specified){
								quantity = parseInt(xmlAttribute.value);										
							};
						}
						var newPlaceCoords = new Array(startPlaceX, startPlaceY,
													startPlaceWidth, startPlaceHeight,
													startPlaceSensitivity);
						newPlaceCoords.freePlace = true;
						newPlaceCoords.objectIndex = -1;
						this.startPlaces.push(newPlaceCoords);
						if (quantity > 1){
							for(var i = 1; i < quantity; i++){
								var newPlaceCoords2 = new Array(startPlaceX, startPlaceY,
													startPlaceWidth, startPlaceHeight,
													startPlaceSensitivity);
								newPlaceCoords2.freePlace = true;
								newPlaceCoords2.objectIndex = -1;
								this.startPlaces.push(newPlaceCoords2);
							}
						}
					}
					startPlaceNode = startPlaceNode.nextSibling;
				}
			}
			xmlNode = xmlNode.nextSibling;
		}

		return true;
	}

//	показать таскаемый объект
	function showDragObject(intObj){
		if(intObj){
		//	не показываем объекты, которые еще не на старте или уже скрыты
		// (в случае, если в настройке после отпускания объекта вне цели - скрывать его)
			if(intObj.objectState == DRAGOBJECT_STATE_PLACED
				|| intObj.objectState == DRAGOBJECT_STATE_ONSTART){
				intObj.draggingEnabled = true;
				intObj.integration = true;
				intObj.showObject();

				if (intObj.onPressHandlerOriginal == undefined){
					intObj.onPressHandlerOriginal = intObj.onPressHandler;
					intObj.onPressHandler = function() {
						intObj.depth -= 500;
						checkQuantity(intObj);
						intObj.onPressHandlerOriginal();
					}
				}

				if (intObj.onReleaseHandlerOriginal == undefined){
					intObj.onReleaseHandlerOriginal = intObj.onReleaseHandler;
					intObj.onReleaseHandler = function() {
						if(intObj.objectCaptured){
							placeObject(intObj);
						}
						intObj.onReleaseHandlerOriginal();
					}
				}

				if (intObj.onReleaseOutsideHandlerOriginal == undefined){
					intObj.onReleaseOutsideHandlerOriginal = intObj.onReleaseOutsideHandler;
					intObj.onReleaseOutsideHandler = function() {
						if(intObj.objectCaptured){
							placeObject(intObj);
						}
						intObj.onReleaseOutsideHandlerOriginal();
					}
				}
			}

			if(intObj.objectState == DRAGOBJECT_STATE_ONSTART){
				intObj.setPosition(intObj.startX, intObj.startY);
			}
		// сохранение исходной глубины таскаемых объектов,
		// чтобы после установки их в цель, вернуть ее
			intObj.originalDepth = intObj.objectDepth;
		} else 
			trace("#FF0000!!!!!!!!!!НЕ ЗАДАН ТАСКАЕМЫЙ ОБЪЕКТ");
	}

	function showObject(){
		if(this.targetObj){
			if(this.targetObj.visibility != OBJECT_VISIBILITY_FALSE)
				this.targetObj.showObject();
		//	переопределние кнопок сохранить и копировать для цели
			if(this.targetObj.rolloverMenuDefined){
				this.targetObj.rolloverMenuObject.setCallBack(this.targetObj, this.buttonDispatcher);
			}
		} else
			trace("#FF0000!!!!!!!!!!НЕ ЗАДАНА ЦЕЛЕВАЯ ОБЛАСТЬ");
		if(this.buttons)
			for(var i = 0; i < this.buttons.length; i++)
				if(this.buttons[i].visibility != OBJECT_VISIBILITY_FALSE)
					this.buttons[i].showObject();

		for(var i = 0; i < this.integration.length; i++)
			if(this.integration[i].objectState == DRAGOBJECT_STATE_PLACED
				|| this.integration[i].objectState == DRAGOBJECT_STATE_ONSTART){
				if(this.integration[i].quantity > 1)
					for(var j = 1; j < this.integration[i].quantity; j++)
						if(this.integration[i].copies[j].objectState == DRAGOBJECT_STATE_PLACED ||
							this.integration[i].copies[j].objectState == DRAGOBJECT_STATE_ONSTART)
							this.integration[i].copies[j].showObject();
				this.integration[i].showObject();
			}

		if(this.startOrder)
			this.startOrder = null;
		this.startOrder = new Array();
		if(this.randomOnStart){
		//	если таскаемые объекты расставляются в стартовых позициях в случайном порядке
			var tempSequence = new Array();
			for(var i = 0; i < this.integration.length; i++)
				tempSequence.push(i);
			this.startOrder = scene.Utils.permutateArray(tempSequence);
			tempSequence = null;
		} else {
			for(var i = 0; i < this.integration.length; i++)
				this.startOrder.push(i);
		}

		this.prepareStartPlace();

		this.objectResult = 0;	
                rnmc_stdMediaObject_showObject();
	}

	function hideDragObject(intObj){
		if(intObj && intObj.visible){
			intObj.draggingEnabled = false;
			intObj.hideObject();

			intObj.onPressHandler = intObj.onPressHandlerOriginal;
			delete intObj.onPressHandlerOriginal;

			intObj.onReleaseHandler = intObj.onReleaseHandlerOriginal;
			delete intObj.onReleaseHandlerOriginal;
		}
	}

	function hideObject(){
		this.targetObj.hideObject();

		for(var i = 0; i < this.buttons.length; i++)
			this.buttons[i].hideObject();

		for(var i = 0; i < this.integration.length; i++){
			if(this.integration[i].quantity > 1)
				for(var j = 1; j < this.integration[i].quantity; j++)
					this.integration[i].copies[j].hideObject();
			this.integration[i].hideObject();
		}
		rnmc_stdMediaObject_hideObject();
	}

//	сохраняет получившуюся композицию (переопределение кнопок сохранить и копировать)
	function buttonDispatcher(btnId){
		this.objectContent.depth -= 20;

		this.picture = new Image();
		this.picture.visible = false;
		this.picture.parent = this.objectContent;
		var globCoord = parent.localToGlobal(this.objectContent.x, this.objectContent.y);
		this.picture.makeSnapshot(globCoord.x, globCoord.y,
			globCoord.x+this.objectContent.width, globCoord.y+this.objectContent.height);

		switch(btnId.toLowerCase()){
			case "save":
				this.picture.saveAs();
				break;
			case "copy":
				this.picture.copyToClipboard();
				break;
			default:
				trace("UNKNOWN BUTTON ID: " + btnId);
		}

		this.objectContent.depth += 20;
		this.picture.parent = null;
		this.picture = null;
	}

//	обновляет объекты на старте
	function prepareStartPlace(){
//trace("prepareStartPlace()");
	//	режим замещения объекта (т.е на пустом месте появляется следующий
	//	объект из набора, в том случае если он есть)
		for(var i = 0; i < this.startPlaces.length; i++){
			if(this.startPlaces[i].freePlace){
				for(var j = 0; j < this.startOrder.length; j++){
				//	перебираем таскаемые объекты в той последовательности
				//    которая startOrder
				//	и выбираем из них те, которые еще не помещены
				//    и которые еще не на старте
					if(this.integration[this.startOrder[j]].objectState == DRAGOBJECT_STATE_BEFORESTART){
						this.setStartPlace(this.integration[this.startOrder[j]], i);
						this.integration[this.startOrder[j]].objectState = DRAGOBJECT_STATE_ONSTART;
						this.showDragObject(this.integration[this.startOrder[j]]);

						this.startPlaces[i].freePlace = false;
						this.startPlaces[i].objectIndex = j;
						break;
					} else if(this.integration[this.startOrder[j]].objectState == DRAGOBJECT_STATE_PLACED){ 
						if(this.integration[this.startOrder[j]].quantity > 1){
							var copBreak = false;
							for(var k = 1; k < this.integration[this.startOrder[j]].quantity; k++){
								if(this.integration[this.startOrder[j]].copies[k].objectState == DRAGOBJECT_STATE_BEFORESTART){
									this.setStartPlace(this.integration[this.startOrder[j]].copies[k], i);
									this.integration[this.startOrder[j]].copies[k].objectState = DRAGOBJECT_STATE_ONSTART;
									this.showDragObject(this.integration[this.startOrder[j]].copies[k]);
									this.startPlaces[i].freePlace = false;
									this.startPlaces[i].objectIndex = j;
									copBreak = true;
									break;
								}
							}
							if(copBreak)
								break;
						}
					}
				}
			}
		}
	}

	function refreshStartPlace(){
//trace("refreshStartPlace()");
		for(var i = 0; i < this.startPlaces.length; i++){
			if(this.startPlaces[i].freePlace){
				for(var j = 0; j < this.startOrder.length; j++){
			//	перебираем таскаемые объекты в той последовательности которая startOrder
			//	и выбираем из них те, которые еще не помещены и которые еще не на старте
					if(this.integration[this.startOrder[j]].objectState == DRAGOBJECT_STATE_ONSTART)
						continue;
					var onStart = false;
					if(this.integration[this.startOrder[j]].quantity > 1)
						for(var k = 1; k < this.integration[this.startOrder[j]].quantity; k++)
							if(this.integration[this.startOrder[j]].copies[k].objectState == DRAGOBJECT_STATE_ONSTART){
								onStart = true;
								break;
							}
					if(onStart)
						continue;
					if(this.integration[this.startOrder[j]].objectState == DRAGOBJECT_STATE_BEFORESTART){
						this.setStartPlace(this.integration[this.startOrder[j]], i);
						this.integration[this.startOrder[j]].objectState = DRAGOBJECT_STATE_ONSTART;
						this.showDragObject(this.integration[this.startOrder[j]]);
						this.startPlaces[i].freePlace = false;
						this.startPlaces[i].objectIndex = j;
						this.startPlaces[i].placedObject = this.integration[this.startOrder[j]].id;
						break;
					} else if(this.integration[this.startOrder[j]].objectState == DRAGOBJECT_STATE_PLACED){ 
						if(this.integration[this.startOrder[j]].quantity > 1){
							var copBreak = false;
							for(var k = 1; k < this.integration[this.startOrder[j]].quantity; k++){
								if(this.integration[this.startOrder[j]].copies[k].objectState == DRAGOBJECT_STATE_BEFORESTART){
									this.setStartPlace(this.integration[this.startOrder[j]].copies[k], i);
									this.integration[this.startOrder[j]].copies[k].objectState = DRAGOBJECT_STATE_ONSTART;	
									this.showDragObject(this.integration[this.startOrder[j]].copies[k]);
									this.startPlaces[i].freePlace = false;
									this.startPlaces[i].objectIndex = j;
									this.startPlaces[i].placedObject = this.integration[this.startOrder[j]].copies[k].id;
									copBreak = true;
									break;
								}
							}
							if(copBreak)
								break;
						}
					}
				}
			}
		}
	}	

//	возвращет координаты i-ого стартового места
// 	(под местом понимается ячейка под один перетаскиваемый объект)
	function getStartPlaceCoords(placeIndex){
		if(placeIndex < this.startPlaces.length){
			var placeCoords = (this.startPlaces[placeIndex]).slice(0);
			return placeCoords;
		}
	}

//	ссобщение от таскаемого объекта об освобождении некотрой стартовой позиции
	function notifyStartPlaceFree(placeIndex){
//trace("#FF0000notifyStartPlaceFree(" + placeIndex + ")");
		if(placeIndex >= 0 && placeIndex < this.startPlaces.length){
			this.startPlaces[placeIndex].freePlace = true;
			this.startPlaces[placeIndex].objectIndex = -1;
			this.refreshStartPlace();
		}
	}	

//	actions при наведении и отведении объекта на цель
	function notifyMouseCoords(intObj){
		this.regPoint(intObj);
		var globCoord = parent.localToGlobal(intObj.testOffsetX, intObj.testOffsetY);

		if(this.testMatched(globCoord.x, globCoord.y)){
			if(!intObj.objectInsideTarget){
				intObj.objectInsideTarget = true;
				if(this.onEnterTargetActions){
					for(var i = 0; i < this.onEnterTargetActions.length; i++){
						this.dispatchAction(this.onEnterTargetActions[i]);
					}
				}
				if(intObj.onEnterTargetActions){
					for(var i = 0; i < intObj.actionsList[EVENT_ON_ENTERTARGET].length; i++){
						this.dispatchAction(intObj.actionsList[EVENT_ON_ENTERTARGET][i]);
					}
				}
			}
		} else {
			if(intObj.objectInsideTarget){
				intObj.objectInsideTarget = false;
				if(this.onLeaveTargetActions){
					for(var i = 0; i < this.onLeaveTargetActions.length; i++){
						this.dispatchAction(this.onLeaveTargetActions[i]);
					}
				}
				if(intObj.onLeaveTargetActions){
					for(var i = 0; i < intObj.actionsList[EVENT_ON_LEAVETARGET].length; i++){
						this.dispatchAction(intObj.actionsList[EVENT_ON_LEAVETARGET][i]);
					}
				}
			}
		}
	}

//	сдвиг таскаемых объектов в стартовых позициях вправо (для прокрутки используемых объектов кнопками с actions - nextObject и previousObject)
	function shiftRight(i, number){
		if(this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART){
			this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].objectState = DRAGOBJECT_STATE_BEFORESTART;
			this.hideDragObject(this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]]);
		} else if(this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].quantity > 1){

		//	проверяем не поставлены ли в цель копии объекта, занимавшего последнюю стартовую позицию
			for(var j = 1; j < this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].quantity; j++){
				if(this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].copies[j].objectState == DRAGOBJECT_STATE_ONSTART){
					this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].copies[j].objectState = DRAGOBJECT_STATE_BEFORESTART;
					this.hideDragObject(this.integration[this.startOrder[this.startPlaces[number-1].objectIndex]].copies[j]);
					break;
				}
			}
		}
		for(var j = number - 1; j > 0; j--){
			if(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART){
				this.setStartPlace(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]], j);
				this.showDragObject(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]]);
				this.startPlaces[j].objectIndex = this.startPlaces[j-1].objectIndex;
				this.startPlaces[j].placedObject = this.startPlaces[j-1].placedObject;
				this.startPlaces[j].freePlace = this.startPlaces[j-1].freePlace;
			} else if(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].quantity > 1){
				for(var k = 1; k < this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].quantity; k++){
					if(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].copies[k].objectState == DRAGOBJECT_STATE_ONSTART){
						this.setStartPlace(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].copies[k], j);
						this.showDragObject(this.integration[this.startOrder[this.startPlaces[j-1].objectIndex]].copies[k]);
						this.startPlaces[j].objectIndex = this.startPlaces[j-1].objectIndex;
						this.startPlaces[j].placedObject = this.startPlaces[j-1].placedObject;
						this.startPlaces[j].freePlace = this.startPlaces[j-1].freePlace;
						break;
					}
				}
			}
		}
	}

//	сдвиг таскаемых объектов в стартовых позициях влево (для прокрутки используемых объектов кнопками с actions - nextObject и previousObject)
	function shiftLeft(i, number){
		if(this.integration[this.startOrder[this.startPlaces[0].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART){
			this.integration[this.startOrder[this.startPlaces[0].objectIndex]].objectState = DRAGOBJECT_STATE_BEFORESTART;
			this.hideDragObject(this.integration[this.startOrder[this.startPlaces[0].objectIndex]]);
		} else if(this.integration[this.startOrder[this.startPlaces[0].objectIndex]].quantity > 1){
		//	проверяем не поставлены ли в цель копии объекта, занимавшего последнюю стартовую позицию
			for(var j = 1; j < this.integration[this.startOrder[this.startPlaces[0].objectIndex]].quantity; j++){
				if(this.integration[this.startOrder[this.startPlaces[0].objectIndex]].copies[j].objectState == DRAGOBJECT_STATE_ONSTART){
					this.integration[this.startOrder[this.startPlaces[0].objectIndex]].copies[j].objectState = DRAGOBJECT_STATE_BEFORESTART;
					this.hideDragObject(this.integration[this.startOrder[this.startPlaces[0].objectIndex]].copies[j]);
					break;
				}
			}
		}
		for(var j = 1; j < number; j++){
			if(this.integration[this.startOrder[this.startPlaces[j].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART){
				this.setStartPlace(this.integration[this.startOrder[this.startPlaces[j].objectIndex]], j-1);
				this.showDragObject(this.integration[this.startOrder[this.startPlaces[j].objectIndex]]);
				this.startPlaces[j-1].objectIndex = this.startPlaces[j].objectIndex;
				this.startPlaces[j-1].placedObject = this.startPlaces[j].placedObject;
				this.startPlaces[j-1].freePlace = this.startPlaces[j].freePlace;
			} else if(this.integration[this.startOrder[this.startPlaces[j].objectIndex]].quantity > 1){
				for(var k = 1; k < this.integration[this.startOrder[this.startPlaces[j].objectIndex]].quantity; k++){
					if(this.integration[this.startOrder[this.startPlaces[j].objectIndex]].copies[k].objectState == DRAGOBJECT_STATE_ONSTART){
						this.setStartPlace(this.integration[this.startOrder[this.startPlaces[j].objectIndex]].copies[k], j-1);
						this.showDragObject(this.integration[this.startOrder[this.startPlaces[j].objectIndex]].copies[k]);
						this.startPlaces[j-1].objectIndex = this.startPlaces[j].objectIndex;
						this.startPlaces[j-1].placedObject = this.startPlaces[j].placedObject;
						this.startPlaces[j-1].freePlace = this.startPlaces[j].freePlace;
						break;
					}
				}
			}
		}
	}

//	перебор: предыдущий объект
	function previousObject(){
//trace("previousObject()");
		var nextFound = false;
		var number = this.startPlaces.length;
		var i = this.startPlaces[0].objectIndex;
		if(i < 0)
			return;
		while(!nextFound){
			if(i == 0)
				i = this.startOrder.length - 1
			else
				i--;
			if(i == this.startPlaces[0].objectIndex)
				break;
			if(this.integration[this.startOrder[i]].objectState == DRAGOBJECT_STATE_ONSTART)
				continue;
			var onStart = false;
			if(this.integration[this.startOrder[i]].quantity > 1)
				for(var j = 1; j < this.integration[this.startOrder[i]].quantity; j++)
					if(this.integration[this.startOrder[i]].copies[j].objectState == DRAGOBJECT_STATE_ONSTART){
						onStart = true;
						break;
					}
			if(onStart)
				continue;

			 if(this.integration[this.startOrder[i]].objectState == DRAGOBJECT_STATE_BEFORESTART){
				nextFound = true;
				this.shiftRight(i, number);
				this.setStartPlace(this.integration[this.startOrder[i]], 0);
				this.integration[this.startOrder[i]].objectState = DRAGOBJECT_STATE_ONSTART;
				this.showDragObject(this.integration[this.startOrder[i]]);
				this.startPlaces[0].objectIndex = i;
				this.startPlaces[0].placedObject = this.integration[this.startOrder[i]].id;
				this.startPlaces[0].freePlace = false;
				break;
			} else if(this.integration[this.startOrder[i]].quantity > 1){
				for(var j = 1; j < this.integration[this.startOrder[i]].quantity; j++){
					if(this.integration[this.startOrder[i]].copies[j].objectState == DRAGOBJECT_STATE_BEFORESTART){
						nextFound = true;
						this.shiftRight(i, number);
						this.setStartPlace(this.integration[this.startOrder[i]].copies[j], 0);
						this.integration[this.startOrder[i]].copies[j].objectState = DRAGOBJECT_STATE_ONSTART;
						this.showDragObject(this.integration[this.startOrder[i]].copies[j]);
						this.startPlaces[0].objectIndex = i;
						this.startPlaces[0].placedObject = this.integration[this.startOrder[i]].id;
						this.startPlaces[0].freePlace = false;
						break;
					}
				}
			}
		};
	}

//	перебор: следующий объект
	function nextObject(){
//trace("nextObject()");
		var nextFound = false;
		var number = this.startPlaces.length;
		var i = this.startPlaces[number-1].objectIndex;
		if(i < 0)
			return;
		while(!nextFound){
			if(i == this.startOrder.length - 1)
				i = 0
			else
				i++;
			if(i == this.startPlaces[number-1].objectIndex)
				break;
			if(this.integration[this.startOrder[i]].objectState == DRAGOBJECT_STATE_ONSTART)
				continue;
			var onStart = false;
			if(this.integration[this.startOrder[i]].quantity > 1)
				for(var j = 1; j < this.integration[this.startOrder[i]].quantity; j++)
					if(this.integration[this.startOrder[i]].copies[j].objectState == DRAGOBJECT_STATE_ONSTART){
						onStart = true;
						break;
					}
			if(onStart)
				continue;

			if(this.integration[this.startOrder[i]].objectState == DRAGOBJECT_STATE_BEFORESTART){
				nextFound = true;
				this.shiftLeft(i, number);
				this.setStartPlace(this.integration[this.startOrder[i]], number-1);
				this.integration[this.startOrder[i]].objectState = DRAGOBJECT_STATE_ONSTART;
				this.showDragObject(this.integration[this.startOrder[i]]);
				this.startPlaces[number-1].objectIndex = i;
				this.startPlaces[number-1].placedObject = this.integration[this.startOrder[i]].id;
				this.startPlaces[number-1].freePlace = false;
				break;
			} else if(this.integration[this.startOrder[i]].quantity > 1){
				for(var j = 1; j < this.integration[this.startOrder[i]].quantity; j++){
					if(this.integration[this.startOrder[i]].copies[j].objectState == DRAGOBJECT_STATE_BEFORESTART){
						nextFound = true;
						this.shiftLeft(i, number);
						this.setStartPlace(this.integration[this.startOrder[i]].copies[j], number-1);
						this.integration[this.startOrder[i]].copies[j].objectState = DRAGOBJECT_STATE_ONSTART;
						this.showDragObject(this.integration[this.startOrder[i]].copies[j]);
						this.startPlaces[number-1].objectIndex = i;
						this.startPlaces[number-1].placedObject = this.integration[this.startOrder[i]].id;
						this.startPlaces[number-1].freePlace = false;
						break;
					}
				}
			}
		};
	}	

//	сброс
	function resetObject(){
//trace("#FF0000resetObject()");
		//	устанавливаем изначальное состояние объектов
		for(var i = 0; i < this.integration.length; i++){
			if(this.integration[i].quantity > 1)
				for(var j = 1; j < this.integration[i].quantity; j++){
					this.integration[i].copies[j].startPlace = -1;
					this.integration[i].copies[j].objectState = DRAGOBJECT_STATE_BEFORESTART;
					this.hideDragObject(integration[i].copies[j]);
				}
			this.integration[i].startPlace = -1;
			this.integration[i].objectState = DRAGOBJECT_STATE_BEFORESTART;
			this.hideDragObject(this.integration[i]);
		}
		//	очищаем стартовые позиции
		for(var i = 0; i < this.startPlaces.length; i++){
			this.startPlaces[i].freePlace = true;
			this.startPlaces[i].objectIndex = -1;
		}

		this.objectResult = 0;

		if(this.startOrder)
			this.startOrder = null;
		this.startOrder = new Array();
		if(this.randomOnStart){
			var tempSequence = new Array();
			for(var i = 0; i < this.integration.length; i++)
				tempSequence.push(i);
			this.startOrder = scene.Utils.permutateArray(tempSequence);
			tempSequence = null;
		} else {
			for(var i = 0; i < this.integration.length; i++)
				this.startOrder.push(i);
		}
		this.prepareStartPlace();
		rnmc_stdMediaObject_resetObject();
	}

	function dispatchAction(singleAction){
		switch (singleAction[0]) {
			case "showDragObject":
			case "hideDragObject":
			case "previousObject":
			case "nextObject":
			case "resetObject":
				this.doAction(singleAction);
				break;

			default:
				rnmc_stdMediaGroup_dispatchAction(singleAction);
				break;
		}
	}


//	выполняет специфичные для объекта rnmc_stdIntegration действия
	function doAction(singleAction){
//trace("integration: " + this.id + " - doAction: " + singleAction);	
		switch(singleAction[0]){
		case "showDragObject":
			for(var i = 0; i < this.integration.length; i++){
				if(this.integration[i].id == singleAction[1]){
					if(!this.integration[i].disabled){
						this.showDragObject(this.integration[i]);
					}
				}
			}
			break;
		case "hideDragObject":
			for(var i = 0; i < this.integration.length; i++){
				if(this.integration[i].id == singleAction[1]){
					if(!this.integration[i].disabled)
						this.hideDragObject(this.integration[i]);
				}
			}
			break;
		case "previousObject":
			this.previousObject();
			break;	
		case "nextObject":
			this.nextObject();
			break;
		case "resetObject":
			this.resetObject();
			break;	
		default:
			rnmc_stdMediaGroup_doAction(singleAction);
			break;
		};
	}

	function applyDefaultActions(intObj, forEvent){
		switch(forEvent){
		case "onPlacedRight":
			if(this.onPlacedRightActions){
				for(var i = 0; i < this.onPlacedRightActions.length; i++){
					this.dispatchAction(this.onPlacedRightActions[i]);
				}
			}
			if(intObj.onPlacedRightActions){
				for(var i = 0; i < intObj.actionsList[EVENT_ON_PLACEDRIGHT].length; i++){
					this.dispatchAction(intObj.actionsList[EVENT_ON_PLACEDRIGHT][i]);
				}
			}
			break;
		case "onPlacedWrong":
			if(this.onPlacedWrongActions){
				for(var i = 0; i < this.onPlacedWrongActions.length; i++){
					this.dispatchAction(this.onPlacedWrongActions[i]);
				}
			}
			if(intObj.onPlacedWrongActions){
				for(var i = 0; i < intObj.actionsList[EVENT_ON_PLACEDWRONG].length; i++){
					this.dispatchAction(intObj.actionsList[EVENT_ON_PLACEDWRONG][i]);
				}
			}
			break;
		case "onAllObjectsPlaced":
			if(this.onAllObjectsPlacedActions){
				for(var i = 0; i < this.onAllObjectsPlacedActions.length; i++){
					this.dispatchAction(this.onAllObjectsPlacedActions[i]);
				}
			}
			break;
		}
	}

//	проверка нахождения таскаемого объекта над целью
	function testMatched(testX, testY){
		if (!this.targetEnabled)
			return false;

		var locCoord = parent.globalToLocal(testX, testY);
		testX = locCoord.x;// + scene.x;
		testY = locCoord.y;// + scene.y;
		if(this.targetEnabled){
			if(testX > this.targetObj.objectContent.x &&
				testX < this.targetObj.objectContent.x + this.targetObj.objectContent.width &&
				testY > this.targetObj.objectContent.y &&
				testY < this.targetObj.objectContent.y + this.targetObj.objectContent.height){

				return true;
			} else return false;
		}
	}	

//	устанавливает занятую стартовую позицию
	function setStartPlace(intObj, placeIndex){
		intObj.startPlace = placeIndex;
		if(placeIndex >= 0){
			var startPlaceCoords = this.getStartPlaceCoords(placeIndex);
			intObj.startX = startPlaceCoords[0];
			intObj.startY = startPlaceCoords[1];
		}
	}

//	скрывает крайний левый или крайний правый объект в стартовых позициях (при переборе таскаемых объектов)
	function hideOnStart(intObj){
		if(intObj.releasedStartPlace >= 0){			
			if(!this.startPlaces[intObj.releasedStartPlace].freePlace){
				if(this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART){
					this.hideDragObject(this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]]);
					this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].objectState = DRAGOBJECT_STATE_BEFORESTART;
				} else if(this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].quantity > 1){
					for(var i = 1; i < this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].quantity; i++){
						if(this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].copies[i].objectState ==
							DRAGOBJECT_STATE_ONSTART){
							this.hideDragObject(this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].copies[i]);
							this.integration[this.startOrder[this.startPlaces[intObj.releasedStartPlace].objectIndex]].copies[i].objectState = DRAGOBJECT_STATE_BEFORESTART;
							break;
						}
					}
				}
			}
			this.setStartPlace(intObj, intObj.releasedStartPlace);
			this.startPlaces[intObj.releasedStartPlace].freePlace = false;
			if(!intObj.copy)
				this.startPlaces[intObj.releasedStartPlace].objectIndex = this.startOrder.indexOf(this.integration.indexOf(intObj))
			else
				for(var i=0; i<this.integration.length; i++)
					if(this.integration[i].idUnique == intObj.idUnique){
						this.startPlaces[intObj.releasedStartPlace].objectIndex = this.startOrder.indexOf(i);
						break;
					}
		}
	}

//	производит стандартное действие с объектом
	function usePreDefinedBehaviour(intObj){
		if (this.return){
			//	отъезд на стартовую позицию
			var hiddenObject = null;
			if(intObj.quantity > 1){
				var onStart = false;
				for(var i = 1; i < intObj.quantity; i++)
					if(intObj.copies[i].objectState == DRAGOBJECT_STATE_ONSTART){
						hiddenObject = intObj.copies[i];
						intObj.copies[i].objectState = DRAGOBJECT_STATE_BEFORESTART;
						if(intObj.copies[i].startPlace >= 0){
							this.setStartPlace(intObj, intObj.copies[i].startPlace);
							this.startPlaces[intObj.copies[i].startPlace].freePlace = false;
						}
						onStart = true;
						break;
					}
				if(!onStart && intObj.objectState == DRAGOBJECT_STATE_PLACED)
					this.hideOnStart(intObj);
			} else if(intObj.copy){
				for(var i = 0; i < this.integration.length; i++)
					if(this.integration[i].idUnique == intObj.idUnique){
						if(this.integration[i].objectState == DRAGOBJECT_STATE_ONSTART){
							hiddenObject = this.integration[i];
							this.integration[i].objectState = DRAGOBJECT_STATE_BEFORESTART;
							if(this.integration[i].startPlace >= 0){
								this.setStartPlace(intObj, this.integration[i].startPlace);
								this.startPlaces[this.integration[i].startPlace].freePlace = false;
							}
						} else{
							var onStart = false;
							for(var j = 1; j < this.integration[i].quantity; j++)
								if(this.integration[i].copies[j].objectState == DRAGOBJECT_STATE_ONSTART && this.integration[i].copies[j] != intObj){
									hiddenObject = this.integration[i].copies[j];
									this.integration[i].copies[j].objectState = DRAGOBJECT_STATE_BEFORESTART;
									if(this.integration[i].copies[j].startPlace >= 0){
										this.setStartPlace(intObj, this.integration[i].copies[j].startPlace);
										this.startPlaces[this.integration[i].copies[j].startPlace].freePlace = false;
									}
									onStart = true;
									break;
								}
							if(!onStart && intObj.objectState == DRAGOBJECT_STATE_PLACED)
								this.hideOnStart(intObj);
						}
						break;
					}
			} else if(intObj.objectState == DRAGOBJECT_STATE_PLACED)
				this.hideOnStart(intObj);
			intObj.objectState = DRAGOBJECT_STATE_ONSTART;
			this.moveTo(intObj, intObj.startX, intObj.startY, hiddenObject);
		} else {
		//	объект - в корзину (скрыть)
			this.hideDragObject(intObj);
			intObj.objectState = DRAGOBJECT_STATE_INTRASHBOX;
		//	сообщаем что стартовое место, которое занимал этот объект теперь свободно
			if(intObj.releasedStartPlace >= 0){
				if(intObj.quantity > 1){
					var startFree = true;
					for(var i = 1; i < intObj.quantity; i++)
						if(intObj.copies[i].objectState == DRAGOBJECT_STATE_ONSTART){
							startFree = false
							break;
						}
					if(startFree){
						this.notifyStartPlaceFree(intObj, intObj.releasedStartPlace);
						intObj.startPlace = -1;
					}
				} else if(intObj.copy){
					var startFree = true;
					if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART)
						startFree = false;
					else
						for(var i = 1; i < this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].quantity; i++)
							if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i].objectState == DRAGOBJECT_STATE_ONSTART){
								startFree = false;
								break;
							}
					if(startFree == true){
						this.notifyStartPlaceFree(intObj, intObj.releasedStartPlace);
						intObj.startPlace = -1;
					}
				} else{
					this.notifyStartPlaceFree(intObj, intObj.releasedStartPlace);
					intObj.startPlace = -1;
				}
			}
		}
	}

	function moveTo(intObj, xDest, yDest, hiddenObject){
		var newEffect = new Composition();
		newEffect._class = "rnmc_stdEffect";
		newEffect.parent = intObj;
		newEffect.effectRunning = true;				
		newEffect.effectDelta = this.flowdelta;
		newEffect.effectType = EFFECT_MOVE;
		newEffect.targetObject = intObj.objectContent;
		newEffect.objectFinishX = xDest;
		newEffect.objectFinishY = yDest;		
		newEffect.integration = true;
		newEffect.hiddenObject = hiddenObject;
		newEffect.updateSequencer.playing = true;
	}

//	красивый возврат объекта на стартовую позицию
	function updateObject(intObj){
		if(!intObj.moveDestinationX)
			intObj.moveDestinationX = 0;
		if(!intObj.moveDestinationY)
			intObj.moveDestinationY = 0;

		var deltaX = intObj.objectContent.x;
		var deltaY = intObj.objectContent.y;

		var xTargetOffset = intObj.moveDestinationX - intObj.objectContent.x;
		var yTargetOffset = intObj.moveDestinationY - intObj.objectContent.y;

		if(xTargetOffset != 0){
			if (xTargetOffset > this.flowdelta)
				intObj.objectContent.x += this.flowdelta;
			else if (xTargetOffset < - this.flowdelta)
				intObj.objectContent.x -= this.flowdelta;
			else
				intObj.objectContent.x += xTargetOffset;
		};

		if(yTargetOffset != 0){
			if (yTargetOffset > this.flowdelta)
				intObj.objectContent.y += this.flowdelta;
			else if (yTargetOffset < - this.flowdelta)
				intObj.objectContent.y -= this.flowdelta;
			else
				intObj.objectContent.y += yTargetOffset;
		};

		deltaX -= intObj.objectContent.x;
		deltaY -= intObj.objectContent.y;
		
	// переместить присоединенный контрол
		if(intObj.controlAttachPoint && intObj.attachedControl){
			intObj.attachedControl.x -= deltaX;
			intObj.attachedControl.y -= deltaY;
		}

	// переместить присоединенную подпись
		if(intObj.titleAttachStyle != AUTOATTACH_NO){
			intObj.titleObject.x -= deltaX;
			intObj.titleObject.y -= deltaY;
		}

	// переместить скролинг
		if(intObj.objectContent && intObj.objectContent.scroller){
			intObj.objectContent.scroller.x -= deltaX;
			intObj.objectContent.scroller.y -= deltaY;
		}

		if (Math.round(xTargetOffset - 0.5) == 0 && Math.round(yTargetOffset - 0.5) == 0){
			intObj.updateSequencer.playing = false;
//			intObj.objectContent.depth = intObj.originalDepth;
//			if(intObj.controlAttachPoint && intObj.attachedControl)
//				intObj.attachedControl.depth = intObj.originalDepth;
			intObj.flowsNow = false;
		};
	};

//	точка регистрации таскаемых объектов при отпускании мышки
	function regPoint(intObj){
		switch(this.regPointType){
		case "LEFT_TOP":
			intObj.testOffsetX = intObj.objectContent.x;
			intObj.testOffsetY = intObj.objectContent.y;
			break;
		case "CENTER":
			intObj.testOffsetX = parseInt(intObj.objectContent.width/2);
			intObj.testOffsetY = parseInt(intObj.objectContent.height/2);
			break;
		case "MOUSE":
			if(intObj.xMouse < this.minDraggingBoundX)
				intObj.testOffsetX = 0
			else
				intObj.testOffsetX = intObj.xMouse;
			if(intObj.xMouse > this.maxDraggingBoundX)
				intObj.testOffsetX = this.maxDraggingBoundX
			else
				intObj.testOffsetX = intObj.xMouse;
			if(intObj.yMouse < this.minDraggingBoundY)
				intObj.testOffsetY = 0
			else
				intObj.testOffsetY = intObj.yMouse;
			if(intObj.yMouse > this.maxDraggingBoundY)
				intObj.testOffsetY = this.maxDraggingBoundY
			else
				intObj.testOffsetY = intObj.yMouse;
			break;
		}
	}

//	проверка на копии объкта после начала таскания 
// (сразу появляется копия этого объекта на той же стартовой позиции, если она есть)
	function checkQuantity(intObj){
		if(intObj.objectState == DRAGOBJECT_STATE_ONSTART){
			if(intObj.quantity > 1){
				for(var i = 1; i < intObj.quantity; i++){
					if(intObj.copies[i].objectState == DRAGOBJECT_STATE_BEFORESTART){
						this.setStartPlace(intObj.copies[i], intObj.startPlace);
						this.startPlaces[intObj.startPlace].freePlace = false;
						intObj.copies[i].objectState = DRAGOBJECT_STATE_ONSTART;
						this.showDragObject(intObj.copies[i]);
						break;
					}
				}
			} else if(intObj.copy){
				if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].objectState == DRAGOBJECT_STATE_BEFORESTART){
					this.setStartPlace(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]], intObj.startPlace);
					this.startPlaces[intObj.startPlace].freePlace = false;
					this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].objectState = DRAGOBJECT_STATE_ONSTART;
					this.showDragObject(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]]);
				} else{
					for(var i = 1; i < this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].quantity; i++){
						if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i].objectState == DRAGOBJECT_STATE_BEFORESTART){
							this.setStartPlace(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i], intObj.startPlace);
							this.startPlaces[intObj.startPlace].freePlace = false;
							this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i].objectState = DRAGOBJECT_STATE_ONSTART;
							this.showDragObject(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i]);
							break;
						}
					}
				}
			}
		}
	}

	function placeObject(intObj){
//trace("testIsInPlace");
		this.regPoint(intObj);

		//	сохраняем параметры последнего положения объекта 
		var globCoord = parent.localToGlobal(intObj.testOffsetX, intObj.testOffsetY);

		if(this.targetID){
		//	у объекта есть цель
			var matchedTargets = this.testMatched(globCoord.x, globCoord.y);
			var x = 0;
			var y = 0;

			if(matchedTargets){
				intObj.objectState = DRAGOBJECT_STATE_PLACED;

				if(intObj.objectContent.x + intObj.objectContent.width > this.targetObj.objectContent.x + this.targetObj.objectContent.width)
					x = this.targetObj.objectContent.x + this.targetObj.objectContent.width - intObj.objectContent.width
				else if(intObj.objectContent.x < this.targetObj.objectContent.x)
					x = this.targetObj.objectContent.x
				else
					x = intObj.objectContent.x;

				if(intObj.objectContent.y + intObj.height > this.targetObj.objectContent.y + this.targetObj.objectContent.height)
					y = this.targetObj.objectContent.y + this.targetObj.objectContent.height - intObj.objectContent.height
				else if(intObj.objectContent.y < this.targetObj.objectContent.y)
					y = this.targetObj.objectContent.y;	
				else
					y = intObj.objectContent.y;

				this.moveTo(intObj, x, y);
				
				if(intObj.startPlace >= 0){
					if(intObj.quantity > 1){
						var startFree = true;
						for(var i = 1; i < intObj.quantity; i++)
							if(intObj.copies[i].objectState == DRAGOBJECT_STATE_ONSTART){
								startFree = false
								break;
							}
						if(startFree)
							this.notifyStartPlaceFree(intObj.startPlace);
					} else if(intObj.copy){
						var startFree = true;
						if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].objectState == DRAGOBJECT_STATE_ONSTART)
							startFree = false;
						else
							for(var i = 1; i < this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].quantity; i++)
								if(this.integration[this.startOrder[this.startPlaces[intObj.startPlace].objectIndex]].copies[i].objectState == DRAGOBJECT_STATE_ONSTART){
									startFree = false;
									break;
								}
						if(startFree == true)
							this.notifyStartPlaceFree(intObj.startPlace);
					} else{
						this.notifyStartPlaceFree(intObj.startPlace);
					}
					intObj.releasedStartPlace = intObj.startPlace;
					intObj.startPlace = -1;
				}

				this.applyDefaultActions(intObj, "onPlacedRight");

				var all = true;
				for(var i = 0; i < this.integration.length; i++){
					if(this.integration[i].objectState != DRAGOBJECT_STATE_PLACED)
						break;
					if(this.integration[i].quantity > 1)
						for(var j = 1; j < this.integration[i].quantity; j++)
							if(this.integration[i].copies[j].objectState != DRAGOBJECT_STATE_PLACED)
								all = false;
					if(i == this.integration.length - 1 && all)
						this.applyDefaultActions(intObj, "onAllObjectsPlaced");
				}
			} else {
				this.applyDefaultActions(intObj, "onPlacedWrong");
				this.usePreDefinedBehaviour(intObj);
			}
		}
	};

//==================================================================
//	функция пока не используется
	function getResult(resultsArray){
		if(resultsArray && this.crAlgorithm != "none"){
			var resultString = this.objectResult + ";1.0";
			resultsArray.push(resultString);
		}

		rnmc_stdMediaGroup_getResult(resultsArray);
	}
]]></script>
</composition>
</rmml>