// JavaScript Document



function Chechboxchange(title,status,row_count)

{



if (status ==false) {disabledstatus =true;backgroundstatus="rgb(210, 210, 210)";}

else {disabledstatus =false;backgroundstatus="rgb(255, 255, 255)";}



for (var i=0; i<row_count; i++)

	{

	document.getElementById(title+"["+i+"]").style.background=backgroundstatus;

	document.getElementById(title+"["+i+"]").readOnly = disabledstatus;	

	}	

}





function CheckboxStartup(chboxname,title,mEnabled,row_count)

{

	if (mEnabled=="0")  {enstatus = false; }

	else {enstatus = true;document.getElementById(chboxname).checked=true;}

	

Chechboxchange(title,enstatus,row_count);

}





function MainCurrency_change(index)

{

var MainCurrency = document.getElementById('MainCurrency['+index+']');

var MirrorCurrency = document.getElementById('MirrorCurrency['+index+']');

//alert(MirrorCurrency.options[MainCurrency.selectedIndex].value);



MirrorCurrency.selectedIndex= MainCurrency.selectedIndex;

}









function isValidIF4Form_1(counter) {



fieldarr = new Array();

fieldarr = fieldarr.concat('BlockTrainOperator','depCountryName','DepartureRailwayPointName','desCountryName','DestinationRailwayPointName','Frequency','OverallTransitTime','AgentOf','ContainerBelonging','validity_day','validity_month','validity_year');

var i=0;

for (i==0;i<counter;i++)



{

	

	if (document.getElementById('d20cbox').checked==true) fieldarr = fieldarr.concat('Main20['+i+']');

	if (document.getElementById('d40cbox').checked==true) fieldarr = fieldarr.concat('Main40['+i+']');

	

fieldarr = fieldarr.concat(	'MainDepartureCountryName['+i+']','MainDepartureRailwayName['+i+']','MainDestinationCountryName['+i+']','MainDestinationRailwayName['+i+']','MainTransitTime['+i+']','MainCurrency['+i+']');

}



var isFieldsValid = validateForm(new Objects(fieldarr));

	var Valid = (isFieldsValid);

	return Valid;



}



function isValidIF4Form_2(counter) {





fieldarr = new Array();

fieldarr = fieldarr.concat('BlockTrainOperator','depCountryName','DepartureRailwayPointName','desCountryName','DestinationRailwayPointName','Frequency','OverallTransitTime','AgentOf','ContainerBelonging','validity_day','validity_month','validity_year');



var i=0;

for (i==0;i<counter;i++)

{

	if (document.getElementById('d20cbox').checked==true) fieldarr = fieldarr.concat('Main20['+i+']','Mirror20['+i+']');

	if (document.getElementById('d40cbox').checked==true) fieldarr = fieldarr.concat('Main40['+i+']','Mirror40['+i+']');



fieldarr = fieldarr.concat(	'MainDepartureCountryName['+i+']','MainDepartureRailwayName['+i+']','MainDestinationCountryName['+i+']','MainDestinationRailwayName['+i+']','MainTransitTime['+i+']','MainCurrency['+i+']','MirrorCurrency['+i+']');

}



var isFieldsValid = validateForm(new Objects(fieldarr));

	var Valid = (isFieldsValid);

	return Valid;



}





function fnMainDepartureCountry() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDepartureRailwayId = document.getElementById('MainDepartureRailwayID['+indx+']');



	_MainDepartureRailwayId.value = '';



	var _MainDepartureRailwayName = document.getElementById('MainDepartureRailwayName['+indx+']');



	_MainDepartureRailwayName.value = '';



	var _MirrorDepartureRailwayID = document.getElementById('MirrorDestinationRailwayID['+indx+']');



	_MirrorDepartureRailwayID.value = '';



	var _MirrorDepartureRailwayName = document.getElementById('MirrorDestinationRailwayName['+indx+']');



	_MirrorDepartureRailwayName.value = '';



	//MainDepartureCountry[indx].MirrorValue = document.getElementsByName('MirrorDepartureCountryID['+indx+']');



	//MainDepartureCountry[indx].MirrorText = document.getElementsByName('MirrorDepartureCountryName['+indx+']');



	MainDepartureCountry[indx].MirrorValue = document.getElementById('MirrorDestinationCountryID['+indx+']');



	MainDepartureCountry[indx].MirrorText = document.getElementById('MirrorDestinationCountryName['+indx+']');

		

	createPopup('popup/test.php?f=countries','Filter',330,540,MainDepartureCountry[indx]);



}







function fnMainDestinationCountry() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDestinationRailwayId = document.getElementById('MainDestinationRailwayID['+indx+']');



	_MainDestinationRailwayId.value = '';



	var _MainDestinationRailwayName = document.getElementById('MainDestinationRailwayName['+indx+']');



	_MainDestinationRailwayName.value = '';



	var _MirrorDestinationRailwayID = document.getElementById('MirrorDepartureRailwayID['+indx+']');



	_MirrorDestinationRailwayID.value = '';



	var _MirrorDestinationRailwayName = document.getElementById('MirrorDepartureRailwayName['+indx+']');



	_MirrorDestinationRailwayName.value = '';



	//MainDestinationCountry[indx].MirrorValue = document.getElementsByName('MirrorDestinationCountryID[]')[indx];



	//MainDestinationCountry[indx].MirrorText = document.getElementsByName('MirrorDestinationCountryName[]')[indx];



	MainDestinationCountry[indx].MirrorValue = document.getElementById('MirrorDepartureCountryID['+indx+']');



	MainDestinationCountry[indx].MirrorText = document.getElementById('MirrorDepartureCountryName['+indx+']');







	createPopup('popup/test.php?f=countries','Filter',330,540,MainDestinationCountry[indx]);



}







function fnMainDepartureRailway() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDepartureCountriesId = document.getElementById('MainDepartureCountryID['+indx+']');



	//MainDepartureRailway[indx].MirrorValue = document.getElementsByName('MirrorDepartureRailwayID[]')[indx];



	//MainDepartureRailway[indx].MirrorText = document.getElementsByName('MirrorDepartureRailwayName[]')[indx];



	



	MainDepartureRailway[indx].MirrorValue = document.getElementById('MirrorDestinationRailwayID['+indx+']');



	MainDepartureRailway[indx].MirrorText = document.getElementById('MirrorDestinationRailwayName['+indx+']');



	



	createPopup("popup/test.php?f=railpoints&addfunct=1&id="+_MainDepartureCountriesId.value,'Filter',330,540,MainDepartureRailway[indx]);



}







function fnMainDestinationRailway() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDestinationCountriesId = document.getElementById('MainDestinationCountryID['+indx+']');



	MainDestinationRailway[indx].MirrorValue = document.getElementById('MirrorDepartureRailwayID['+indx+']');



	MainDestinationRailway[indx].MirrorText = document.getElementById('MirrorDepartureRailwayName['+indx+']');



	



	createPopup("popup/test.php?f=railpoints&addfunct=1&id="+_MainDestinationCountriesId.value,'Filter',330,540,MainDestinationRailway[indx]);



}







var Index = 0;



var MainDepartureCountry = new Array();



var MainDepartureRailway = new Array();



var MainDestinationCountry = new Array();



var MainDestinationRailway = new Array();







var MnDepCountries = new Object();



//var MainDestinationCountryId = new Array();







var MainDepartureRailwayNames = document.getElementById('MainDepartureRailwayName['+Index+']');



var MainDestinationRailwayNames = document.getElementById('MainDestinationRailwayName['+Index+']');



var MainCurrencies = document.getElementById('MainCurrency[0]');





var MirrorDepartureCountriesID = document.getElementById('MirrorDepartureCountryID['+Index+']');



var MirrorDepartureCountriesName = document.getElementById('MirrorDepartureCountryName['+Index+']');



//alert(MirrorDepartureCountriesName.length);







//var MirrorCurrencies = document.getElementById('MirrorCurrency[0]');







var IF4 = new Object();



IF4.Index = 0;







IF4.AddRow = function() {



	var RemoveRowButton = document.getElementById('RemoveRow');



	++IF4.Index;



	var Index = IF4.Index;



	var MainTable = document.getElementById('MainTable');



	var MainTableRows = MainTable.rows.length;



	var MirrorTable = document.getElementById('MirrorTable');



	var MirrorTableRows = MirrorTable.rows.length;



	var MainRow = document.getElementById('MainRow');



	var MirrorRow = document.getElementById('MirrorRow');







	var MainRowElement = document.createElement('tr');



	var MirrorRowElement = document.createElement('tr');



	



	var mainRow = MainTable.insertRow(MainTableRows);



	



	var MainDepartureCountryID = document.createElement('input');



	MainDepartureCountryID.id='MainDepartureCountryID['+Index+']';



	MainDepartureCountryID.name='MainDepartureCountryID['+Index+']';



	MainDepartureCountryID.type='hidden';



	



	var MainDepartureCountryName = document.createElement('input');



	MainDepartureCountryName.id = 'MainDepartureCountryName['+Index+']';



	MainDepartureCountryName.name = 'MainDepartureCountryName['+Index+']';



	MainDepartureCountryName.type = 'text';



	MainDepartureCountryName.readOnly = true;

	

	MainDepartureCountryName.title = 'Country of departure ['+(Index+1)+']';



	MainDepartureCountryName.style.width = '80px';



	MainDepartureCountryName.style.backgroundColor = '#EEEEEE';







	var MainDepartureCountryPopupImage = new Image();



	MainDepartureCountryPopupImage.src = "images/hand.gif";



	MainDepartureCountryPopupImage.border = 0;



	MainDepartureCountryPopupImage.alt = IF4.Index;



	



	var MainDepartureCountryLink = document.createElement('a');



	MainDepartureCountry[IF4.Index] = new Object();



	MainDepartureCountry[IF4.Index].hidden = MainDepartureCountryID;



	MainDepartureCountry[IF4.Index].visible = MainDepartureCountryName;



	//MainDepartureCountryLink.href="javascript:createPopup('popup/test.php?f=countries','Filter',330,540,MainDepartureCountry["+IF4.Index+"]);";



	MainDepartureCountryLink.href="javascript:void(0)";



	addEvent(MainDepartureCountryLink,"click",fnMainDepartureCountry);



	/*



	addEvent(MainDepartureCountryLink,"click",function() {



			var obj = getEvent();



			var indx = obj.target.alt;



			alert("Clicked Departure Country!"+indx);												   



		}



	);



	*/



	MainDepartureCountryLink.appendChild(MainDepartureCountryPopupImage);	



	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainDepartureCountryID);



	Cell.appendChild(MainDepartureCountryName);



	Cell.appendChild(MainDepartureCountryLink);



	mainRow.appendChild(Cell);





	var MainDepartureRailwayID = document.createElement('input');



	MainDepartureRailwayID.id='MainDepartureRailwayID['+Index+']';



	MainDepartureRailwayID.name='MainDepartureRailwayID['+Index+']';



	MainDepartureRailwayID.type='hidden';





	var MainDepartureRailwayName = document.createElement('input');



	MainDepartureRailwayName.id = 'MainDepartureRailwayName['+Index+']';



	MainDepartureRailwayName.name = 'MainDepartureRailwayName['+Index+']';



	MainDepartureRailwayName.type = 'text';



	MainDepartureRailwayName.readOnly = true;



	MainDepartureRailwayName.style.width = '80px';



	MainDepartureRailwayName.style.backgroundColor = '#EEEEEE';



	MainDepartureRailwayName.title = 'Railway point of departure ['+(Index+1)+']';





	var MainDepartureRailwayPopupImage = new Image();



	MainDepartureRailwayPopupImage.src = "images/hand.gif";



	MainDepartureRailwayPopupImage.border = 0;



	MainDepartureRailwayPopupImage.alt = IF4.Index;



	



	var MainDepartureRailwayLink = document.createElement('a');



	//MainDepartureCountryLink.href="javascript:createPopup('popup/test.php?f=countries','Filter',330,540,MainDepartureCountry);";



	MainDepartureRailway[IF4.Index] = new Object();



	MainDepartureRailway[IF4.Index].hidden = MainDepartureRailwayID;



	MainDepartureRailway[IF4.Index].visible = MainDepartureRailwayName;



	MainDepartureRailwayLink.href = "javascript:void(0)";



	addEvent(MainDepartureRailwayLink,"click",fnMainDepartureRailway);



	//MainDepartureRailwayLink.href="javascript:createPopup('popup/test.php?f=railpoints&id="+MainDepartureRailway[IF4.Index].country+"','Filter',330,540,MainDepartureRailway["+IF4.Index+"]);";



	MainDepartureRailwayLink.appendChild(MainDepartureRailwayPopupImage);



	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainDepartureRailwayID);



	Cell.appendChild(MainDepartureRailwayName);



	Cell.appendChild(MainDepartureRailwayLink);



	



	mainRow.appendChild(Cell);



	



	var MainDestinationCountryID = document.createElement('input');



	MainDestinationCountryID.id='MainDestinationCountryID['+Index+']';



	MainDestinationCountryID.name='MainDestinationCountryID['+Index+']';



	MainDestinationCountryID.type='hidden';



	MainDestinationCountryID.value='';



	



	var MainDestinationCountryName = document.createElement('input');



	MainDestinationCountryName.id = 'MainDestinationCountryName['+Index+']';



	MainDestinationCountryName.name = 'MainDestinationCountryName['+Index+']';



	MainDestinationCountryName.type = 'text';



	MainDestinationCountryName.value = '';



	MainDestinationCountryName.readOnly = true;



	MainDestinationCountryName.style.width = '80px';



	MainDestinationCountryName.style.backgroundColor = '#EEEEEE';

	

	MainDestinationCountryName.title = 'Country of destination ['+(Index+1)+']';





	var MainDestinationCountryPopupImage = new Image();



	MainDestinationCountryPopupImage.src = "images/hand.gif";



	MainDestinationCountryPopupImage.border = 0;



	MainDestinationCountryPopupImage.alt = IF4.Index;



	



	var MainDestinationCountryLink = document.createElement('a');



	MainDestinationCountry[IF4.Index] = new Object();



	MainDestinationCountry[IF4.Index].hidden = MainDestinationCountryID;



	MainDestinationCountry[IF4.Index].visible = MainDestinationCountryName;



	MainDepartureCountryLink.href="javascript:void(0)";



	addEvent(MainDestinationCountryLink,"click",fnMainDestinationCountry);



	MainDestinationCountryLink.appendChild(MainDestinationCountryPopupImage);



	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainDestinationCountryID);



	Cell.appendChild(MainDestinationCountryName);



	Cell.appendChild(MainDestinationCountryLink);



	mainRow.appendChild(Cell);



	



	



	var MainDestinationRailwayID = document.createElement('input');



	MainDestinationRailwayID.id='MainDestinationRailwayID['+Index+']';



	MainDestinationRailwayID.name='MainDestinationRailwayID['+Index+']';



	MainDestinationRailwayID.type='hidden';



	MainDestinationRailwayID.value='';



	



	var MainDestinationRailwayName = document.createElement('input');



	MainDestinationRailwayName.id = 'MainDestinationRailwayName['+Index+']';



	MainDestinationRailwayName.name = 'MainDestinationRailwayName['+Index+']';



	MainDestinationRailwayName.type = 'text';



	MainDestinationRailwayName.value = '';



	MainDestinationRailwayName.readOnly = true;



	MainDestinationRailwayName.style.width = '80px';



	MainDestinationRailwayName.style.backgroundColor = '#EEEEEE';



	MainDestinationRailwayName.title = 'Railway point of destination ['+(Index+1)+']';

	



	var MainDestinationRailwayPopupImage = new Image();



	MainDestinationRailwayPopupImage.src = "images/hand.gif";



	MainDestinationRailwayPopupImage.border = 0;



	MainDestinationRailwayPopupImage.alt = IF4.Index;



	



	var MainDestinationRailwayLink = document.createElement('a');



	MainDestinationRailway[IF4.Index] = new Object();



	MainDestinationRailway[IF4.Index].hidden = MainDestinationRailwayID;



	MainDestinationRailway[IF4.Index].visible = MainDestinationRailwayName;



	MainDestinationRailwayLink.href="javascript:void(0)";



	addEvent(MainDestinationRailwayLink,"click",fnMainDestinationRailway);



	MainDestinationRailwayLink.appendChild(MainDestinationRailwayPopupImage);



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainDestinationRailwayID);



	Cell.appendChild(MainDestinationRailwayName);



	Cell.appendChild(MainDestinationRailwayLink);



	mainRow.appendChild(Cell);



	



	//<input type="text" onkeypress="return isNumberKey(event);" style="width: 60px;">



	var MainTransitTime = document.createElement('input');



	MainTransitTime.name = 'MainTransitTime['+Index+']';



	MainTransitTime.id = 'MainTransitTime['+Index+']';



	MainTransitTime.type = 'text'



	MainTransitTime.style.width = '60px';

	

	MainTransitTime.title = 'Transit time ['+(Index+1)+']';

	

	//addEvent(MainTransitTime,"keypress",return onlyDigits);



	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainTransitTime);



	mainRow.appendChild(Cell);



	



	var MainCurrency = document.createElement('select');



	MainCurrency.id = 'MainCurrency['+Index+']';



	MainCurrency.name  = 'MainCurrency['+Index+']';



	MainCurrency.style.width = '60px';

	

	MainCurrency.title = 'Currency ['+(Index+1)+']';

	

	

	MainCurrency.onchange= function(){ MainCurrency_change(Index);};



	//MainCurrency.setAttribute("onchange", "alert('d');" );



//if( MainCurrency.addEventListener ) {

//  MainCurrency.addEventListener('change',function (e) {

//	  MainCurrency_change(Index);

//	},false);

//} else if ( MainCurrency.attachEvent ) {

//  MainCurrency.attachEvent('change',function (e) {

//  MainCurrency_change(Index);

//	});

//} else {

//  MainCurrency.onchange = function (e) {

//	  MainCurrency_change(Index);

//	};

//}



	

	var inheritableSelect = document.getElementById('MainCurrency[0]');



for (var opt=0; opt<inheritableSelect.options.length; opt++) {



		var optionElement = document.createElement('option');



		optionElement.value = inheritableSelect.options[opt].value;



		optionElement.text = inheritableSelect.options[opt].text;



		try {



			MainCurrency.add(optionElement, null);



		} catch(ex) {



			MainCurrency.add(optionElement);



		}



	}



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MainCurrency);



	mainRow.appendChild(Cell);

	





	var Main20 = document.createElement('input');



	Main20.id = "Main20["+Index+"]";



	Main20.name = "Main20["+Index+"]";



	Main20.type = 'text';



	Main20.style.width = '50px';



	Main20.title = '20DC Tariff ['+(Index+1)+']';

	

	Main20.style.background= document.getElementById("Main20[0]").style.background;

	

	Main20.readOnly= document.getElementById("Main20[0]").readOnly;

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(Main20);



	mainRow.appendChild(Cell);

	



	var Main40 = document.createElement('input');



	Main40.id = "Main40["+Index+"]";



	Main40.name = "Main40["+Index+"]";



	Main40.type = "text";



	Main40.style.width = '50px';

	

	Main40.title = '40DC/HC Tariff ['+(Index+1)+']';

	

	Main40.style.background= document.getElementById("Main40[0]").style.background;

	

	Main40.readOnly= document.getElementById("Main40[0]").readOnly;

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.appendChild(Main40);



	mainRow.appendChild(Cell);

	



	var mirrorRow = MirrorTable.insertRow(MirrorTableRows);



	var MirrorDepartureCountryID = document.createElement('input');



	MirrorDepartureCountryID.id = "MirrorDepartureCountryID["+Index+"]";



	MirrorDepartureCountryID.name = "MirrorDepartureCountryID["+Index+"]";



	MirrorDepartureCountryID.type = "hidden";

	

	MirrorDepartureCountryID.value = '';



	



	var MirrorDepartureCountryName = document.createElement('input');



	MirrorDepartureCountryName.id = "MirrorDepartureCountryName["+Index+"]";



	MirrorDepartureCountryName.name = "MirrorDepartureCountryName["+Index+"]";



	MirrorDepartureCountryName.type = "text";



	MirrorDepartureCountryName.readOnly = true;



	MirrorDepartureCountryName.style.width = '114px';



	MirrorDepartureCountryName.style.backgroundColor = '#EEEEEE';

	

	MirrorDepartureCountryName.title = "Country of departure (Empty cont.) ["+(Index+1)+"]";

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MirrorDepartureCountryID);



	Cell.appendChild(MirrorDepartureCountryName);



	mirrorRow.appendChild(Cell);



	



	var MirrorDepartureRailwayID = document.createElement('input');



	MirrorDepartureRailwayID.id = "MirrorDepartureRailwayID["+Index+"]";



	MirrorDepartureRailwayID.name = "MirrorDepartureRailwayID["+Index+"]";



	MirrorDepartureRailwayID.type = "hidden";



	MirrorDepartureRailwayID.value = '';



	



	var MirrorDepartureRailwayName = document.createElement('input');



	MirrorDepartureRailwayName.id = "MirrorDepartureRailwayName["+Index+"]";



	MirrorDepartureRailwayName.name = "MirrorDepartureRailwayName["+Index+"]";



	MirrorDepartureRailwayName.type = "text";



	MirrorDepartureRailwayName.readOnly = true;



	MirrorDepartureRailwayName.style.width = '114px';



	MirrorDepartureRailwayName.style.backgroundColor = '#EEEEEE';



	MirrorDepartureRailwayName.title = "Railway point of departure (Empty cont.) ["+(Index+1)+"]";

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MirrorDepartureRailwayID);



	Cell.appendChild(MirrorDepartureRailwayName);



	mirrorRow.appendChild(Cell);



	



	var MirrorDestinationCountryID = document.createElement('input');



	MirrorDestinationCountryID.id = "MirrorDestinationCountryID["+Index+"]";



	MirrorDestinationCountryID.name = "MirrorDestinationCountryID["+Index+"]";



	MirrorDestinationCountryID.type = "hidden";



	MirrorDestinationCountryID.value = '';



	



	var MirrorDestinationCountryName = document.createElement('input');



	MirrorDestinationCountryName.id = "MirrorDestinationCountryName["+Index+"]";



	MirrorDestinationCountryName.name = "MirrorDestinationCountryName["+Index+"]";



	MirrorDestinationCountryName.type = "text";



	MirrorDestinationCountryName.readOnly = true;



	MirrorDestinationCountryName.style.width = '114px';



	MirrorDestinationCountryName.style.backgroundColor = '#EEEEEE';



	MirrorDestinationCountryName.title = "Country of destination (Empty cont.) ["+(Index+1)+"]";

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MirrorDestinationCountryID);



	Cell.appendChild(MirrorDestinationCountryName);



	mirrorRow.appendChild(Cell);



	



	/*



	<input type="hidden" name="MirrorDepartureCountryID[]" id="MirrorDepartureCountryID[]" value="">



	<input type="text" name="MirrorDepartureCountryName[]" id="MirrorDepartureCountryName[]" title="MirrorDepartureCountryName[0]" style="width:114px;background-color:#EEEEEE;" readonly>



	*/



	



	var MirrorDestinationRailwayID = document.createElement('input');



	MirrorDestinationRailwayID.id = "MirrorDestinationRailwayID["+Index+"]";



	MirrorDestinationRailwayID.name = "MirrorDestinationRailwayID["+Index+"]";



	MirrorDestinationRailwayID.type = "hidden";



	MirrorDestinationRailwayID.value = '';



	var MirrorDestinationRailwayName = document.createElement('input');



	MirrorDestinationRailwayName.id = "MirrorDestinationRailwayName["+Index+"]";



	MirrorDestinationRailwayName.name = "MirrorDestinationRailwayName["+Index+"]";



	MirrorDestinationRailwayName.type = "text";



	MirrorDestinationRailwayName.readOnly = true;



	MirrorDestinationRailwayName.style.width = '114px';



	MirrorDestinationRailwayName.style.backgroundColor = '#EEEEEE';



	MirrorDestinationRailwayName.title = "Railway point of destination (Empty cont.) ["+(Index+1)+"]";

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MirrorDestinationRailwayID);



	Cell.appendChild(MirrorDestinationRailwayName);



	mirrorRow.appendChild(Cell);



	



	var MirrorCurrency = document.createElement('select');



	MirrorCurrency.id = 'MirrorCurrency['+Index+']';



	MirrorCurrency.name  = 'MirrorCurrency['+Index+']';



	MirrorCurrency.style.width = '60px';



	MirrorCurrency.title = "Currency (Empty cont.) ["+(Index+1)+"]";

	

	MirrorCurrency.disabled = "disabled";

	



	var inheritableSelect = document.getElementById('MirrorCurrency[0]');



	for (var opt=0; opt<inheritableSelect.options.length; opt++) {



		var optionElement = document.createElement('option');



		optionElement.value = inheritableSelect.options[opt].value;



		optionElement.text = inheritableSelect.options[opt].text;



		try {



			MirrorCurrency.add(optionElement, null);



		} catch(ex) {



			MirrorCurrency.add(optionElement);



		}



	}







	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(MirrorCurrency);



	mirrorRow.appendChild(Cell);



	



	//<input name="Mirror20[]" type="text" onkeypress="return isNumberKey(event);" id="Mirror20[]" title="Mirror20[0]" style="width: 60px;">



	var Mirror20 = document.createElement('input');



	Mirror20.id = "Mirror20["+Index+"]";



	Mirror20.name = "Mirror20["+Index+"]";



	Mirror20.type = "text";



	Mirror20.style.width = '60px';



	Mirror20.title = "20DC Tariff (Empty cont.) ["+(Index+1)+"]";

		

	Mirror20.style.background= document.getElementById("Mirror20[0]").style.background;

	

	Mirror20.readOnly= document.getElementById("Mirror20[0]").readOnly;

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.style.borderRight = '1px solid #003366';



	Cell.appendChild(Mirror20);



	mirrorRow.appendChild(Cell);



	



	//<input name="Mirror40[]" type="text" onkeypress="return isNumberKey(event);" id="Mirror40[]" title="Mirror40[0]" style="width: 60px;">



	var Mirror40 = document.createElement('input');



	Mirror40.id = "Mirror40["+Index+"]";



	Mirror40.name = "Mirror40["+Index+"]";



	Mirror40.type = "text";



	Mirror40.style.width = '60px';



	Mirror40.title = "40DC/HC Tariff (Empty cont.) ["+(Index+1)+"]";



	Mirror40.style.background= document.getElementById("Mirror40[0]").style.background;

	

	Mirror40.readOnly= document.getElementById("Mirror40[0]").readOnly;

	



	var Cell = document.createElement('td');



	Cell.bgColor = '#E4E4E4';



	Cell.align = 'center';



	Cell.style.borderBottom = '1px dotted #666666';



	Cell.appendChild(Mirror40);



	mirrorRow.appendChild(Cell);



	



	if (IF4.Index>0) {



		//alert(IF4.Index);



		RemoveRowButton.disabled = false;



	}



}







var JunctionsTableObject = null;



var JunctionsTableParentObject = null;



var JunctionsRemoved = false;







IF4.ShowJunctions = function() {



	//alert(JunctionsTableObject);



	if (JunctionsTableObject != null && JunctionsTableParentObject != null && JunctionsRemoved) {



		JunctionsTableParentObject.appendChild(JunctionsTableObject);



		JunctionsRemoved = false;



	} /* else {



		alert("Junctions already is appearing");



	} */



}







IF4.DestroyJunctions = function() {



	if (JunctionsRemoved != true) {



		JunctionsTableObject = document.getElementById('JunctionsTable');



		JunctionsTableParentObject = JunctionsTableObject.parentNode;



		JunctionsTableParentObject.removeChild(JunctionsTableObject);



		JunctionsRemoved = true;



	} /* else {



		alert("Junctions already removed");



	} */



}







IF4.TableTitle = function(Title) {



	/*



	var MainMessage = "<?=$lang['railexpect'];?>";



	MainMessage+=Title;



	var MirrorMessage = "RAILWAY TARIFF for empty container return way for ";



	MirrorMessage+=Title;



	*/



	var MainMessage = if4MainMessage;



	//MainMessage+=Title;



	var MirrorMessage = if4MirrosMessage;



	//MirrorMessage+=Title;



	switch (Title) {



		case "COC":



			IF4.ShowJunctions();



			IF4.ToogleJunctionsTable('show');



			document.getElementById('MainTitle').innerHTML = MainMessage;



			IF4.ToogleMainTable('show');



			document.getElementById('MirrorTitle').innerHTML = MirrorMessage;



			IF4.ToogleMirrorTable('hide');



		break;



		case "LOC-SOC":



			IF4.ShowJunctions();



			IF4.ToogleJunctionsTable('show');



			document.getElementById('MainTitle').innerHTML = MainMessage;



			IF4.ToogleMainTable('show');



			document.getElementById('MirrorTitle').innerHTML = MirrorMessage;



			IF4.ToogleMirrorTable('show');



		break;



		default:



			IF4.ToogleJunctionsTable('hide');



			IF4.ToogleMainTable('hide');



			IF4.ToogleMirrorTable('hide');



			document.getElementById('MainTitle').innerHTML = '';



			document.getElementById('MirrorTitle').innerHTML = '';



			IF4.DestroyJunctions();



		break;



	}



}







IF4.ToogleJunctionsTable = function(action) {



	var obj = document.getElementById('JunctionsTable');



	switch(action) {



		case "show": obj.style.visibility = 'visible'; break;



		case "hide": obj.style.visibility = 'hidden'; break;



	}



	return (action=="show")?true:false;



}







IF4.ToogleMainTable = function(action) {



	var obj = document.getElementById('MainTable');



	switch(action) {



		case "show": obj.style.visibility = 'visible'; break;



		case "hide": obj.style.visibility = 'hidden'; break;



	}



	return (action=="show")?true:false;



}







IF4.ToogleMirrorTable = function(action) {



	var obj = document.getElementById('MirrorTable');



	switch(action) {



		case "show": obj.style.display = 'block'; obj.style.visibility = 'visible'; break;



		case "hide": obj.style.display = 'none'; obj.style.visibility = 'hidden'; break;



	}



	return (action=="show")?true:false;



}







IF4.MirrorTable = function() {



	var obj = document.getElementById('MirrorTable');



	if (obj!=null) {



		var pNode = obj.parentNode;



		



	}



}







IF4.RemoveLastRow = function() {



	var RemoveRowButton = document.getElementById('RemoveRow');



	//alert("Before: "+IF4.Index);



	var MainTable = document.getElementById('MainTable');



	var MirrorTable = document.getElementById('MirrorTable');



	



	var MainRows = MainTable.rows.length;



	if (MainRows>3 && IF4.Index>0) {



		MainTable.deleteRow(--MainRows);



	}



	



	var MirrorRows = MirrorTable.rows.length;



	if (MirrorRows>3 && IF4.Index>0) {



		MirrorTable.deleteRow(--MirrorRows);



	}



	IF4.Index--;



	//alert("After: "+IF4.Index);



	if (IF4.Index == 0) RemoveRowButton.disabled = true;



}
















