var 
  an_URL = "/bio/an_app/"
//  an_URL = "http://192.168.5.27/aa/" // URL, откуда скачивается и на который обращается аналитический аплет.

  an_ap_params = "empty" // A list of VidNo, passing to analytic java applet
  cur_vids_count = 0; // A number of vids, selected by query
  cur_layerlist = null // Layers for selected species
  all_layerlist = null // Layers for all species

  refresh_made = 1 		// shows, if user presses Refresh button in browser. 

  resultpath = "" 		// Файл результата
				//			(Then the variable becomes null)


var
  cur_Lang = 'r' // Current interface (r,e)(const)
  cur_SType = 'a' // Current species type (a,p)(const)
  cur_Language = 'r' // Current list language (l,r,e)
  cur_Info = 1 // Current info page (1..5)
  cur_VidNo = 104 // Current species
  cur_Letter = 0 // Current letter 
  cur_QueryVids = null // Current list of vids returned by query if it is null
                  // then no query is defined

  
  b_id = 0 // Browser id (0 - unknown, 1 - Netscape, 2 - IE)
  base_url = '' // base url oth the document, i.e. protocol+host
  
  
  thunker = '/scripts/bio/thunker.exe?target=newbio&' // path to thunk
  map_thunk = '/scripts/bio/thunker.exe'
  map_er = 'newbiomap'
  map_thunker = map_thunk + '?target=' + map_er + '&' // path to map thunk
  query_thunker = '/scripts/bio/thunker.exe?target=newbiosr'
  apr_thunker = '/scripts/ap/thunker.exe?'

  bio_root = null // path to bio root (set from top frame) // Attic ??

// ancillary window pointers
var
  picture_wnd = null // "Big Picture" window
  map_wnd = null // "Big Map" window
  dens_wnd = null // Density codes help wnd
  stats_wnd = null // Stat codes help wnd

var
  map_images = new Array(new Image(), new Image(), new Image())
  map_images[0].src = "image/FullExtentUA.gif"
  map_images[1].src = "image/FullExtent.gif"
  
  lang_images = new Array(new Image(), new Image())
  lang_images[0].src = "image/lang_1.gif"
  lang_images[1].src = "image/lang_2.gif"
  
var
  help_P = null // help on place codes
  help_D = null // --//-- density
  help_I = null // --//-- importance

var
  vid_list_r = null // species list, Russian names
  vid_list_e = null // species list, English names
  vid_list_l = null // species list, Latin names


function LoadPageToMainFrame() {
  if (help_D == null) S='&needhelparray=1'; else S=''
  main.location.replace(thunker+'type='+cur_SType+'&request=show&lang='+
  						cur_Lang+'&language='+cur_Language+'&vid='+cur_VidNo+
						'&info='+cur_Info+'&b_id='+b_id+S)
}

function LoadPageToTopFrame() {
  if (top['vid_list_'+cur_Language] == null) S1='&needvidarray=1'; else S1='';
  if (bio_root == null) S2='&needbioroot=1'; else S2='';
  topframe.location.replace(thunker+'type='+cur_SType+'&request=show&lang='+
			    cur_Lang+'&language='+cur_Language+'&letter='+cur_Letter+
  						     '&info=101'+'&b_id='+b_id+S1+S2)
}

function set_Letter(Letter) {
  cur_Letter = Letter;
  LoadPageToTopFrame()
}

function set_Info(InfoNo) {
  cur_Info = InfoNo
  LoadPageToMainFrame()
}

function set_Language(lang) {
  if (lang == cur_Language) return
  cur_Language = lang
  cur_Letter = 0
  vid_list = null
  if (cur_Info != 1) {
    cur_Info = 1
    left.location.reload()
  }
  LoadPageToTopFrame()
}

function set_VidAbs(VidNo) {
  cur_VidNo = VidNo
  LoadPageToMainFrame()
}

function ShowBigPicture() {
  if ((picture_wnd != null) && (picture_wnd.closed != null) && (!picture_wnd.closed)) 
    picture_wnd.close()

  picture_wnd= window.open(thunker+'type='+cur_SType+'&request=show&lang='+cur_Lang+
				  '&language='+cur_Language+'&info=100&vid='+cur_VidNo,
				  'picture_wnd', 'width=640,height=480,scrollbars=yes,resizable=1', true)
}

function ShowBigMap() {
  if ((map_wnd != null) && (map_wnd.closed != null) && (!map_wnd.closed)) 
    map_wnd.close()
  if (cur_Lang == 'r') s = 'r'; else s = 'e'
  map_wnd=window.open(bioroot+'animals_'+S+'.html', 'map_wnd', 'width=640,height=480,scrollbars=yes,resizable=1', true)
}

function help_on_stats() {
  if ((stats_wnd != null) && (stats_wnd.closed != null) && (!stats_wnd.closed))
    stats_wnd.close();
  stats_wnd=window.open(bio_root+'stats_'+cur_Lang+'.html', 'stats_wnd',
  				        'width=550,height=280,scrollbars=yes', true)
}

function help_on_dens() {
  if ((dens_wnd != null) && (dens_wnd.closed != null) && (!dens_wnd.closed))
    dens_wnd.close()
  dens_wnd=window.open(bio_root+'dens_'+cur_Lang+'.html', 'dens_wnd',
  					   'width=300,height=280,scrollbars=yes', true)
}

function load_help_arrays() {
  
}

S = location.toString()

if (S.indexOf('_r') != -1) cur_Lang = cur_Language = 'r'
		      else cur_Lang = cur_Language = 'e'

id = navigator.appName
if (id == 'Netscape') b_id = 1
if (id == 'Microsoft Internet Explorer') b_id = 2

i = S.indexOf('://')
if (i != -1) {
  i = S.indexOf('/', i+3)
  base_url = S.substring(0, i) 
}
