/* Copyright (c) 2007, Rapex.dk All rights reserved. version: 0.0.0 */ 
var Tool_Box = function(name) {
	this.name=name;
	this.TargetBoxElement = null;
	this.LabelPos ="F";
	this.FormObjArray = false;
	this.SaveButton = false
	this.SaveButtonValue = "1px solid transparent";
	this.SaveTarget = null;
	this.CheckFlag = false;
	this.BackUpCounter = 0;
	this.FCKEditorMenu = "Default"; // "Default","News","Calender","Small","Basic"
	this.SetCalenderItemValue = false;
	this.SetDocumentItemValue = false;
	this.SetDocumentItemType = "";
	this.CalcInputValue = new Array;
	this.DocInputValue = new Array;
	this.SetCollumnLineFlag = false;
	this.FormObjectTarget = null;
	this.FormObjectTargetBuffer = new Array();
	this.aPostData = new Array();
	this.aPostData.Name = new Array();
	this.aPostData.Obj = new Array();
	this.aPostData.Type = new Array();
	this.ParrentObj = null;
	this.SaveClassFile = "";
	this.SaveClassName = "";
	this.SaveFunctionName = "";
	this.DraftsClassFile = "";
	this.DraftsClassName = "";
	this.DraftsFunctionName = "";
	this.SaveChangeValue = false;
	this.AutoSaveFlag = false;
}

Tool_Box.prototype.SetTitle = function(Obj,TitleValue) {
	Obj.title = TitleValue;
}

Tool_Box.prototype.NewValueReady = function() {
	BOX.NewValueReadyValue = true;
	BOX.SaveButton.style.border = "1px solid red"
	BOX.SaveButtonValue = "1px solid red";
}

Tool_Box.prototype.SetSaveFlag = function(b) {
	BOX.NewValueReadyValue = b==false;
	if (b)	BOX.SaveButtonValue = "1px solid red";
	else BOX.SaveButtonValue = "1px solid transparent";
	BOX.SaveButton.style.border = BOX.SaveButtonValue;
}

Tool_Box.prototype.SetSaveBorder = function(B)
{
	if (BOX.NewValueReadyValue) B = "1px solid red";
	BOX.SaveButton.style.border= B;
}

Tool_Box.prototype.InsertLink = function(TargeObject,LinkString, TextString, ClassName,Target)
{
	if (typeof Target=="undefined"||Target == "_top") Target = "_top"; else Target = "_blank";
  var returnObject = ELM.Div(TargeObject);
  returnObject.className = ClassName;
	var returnObject_A = ELM.A(returnObject);
	returnObject_A.href = LinkString;
	returnObject_A.target = Target;
  ELM.InsertTextLine(returnObject_A,TextString);
  return returnObject;
}

Tool_Box.prototype.CreateBox = function(NameOfId) {
	this.MainBoxElement = document.createElement("div");
	this.MainBoxElement.id = NameOfId;
	this.SetTarget(this.MainBoxElement);
	return this.MainBoxElement;
}

Tool_Box.prototype.SetTarget = function(Obj) {
	this.TargetBoxElement = Obj;
}

Tool_Box.prototype.AppendBox = function(TargeObject) {
	TargeObject = testObj(TargeObject);
	TargeObject.appendChild(this.MainBoxElement);
	if (this.FormObjArray)
	{
		var MaxLength = 0;
		for (n=0; n<this.FormObjArray.length; n++)
		{
			MaxLength = max(this.FormObjArray[n].offsetLeft,MaxLength);
		}
		for (n=0; n<this.FormObjArray.length; n++)
		{
			this.FormObjArray[n].style.position = "absolute"; 
			this.FormObjArray[n].style.left = MaxLength + "px";
		}
	}
}

Tool_Box.prototype.Div = function(ID,Target) {
	if (typeof Target=="undefined") Target = 1;
	var returnObject = ELM.Div(this.TargetBoxElement,"id='"+ID+"'")
	if (Target) this.SetTarget(returnObject);
	return returnObject;
}

Tool_Box.prototype.WriteLn = function(TextValue,ClassName) {
	try {
	var returnObject = ELM.InsertTextLine(this.TargetBoxElement,TextValue);
  if (ClassName) returnObject.className = ClassName;
	ELM.Br(this.TargetBoxElement);
	return returnObject;
  }
  catch(e){
    if (DebugMode) Errors(e,"Tool_Box.prototype.WriteLn");
  }
}

Tool_Box.prototype.Br = function(){
	ELM.Br(this.TargetBoxElement);	
}

Tool_Box.prototype.CloseWindow = function(Obj,ConfirmText) {
	if (Obj.ItemAlreadyOn && !confirm(ConfirmText)) return;
	window.close();
}

Tool_Box.prototype.Write = function(TextValue,ClassName) {
	try {
    var returnObject = ELM.InsertTextLine(this.TargetBoxElement,TextValue);
    if (ClassName) returnObject.className = ClassName;
    return returnObject;
  }
  catch(e){
    if (DebugMode) Errors(e,"Tool_Box.prototype.Write");
  }
}

Tool_Box.prototype.ButtonSave = function(ClassName,TextValue,SaveCallBackFunction,DraftsCallBackFunction,SaveClassFile,SaveClassName,SaveFunctionName,DraftsClassFile,DraftsClassName,DraftsFunctionName) {
	this.SaveCallBackFunction = SaveCallBackFunction;
	this.DraftsCallBackFunction = DraftsCallBackFunction;
	this.SaveClassFile = SaveClassFile;
	this.SaveClassName = SaveClassName;
	this.SaveFunctionName = SaveFunctionName;
	this.DraftsClassFile = DraftsClassFile;
	this.DraftsClassName = DraftsClassName;
	this.DraftsFunctionName = DraftsFunctionName;

	if (ClassName!="")  {
		var returnObject = ELM.Div(this.TargetBoxElement,"class='" + ClassName + " Button'","title='" + TextValue + "'");
		function SetBorder(B,C)
		{
			if (BOX.NewValueReadyValue && C) B = "1px solid red";
			returnObject.style.border= B;
		}
		ELM.MouseOver(returnObject,SetBorder,"1px outset Gray",0);
		ELM.MouseOut(returnObject,SetBorder,"1px solid transparent",1);
		ELM.MouseDown(returnObject,SetBorder,"1px inset Gray",0);
	}
	else {
		var returnObject = ELM.Button(this.TargetBoxElement);
		ELM.InsertTextLine(returnObject,TextValue);
	}
	ELM.Click(returnObject,this.SaveCalItem,this);
	this.SaveButton = returnObject;
	this.SaveTarget = this.SaveCalItem;
	this.SaveTargetObj = this;
	return returnObject;
}

Tool_Box.prototype.SaveCalItem = function(Obj) {
	if (Obj.BackupFlag)	{
		Obj.OldEditorValue = Obj.EditorValue.value;
		if (Obj.DraftsFunctionName!="" && typeof Obj.DraftsFunctionName!="undefined") Obj.Save(Obj.DraftsClassFile,Obj.DraftsClassName,Obj.DraftsFunctionName,Obj.DraftsCallBackFunction);
	}
	else{
		Obj.StartAutoSave = true;
		Obj.SetSaveFlag(true);
		if (Obj.SaveFunctionName!="" && typeof Obj.SaveFunctionName!="undefined") Obj.Save(Obj.SaveClassFile,Obj.SaveClassName,Obj.SaveFunctionName,Obj.SaveCallBackFunction);
	}
}

Tool_Box.prototype.CheckEditorValue = function(Obj){
	if (!Obj.AutoSaveFlag) return false;
	if (Obj.SaveChangeValue) {
		Obj.BackupFlag = true;
		Obj.SaveTarget(Obj.SaveTargetObj);
		Obj.SaveChangeValue = false;
		Obj.BackupFlag = false;
	}
	try{
		FCK = Obj.EditorFckObject.contentWindow.FCK;
		var EditorValue = FCK.EditorContainer.firstChild.contentWindow.document.body.innerHTML;
		var editorReady = true;
	}
	catch(e){
		var editorReady = false;
	}
	if (editorReady){
		if (Obj.StartAutoSave){
			Obj.OldEditorValue = EditorValue;
			Obj.StartAutoSave = false;
		}
		if (EditorValue!=Obj.OldEditorValue) {
			Obj.EditorValue.value = EditorValue;
			Obj.SetSaveFlag(false);
			Obj.SaveChangeValue = true;
			Obj.NewValueReady();	
		}
	}
  setTimeout(Obj.action_display, 1000);
}
Tool_Box.prototype.SetAutoSaveFlag = function(Obj,val){
	Obj.AutoSaveFlag = val;	
}

Tool_Box.prototype.SetChanceFlag = function(Obj){
	Obj.SaveChangeValue = true;	
}

Tool_Box.prototype.Button = function(ClassName,TextValue,TargetObj,V0,V1,V2,V3,V4,V5,V6,V7,V8,V9) {
	if (ClassName!="")  {
		var returnObject = ELM.Div(this.TargetBoxElement,"class='" + ClassName + " Button'","title='" + TextValue + "'");
		function SetBorder(B)
		{
			returnObject.style.border= B;
		}
		ELM.MouseOver(returnObject,SetBorder,"1px outset Gray");
		ELM.MouseOut(returnObject,SetBorder,"1px solid transparent");
		ELM.MouseDown(returnObject,SetBorder,"1px inset Gray");
	}
	else {
		var returnObject = ELM.Button(this.TargetBoxElement);
		ELM.InsertTextLine(returnObject,TextValue);
	}
	function HtmlSend(A,T){
		if (T!="blank")	location.href = A;
		else  window.open (A,"mywindow");
	}
	if (typeof TargetObj=="string") { 
		var t=TargetObj.split(" ");
		V0 = t[0];
		if (V0.substr(0,6)!="http://") V0 = "http://" + V0;
		V1 = t[1];
		TargetObj = HtmlSend; 
	}
	ELM.Click(returnObject,TargetObj,V0,V1,V2,V3,V4,V5,V6,V7,V8,V9)
	return returnObject;
}

/** Form start **/
Tool_Box.prototype.NewFormTarget = function(sClassName){
 	if (typeof sClassName!="string") sClassName = "None";
	var NewTarget = ELM.Form(this.FormObjectTarget,"class='" + sClassName + "'");
	this.FormObjectTargetBuffer.push(this.FormObjectTarget);
	this.FormObjectTarget = NewTarget;
	return NewTarget;
}

Tool_Box.prototype.OldFormTarget = function()
{
	this.FormObjectTarget = this.FormObjectTargetBuffer.pop();
}

Tool_Box.prototype.EmptyFormTargetObject = function(){
	ELM.Empty(this.FormObjectTarget)
}

Tool_Box.prototype.Form = function(FC) {
	this.FormObjectTarget = ELM.Form(this.TargetBoxElement);

	this.FormObjectTarget.metod="POST";
	this.FormObjectTarget.action = this.SaveTarget;
//	this.FormObject.onsubmit = 'void(0); return false;';
	this.FormClass(FC);
	this.FormObjArray = new Array();
  return this.FormObjectTarget;
}

Tool_Box.prototype.FormClass = function(FC) {
	this.FormObjectTarget.className = FC;
}

Tool_Box.prototype.Hidden = function(Value,Name) {
	var InputValue = ELM.Input(this.FormObjectTarget,"hidden");
	InputValue.value = Value;
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(InputValue);
	this.aPostData.Type.push("hidden");
	return InputValue;
}

Tool_Box.prototype.LabelPosition = function(P){
	if (P=="F") this.LabelPos="F"; else this.LabelPos= "L";
}

Tool_Box.prototype.SetFCKMenu = function(Menu){
	this.FCKEditorMenu = (Menu);
}

Tool_Box.prototype.SetCalenderItem = function(Val){	this.SetCalenderItemValue = Val; }
Tool_Box.prototype.SetDocumentItem = function(Val,TYPE){
	this.SetDocumentItemValue = Val;
	if (Val) {
		if (typeof TYPE=="undefined") TYPE = "";
		this.SetDocumentItemType = TYPE;
	}
 }

Tool_Box.prototype.Editor = function(Label,Value,Width,Height,Name){
	if (Label.length>0) Label += ":" 
	var LabelCont = ELM.Div(this.FormObjectTarget,"class='FormTopBox'");
	var LabelObj = ELM.InsertTextLine(LabelCont,Label);
	this.OldEditorValue = Value;
  this.EditorValue = EDI.Create_Editor_Iframe(this.FormObjectTarget,Name,Value,Width,Height,this.FCKEditorMenu);
  this.EditorFckObject = EDI.EditorObject;
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(this.EditorValue);
	this.aPostData.Type.push("editor");

  this.action_display = this.name + ".CheckEditorValue(" + this.name + ")";
  this.StartAutoSave = true;
  setTimeout(this.action_display, 5000);
  return this.EditorValue;
}

Tool_Box.prototype.DescEditor = function(Label,Value,Width,Height,Name){
	if (Label.length>0) Label += ":" 
	var LabelCont = ELM.Div(this.FormObjectTarget,"class='FormTopBox'");
	var LabelObj = ELM.InsertTextLine(LabelCont,Label);
  this.DescEditorValue = EDI.Create_Editor_Iframe(this.FormObjectTarget,Name,Value,Width,Height,this.FCKEditorMenu);
  this.DescEditorFckObject = EDI.EditorObject;
 
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(this.DescEditorValue);
	this.aPostData.Type.push("DescEditor");
	return this.DescEditorValue;
}

Tool_Box.prototype.handleSelect = function(type,args,obj) {
	var dates = args[0]; 
	var date = dates[0];
	var year = date[0], month = NumToStr(date[1]), day = NumToStr(date[2]);
	BOX.TagetCalenderValue.value = day + "-" + month + "-" + year + " 00:00:00";
	BOX.SetChanceFlag(BOX);
	YAHOO.example.calendar.cal.hide();
}

Tool_Box.prototype.ShowCalender= function(Target){
	document.getElementById("calContainer").style.left = MousePosX+"px"
	var xPos = (MousePosY-100>0) ? MousePosY-100 : 1;
	document.getElementById("calContainer").style.top = xPos+"px"
	YAHOO.example.calendar.cal.show();
	this.TagetCalenderValue = Target;
	YAHOO.example.calendar.cal.selectEvent.subscribe(this.handleSelect, YAHOO.example.calendar.cal, true);
}
Tool_Box.prototype.DeleteTagetValue = function(Target){
	Target.value = "";
	BOX.SetChanceFlag(BOX);
}


Tool_Box.prototype.InsertCalender = function(Obj,InsertObj) {
	var CalObj = ELM.Div(Obj,"class='Calender'");
	this.InsertLink(CalObj,"JavaScript: " + this.name + ".ShowCalender(" + InsertObj + ");", '<img class="Calender" src="files/cal.gif" alt="cal">', "Calender");
	this.InsertLink(CalObj,"JavaScript: " + this.name + ".DeleteTagetValue(" + InsertObj + ");", '<img class="Delete" src="files/delete.gif" alt="delete">', "Delete");
}

Tool_Box.prototype.ShowDocument= function(Target){
	EDI.Browse("Browser",Target,this.SetDocumentItemType);
}

Tool_Box.prototype.InsertBrowser = function(Obj,InsertObj) {
	var DocObj = ELM.Div(Obj,"class='Browser'");
	this.InsertLink(DocObj,"JavaScript: " + this.name + ".ShowDocument(" + InsertObj + ");", '<img class="Browser" src="files/browser.gif" alt="cal">', "Browser");
	this.InsertLink(DocObj,"JavaScript: " + this.name + ".DeleteTagetValue(" + InsertObj + ");", '<img class="Delete" src="files/delete.gif" alt="delete">', "Delete");
}

Tool_Box.prototype.SetCollumnLine = function(Val) {
	if (Val==1)
	{
		if (this.SetCollumnLineFlag) return
		this.SetCollumnLineFlag = true
	}
	else {
		this.SetCollumnLineFlag = false
		var bx = ELM.Div(this.FormObjectTarget,"class='CollumnLineBox'");
	
	}
}
Tool_Box.prototype.Input = function(Value, Label, Style,Size,Collumn,Name) {
	this.SetCollumnLine(Collumn);
	if (Label.length>0) Label += ":" 
//	if (Collumn==1) var bx = ELM.Span(this.FormObjectTarget,"class='FormLineBox'");
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='FormLeftBox'");
	var rb = ELM.Span(bx,"class='FormRightBox'");
	if (Style) bx.style.backgroundColor=Style;
	if (this.LabelPos == "F") {
		var LabelObj = ELM.InsertTextLine(lb,Label);
		var InputValue = ELM.Input(rb,"text");
	} else {
		var LabelObj = ELM.InsertTextLine(rb,Label);
		var InputValue = ELM.Input(lb,"text");
	}
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	if (typeof Size == "number") InputValue.size = Size;
	InputValue.value = Value;
	InputValue.Frame = bx;
	if (this.SetCalenderItemValue) {
		var inputNum = this.CalcInputValue.length;
		this.CalcInputValue[inputNum] = InputValue;
		InputValue.style.color = "black"
		InputValue.disabled = true;
		this.InsertCalender(rb,this.name + ".CalcInputValue[" +inputNum + "]")
	}
	if (this.SetDocumentItemValue) {
		var inputNum = this.DocInputValue.length;
		this.DocInputValue[inputNum] = InputValue;
		InputValue.style.color = "black"
		InputValue.disabled = true;
		this.InsertBrowser(rb,this.name + ".DocInputValue[" +inputNum + "]")
		ELM.Change(InputValue,this.SetChanceFlag,this)
	}

	if (IE) lb.style.top = "-1px"; 
	ELM.KeyUp(InputValue,this.SetChanceFlag,this)
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(InputValue);
	this.aPostData.Type.push("input");
	return InputValue;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.TextArray = function(Value, Label,rows,cols, Name) {
	if (Label.length>0) Label += ":" 
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	var lb = ELM.Div(bx,"class='FormLeftBox'");
	var rb = ELM.Div(bx,"class='FormTextArrayBox'");
	var LabelObj = ELM.InsertTextLine(lb,Label);
	var TexArrayValue = ELM.Textarray(rb);
	TexArrayValue.rows = rows;
	TexArrayValue.cols = cols;
	ELM.Text(Value,TexArrayValue);
	ELM.KeyUp(TexArrayValue,this.SetChanceFlag,this);
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(TexArrayValue);
	this.aPostData.Type.push("textarray");
	return TexArrayValue;
}

Tool_Box.prototype.Checkbox = function(Value, Label, Style,Collumn,Name) {
	if (Label.length>0) Label += ":" 
	if ( Value==true || Value==1 || Value == "y" || Value == "j" || Value == "Y" || Value == "J" ) Value = true; else Value = false;
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='FormLeftBox'");
	var rb = ELM.Span(bx,"class='FormRightBox'");
	if (Style) bx.style.backgroundColor=Style;
	if (this.LabelPos == "F") {
		var LabelObj = ELM.InsertTextLine(lb,Label);
		var InputValue = ELM.Input(rb,"checkbox");
	}	else {
		var LabelObj = ELM.InsertTextLine(rb,Label);
		var InputValue = ELM.Input(lb,"checkbox");
	}
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	InputValue.checked = Value;
	ELM.Change(InputValue,this.SetChanceFlag,this);
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(InputValue);
	this.aPostData.Type.push("checkbox");
	return InputValue;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.Radio = function(Check,Value, Label, Style,Collumn,Name) {
	if (Label.length>0) Label += ":" 
	if ( Check==true || Check==1 || Check == "y" || Check == "j" || Check == "Y" || Check == "J"  ) Check = true; else Check = false;
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='FormLeftBox'");
	var rb = ELM.Span(bx,"class='FormRightBox'");
	if (Style) bx.style.backgroundColor=Style;
	if (this.LabelPos == "F") {
		var LabelObj = ELM.InsertTextLine(lb,Label);
		var InputValue = ELM.Input(rb,"radio");
	} else {
		var InputValue = ELM.Input(lb,"radio");
		var LabelObj = ELM.InsertTextLine(rb,Label);
	}
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	InputValue.name = Name;
	InputValue.value = Value;
	InputValue.checked = Check;
	ELM.Change(InputValue,this.SetChanceFlag,this);
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(InputValue);
	this.aPostData.Type.push("radio");
	return InputValue;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.Submit = function(Value, Reset,Style,OnSubmitFunction,OnSubmitObj,Collumn) {
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='SearcLeftBox'");
	var rb = ELM.Span(bx,"class='SearcRightBox'");
	if (Style) bx.style.backgroundColor=Style;
		if (Reset) var SubmitObj =  ELM.Input(lb,"submit");
		else var SubmitObj =  ELM.Input(rb,"submit");
		if (Reset) var ResetObj = ELM.Input(rb,"reset");
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	SubmitObj.value = Value;
	if (Reset) ResetObj.value = "Reset";

	if (typeof OnSubmitFunction=="function"){
			ELM.Click(SubmitObj,OnSubmitFunction,OnSubmitObj)
			this.FormObjectTarget.action = "Javascript: void(0)";
	}
	else this.FormObjectTarget.action = OnSubmitFunction;
	return SubmitObj;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.Select = function(SelectName,SelectValue,SelectedValue,Label,Style,SelectSize,Name,Collumn,Name) {
	if (Label.length>0) Label += ":" 
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='FormLeftBox'");
	var rb = ELM.Span(bx,"class='FormRightBox'");
	if (this.LabelPos == "F") {
		var LabelObj = ELM.InsertTextLine(lb,Label);
		var SelectValue = ELM.InsertSelect(rb,SelectName,SelectValue,SelectedValue,SelectSize,Name);
	} else{
		var LabelObj = ELM.InsertTextLine(rb,Label);
		var SelectValue = ELM.InsertSelect(lb,SelectName,SelectValue,SelectedValue,SelectSize,Name);
	}
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	SelectValue.name = Name;
	ELM.Change(SelectValue,this.SetChanceFlag,this);
	this.aPostData.Name.push(Name);
	this.aPostData.Obj.push(SelectValue);
	this.aPostData.Type.push("select");
	return SelectValue;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.File = function(Label,Size,Name,Style,Collumn,Name) {
	if (Label.length>0) Label += ":" 
	var bx = ELM.Div(this.FormObjectTarget,"class='FormLineBox'");
	if (Collumn!=0) bx.style.display = "inline";
	var lb = ELM.Span(bx,"class='FormLeftBox'");
	var rb = ELM.Span(bx,"class='FormRightBox'");
	if (this.LabelPos == "F") {
		var LabelObj = ELM.InsertTextLine(lb,Label);
		var FileObj = ELM.Input(rb,"file");;
	} else{
		var LabelObj = ELM.InsertTextLine(rb,Label);
		var FileObj = ELM.Input(lb,"file");;
	}
	if (this.LabelPos == "F") this.FormObjArray.push(rb);
	FileObj.name = Name;
	FileObj.size = Size;
	return FileObj;
	if (Collumn==2) ELM.Div(this.FormObjectTarget);
}

Tool_Box.prototype.CheckBoxArray = function(CheckBoxes,ClassName,HeadLineText,HeadLineStyle,Name) {
		if (typeof CheckBoxes[0] == "undefined" || typeof CheckBoxes[0][0] == "undefined") return false;
    var Headline = ELM.Div(this.FormObjectTarget);
    var Element = ELM.Div(this.FormObjectTarget);
    ELM.InsertTextLine(Headline,HeadLineText,HeadLineStyle);
    Element.className = ClassName;
    var Boxes = new Array();
    for (var n=0; n<CheckBoxes.length; n++){
        var Cont = ELM.Div(Element);
        Boxes[n] = new Array();
        Boxes[n].id = CheckBoxes[n][0];          
				Boxes[n].box = ELM.Input(Cont,"checkbox");
        Boxes[n].box.checked = CheckBoxes[n][3];
        Boxes[n].box.title = CheckBoxes[n][2];
				var TextVal = ELM.Span(Cont);
        TextVal.className = "tab_2";
        ELM.Text(" "+CheckBoxes[n][1],TextVal);
        TextVal.title = CheckBoxes[n][2];
    }
		this.aPostData.Name.push(Name);
		this.aPostData.Obj.push(Boxes);
		this.aPostData.Type.push("CheckBoxArray");
    return Boxes;
}

/** Form end **/

/** Connect Start **/
Tool_Box.prototype.DelPostData = function(DATA) {
	this.aPostDataNew = new Array();
	this.aPostDataNew.Name = new Array();
	this.aPostDataNew.Obj = new Array();
	this.aPostDataNew.Type = new Array();
	
	for (var n=0; n<this.aPostData.Name.length;n++)
	{
		if (this.aPostData.Name[n]!=DATA){
			this.aPostDataNew.Name.push(this.aPostData.Name[n]);
			this.aPostDataNew.Obj.push(this.aPostData.Obj[n]);
			this.aPostDataNew.Type.push(this.aPostData.Type[n]);
		}
	}	
	this.aPostData = null;
	this.aPostData = this.aPostDataNew;
}
Tool_Box.prototype.GetPostData = function() {
//	BOX.FormObjectTarget.submit();

	function GetPDArray(gProp,gValue){
		var pd="";
		for (var i=0; i<gProp.length; i++){
			pd+= "&"+gProp[i]+"[]=" + gValue[i];
		}
		return pd;
	}
	this.postdata = "";
	for (var n=0; n<this.aPostData.Name.length;n++)
	{
		if (typeof this.aPostData.Name[n] == "string")
		{
			if (this.aPostData.Type[n]=="checkbox") this.postdata+= "&"+this.aPostData.Name[n]+"=" + this.aPostData.Obj[n].checked;
			else if (this.aPostData.Type[n]=="radio") { if (this.aPostData.Obj[n].checked)this.postdata+= "&"+this.aPostData.Name[n]+"=" + this.aPostData.Obj[n].value;}
			else if (this.aPostData.Type[n]=="DescEditor") { 
					FCK = BOX.DescEditorFckObject.contentWindow.FCK;
					var DescEditorValue = FCK.EditorContainer.firstChild.contentWindow.document.body.innerHTML;
					this.postdata+= "&"+this.aPostData.Name[n]+"=" + escape(DescEditorValue);
				}
			else if (this.aPostData.Type[n]=="CheckBoxArray") { 
					for (var i=0; i<this.aPostData.Obj[n].length; i++){
						if (this.aPostData.Obj[n][i].box.checked) this.postdata+= "&"+this.aPostData.Name[n]+"[]="+this.aPostData.Obj[n][i].id;
					}
				}
			else this.postdata+= "&"+this.aPostData.Name[n]+"=" + escape(this.aPostData.Obj[n].value);
		}
	}
	return this.postdata;
}

Tool_Box.prototype.Save = function(ConnectInclude,ConnectClass,ConnectFunction,CallBack) {
	this.postdata = this.GetPostData();
	this.postdata = "&ConnectInclude=" + ConnectInclude + "&ConnectClass=" + ConnectClass + "&ConnectFunction=" + ConnectFunction + this.postdata;
	CON.Save("php_script/Save.php",this.postdata,CallBack)	
}

Tool_Box.prototype.Load = function(ConnectInclude,ConnectClass,ConnectFunction,CallBackObj,CallBackFunction) {
  var Value = new Array();
	for (var n=5; n<arguments.length; n++) Value.push(arguments[n]);
  CON.Server_Connector(share_files+"Load.php",ConnectInclude,ConnectClass,ConnectFunction,CallBackObj,CallBackFunction,Value);
}
/** Connect End **/

Tool_Box.prototype.LinkBox = function(Header,Links,LinkBoxClass,Limit,TargetFunction,TargetObj,TargetArrayNr,DeleteFunction,DraftFunction) {
	var nr = TargetArrayNr.split(",");
	var nr1 = parseInt(nr[0]);
	var nr2 = parseInt(nr[1]);
	this.Table = ELM.Table(this.TargetBoxElement,"class='" + LinkBoxClass + "'");
	this.Thead = ELM.Thead(this.Table)
	this.Tr = ELM.Tr(this.Thead)
	   for (var val in Header) {
			this.Th = ELM.Th(this.Tr)
			this.ThText = ELM.InsertTextLine(this.Th,Header[val]);
   }
	this.Tbody = ELM.Tbody(this.Table)

	   for (var v1 in Links) {
			this.Tr = ELM.Tr(this.Tbody)
			var TargetValueNr = 1; 
	   	for (var v2 in Links[v1]) {
	   		if (TargetValueNr == nr1){
	   			var TargetValue = Links[v1][v2];
					this.Td = ELM.Td(this.Tr,"class='EditButton'");
					ELM.Click(this.Td,TargetFunction,TargetObj,TargetValue);
				}
	   		else if (typeof DraftFunction != "undefined" && TargetValueNr == nr2 && Links[v1][v2]!=""){
	   			var TargetValue2 = Links[v1][v2];
					this.Td = ELM.Td(this.Tr,"class='DraftButton'");
					ELM.Click(this.Td,DraftFunction,TargetObj,TargetValue2);
				}
				else
				{
					this.Td = ELM.Td(this.Tr)
					this.TdText = ELM.InsertTextLine(this.Td,Links[v1][v2]);
				}
				TargetValueNr++
			}
	   	if (typeof DeleteFunction != "undefined" && typeof TargetValue!="undefined"){
				this.Td = ELM.Td(this.Tr,"class='DeleteButton'");
				ELM.Click(this.Td,DeleteFunction,TargetObj,TargetValue);
			}
   }
}

Tool_Box.prototype.LinkBoxControl = function(LIMIT,TagetObjFunction,TargetObj,LinkBoxControlClass){
	this.Br();
	var L_B = LIMIT[0]-20;
	if (L_B<0) L_B = 0;
	var L_F = LIMIT[0]+20;
	
	var OldTarget = this.TargetBoxElement;
	this.LinkBoxControlTarget = ELM.Div(this.TargetBoxElement,"class='" + LinkBoxControlClass + "'");
	this.SetTarget(this.LinkBoxControlTarget);
	this.ButtonStart = this.Button(LinkBoxControlClass + "Start'","",TagetObjFunction,TargetObj,"0,"+LIMIT[1]) 
	this.ButtonBack = this.Button(LinkBoxControlClass + "Back'","",TagetObjFunction,TargetObj, L_B + ","+LIMIT[1]) 
	this.ButtonForward = this.Button(LinkBoxControlClass + "Forward'","",TagetObjFunction,TargetObj,L_F+ ","+LIMIT[1]) 
	this.ButtonEnd = this.Button(LinkBoxControlClass + "End'","",TagetObjFunction,TargetObj,"-1,"+LIMIT[1]) 
	this.SetTarget(OldTarget);
/**
	this.Table = ELM.Table(this.TargetBoxElement,"class='" + LinkBoxControlClass + "'");
	this.Thead = ELM.Thead(this.Table)
	this.Tr = ELM.Tr(this.Thead)
	this.ThStart = ELM.Th(this.Tr,"class='" + LinkBoxControlClass + "Start'")
	this.ThBack = ELM.Th(this.Tr,"class='" + LinkBoxControlClass + "Back'")
	this.ThForvard = ELM.Th(this.Tr,"class='" + LinkBoxControlClass + "Forward'")
	this.ThEnd = ELM.Th(this.Tr,"class='" + LinkBoxControlClass + "End'")
**/
}
