
function dynamicSelect(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};

	}
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}

function dynamicSelectForReg(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refreshDynamicSelectOptionsForReg(sel1, sel2, clonedOptions);
		
		sel1.onchange = function() {
			refreshDynamicSelectOptionsForReg(sel1, sel2, clonedOptions);
		};


	}
}
function refreshDynamicSelectOptionsForReg(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}

    	var repHideText=document.getElementById('inputRepublic');
    	var vilHideText=document.getElementById('inputViloyat');
    	var tumHideText=document.getElementById('inputTuman');
    	var contact_oblast=document.getElementById('contact_oblast');
    	var contact_gorod=document.getElementById('contact_gorod');

	repHideText.style.visibility=(sel1.value=='999999999')?'visible':'hidden';
 	vilHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'visible':'hidden';
 	tumHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888' || sel1.value=='777777777')?'visible':'hidden';

 	contact_oblast.style.visibility=(sel1.value=='999999999')?'hidden':'visible';
 	contact_gorod.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'hidden':'visible';

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}

function dynamicSelectForGruzOtkuda(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refSelOptnsForGruzOtkuda(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refSelOptnsForGruzOtkuda(sel1, sel2, clonedOptions);
		};
	}
}
function refSelOptnsForGruzOtkuda(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
    	var repHideText=document.getElementById('inputOtkudaRepublic');
    	var vilHideText=document.getElementById('inputOtkudaViloyat');
    	var tumHideText=document.getElementById('inputOtkudaTuman');
    	var contact_otkuda_oblast=document.getElementById('contact_otkuda_oblast');
    	var contact_otkuda_gorod=document.getElementById('contact_otkuda_gorod');

	repHideText.style.visibility=(sel1.value=='999999999')?'visible':'hidden';
 	vilHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'visible':'hidden';
 	tumHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888' || sel1.value=='777777777')?'visible':'hidden';

 	contact_otkuda_oblast.style.visibility=(sel1.value=='999999999')?'hidden':'visible';
 	contact_otkuda_gorod.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'hidden':'visible';

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}


function dynamicSelectForGruzKuda(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refSelOptnsForGruzKuda(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refSelOptnsForGruzKuda(sel1, sel2, clonedOptions);
		};
	}
}
function refSelOptnsForGruzKuda(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
    	var repHideText=document.getElementById('inputKudaRepublic');
    	var vilHideText=document.getElementById('inputKudaViloyat');
    	var tumHideText=document.getElementById('inputKudaTuman');
    	var contact_kuda_oblast=document.getElementById('contact_kuda_oblast');
    	var contact_kuda_gorod=document.getElementById('contact_kuda_gorod');

	repHideText.style.visibility=(sel1.value=='999999999')?'visible':'hidden';
 	vilHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'visible':'hidden';
 	tumHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888' || sel1.value=='777777777')?'visible':'hidden';

 	contact_kuda_oblast.style.visibility=(sel1.value=='999999999')?'hidden':'visible';
 	contact_kuda_gorod.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'hidden':'visible';

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}


function dynamicSelectForTransOtkuda(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refSelOptnsForGruzOtkuda(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refSelOptnsForGruzOtkuda(sel1, sel2, clonedOptions);
		};
	}
}
function refSelOptnsForTransOtkuda(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
    	var repHideText=document.getElementById('inputOtkudaRepublic');
    	var vilHideText=document.getElementById('inputOtkudaViloyat');
    	var tumHideText=document.getElementById('inputOtkudaTuman');
    	var contact_otkuda_oblast=document.getElementById('contact_otkuda_oblast');
    	var contact_otkuda_gorod=document.getElementById('contact_otkuda_gorod');

	repHideText.style.visibility=(sel1.value=='999999999')?'visible':'hidden';
 	vilHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'visible':'hidden';
 	tumHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888' || sel1.value=='777777777')?'visible':'hidden';

 	contact_otkuda_oblast.style.visibility=(sel1.value=='999999999')?'hidden':'visible';
 	contact_otkuda_gorod.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'hidden':'visible';

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}


function dynamicSelectForTransKuda(id1, id2) {
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refSelOptnsForGruzKuda(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refSelOptnsForTransKuda(sel1, sel2, clonedOptions);
		};
	}
}
function refSelOptnsForTransKuda(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
    	var repHideText=document.getElementById('inputKudaRepublic');
    	var vilHideText=document.getElementById('inputKudaViloyat');
    	var tumHideText=document.getElementById('inputKudaTuman');
    	var contact_kuda_oblast=document.getElementById('contact_kuda_oblast');
    	var contact_kuda_gorod=document.getElementById('contact_kuda_gorod');

	repHideText.style.visibility=(sel1.value=='999999999')?'visible':'hidden';
 	vilHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'visible':'hidden';
 	tumHideText.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888' || sel1.value=='777777777')?'visible':'hidden';

 	contact_kuda_oblast.style.visibility=(sel1.value=='999999999')?'hidden':'visible';
 	contact_kuda_gorod.style.visibility=(sel1.value=='999999999' || sel1.value=='888888888')?'hidden':'visible';

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}


