
<div style="width:100%;">
<?if ($this->message) :?>
<div style="background-color:PaleGreen; width:100%;">
<?=$this->message?>
</div>
<?endif;?>

<?=$this->form->renderOpen()?>

<div style="margin-left:10px;">
<?foreach ($this->form->getErrorMessages() as $error) {?>
<?=$error?>
<?}?>
</div>

<div class="formRow" style="padding-top:4px;">
	<?=$this->form->guid->renderLabel()?>
	<?$this->form->guid->setAttrib('size',55)?>
	<?=$this->form->guidInput()?>
</div>
<br style="clear:left;" />
<div class="formRow" style="padding-top:4px;">
	<?=$this->form->name->renderLabel()?>
	<?$this->form->name->setAttrib('size',30)?>
	<?=$this->form->nameInput()?>
	<?=$this->formButton('generateId',__('Generate Code'),array('onClick'=>'generateDefaultDestination()'))?>
</div>
<br style="clear:left;" />
<div class="formRow" style="padding-top:4px;">
	<?=$this->form->type->renderLabel()?>
	<?$this->form->type->setAttrib('size',55)?>
	<?=$this->form->typeInput()?>
</div>
<br style="clear:left;" />
<div class="formRow" style="padding-top:4px;">
	<?=$this->form->connectInfoInput('FormTextarea',array('style'=>'width:470px;height:220px;'))?>
</div>
<br style="clear:left;" />
<div class="formRow" style="padding-top:4px;">
	<?=$this->formHidden('id',$this->form->dataIntegrationDestinationId->getValue())?>
	<?=$this->form->dataIntegrationDestinationIdInput('FormHidden')?>
	<?=$this->formHidden('type',$this->form->handlerType->getValue())?>
	<?=$this->form->handlerTypeInput('FormHidden')?>
	<?=$this->form->okInput()?>
	<?=$this->formButton('cancelId',__('Cancel'),array('onClick'=>'dhxWins.window(\''.$this->form->getWindow().'\').close()'))?>
</div>

<script>
var defaultDestination = (<r><![CDATA[<?=$this->destination->defaultTemplate()?>]]></r>).toString();

function postSubmit<?=$this->form->getId()?>(data) {
<?if (strlen($this->callback) > 0):?>
	if (window.<?=$this->callback?>) {
		window.<?=$this->callback?>(data);
	}
<?endif;?>
	dhxWins.window('<?=$this->form->getWindow()?>').close();
	return false;
}

function preSubmit<?=$this->form->getId()?>() {
	var validName = "class "+globalNormalizedName(dojo.byId("<?=$this->form->name->getId()?>").value)+"DataIntegrationDestination";
	var connectInfo = dojo.byId("<?=$this->form->connectInfo->getId()?>").value;
	if (connectInfo.substr(0,validName.length) != validName) {
		alert("Must be defined as: \n"+validName);
		return false;
	}
	return true;
}

function generateDefaultDestination() {
	var name = dojo.byId("<?=$this->form->name->getId()?>").value;
	if (name.length <= 0) {
		alert("<?=__('Name must be supplied.')?>");
		return;
	}
	if (!confirm("Continue?")) return;
	dojo.byId("<?=$this->form->connectInfo->getId()?>").value = defaultDestination.replace("class [[ClassName]]DataIntegrationDestination","class "+globalNormalizedName(name)+"DataIntegrationDestination");
}
</script>

<?=$this->form->renderClose()?>
</div>

