/**//**//**//**//**//**//**//**//**//**//**//**//**//**/
function table_info_on(){
    document.getElementById('table_info').style.display = 'block';
}

function switch_table_info(){
    if(document.getElementById('table_info').style.display == 'block'){
        document.getElementById('table_info').style.display = 'none';
    }else{
    document.getElementById('table_info').style.display = 'block';
    }
}

function switch_calendar(){
    if(document.getElementById('calendar_status').value == 1){
        document.getElementById('div_calendar').style.display='none';
        document.getElementById('calendar_status').value = 0;
    }else{
        document.getElementById('div_calendar').style.display='block';
        document.getElementById('calendar_status').value = 1;
    }
}

function make_calendar_date(switch_object){
    var temp = switch_object.split('-');
    var month = new Array();
    month['01'] = "Января";
    month['02'] = "Февраля";
    month['03'] = "Марта";
    month['04'] = "Апреля";
    month['05'] = "Мая";
    month['06'] = "Июня";
    month['07'] = "Июля";
    month['08'] = "Августа";
    month['09'] = "Сентября";
    month['10'] = "Октября";
    month['11'] = "Ноября";
    month['12'] = "Декабря";
    document.getElementById('date1').value = temp[2] + '.' + temp[1] + '.' + temp[0];
}

function change_bedding_type(){
    var payment_count = document.getElementById('payment_count').value;
    for (i=1; i<=payment_count; i++){
        document.getElementById('pict_'+i).src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
    }
    document.getElementById('payment_system').value = '0';
    var bedding_type = document.getElementById('bedding').value;
    if(bedding_type == 1){
        document.getElementById('ETICKET_without_bedding').style.display="block";
        document.getElementById('ETICKET_with_bedding').style.display="none";
        document.getElementById('ETICKET_payment_systems_without_bedding').style.display="block";
        document.getElementById('ETICKET_payment_systems_with_bedding').style.display="none";
        document.getElementById('bedding').value = 0;
    }else{
        document.getElementById('ETICKET_without_bedding').style.display="none";
        document.getElementById('ETICKET_with_bedding').style.display="block";
        document.getElementById('ETICKET_payment_systems_without_bedding').style.display="none";
        document.getElementById('ETICKET_payment_systems_with_bedding').style.display="block";
        document.getElementById('bedding').value = 1;
    }
}

function set_payment_system(settype){
    var payment_count = document.getElementById('payment_count').value;
    for (i=1; i<=payment_count; i++){
        document.getElementById('pict_'+i).src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
    }
    document.getElementById('pict_'+settype).src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
    document.getElementById('payment_system').value = document.getElementById('ps_'+settype).value;
    document.getElementById('result_comission').innerHTML = 'Стоимость с учетом комиссии: <b>'+document.getElementById('p_'+settype).value+'</b> руб.';
    document.getElementById('GETTICKET-button-prices').value = 'Полная стоимость: ' + document.getElementById('p_'+settype).value + ' руб (электронный билет)';
}

function check_contact(){
    var abonent_first    = document.getElementById('abonent_first').value;
    var contact_phone    = document.getElementById('contact_phone').value;
    var timetocall    = document.getElementById('timetocall').value;
    if(abonent_first == ""){
        alert('вы не ввели имя контактного лица');
        return false;
    }
    if(contact_phone == ""){
        alert('введите пожалуйста номер телефона');
        return false;
    }
}

function change_dost_type(temp){
	var delivery_type = temp;
	var delivery_type_id = document.getElementById('delivery_type').value;
    tscost = document.getElementById('tscost').value;
//	document.getElementById('forward').style.display = (this.checked ? 'block' : 'none');
	if(delivery_type == 'FAST' && delivery_type_id == 'FAST'){
		document.getElementById('DELIVERY_CUR').style.display="block";
		document.getElementById('DELIVERY_OWN').style.display="none";
        document.getElementById('DELIVERY_OWN_TEXT').style.display="none";
        document.getElementById('DELIVERY_CUR_TEXT').style.display="block";
		document.getElementById('delivery_type').value = 'CUR';
        document.getElementById('GETTICKET-button-prices').value = 'окончательная стоимость: ' + tscost + ' руб + 200 руб доставка';
		document.dost_cur.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
		document.dost_own.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
		document.dost_fast.src = 'http://train.vnukovo-bilet.ru/images/checkbox_unchecked.png';
		return false;
	}
	if(delivery_type == 'CUR'){
		document.getElementById('DELIVERY_CUR').style.display="block";
		document.getElementById('DELIVERY_OWN').style.display="none";
        document.getElementById('DELIVERY_OWN_TEXT').style.display="none";
        document.getElementById('DELIVERY_CUR_TEXT').style.display="block";
		document.getElementById('delivery_type').value = 'CUR';
        document.getElementById('GETTICKET-button-prices').value = 'окончательная стоимость: ' + tscost + ' руб + 200 руб доставка';
		document.dost_cur.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
		document.dost_own.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
		document.dost_fast.src = 'http://train.vnukovo-bilet.ru/images/checkbox_unchecked.png';
		return false;
	}
	if(delivery_type == 'OWN'){
		document.getElementById('DELIVERY_CUR').style.display="none";
		document.getElementById('DELIVERY_OWN').style.display="block";
        document.getElementById('DELIVERY_OWN_TEXT').style.display="block";
        document.getElementById('DELIVERY_CUR_TEXT').style.display="none";
		document.getElementById('delivery_type').value = 'OWN';
        document.getElementById('GETTICKET-button-prices').value = 'окончательная стоимость: ' + tscost + ' руб билет можно получить в офисе';
		document.dost_own.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
		document.dost_cur.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
		document.dost_fast.src = 'http://train.vnukovo-bilet.ru/images/checkbox_unchecked.png';
		return false;
	}
	if(delivery_type == 'FAST'){
		document.getElementById('DELIVERY_CUR').style.display="block";
		document.getElementById('DELIVERY_OWN').style.display="none";
        document.getElementById('DELIVERY_OWN_TEXT').style.display="none";
        document.getElementById('DELIVERY_CUR_TEXT').style.display="block";
		document.getElementById('delivery_type').value = 'FAST';
        document.getElementById('GETTICKET-button-prices').value = 'окончательная стоимость: ' + tscost + ' руб + 400 руб доставка';
		document.dost_cur.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
		document.dost_own.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
		document.dost_fast.src = 'http://train.vnukovo-bilet.ru/images/checkbox_checked.png';
		return false;
	}
}
/**//**//**//**//**//**//**//**//**//**//**//**//**//**/

var seats_alert_count = 0;

var countOfFields = 1;
var curFieldNameId = 2;
var maxFieldLimit = 9;

var tarif = 100;
var cost = 0;
var vzr = 1;
var child = 0;
var agents = 0; //комиссия агента
var agent_all_cost = 0;
var t_type = 1;
var see_timelist = 0;

function roll_over(img_name, img_src){
	document[img_name].src = 'http://biletix.ru/zhdbooking_templ/'+img_src;
}

function count_cost(){
	if(t_type == 1){
		var tarif = document.getElementById('tarif_full').value;
		cost = tarif*vzr;
		cost += 0.45*tarif*child;
		temp = (cost)+agents;
		if(temp == 150){
			temp = 0;
		}
	}

	if(t_type == 2){
		var etarif_full = document.getElementById('etarif_full').value;
		var etarif_child = document.getElementById('etarif_child').value;
		cost = etarif_full*vzr;
		cost += etarif_child*child;
		temp = (cost/100);
	}

	document.getElementById("sum").value = temp;
	document.getElementById("t").value = cost;
}

function check_seats(){
	var hidden_selected_seats_lenght = document.getElementById('hidden_selected_seats').value.length - 2;
	if(hidden_selected_seats_lenght <= 0){
		alert('выберите пожалуйста места');
		return false;
	}
}

function change_ticket_dost (){
	var way_type	= document.getElementById('way_type').value;
	if(way_type == 1){
		document.getElementById('way_type').value	=	2;
		document.getElementById('rt').value	=	"RT";
		document.getElementById('need_back_way_ticket').style.visibility="visible";
		return false;
	}
	if(way_type == 2){
		document.getElementById('way_type').value	=	1;
		document.getElementById('rt').value	=	"OW";
		document.getElementById('need_back_way_ticket').style.visibility="hidden";
		return false;
	}
} 
			
function check_all_forms (){
	var date1 = document.getElementById('date1').value;
	var depart = document.getElementById('depart').value;
	var arrival = document.getElementById('arrival').value;
	if (date1 == ""){
		alert("вы не выбрали дату отправления.");
		return false;
	}
	if (depart == ""){
		alert("вы не выбрали отдно из направлений.");
		return false;
	}
	if (arrival == ""){
		alert("вы не выбрали отдно из направлений.");
		return false;
	}
}

var passengers_count = 0;

function explode(separator, string){
   return string.split (seperator);
}

function makeselected(selectobj){
    var result = new Array(); 
    var temp = selectobj.value.split('_');
    document.getElementById('passportRF'+temp[1]).style.display="none";
    document.getElementById('ID'+temp[1]).style.display="none";
    document.getElementById('BC'+temp[1]).style.display="none";
    document.getElementById('passportFRN'+temp[1]).style.display="none";
    document.getElementById('FRNdoc'+temp[1]).style.display="none";
    document.getElementById('passportSEAMAN'+temp[1]).style.display="none";
    document.getElementById(temp[0]+temp[1]).style.display="block";
/*
    result = explode('_', temp, 2);
*/
}
function add_o() {
    if(passengers_count == 9){
        alert('пассажиров может быть не больше девяти.');
        return false;
    }
    var ni = document.getElementById('myDiv');
    var numi = document.getElementById('theValue');
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;
    var divIdName = ""+num+"";
    var newdiv = document.createElement('div');
    newdiv.setAttribute("id",divIdName);
    newdiv.innerHTML = "<!-- скрытое поле --><input type=hidden id=ptype_"+divIdName+" value=o name=ptype_"+divIdName+"><table id=table_"+divIdName+" border=0><tr><td><div id=age_type_o_"+divIdName+" class=div_age_type_o><a href=\"javascript:;\" class=a_u_switch onclick=\"switching_passenger_type('"+divIdName+"');\">взрослый</a></div><div id=age_type_c_"+divIdName+" class=div_age_type_c><a href=\"javascript:;\" class=a_u_switch onclick=\"switching_passenger_type('"+divIdName+"');\">ребёнок</a></div></td><td><!-- фамилия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите фамилию</span><br />пример:<br /><b>Иванов</b>');\" type=text id=first_"+divIdName+" name=first_"+divIdName+" value=\"введите фамилию\" class=input_first onfocus=\"if(this.value=='введите фамилию')this.value=''\" onblur=\"if(this.value=='')this.value='введите фамилию'\"></td><td><!-- имя --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите имя</span><br />пример:<br /><b>Иван</b>');\" type=text id=second_"+divIdName+" name=second_"+divIdName+" value=\"введите имя\" class=input_second onfocus=\"if(this.value=='введите имя')this.value=''\" onblur=\"if(this.value=='')this.value='введите имя'\"></td><td><!-- отчество --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите отчество</span><br />пример:<br /><b>Иванович</b>');\" type=text id=third_"+divIdName+" name=third_"+divIdName+" value=\"введите отчество\" class=input_third onfocus=\"if(this.value=='введите отчество')this.value=''\" onblur=\"if(this.value=='')this.value='введите отчество'\"></td><td><div id=doc_type_o_"+divIdName+" class=div_doc_type_o><!-- поле выбора для взрослого --><select onmouseout=\"hideddrivetip();\" onmouseover=\"ddrivetip('<span class=title>выберите пожалуйста тип документа</span>');\" id=select_o_"+divIdName+" name=select_o_"+divIdName+" class=select_select_o onChange=\"makeselected(this)\"><option value=passportRF_"+divIdName+">паспорт РФ</option><option value=ID_"+divIdName+">Удостоверение</option><option value=BC_"+divIdName+">Св. о рождении РФ</option><option value=passportFRN_"+divIdName+">Загранпаспорт РФ</option><option value=FRNdoc_"+divIdName+">Иностр.документ</option><option value=passportSEAMAN_"+divIdName+">Паспорт моряка</option></select></div><div id=doc_type_c_"+divIdName+" class=div_doc_type_c><!-- поле выбора для ребёнка --><select onmouseout=\"hideddrivetip();\" onmouseover=\"ddrivetip('<span class=title>выберите пожалуйста тип документа</span>');\" id=select_c_"+divIdName+" name=select_c_"+divIdName+" class=select_select_c onChange=\"makeselected(this)\"><option value=BC_"+divIdName+">Св. о рождении РФ</option><option value=passportFRN_"+divIdName+">Загранпаспорт РФ</option><option value=FRNdoc_"+divIdName+">Иностр.документ</option></select></div></td><td><div id=passportRF"+divIdName+" class=div_passportRF><!-- паспорта серия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию паспорта</span><br />пример:<br /><b>0123</b>');\" type=text id=text_passportRFs"+divIdName+" name=text_passportRFs"+divIdName+" class=input_passportRFs maxlength=4 onkeyup=\"num_only('text_passportRFs"+divIdName+"');\"><!-- паспорта номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите номер паспорта</span><br />вводятся последние шесть цифр<br /><img src=./images/demo_RF.jpg>');\" type=text id=text_passportRF"+divIdName+" name=text_passportRF"+divIdName+" class=input_passportRF onkeyup=\"num_only('text_passportRF"+divIdName+"');\"></div><div id=ID"+divIdName+" class=div_ID><!-- удостоверения номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите номер удостоверения</span><br />пример:<br /><b>123456</b>');\" type=text id=text_ID"+divIdName+" name=text_ID"+divIdName+" class=input_ID></div><div id=BC"+divIdName+" class=div_BC><!-- свидетельства серия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер свидетельства.</span><br />В серии от 1 до 6 римских цифр (вводятся заглавными латинскими буквами),<br /> далее две кириллические буквы.<br /><img src=./images/demo_BC.jpg>');\" type=text id=text_BC"+divIdName+" name=text_BC"+divIdName+" class=input_BC><!-- свидетельства год рождения --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите год рождения</span><br />пример:<br /><b>2001</b>');\" type=text id=text_BCy"+divIdName+" name=text_BCy"+divIdName+" class=input_BCy size=5 onkeyup=\"num_only('text_BCy"+divIdName+"');\"></div><div id=passportFRN"+divIdName+" class=div_passportFRN><!-- загран паспорта серия и номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер загранпаспорта</span><br /> без знака №, всего 9 цифр<br /><img src=./images/demo_RFFrn.jpg>');\" type=text id=text_passportFRN"+divIdName+" name=text_passportFRN"+divIdName+" class=input_passportFRN onkeyup=\"translit2en('first_"+divIdName+"'); translit2en('second_"+divIdName+"'); translit2en('third_"+divIdName+"'); num_only('text_passportFRN"+divIdName+"'); num_only('text_passportFRNy"+divIdName+"');\"><!-- загран паспорта срок годности --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите пожалуйста срок годности документа</span><br />пример:<br /><b>2001</b>');\" type=text id=text_passportFRNy"+divIdName+" name=text_passportFRNy"+divIdName+" class=input_passportFRNy size=5></div><div id=FRNdoc"+divIdName+" class=div_FRNdoc><!-- иностренного документа серия и номер --><input type=text id=text_FRNdoc"+divIdName+" name=text_FRNdoc"+divIdName+" class=input_FRNdoc></div><div id=passportSEAMAN"+divIdName+" class=div_passportSEAMAN><!--<input type=text id=text_passportSEAMANs"+divIdName+" name=text_passportSEAMANs"+divIdName+" class=input_passportSEAMAN size=5>--><!-- паспорта моряка номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер паспорта моряка</span><br /><img src=./images/passportSEAMAN.jpg>');\" type=text id=text_passportSEAMAN"+divIdName+" name=text_passportSEAMAN"+divIdName+" class=input_passportSEAMAN></div></td><td><a href=\"javascript:;\" onclick=\"removeElement('"+divIdName+"')\" onmouseout=\"roll_over('pict_r_"+divIdName+"', 'X.gif')\" onmouseover=\"roll_over('pict_r_"+divIdName+"', 'X_hove.gif')\" ><img id=pict_r_"+divIdName+" src=http://train.vnukovo-bilet.ru/images/X.gif width=25 height=25 border=0></a></td></tr></table>";
    ni.appendChild(newdiv);
    document.getElementById('passportRF'+divIdName).style.display="block";
    document.getElementById('ID'+divIdName).style.display="none";
    document.getElementById('BC'+divIdName).style.display="none";
    document.getElementById('passportFRN'+divIdName).style.display="none";
    document.getElementById('FRNdoc'+divIdName).style.display="none";
    document.getElementById('passportSEAMAN'+divIdName).style.display="none";
    document.getElementById('doc_type_c_'+divIdName).style.display="none";
    document.getElementById('age_type_c_'+divIdName).style.display="none";
    document.getElementById('peoples_num').value=document.getElementById('peoples_num').value + divIdName + ',';
    passengers_count++;
}

function add_c() {
    if(passengers_count == 9){
        alert('абломс, кол-во пассенгеров превышает лимит =)');
        return false;
    }
    var ni = document.getElementById('myDiv');
    var numi = document.getElementById('theValue');
    var num = (document.getElementById("theValue").value -1)+ 2;
    numi.value = num;
    var divIdName = ""+num+"";
    var newdiv = document.createElement('div');
    newdiv.setAttribute("id",divIdName);
    newdiv.innerHTML = "<!-- скрытое поле --><input type=hidden id=ptype_"+divIdName+" value=o name=ptype_"+divIdName+"><table id=table_"+divIdName+" border=0><tr><td><div id=age_type_o_"+divIdName+" class=div_age_type_o><a href=\"javascript:;\" class=a_u_switch onclick=\"switching_passenger_type('"+divIdName+"');\">взрослый</a></div><div id=age_type_c_"+divIdName+" class=div_age_type_c><a href=\"javascript:;\" class=a_u_switch onclick=\"switching_passenger_type('"+divIdName+"');\">ребёнок</a></div></td><td><!-- фамилия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите фамилию</span><br />пример:<br /><b>Иванов</b>');\" type=text id=first_"+divIdName+" name=first_"+divIdName+" value=\"введите фамилию\" class=input_first onfocus=\"if(this.value=='введите фамилию')this.value=''\" onblur=\"if(this.value=='')this.value='введите фамилию'\"></td><td><!-- имя --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите имя</span><br />пример:<br /><b>Иван</b>');\" type=text id=second_"+divIdName+" name=second_"+divIdName+" value=\"введите имя\" class=input_second onfocus=\"if(this.value=='введите имя')this.value=''\" onblur=\"if(this.value=='')this.value='введите имя'\"></td><td><!-- отчество --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите отчество</span><br />пример:<br /><b>Иванович</b>');\" type=text id=third_"+divIdName+" name=third_"+divIdName+" value=\"введите отчество\" class=input_third onfocus=\"if(this.value=='введите отчество')this.value=''\" onblur=\"if(this.value=='')this.value='введите отчество'\"></td><td><div id=doc_type_o_"+divIdName+" class=div_doc_type_o><!-- поле выбора для взрослого --><select onmouseout=\"hideddrivetip();\" onmouseover=\"ddrivetip('<span class=title>выберите пожалуйста тип документа</span>');\" id=select_o_"+divIdName+" name=select_o_"+divIdName+" class=select_select_o onChange=\"makeselected(this)\"><option value=passportRF_"+divIdName+">паспорт РФ</option><option value=ID_"+divIdName+">Удостоверение</option><option value=BC_"+divIdName+">Св. о рождении РФ</option><option value=passportFRN_"+divIdName+">Загранпаспорт РФ</option><option value=FRNdoc_"+divIdName+">Иностр.документ</option><option value=passportSEAMAN_"+divIdName+">Паспорт моряка</option></select></div><div id=doc_type_c_"+divIdName+" class=div_doc_type_c><!-- поле выбора для ребёнка --><select onmouseout=\"hideddrivetip();\" onmouseover=\"ddrivetip('<span class=title>выберите пожалуйста тип документа</span>');\" id=select_c_"+divIdName+" name=select_c_"+divIdName+" class=select_select_c onChange=\"makeselected(this)\"><option value=BC_"+divIdName+">Св. о рождении РФ</option><option value=passportFRN_"+divIdName+">Загранпаспорт РФ</option><option value=FRNdoc_"+divIdName+">Иностр.документ</option></select></div></td><td><div id=passportRF"+divIdName+" class=div_passportRF><!-- паспорта серия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию паспорта</span><br />пример:<br /><b>0123</b>');\" type=text id=text_passportRFs"+divIdName+" name=text_passportRFs"+divIdName+" class=input_passportRFs maxlength=4 onkeyup=\"num_only('text_passportRFs"+divIdName+"');\"><!-- паспорта номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите номер паспорта</span><br />вводятся последние шесть цифр<br /><img src=./images/demo_RF.jpg>');\" type=text id=text_passportRF"+divIdName+" name=text_passportRF"+divIdName+" class=input_passportRF onkeyup=\"num_only('text_passportRF"+divIdName+"');\"></div><div id=ID"+divIdName+" class=div_ID><!-- удостоверения номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите номер удостоверения</span><br />пример:<br /><b>123456</b>');\" type=text id=text_ID"+divIdName+" name=text_ID"+divIdName+" class=input_ID></div><div id=BC"+divIdName+" class=div_BC><!-- свидетельства серия --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер свидетельства.</span><br />В серии от 1 до 6 римских цифр (вводятся заглавными латинскими буквами),<br /> далее две кириллические буквы.<br /><img src=./images/demo_BC.jpg>');\" type=text id=text_BC"+divIdName+" name=text_BC"+divIdName+" class=input_BC><!-- свидетельства год рождения --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите год рождения</span><br />пример:<br /><b>2001</b>');\" type=text id=text_BCy"+divIdName+" name=text_BCy"+divIdName+" class=input_BCy size=5 onkeyup=\"num_only('text_BCy"+divIdName+"');\"></div><div id=passportFRN"+divIdName+" class=div_passportFRN><!-- загран паспорта серия и номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер загранпаспорта</span><br /> без знака №, всего 9 цифр<br /><img src=./images/demo_RFFrn.jpg>');\" type=text id=text_passportFRN"+divIdName+" name=text_passportFRN"+divIdName+" class=input_passportFRN onkeyup=\"translit2en('first_"+divIdName+"'); translit2en('second_"+divIdName+"'); translit2en('third_"+divIdName+"'); num_only('text_passportFRN"+divIdName+"'); num_only('text_passportFRNy"+divIdName+"');\"><!-- загран паспорта срок годности --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите пожалуйста срок годности документа</span><br />пример:<br /><b>2001</b>');\" type=text id=text_passportFRNy"+divIdName+" name=text_passportFRNy"+divIdName+" class=input_passportFRNy size=5></div><div id=FRNdoc"+divIdName+" class=div_FRNdoc><!-- иностренного документа серия и номер --><input type=text id=text_FRNdoc"+divIdName+" name=text_FRNdoc"+divIdName+" class=input_FRNdoc></div><div id=passportSEAMAN"+divIdName+" class=div_passportSEAMAN><!--<input type=text id=text_passportSEAMANs"+divIdName+" name=text_passportSEAMANs"+divIdName+" class=input_passportSEAMAN size=5>--><!-- паспорта моряка номер --><input onmouseout=\"hideddrivetip();\"  onmouseover=\"ddrivetip('<span class=title>введите серию и номер паспорта моряка</span><br /><img src=./images/passportSEAMAN.jpg>');\" type=text id=text_passportSEAMAN"+divIdName+" name=text_passportSEAMAN"+divIdName+" class=input_passportSEAMAN></div></td><td><a href=\"javascript:;\" onclick=\"removeElement('"+divIdName+"')\" onmouseout=\"roll_over('pict_r_"+divIdName+"', 'X.gif')\" onmouseover=\"roll_over('pict_r_"+divIdName+"', 'X_hove.gif')\" ><img id=pict_r_"+divIdName+" src=http://train.vnukovo-bilet.ru/images/X.gif width=25 height=25 border=0></a></td></tr></table>";
    ni.appendChild(newdiv);
    document.getElementById('passportRF'+divIdName).style.display="block";
    document.getElementById('ID'+divIdName).style.display="none";
    document.getElementById('BC'+divIdName).style.display="none";
    document.getElementById('passportFRN'+divIdName).style.display="none";
    document.getElementById('FRNdoc'+divIdName).style.display="none";
    document.getElementById('passportSEAMAN'+divIdName).style.display="none";
    document.getElementById('doc_type_c_'+divIdName).style.display="none";
    document.getElementById('age_type_c_'+divIdName).style.display="none";
    document.getElementById('peoples_num').value=document.getElementById('peoples_num').value + divIdName + ',';
    switching_passenger_type(divIdName);
    passengers_count++;
}

function removeElement(divNum){
  var d = document.getElementById('myDiv');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
  passengers_count--;
  document.getElementById('peoples_num').value=document.getElementById('peoples_num').value.replace(divNum + ',', '');
}

function switching_passenger_type(selectobj){
    var p_type = document.getElementById('ptype_'+selectobj).value;
    if(p_type == 'o'){
        document.getElementById('select_c_'+selectobj).selectedIndex = 0;
        document.getElementById('doc_type_c_'+selectobj).style.display="block";
        document.getElementById('age_type_c_'+selectobj).style.display="block";
        document.getElementById('doc_type_o_'+selectobj).style.display="none";
        document.getElementById('age_type_o_'+selectobj).style.display="none";
    document.getElementById('passportRF'+selectobj).style.display="none";
    document.getElementById('ID'+selectobj).style.display="none";
    document.getElementById('BC'+selectobj).style.display="block";
    document.getElementById('passportFRN'+selectobj).style.display="none";
    document.getElementById('FRNdoc'+selectobj).style.display="none";
    document.getElementById('passportSEAMAN'+selectobj).style.display="none";
        document.getElementById('ptype_'+selectobj).value = 'c';
/*
        document.getElementById('pict_p_'+selectobj).src = 'http://train.vnukovo-bilet.ru/images/checkbox_checked.gif';
*/
    }else{
        document.getElementById('select_o_'+selectobj).selectedIndex = 0;
        document.getElementById('doc_type_c_'+selectobj).style.display="none";
        document.getElementById('age_type_c_'+selectobj).style.display="none";
        document.getElementById('doc_type_o_'+selectobj).style.display="block";
        document.getElementById('age_type_o_'+selectobj).style.display="block";
    document.getElementById('passportRF'+selectobj).style.display="block";
    document.getElementById('ID'+selectobj).style.display="none";
    document.getElementById('BC'+selectobj).style.display="none";
    document.getElementById('passportFRN'+selectobj).style.display="none";
    document.getElementById('FRNdoc'+selectobj).style.display="none";
    document.getElementById('passportSEAMAN'+selectobj).style.display="none";
        document.getElementById('ptype_'+selectobj).value = 'o';
/*
        document.getElementById('pict_p_'+selectobj).src = 'http://train.vnukovo-bilet.ru/images/checkbox.gif';
*/
    }
}

function roll_over(selectobj, picture){
    document.getElementById(selectobj).src = 'http://train.vnukovo-bilet.ru/images/' + picture;
}

function make_check(){
    var data = document.getElementById('peoples_num').value.replace('c', '').split(',');
    if(data.length == 1){
        alert('введите хотя бы одного пассажира');
        return false;
    }
    for(var key in data){
        if((data[key ]).length > 0){
            document.getElementById('first_'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('second_'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('third_'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_passportRF'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_passportRFs'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_ID'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_BC'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_BCy'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_passportFRN'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_passportFRNy'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_FRNdoc'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_passportSEAMAN'+data[key ]).style.borderColor="#DCDCDC";
            document.getElementById('text_FRNdoc'+data[key ]).style.borderColor="#DCDCDC";

            if(check_first(document.getElementById('first_'+data[key ]).value) == 'error'){
                document.getElementById('first_'+data[key ]).style.borderColor="red";
                return false;
            }
            if(check_second(document.getElementById('second_'+data[key ]).value) == 'error'){
                document.getElementById('second_'+data[key ]).style.borderColor="red";
                return false;
            }
            if(check_third(document.getElementById('third_'+data[key ]).value) == 'error'){
                document.getElementById('third_'+data[key ]).style.borderColor="red";
                return false;
            }
            if(document.getElementById('ptype_'+data[key ]).value == 'o'){
                var temp = document.getElementById('select_o_'+data[key ]).value.split('_');
                if(temp[0] == 'passportRF'){
                    if(check_passportRF(document.getElementById('text_passportRF'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportRF'+temp[1]).style.borderColor="red";
/*
                        document.getElementById('text_passportRFs'+temp[1]).style.borderWidth="3px 5px";
*/
                        return false;
                    };
                    if(check_passportRFs(document.getElementById('text_passportRFs'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportRFs'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'ID'){
                    if(check_ID(document.getElementById('text_ID'+temp[1]).value) == 'error'){
                        document.getElementById('text_ID'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'BC'){
                    if(check_BC(document.getElementById('text_BC'+temp[1]).value) == 'error'){
                        document.getElementById('text_BC'+temp[1]).style.borderColor="red";
                        return false;
                    };
                    if(check_BCy(document.getElementById('text_BCy'+temp[1]).value) == 'error'){
                        document.getElementById('text_BCy'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'passportFRN'){
                    if(check_passportFRN(document.getElementById('text_passportFRN'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportFRN'+temp[1]).style.borderColor="red";
                        return false;
                    };
                    if(check_passportFRNy(document.getElementById('text_passportFRNy'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportFRNy'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'FRNdoc'){
                    if(check_FRNdoc(document.getElementById('text_FRNdoc'+temp[1]).value) == 'error'){
                        document.getElementById('text_FRNdoc'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'passportSEAMAN'){
                    if(check_passportSEAMAN(document.getElementById('text_passportSEAMAN'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportSEAMAN'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }
            }else{
                var temp = document.getElementById('select_c_'+data[key ]).value.split('_');
/*
                alert('проверяем ребёнка');
*/
                if(temp[0] == 'BC'){
                    if(check_BC(document.getElementById('text_BC'+temp[1]).value) == 'error'){
                        document.getElementById('text_BC'+temp[1]).style.borderColor="red";
                        return false;
                    };
                    if(check_BCy(document.getElementById('text_BCy'+temp[1]).value) == 'error'){
                        document.getElementById('text_BCy'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'passportFRN'){
                    if(check_passportFRN(document.getElementById('text_passportFRN'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportFRN'+temp[1]).style.borderColor="red";
                        return false;
                    };
                    if(check_passportFRNy(document.getElementById('text_passportFRNy'+temp[1]).value) == 'error'){
                        document.getElementById('text_passportFRNy'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }else if(temp[0] == 'FRNdoc'){
                    if(check_FRNdoc(document.getElementById('text_FRNdoc'+temp[1]).value) == 'error'){
                        document.getElementById('text_FRNdoc'+temp[1]).style.borderColor="red";
                        return false;
                    };
                }
            }
        }
    }
}

function check_first(check){
    if(check.length < 3){
        alert('фамилия содержит слишком мало букв');
        return 'error';
    }else{
        if(check == 'введите фамилию'){
            alert('введите фамилию');
            return 'error';
        }
    }
}

function check_second(check){
    if(check.length < 3){
        alert('имя содержит слишком мало букв');
        die();
    }else{
        if(check == 'введите имя'){
            alert('введите имя');
            return 'error';
        }
    }
}

function check_third(check){
    if(check.length < 3){
        alert('отчество содержит слишком мало букв');
        return 'error';
    }else{
        if(check == 'введите отчество'){
            alert('введите отчество');
            return 'error';
        }
    }
}

function check_passportRF(check){
    if(check.length != 6){
        alert('проверьте данные паспорта');
        return 'error';
    }else{
        if(check == 'введите номер паспорта'){
            alert('проверьте номер паспорта');
            return 'error';
        }
    }
}

function check_passportRFs(check){
    if(check.length != 4){
        alert('серия паспорта должна содержать 4 цифры');
        return 'error';
    }else{
        if(check == 'введите серию паспорта'){
            alert('проверьте серию паспорта');
            return 'error';
        }
    }
}

function check_ID(check){
    if(check.length < 5){
        alert('этот номер не похож на номер удостоверения!');
        return 'error';
    }else{
        if(check == 'введите серию'){
            alert('проверьте серию удостоверения...');
            return 'error';
        }
    }
}

function check_BC(check){
    if(check.length < 3){
        alert('введённая серия не похожа на настоящую!');
        return 'error';
    }else{
        if(check == 'введите серию'){
            alert('введите серию свидетельства о рождении');
            return 'error';
        }
    }
}

function check_BCy(check){
    if(check.length != 4){
        alert('не верный формат даты рождения пассажира!');
        return 'error';
    }else{
        if(check == 'введите д.р.'){
            alert('введена не корректная дата рождения');
            return 'error';
        }
    }
}

function check_passportFRN(check){
    if(check.length < 5){
        alert('проверьте данные серии загран паспорта');
        return 'error';
    }else{
        if(check == 'введите серию'){
            alert('вы не ввели серию загран паспорта');
            return 'error';
        }
    }
}

function check_passportFRNy(check){
    if(check.length < 3){
        alert('проверьте срок действия загран паспорта');
        return 'error';
    }else{
        if(check == 'введите дату'){
            alert('вы не ввели срок действия загран паспорта');
            return 'error';
        }
    }
}

function check_FRNdoc(check){
    if(check.length < 3){
        alert('не верный номер документа');
        return 'error';
    }else{
        if(check == 'введите серию'){
            alert('проверьте серию иностранного документа');
            return 'error';
        }
    }
}

function check_passportSEAMAN(check){
    if(check.length < 3){
        alert('проверьте сирию в паспорте моряка');
        return 'error';
    }else{
        if(check == 'введите серию'){
            alert('введите серию паспорта моряка');
            return 'error';
        }
    }
}

function die(){
    exit;
}

function translit2en(selectobj){
    el = document.getElementById(selectobj);
    A = new Array();
    A["Ё"]="YO";A["Й"]="I";A["Ц"]="TS";A["У"]="U";A["К"]="K";A["Е"]="E";A["Н"]="N";A["Г"]="G";A["Ш"]="SH";A["Щ"]="SCH";A["З"]="Z";A["Х"]="H";A["Ъ"]="'";
    A["ё"]="yo";A["й"]="i";A["ц"]="ts";A["у"]="u";A["к"]="k";A["е"]="e";A["н"]="n";A["г"]="g";A["ш"]="sh";A["щ"]="sch";A["з"]="z";A["х"]="h";A["ъ"]="'";
    A["Ф"]="F";A["Ы"]="I";A["В"]="V";A["А"]="A";A["П"]="P";A["Р"]="R";A["О"]="O";A["Л"]="L";A["Д"]="D";A["Ж"]="ZH";A["Э"]="E";
    A["ф"]="f";A["ы"]="i";A["в"]="v";A["а"]="a";A["п"]="p";A["р"]="r";A["о"]="o";A["л"]="l";A["д"]="d";A["ж"]="zh";A["э"]="e";
    A["Я"]="YA";A["Ч"]="CH";A["С"]="S";A["М"]="M";A["И"]="I";A["Т"]="T";A["Ь"]="'";A["Б"]="B";A["Ю"]="YU";
    A["я"]="ya";A["ч"]="ch";A["с"]="s";A["м"]="m";A["и"]="i";A["т"]="t";A["ь"]="'";A["б"]="b";A["ю"]="yu";
    document.getElementById(selectobj).value = el.value.replace(/([\u0410-\u0451])/g,
        function (str,p1,offset,s){
            if (A[str] != 'undefined'){return A[str];}
        }
    );
}

function translit2ru(selectobj){
    el = document.getElementById(selectobj);
    A = new Array();
    A["Ё"]="YO";A["Й"]="I";A["Ц"]="TS";A["У"]="U";A["К"]="K";A["Е"]="E";A["Н"]="N";A["Г"]="G";A["Ш"]="SH";A["Щ"]="SCH";A["З"]="Z";A["Х"]="H";A["Ъ"]="'";
    A["ё"]="yo";A["й"]="i";A["ц"]="ts";A["у"]="u";A["к"]="k";A["е"]="e";A["н"]="n";A["г"]="g";A["ш"]="sh";A["щ"]="sch";A["з"]="z";A["х"]="h";A["ъ"]="'";
    A["Ф"]="F";A["Ы"]="I";A["В"]="V";A["А"]="A";A["П"]="P";A["Р"]="R";A["О"]="O";A["Л"]="L";A["Д"]="D";A["Ж"]="ZH";A["Э"]="E";
    A["ф"]="f";A["ы"]="i";A["в"]="v";A["а"]="a";A["п"]="p";A["р"]="r";A["о"]="o";A["л"]="l";A["д"]="d";A["ж"]="zh";A["э"]="e";
    A["Я"]="YA";A["Ч"]="CH";A["С"]="S";A["М"]="M";A["И"]="I";A["Т"]="T";A["Ь"]="'";A["Б"]="B";A["Ю"]="YU";
    A["я"]="ya";A["ч"]="ch";A["с"]="s";A["м"]="m";A["и"]="i";A["т"]="t";A["ь"]="'";A["б"]="b";A["ю"]="yu";
    document.getElementById(selectobj).value = el.value.replace(/([\u0410-\u0451])/g,
        function (str,p1,offset,s){
            if (A[str] != 'undefined'){return A[str];}
        }
    );
}

function str_split(string, split_length){
    if (string === undefined || !string.toString || split_length < 1) {
        return false;
    }
    return string.toString().match(new RegExp('.{1,' + (split_length || '1') + '}', 'g'));
}

function num_only(selectobj){
    var temp = document.getElementById(selectobj).value;
    var abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя!@#$%^&*()-={}[]<>?~`:" \|/';
    var data = str_split(abc, 1);
    for(var key in data){
        temp = temp.replace(data[key], '');
    }
    document.getElementById(selectobj).value = temp;
}

function printpage(){
    window.print();
}

function change_t_type_p(){
    t_type = 1;
    document.pict_p.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
    document.pict_e.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
    document.getElementById("tt").value = 1;
}

function change_t_type_e(){
    t_type = 2;
    document.pict_p.src = 'http://biletix.ru/zhdbooking_templ/select_type_off.gif';
    document.pict_e.src = 'http://biletix.ru/zhdbooking_templ/select_type_on.gif';
    document.getElementById("tt").value = 2;
}

if (typeof dd_domreadycheck=="undefined") //global variable to detect if DOM is ready
    var dd_domreadycheck=false

var ddlevelsmenu={

enableshim: true, //enable IFRAME shim to prevent drop down menus from being hidden below SELECT or FLASH elements? (tip: disable if not in use, for efficiency)

arrowpointers:{
    downarrow: ["ddlevelsfiles/arrow-down.gif", 11,7], //[path_to_down_arrow, arrowwidth, arrowheight]
    rightarrow: ["ddlevelsfiles/arrow-right.gif", 12,12], //[path_to_right_arrow, arrowwidth, arrowheight]
    showarrow: {toplevel: false, sublevel: false} //Show arrow images on top level items and sub level items, respectively?
},
hideinterval: 200, //delay in milliseconds before entire menu disappears onmouseout.
effects: {enableswipe: true, enablefade: true, duration: 200},
httpsiframesrc: "blank.htm", //If menu is run on a secure (https) page, the IFRAME shim feature used by the script should point to an *blank* page *within* the secure area to prevent an IE security prompt. Specify full URL to that page on your server (leave as is if not applicable).

///No need to edit beyond here////////////////////

topmenuids: [], //array containing ids of all the primary menus on the page
topitems: {}, //object array containing all top menu item links
subuls: {}, //object array containing all ULs
lastactivesubul: {}, //object object containing info for last mouse out menu item's UL
topitemsindex: -1,
ulindex: -1,
hidetimers: {}, //object array timer
shimadded: false,
nonFF: !/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent), //detect non FF browsers
getoffset:function(what, offsettype){
    return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
},

getoffsetof:function(el){
    el._offsets={left:this.getoffset(el, "offsetLeft"), top:this.getoffset(el, "offsetTop")}
},

getwindowsize:function(){
    this.docwidth=window.innerWidth? window.innerWidth-10 : this.standardbody.clientWidth-10
    this.docheight=window.innerHeight? window.innerHeight-15 : this.standardbody.clientHeight-18
},

gettopitemsdimensions:function(){
    for (var m=0; m<this.topmenuids.length; m++){
        var topmenuid=this.topmenuids[m]
        for (var i=0; i<this.topitems[topmenuid].length; i++){
            var header=this.topitems[topmenuid][i]
            var submenu=document.getElementById(header.getAttribute('rel'))
            header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight}
        }
    }
},

isContained:function(m, e){
    var e=window.event || e
    var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
    while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
    if (c==m)
        return true
    else
        return false
},

addpointer:function(target, imgclass, imginfo, BeforeorAfter){
    var pointer=document.createElement("img")
    pointer.src=imginfo[0]
    pointer.style.width=imginfo[1]+"px"
    pointer.style.height=imginfo[2]+"px"
    if(imgclass=="rightarrowpointer"){
        pointer.style.left=target.offsetWidth-imginfo[2]-2+"px"
    }
    pointer.className=imgclass
    var target_firstEl=target.childNodes[target.firstChild.nodeType!=1? 1 : 0] //see if the first child element within A is a SPAN (found in sliding doors technique)
    if (target_firstEl && target_firstEl.tagName=="SPAN"){
        target=target_firstEl //arrow should be added inside this SPAN instead if found
    }
    if (BeforeorAfter=="before")
        target.insertBefore(pointer, target.firstChild)
    else
        target.appendChild(pointer)
},

css:function(el, targetclass, action){
    var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
    if (action=="check")
        return needle.test(el.className)
    else if (action=="remove")
        el.className=el.className.replace(needle, "")
    else if (action=="add" && !needle.test(el.className))
        el.className+=" "+targetclass
},

addshimmy:function(target){
    var shim=(!window.opera)? document.createElement("iframe") : document.createElement("div") //Opera 9.24 doesnt seem to support transparent IFRAMEs
    shim.className="ddiframeshim"
    shim.setAttribute("src", location.protocol=="https:"? this.httpsiframesrc : "about:blank")
    shim.setAttribute("frameborder", "0")
    target.appendChild(shim)
    try{
        shim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
    }
    catch(e){}
    return shim
},

positionshim:function(header, submenu, dir, scrollX, scrollY){
    if (header._istoplevel){
        var scrollY=window.pageYOffset? window.pageYOffset : this.standardbody.scrollTop
        var topgap=header._offsets.top-scrollY
        var bottomgap=scrollY+this.docheight-header._offsets.top-header._dimensions.h
        if (topgap>0){
            this.shimmy.topshim.style.left=scrollX+"px"
            this.shimmy.topshim.style.top=scrollY+"px"
            this.shimmy.topshim.style.width="99%"
            this.shimmy.topshim.style.height=topgap+"px" //distance from top window edge to top of menu item
        }
        if (bottomgap>0){
            this.shimmy.bottomshim.style.left=scrollX+"px"
            this.shimmy.bottomshim.style.top=header._offsets.top + header._dimensions.h +"px"
            this.shimmy.bottomshim.style.width="99%"
            this.shimmy.bottomshim.style.height=bottomgap+"px" //distance from bottom of menu item to bottom window edge
        }
    }
},

hideshim:function(){
    this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0
    this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0
},


buildmenu:function(mainmenuid, header, submenu, submenupos, istoplevel, dir){
    header._master=mainmenuid //Indicate which top menu this header is associated with
    header._pos=submenupos //Indicate pos of sub menu this header is associated with
    header._istoplevel=istoplevel
    if (istoplevel){
        this.addEvent(header, function(e){
        ddlevelsmenu.hidemenu(ddlevelsmenu.subuls[this._master][parseInt(this._pos)])
        }, "click")
    }
    this.subuls[mainmenuid][submenupos]=submenu
    header._dimensions={w:header.offsetWidth, h:header.offsetHeight, submenuw:submenu.offsetWidth, submenuh:submenu.offsetHeight}
    this.getoffsetof(header)
    submenu.style.left=0
    submenu.style.top=0
    submenu.style.visibility="hidden"
    this.addEvent(header, function(e){ //mouseover event
        if (!ddlevelsmenu.isContained(this, e)){
            var submenu=ddlevelsmenu.subuls[this._master][parseInt(this._pos)]
            if (this._istoplevel){
                ddlevelsmenu.css(this, "selected", "add")
            clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos])
            }
            ddlevelsmenu.getoffsetof(header)
            var scrollX=window.pageXOffset? window.pageXOffset : ddlevelsmenu.standardbody.scrollLeft
            var scrollY=window.pageYOffset? window.pageYOffset : ddlevelsmenu.standardbody.scrollTop
            var submenurightedge=this._offsets.left + this._dimensions.submenuw + (this._istoplevel && dir=="topbar"? 0 : this._dimensions.w)
            var submenubottomedge=this._offsets.top + this._dimensions.submenuh
            //Sub menu starting left position
            var menuleft=(this._istoplevel? this._offsets.left + (dir=="sidebar"? this._dimensions.w : 0) : this._dimensions.w)
            if (submenurightedge-scrollX>ddlevelsmenu.docwidth){
                menuleft+= -this._dimensions.submenuw + (this._istoplevel && dir=="topbar" ? this._dimensions.w : -this._dimensions.w)
            }
            submenu.style.left=menuleft+"px"
            //Sub menu starting top position
            var menutop=(this._istoplevel? this._offsets.top + (dir=="sidebar"? 0 : this._dimensions.h) : this.offsetTop)
            if (submenubottomedge-scrollY>ddlevelsmenu.docheight){ //no room downwards?
                if (this._dimensions.submenuh<this._offsets.top+(dir=="sidebar"? this._dimensions.h : 0)-scrollY){ //move up?
                    menutop+= - this._dimensions.submenuh + (this._istoplevel && dir=="topbar"? -this._dimensions.h : this._dimensions.h)
                }
                else{ //top of window edge
                    menutop+= -(this._offsets.top-scrollY) + (this._istoplevel && dir=="topbar"? -this._dimensions.h : 0)
                }
            }
            submenu.style.top=menutop+"px"
            if (ddlevelsmenu.enableshim && (ddlevelsmenu.effects.enableswipe==false || ddlevelsmenu.nonFF)){ //apply shim immediately only if animation is turned off, or if on, in non FF2.x browsers
                ddlevelsmenu.positionshim(header, submenu, dir, scrollX, scrollY)
            }
            else{
                submenu.FFscrollInfo={x:scrollX, y:scrollY}
            }
            ddlevelsmenu.showmenu(header, submenu, dir)
        }
    }, "mouseover")
    this.addEvent(header, function(e){ //mouseout event
        var submenu=ddlevelsmenu.subuls[this._master][parseInt(this._pos)]
        if (this._istoplevel){
            if (!ddlevelsmenu.isContained(this, e) && !ddlevelsmenu.isContained(submenu, e)) //hide drop down ul if mouse moves out of menu bar item but not into drop down ul itself
                ddlevelsmenu.hidemenu(submenu)
        }
        else if (!this._istoplevel && !ddlevelsmenu.isContained(this, e)){
            ddlevelsmenu.hidemenu(submenu)
        }

    }, "mouseout")
},

setopacity:function(el, value){
    el.style.opacity=value
    if (typeof el.style.opacity!="string"){ //if it's not a string (ie: number instead), it means property not supported
        el.style.MozOpacity=value
        if (el.filters){
            el.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+ value*100 +")"
        }
    }
},

showmenu:function(header, submenu, dir){
    if (this.effects.enableswipe || this.effects.enablefade){
        if (this.effects.enableswipe){
            var endpoint=(header._istoplevel && dir=="topbar")? header._dimensions.submenuh : header._dimensions.submenuw
            submenu.style.width=submenu.style.height=0
            submenu.style.overflow="hidden"
        }
        if (this.effects.enablefade){
            this.setopacity(submenu, 0) //set opacity to 0 so menu appears hidden initially
        }
        submenu._curanimatedegree=0
        submenu.style.visibility="visible"
        clearInterval(submenu._animatetimer)
        submenu._starttime=new Date().getTime() //get time just before animation is run
        submenu._animatetimer=setInterval(function(){ddlevelsmenu.revealmenu(header, submenu, endpoint, dir)}, 10)
    }
    else{
        submenu.style.visibility="visible"
    }
},

revealmenu:function(header, submenu, endpoint, dir){
    var elapsed=new Date().getTime()-submenu._starttime //get time animation has run
    if (elapsed<this.effects.duration){
        if (this.effects.enableswipe){
            if (submenu._curanimatedegree==0){ //reset either width or height of sub menu to "auto" when animation begins
                submenu.style[header._istoplevel && dir=="topbar"? "width" : "height"]="auto"
            }
            submenu.style[header._istoplevel && dir=="topbar"? "height" : "width"]=(submenu._curanimatedegree*endpoint)+"px"
        }
        if (this.effects.enablefade){
            this.setopacity(submenu, submenu._curanimatedegree)
        }
    }
    else{
        clearInterval(submenu._animatetimer)
        if (this.effects.enableswipe){
            submenu.style.width="auto"
            submenu.style.height="auto"
            submenu.style.overflow="visible"
        }
        if (this.effects.enablefade){
            this.setopacity(submenu, 1)
            submenu.style.filter=""
        }
        if (this.enableshim && submenu.FFscrollInfo) //if this is FF browser (meaning shim hasn't been applied yet
            this.positionshim(header, submenu, dir, submenu.FFscrollInfo.x, submenu.FFscrollInfo.y)
    }
    submenu._curanimatedegree=(1-Math.cos((elapsed/this.effects.duration)*Math.PI)) / 2
},

hidemenu:function(submenu){
    if (typeof submenu._pos!="undefined"){ //if submenu is outermost UL drop down menu
        this.css(this.topitems[submenu._master][parseInt(submenu._pos)], "selected", "remove")
        if (this.enableshim)
            this.hideshim()
    }
    clearInterval(submenu._animatetimer)
    submenu.style.left=0
    submenu.style.top="-1000px"
    submenu.style.visibility="hidden"
},


addEvent:function(target, functionref, tasktype) {
    if (target.addEventListener)
        target.addEventListener(tasktype, functionref, false);
    else if (target.attachEvent)
        target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},

domready:function(functionref){ //based on code from the jQuery library
    if (dd_domreadycheck){
        functionref()
        return
    }
    // Mozilla, Opera and webkit nightlies currently support this event
    if (document.addEventListener) {
        // Use the handy event callback
        document.addEventListener("DOMContentLoaded", function(){
            document.removeEventListener("DOMContentLoaded", arguments.callee, false )
            functionref();
            dd_domreadycheck=true
        }, false )
    }
    else if (document.attachEvent){
        // If IE and not an iframe
        // continually check to see if the document is ready
        if ( document.documentElement.doScroll && window == window.top) (function(){
            if (dd_domreadycheck){
                functionref()
                return
            }
            try{
                // If IE is used, use the trick by Diego Perini
                // http://javascript.nwbox.com/IEContentLoaded/
                document.documentElement.doScroll("left")
            }catch(error){
                setTimeout( arguments.callee, 0)
                return;
            }
            //and execute any waiting functions
            functionref();
            dd_domreadycheck=true
        })();
    }
    if (document.attachEvent && parent.length>0) //account for page being in IFRAME, in which above doesn't fire in IE
        this.addEvent(window, function(){functionref()}, "load");
},


init:function(mainmenuid, dir){
    this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
    this.topitemsindex=-1
    this.ulindex=-1
    this.topmenuids.push(mainmenuid)
    this.topitems[mainmenuid]=[] //declare array on object
    this.subuls[mainmenuid]=[] //declare array on object
    this.hidetimers[mainmenuid]=[] //declare hide entire menu timer
    if (this.enableshim && !this.shimadded){
        this.shimmy={}
        this.shimmy.topshim=this.addshimmy(document.body) //create top iframe shim obj
        this.shimmy.bottomshim=this.addshimmy(document.body) //create bottom iframe shim obj
        this.shimadded=true
    }
    var menubar=document.getElementById(mainmenuid)
    var alllinks=menubar.getElementsByTagName("a")
    this.getwindowsize()
    for (var i=0; i<alllinks.length; i++){
        if (alllinks[i].getAttribute('rel')){
            this.topitemsindex++
            this.ulindex++
            var menuitem=alllinks[i]
            this.topitems[mainmenuid][this.topitemsindex]=menuitem //store ref to main menu links
            var dropul=document.getElementById(menuitem.getAttribute('rel'))
            document.body.appendChild(dropul) //move main ULs to end of document
            dropul.style.zIndex=2000 //give drop down menus a high z-index
            dropul._master=mainmenuid  //Indicate which main menu this main UL is associated with
            dropul._pos=this.topitemsindex //Indicate which main menu item this main UL is associated with
            this.addEvent(dropul, function(){ddlevelsmenu.hidemenu(this)}, "click")
            var arrowclass=(dir=="sidebar")? "rightarrowpointer" : "downarrowpointer"
            var arrowpointer=(dir=="sidebar")? this.arrowpointers.rightarrow : this.arrowpointers.downarrow
            if (this.arrowpointers.showarrow.toplevel)
                this.addpointer(menuitem, arrowclass, arrowpointer, (dir=="sidebar")? "before" : "after")
            this.buildmenu(mainmenuid, menuitem, dropul, this.ulindex, true, dir) //build top level menu

            dropul.onmouseover=function(){
                clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos])
            }
            this.addEvent(dropul, function(e){ //hide menu if mouse moves out of main UL element into open space
                if (!ddlevelsmenu.isContained(this, e) && !ddlevelsmenu.isContained(ddlevelsmenu.topitems[this._master][parseInt(this._pos)], e)){
                    var dropul=this
                    if (ddlevelsmenu.enableshim)
                        ddlevelsmenu.hideshim()
                    ddlevelsmenu.hidetimers[this._master][this._pos]=setTimeout(function(){
                        ddlevelsmenu.hidemenu(dropul)
                    }, ddlevelsmenu.hideinterval)
                }
            }, "mouseout")
            var subuls=dropul.getElementsByTagName("ul")
            for (var c=0; c<subuls.length; c++){
                this.ulindex++
                var parentli=subuls[c].parentNode
                if (this.arrowpointers.showarrow.sublevel)
                    this.addpointer(parentli.getElementsByTagName("a")[0], "rightarrowpointer", this.arrowpointers.rightarrow, "before")
                this.buildmenu(mainmenuid, parentli, subuls[c], this.ulindex, false, dir) //build sub level menus
            }
        }
    } //end for loop
    this.addEvent(window, function(){ddlevelsmenu.getwindowsize(); ddlevelsmenu.gettopitemsdimensions()}, "resize")
},

setup:function(mainmenuid, dir){
    this.domready(function(){ddlevelsmenu.init(mainmenuid, dir)})
}

}



ddlevelsmenu.setup("ddsidemenubar", "sidebar")

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
page_request.open('GET', url, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}










/**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**/
/*          описание или всплывающая подсказка                */
/**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**/
var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="http://train.biletix.ru/images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

