// 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 MainDestinationRoad = new Array();





function isValidIF62Form(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+']','MainDestinationRoadName['+i+']','MainZip['+i+']','MainTransitTime['+i+']','MainCurrency['+i+']');

}





var isFieldsValid = validateForm(new Objects(fieldarr));



	



	var Valid = (isFieldsValid);



	return Valid;



}







var IF62 = new Object();



IF62.Index = 0;



IF62.fnMainDestinationCountry = function() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDestinationRoadId = document.getElementById('MainDestinationRoadID['+indx+']');



	_MainDestinationRoadId.value = '';



	var _MainDestinationRoadName = document.getElementById('MainDestinationRoadName['+indx+']');



	_MainDestinationRoadName.value = '';



	createPopup('popup/test.php?f=countries','Filter',330,540,MainDestinationCountry[indx]);



}











IF62.fnMainDestinationRoad = function() {



	var obj = getEvent();



	var indx = obj.target.alt;



	var _MainDestinationCountriesId = document.getElementById('MainDestinationCountryID['+indx+']');

	createPopup("popup/test.php?f=roadpoints&addfunct=1&id="+_MainDestinationCountriesId.value,'Filter',330,540,MainDestinationRoad[indx]);

}







IF62.AddRow = function() {





++IF62.Index;



	var index = IF62.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 ["+(IF62.Index+1)+"]";



	MainDestinationCountryName.readOnly = true;



	MainDestinationCountryName.style.width = '110px';



	MainDestinationCountryName.style.backgroundColor = '#EEEEEE';







	var MainDestinationCountryPopupImage = new Image();



	MainDestinationCountryPopupImage.src = "images/hand.gif";



	MainDestinationCountryPopupImage.border = 0;



	MainDestinationCountryPopupImage.alt = IF62.Index;



	



	var MainDestinationCountryLink = document.createElement('a');



	MainDestinationCountry[IF62.Index] = new Object();



	MainDestinationCountry[IF62.Index].hidden = MainDestinationCountryID;



	MainDestinationCountry[IF62.Index].visible = MainDestinationCountryName;



	MainDestinationCountryLink.href="javascript:void(0)";



	addEvent(MainDestinationCountryLink,"click",IF62.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 MainDestinationRoadID = document.createElement('input');



	MainDestinationRoadID.id='MainDestinationRoadID['+(index)+']';



	MainDestinationRoadID.name='MainDestinationRoadID['+(index)+']';



	MainDestinationRoadID.type='hidden';



	MainDestinationRoadID.value='';



	



	var MainDestinationRoadName = document.createElement('input');



	MainDestinationRoadName.id = 'MainDestinationRoadName['+(index)+']';



	MainDestinationRoadName.name = 'MainDestinationRoadName['+(index)+']';



	MainDestinationRoadName.type = 'text';



	MainDestinationRoadName.value = '';



	MainDestinationRoadName.title = "Destination Road Name ["+(IF62.Index+1)+"]";



	MainDestinationRoadName.readOnly = true;



	MainDestinationRoadName.style.width = '110px';



	MainDestinationRoadName.style.backgroundColor = '#EEEEEE';







	var MainDestinationRoadPopupImage = new Image();



	MainDestinationRoadPopupImage.src = "images/hand.gif";



	MainDestinationRoadPopupImage.border = 0;



	MainDestinationRoadPopupImage.alt = IF62.Index;



	



	var MainDestinationRoadLink = document.createElement('a');



	MainDestinationRoad[IF62.Index] = new Object();



	MainDestinationRoad[IF62.Index].hidden = MainDestinationRoadID;



	MainDestinationRoad[IF62.Index].visible = MainDestinationRoadName;



	MainDestinationRoadLink.href="javascript:void(0)";



	addEvent(MainDestinationRoadLink,"click",IF62.fnMainDestinationRoad);



	MainDestinationRoadLink.appendChild(MainDestinationRoadPopupImage);



	///////////////////////////////////////////////////////////////////////////



	



	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(MainDestinationRoadID);



	Cell.appendChild(MainDestinationRoadName);



	Cell.appendChild(document.createTextNode(' '));



	Cell.appendChild(MainDestinationRoadLink);



	mainRow.appendChild(Cell);



	





	var DestinationZip = document.createElement('input');

	DestinationZip.id = 'MainZip['+(index)+']';

	DestinationZip.name = 'MainZip['+(index)+']';

	DestinationZip.title = "ZIP Code ["+(index+1)+"]";

	DestinationZip.type = 'text';

	DestinationZip.style.width = '71px';

	DestinationZip.style.backgroundColor = '#EEEEEE';

	DestinationZip.readOnly = true;

	MainDestinationRoad[index].zip = DestinationZip;

	addEvent(MainDestinationRoadLink,"click",IF62.fnMainDestinationRoad);





	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(DestinationZip);



	mainRow.appendChild(Cell);

	

	



	var MainTransitTime = document.createElement('input');



	MainTransitTime.name = 'MainTransitTime['+(index)+']';



	MainTransitTime.id = 'MainTransitTime['+(index)+']';



	MainTransitTime.type = 'text'



	MainTransitTime.style.width = '50px';



	MainTransitTime.title = "Transit time ["+(IF62.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 = '68px';



	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 = '63px';



	DC20.title = "20DC Tariff ["+(IF62.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 = '63px';



	DC40.title = "40DC Tariff ["+(IF62.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 = '63px';



	HC40.title = "40HC Tariff["+(IF62.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;



}







IF62.RemoveLastRow = function() {



	var RemoveRowButton = document.getElementById('RemoveRow');



	var NationalTable = document.getElementById('MainTable');



	var Rows = NationalTable.rows.length;



	

		if (IF62.Index>0) 

		{



		NationalTable.deleteRow(--Rows);



		IF62.Index--;



		}





}


