// 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);



}



























var MainDestinationCountry = new Array();







var MainDestinationRailway = new Array();











function isValidIF6Form(nrt_counter) {











fieldarr = new Array();



fieldarr = fieldarr.concat('depCountryName','depPortName','validity_day','validity_month','validity_year');







var i=0;



for (i==0;i<nrt_counter;i++)







{



	



	if (document.getElementById('d20cbox').checked==true) fieldarr = fieldarr.concat('DC20['+i+']');



	if (document.getElementById('d40cbox').checked==true) fieldarr = fieldarr.concat('DC40['+i+']');



	if (document.getElementById('h40cbox').checked==true) fieldarr = fieldarr.concat('HC40['+i+']');



		



fieldarr = fieldarr.concat(	'MainDestinationCountryName['+i+']','MainDestinationRailwayName['+i+']','MainTransitTime['+i+']','MainCurrency['+i+']');



}











var isFieldsValid = validateForm(new Objects(fieldarr));







	







	var Valid = (isFieldsValid);







	return Valid;







}















var IF6 = new Object();







IF6.Index = 0;







IF6.fnMainDestinationCountry = function() {







	var obj = getEvent();







	var indx = obj.target.alt;







	var _MainDestinationRailwayId = document.getElementById('MainDestinationRailwayID['+indx+']');







	_MainDestinationRailwayId.value = '';







	var _MainDestinationRailwayName = document.getElementById('MainDestinationRailwayName['+indx+']');







	_MainDestinationRailwayName.value = '';







	createPopup('popup/test.php?f=countries','Filter',330,540,MainDestinationCountry[indx]);







}























IF6.fnMainDestinationRailway = function() {







	var obj = getEvent();







	var indx = obj.target.alt;







	var _MainDestinationCountriesId = document.getElementById('MainDestinationCountryID['+indx+']');



	createPopup("popup/test.php?f=railpoints&addfunct=1&id="+_MainDestinationCountriesId.value,'Filter',330,540,MainDestinationRailway[indx]);







}















IF6.AddRow = function() {







	++IF6.Index;







	var index = IF6.Index;







	var RemoveRowButton = document.getElementById('RemoveRow');







	







	var MainTable = document.getElementById('MainTable');







	var MainTableRows = MainTable.rows.length;







	var MainRow = document.getElementById('MainRow');







	var MainRowElement = document.createElement('tr');







	var mainRow = MainTable.insertRow(MainTableRows);







	







	//////////////////////////////////////////////////////////////







	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.title = "Country of destination ["+(IF6.Index+1)+"]";







	MainDestinationCountryName.readOnly = true;







	MainDestinationCountryName.style.width = '80px';







	MainDestinationCountryName.style.backgroundColor = '#EEEEEE';















	var MainDestinationCountryPopupImage = new Image();







	MainDestinationCountryPopupImage.src = "images/hand.gif";







	MainDestinationCountryPopupImage.border = 0;







	MainDestinationCountryPopupImage.alt = IF6.Index;







	







	var MainDestinationCountryLink = document.createElement('a');







	MainDestinationCountry[IF6.Index] = new Object();







	MainDestinationCountry[IF6.Index].hidden = MainDestinationCountryID;







	MainDestinationCountry[IF6.Index].visible = MainDestinationCountryName;







	MainDestinationCountryLink.href="javascript:void(0)";







	addEvent(MainDestinationCountryLink,"click",IF6.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(document.createTextNode(' '));







	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.title = "Destination Railway Name ["+(IF6.Index+1)+"]";







	MainDestinationRailwayName.readOnly = true;







	MainDestinationRailwayName.style.width = '80px';







	MainDestinationRailwayName.style.backgroundColor = '#EEEEEE';















	var MainDestinationRailwayPopupImage = new Image();







	MainDestinationRailwayPopupImage.src = "images/hand.gif";







	MainDestinationRailwayPopupImage.border = 0;







	MainDestinationRailwayPopupImage.alt = IF6.Index;







	







	var MainDestinationRailwayLink = document.createElement('a');







	MainDestinationRailway[IF6.Index] = new Object();







	MainDestinationRailway[IF6.Index].hidden = MainDestinationRailwayID;







	MainDestinationRailway[IF6.Index].visible = MainDestinationRailwayName;







	MainDestinationRailwayLink.href="javascript:void(0)";







	addEvent(MainDestinationRailwayLink,"click",IF6.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(document.createTextNode(' '));







	Cell.appendChild(MainDestinationRailwayLink);







	mainRow.appendChild(Cell);







	







	var MainTransitTime = document.createElement('input');







	MainTransitTime.name = 'MainTransitTime['+(index)+']';







	MainTransitTime.id = 'MainTransitTime['+(index)+']';







	MainTransitTime.type = 'text'







	MainTransitTime.style.width = '90px';







	MainTransitTime.title = "Transit time ["+(IF6.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(MainTransitTime);







	mainRow.appendChild(Cell);







	







	







	var MainCurrency = document.createElement('select');







	MainCurrency.id = 'MainCurrency['+(index)+']';







	MainCurrency.name  = 'MainCurrency['+(index)+']';







	MainCurrency.style.width = '92px';







	MainCurrency.title = "Currency ["+(index+1)+"]";



	



	var inheritTableSelect = document.getElementsByName('MainCurrency[0]');







	var inheritableSelect = inheritTableSelect[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);







		}







	}







MainCurrency.selectedIndex= inheritableSelect.selectedIndex;







	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 DC20 = document.createElement('input');







	DC20.name = 'DC20['+(index)+']';







	DC20.id = 'DC20['+(index)+']';







	DC20.type = 'text'







	DC20.style.width = '90px';







	DC20.title = "20DC Tariff ["+(IF6.Index+1)+"]";







	DC20.style.background= document.getElementById("DC20[0]").style.background;



	



	DC20.readOnly= document.getElementById("DC20[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(DC20);







	mainRow.appendChild(Cell);







	







	var DC40 = document.createElement('input');







	DC40.name = 'DC40['+(index)+']';







	DC40.id = 'DC40['+(index)+']';







	DC40.type = 'text'







	DC40.style.width = '90px';







	DC40.title = "40DC Tariff ["+(IF6.Index+1)+"]";







	DC40.style.background= document.getElementById("DC40[0]").style.background;



	



	DC40.readOnly= document.getElementById("DC40[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(DC40);







	mainRow.appendChild(Cell);







	







	var HC40 = document.createElement('input');







	HC40.name = 'HC40['+(index)+']';







	HC40.id = 'HC40['+(index)+']';







	HC40.type = 'text'







	HC40.style.width = '90px';







	HC40.title = "40HC Tariff["+(IF6.Index+1)+"]";



	



	HC40.style.background= document.getElementById("HC40[0]").style.background;



	



	HC40.readOnly= document.getElementById("HC40[0]").readOnly;



	







	var Cell = document.createElement('td');







	Cell.bgColor = '#E4E4E4';







	Cell.align = 'center';







	Cell.style.borderBottom = '1px dotted #666666';







	Cell.appendChild(HC40);







	mainRow.appendChild(Cell);







	







	RemoveRowButton.disabled = false;







}















IF6.RemoveLastRow = function() {







	var RemoveRowButton = document.getElementById('RemoveRow');







	var NationalTable = document.getElementById('MainTable');







	var Rows = NationalTable.rows.length;







	



		if (IF6.Index>0) 



		{







		NationalTable.deleteRow(--Rows);







		IF6.Index--;







		}











}
























