	function insert_metro_new (text_new) {
		index = document.search_form.metro_new.length;
		document.search_form.metro_new.options[index] = new Option(text_new, text_new); 
	
	}

	function insert()
	{
		var sel_ind = document.search_form.metro_all.options.selectedIndex;
		if ( sel_ind >= 0 )
		{
			all_opt = document.search_form.metro_all.options;
			new_opt = document.search_form.metro_new.options;
			p_id = all_opt[sel_ind].value;
			if ( metro_class[all_opt[sel_ind].value] )
			{
				for(var i in metro_class)
				{
					if ( metro_class[i] == metro_class[p_id] )
					{
						exist = 0;
						new_index = document.search_form.metro_new.length;
						for ( j=0; j<new_index; j++ )
							if ( new_opt[j].value == i ) exist = true;
						if ( !exist ) new_opt[new_index] = new Option(i, i); 
					}
				}
			}
			else
			{
				exist = 0;
				new_index = document.search_form.metro_new.length;
				for ( i=0; i<new_index; i++ )
					if ( new_opt[i].value == p_id ) exist = true;
				if ( !exist ) new_opt[new_index] = new Option(p_id, p_id); 
			}
		}
	}



	function erase () {
		if (document.search_form.metro_new.options.selectedIndex!=-1)document.search_form.metro_new.options[document.search_form.metro_new.options.selectedIndex]=null;
	}
	
	 function clear_all ()
	 {
		var mn
		var n
		n=0
		mn = document.search_form.metro_new.length;
		while (document.search_form.metro_new.options[n] != null)
		{
			document.search_form.metro_new.options[n] = null;
		  	n++;
		 	if (n=mn){n=0;}
		}
		document.search_form.metro_new.selectedIndex = 0;
	 }
	
	function prepare_out() {
		mn = document.search_form.metro_new.length;
		if (mn==0){
			
			document.search_form.metro_new_hid.value ="";
			return true;
		} else {
			document.search_form.metro_new_hid.value ="'";
		
		for ( n=0; n<mn; n++ ) {
			document.search_form.metro_new_hid.value += document.search_form.metro_new.options[n].value + "','";
		}
		if ( document.search_form.metro_new_hid.value != '' ) {
			document.search_form.metro_new_hid.value = document.search_form.metro_new_hid.value.substring(0, document.search_form.metro_new_hid.value.length-2);
		}
		document.search_form.submit();
		}
	}

	function map_pop()
	{
		var w,h;
		w=window.screen.width;
		h=window.screen.height;
		if (h>800)
		{
		 window.open('./metro.html',null,'height=800,width=700,top=0,left=0,resizable=yes,menubar=no,scrollbars=yes,status=no,location=no');
		}
		else
		{
		 window.open('./metro.html',null,'height=680,width=630,top=0,left=0,resizable=no,menubar=no,scrollbars=yes,status=no,location=no');
		}
		return false;
	}

function add_m(){
var a = document.search_form;
 num_s = a.metro_all.options.selectedIndex;
 p_id = a.metro_all.options[num_s].value;
 len_d = a["metro_new"].options.length;
 if (a.metro_all.options.selectedIndex!=-1){
  var set;
  for(i=0; i<len_d; i++){ if(a["metro_new"].options[i].value == a.metro_all.options[num_s].value) set = true; }
  if(!set) a["metro_new"].options[len_d] = new Option(a.metro_all.options[num_s].text, a.metro_all.options[num_s].value);
 }
}


function del_m(){
 var a = document.search_form;
 num = a["metro_new"].options.selectedIndex;
 p_id = a["metro_new"].options[num].value;
 if(num!=-1) a["metro_new"].remove(num);
}


var marked_row = new Array;

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function



function open_details(url){
location.href = url;
}

/// array for station intersect
metro_class = new Array();
metro_class['ÊÐÀÑÍÎÏÐÅÑÍÅÍÑÊÀß'] 	= '1';
metro_class['ÁÀÐÐÈÊÀÄÍÀß'] 			= '1';

metro_class['ÍÎÂÎÑËÎÁÎÄÑÊÀß'] 		= '2';
metro_class['ÌÅÍÄÅËÅÅÂÑÊÀß'] 		= '2';

metro_class['ÊÓÐÑÊÀß'] 				= '3';
metro_class['×ÊÀËÎÂÑÊÀß'] 			= '3';

metro_class['ÒÀÃÀÍÑÊÀß'] 			= '4';
metro_class['ÌÀÐÊÑÈÑÒÑÊÀß'] 		= '4';

metro_class['ÄÎÁÐÛÍÈÍÑÊÀß'] 		= '5';
metro_class['ÑÅÐÏÓÕÎÂÑÊÀß'] 		= '5';

metro_class['ÀÐÁÀÒÑÊÀß'] 			= '6';
metro_class['ÀËÅÊÑÀÍÄÐÎÂÑÊÈÉ ÑÀÄ'] 	= '6';
metro_class['ÁÎÐÎÂÈÖÊÀß'] 			= '6';
metro_class['ÁÈÁËÈÎÒÅÊÀ ÈÌ.ËÅÍÈÍÀ'] = '6';

metro_class['ÒÂÅÐÑÊÀß'] 			= '7';
metro_class['ÏÓØÊÈÍÑÊÀß'] 			= '7';
metro_class['×ÅÕÎÂÑÊÀß'] 			= '7';

metro_class['ËÓÁßÍÊÀ'] 				= '8';
metro_class['ÊÓÇÍÅÖÊÈÉ ÌÎÑÒ'] 		= '8';

metro_class['ÒÓÐÃÅÍÅÂÑÊÀß'] 		= '9';
metro_class['×ÈÑÒÛÅ ÏÐÓÄÛ'] 		= '9';

metro_class['ÒÅÀÒÐÀËÜÍÀß'] 			= '10';
metro_class['ÏËÎÙÀÄÜ ÐÅÂÎËÞÖÈÈ'] 	= '10';
metro_class['ÎÕÎÒÍÛÉ ÐßÄ'] 			= '10';

metro_class['ÒÐÅÒÜßÊÎÂÑÊÀß'] 		= '11';
metro_class['ÍÎÂÎÊÓÇÍÅÖÊÀß'] 		= '11';

metro_class['ÏË.ÈËÜÈ×À'] 			= '12';
metro_class['ÐÈÌÑÊÀß'] 				= '12';

metro_class['ÏÐÎËÅÒÀÐÑÊÀß'] 		= '13';
metro_class['ÊÐÅÑÒÜßÍÑÊÀß ÇÀÑÒÀÂÀ'] = '13';

metro_class['ÊÀÕÎÂÑÊÀß'] 			= '14';
metro_class['ÑÅÂÀÑÒÎÏÎËÜÑÊÀß'] 		= '14';

metro_class['ÁÓËÜÂÀÐ ÄÌ.ÄÎÍÑÊÎÃÎ'] 	= '15';
metro_class['ÓË.ÑÒÀÐÎÊÀ×ÀËÎÂÑÊÀß'] 	= '15';


metro_class_leader = new Array();
for(var i in metro_class)
{
	if (!metro_class_leader[metro_class[i]])
	{
		metro_class_leader[metro_class[i]] = i;
		//alert(metro_class[i] + ' = ' + i);
	}
}


