<!--

function openWin(name)
{
    document.geographic.north.value = ""; // clear north so that search on x/y only runs if bbbox is current select
    var where = name.options[name.selectedIndex].value;
    var dest = eval("document.geographic");

	// Ajay's code to open window in center of screen. 
	var w = 300;
	var w2 = 500;
	var h = 480;
	var winl = (screen.width - w) / 2;
	var winl2 = (screen.width - w2) / 2;
    var wint = (screen.height - h) / 2;

	if (where == 'lga')  
    {
        childWin=open("lga_nsw_popup.html", "ChildWin", "width=300,height=480,left="+winl+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        document.geographic.north.value = "0";
        childWin.focus();
    }

	if (where == 'cma')  
    {
        childWin=open("cma_nsw_popup.html", "ChildWin", "width=300,height=480,left="+winl+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        document.geographic.north.value = "0";
        childWin.focus();
    }

    if (where == 'map')
    {
        childWin=open("mapsheet_nsw_popup.html", "ChildWin", "width=300,height=480,left="+winl+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        document.geographic.north.value = "0";
        childWin.focus();
    }

    if (where == 'map_nbr')

    {
        childWin=open("mapsheet_nswPopNr.html", "ChildWin", "width=300,height=480,left="+winl+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        document.geographic.north.value = "0";
        childWin.focus();
    }

    if (where == 'reserve')
    {
        childWin=open("reserve_nsw_popup_redu.html", "ChildWin", "width=300,height=480,left="+winl+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        document.geographic.north.value = "0";
        childWin.focus();
    }

    if (where == 'SelectNSW')
    {
        //if (document.geographic.SpeciesName.value != "") {
        if (!document.geographic.rdSpecies[0].checked) {
			with (dest)	{
                //rType.value = "No area select";
                rType.value = "Area";
                receivedText.value = "NSW";
                receivedType.value = "All of";
                west.value = "140.5";
                south.value = "-37.8125";
                east.value = "154";
                north.value = "-27.6875";
                area.options[0].selected = true; 
                area.blur();
            }
        }

        else {
            //alert ("This option is only available when a single species is chosen in the 'Choose species' section");
			alert ("This option is not available when 'All species' is chosen in the 'Choose species' section");
            document.geographic.area.options[0].selected = true; 
        }
    }

    if (where == 'locator1') {
        childWin=open("locator1_popup.jsp", "ChildWin", "width=500,height=480,left="+winl2+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        childWin.focus();
    }

    if (where == 'locator2') {
        childWin=open("locator2_popup.jsp", "ChildWin", "width=500 ,height=480,left="+winl2+",top="+wint+",resizable=yes");
        document.geographic.area.options[0].selected = true; 
        childWin.focus();
    }

    if (where == 'locatorApplet'){

        w = 420;
        h = 600;

        //var availableWidth = window.screen.availWidth;
        //var availableHeight = window.screen.availHeight;

        //if ( availableWidth - w < w) { w = availableWidth - w; }
        //if ( availableHeight -h < h) { h = availableHeight - h; }
	
	winl = (screen.width - w) / 2;
	wint = (screen.height - h) / 2;
	winl = 0;
	wint = 0;

	childWin=open('interface.jsp', 'ChildWin', 'width='+w+',height='+h+',left='+winl+',top='+wint+',scrollbars=yes,status=yes,resizable=yes'); 
        document.geographic.area.options[0].selected = true; 
        childWin.focus();
    }
}


function setExtent(extent)
{
    var coords=extent.split(",");
    window.document.geographic.west.value = coords[0];
    window.document.geographic.south.value = coords[1];
    window.document.geographic.east.value = coords[2];
    window.document.geographic.north.value = coords[3];
    window.document.geographic.receivedType.value = "Self-drawn";
    window.document.geographic.rType.value = "Self-drawn";
    window.document.geographic.receivedText.value = "in NSW";
    window.document.geographic.area.options[0].selected = true; 
    window.document.geographic.area.blur(); 
    window.display(window.document.geographic.rType.value + "&nbsp;-&nbsp;" + window.document.geographic.receivedText.value);	
}

function clear()
{
    var dest = eval("document.geographic");
    with (dest)
    {
            rdSpecies[0].checked = false;
            rdSpecies[1].checked = false;
            rdSpecies[2].checked = false;
            rdSpecies[3].checked = false;
            selFF[0].checked = true;
            selFF[1].checked = false;
            rdRecords[0].checked = true;
            rdRecords[1].checked = false;
            selType.options[0].selected = true;
            SpeciesName.value = "";
            rType.value = "No type specified yet";
            receivedType.value = "";
            receivedValue.value = "";
            receivedText.value = "No area specified yet";
            East.value = '';
            West.value = '';
            North.value = '';
            South.value = '';
            area.options[0].selected = true; 

    }
    setRadioRep('fauna');
    MDiv.style.visibility='visible';
    MMDiv.style.visibility='visible';

}


var floraalert="You cannot select a Class category if doing a flora search. \n Please make another selection."

function FloraAlert()
{
    if (document.geographic.selFF[1].checked == true) 
    {
        // document.geographic.rdSpecies[0].focus(); Did not work iin NS 6
        document.geographic.rdSpecies[2].checked = false;
        alert(floraalert); 
    }
}


// sets species dropdown and radio to not selected

function setRadioRep(name)	{
	
    if (name == 'flora')
    {
        document.geographic.selType.options[0].selected = true;
        document.geographic.rdSpecies[2].checked = false;
        document.geographic.SpeciesName.value = "";
        if (navigator.appName != "Netscape")
        {
            MDiv.style.visibility='hidden';
            MMDiv.style.visibility='hidden';
        }
        if (navigator.appName == "Netscape")
        {
            document.geographic.selType.options.length = 1;
            document.geographic.selType.options[0].text='No Class Available';
            document.geographic.selType.options[0].selected = true;
        }
    }

    if (name == 'fauna') {
        document.geographic.SpeciesName.value = "";

        if (navigator.appName != "Netscape") 	{
            MDiv.style.visibility='visible';
            MMDiv.style.visibility='visible';
        }

        if (navigator.appName == "Netscape") {			
            var dest = eval("document.geographic");
            with (dest) {
                selType.options.length = 9;
                selType.options[0].text='-- Select a Class --';
                selType.options[1].text='Amphibians';
                selType.options[2].text='Birds';
                selType.options[3].text='Fish';
                selType.options[4].text='Insects';
                selType.options[5].text='Mammals';
                selType.options[6].text='Reptiles';
                selType.options[7].text='Snails';
                selType.options[8].text='Spiders';
                selType.options[0].value='';
                selType.options[1].value='Amphibia';
                selType.options[2].value='Aves';
                selType.options[3].value='Actinopterygii';
                selType.options[4].value='Insecta';
                selType.options[5].value='Mammalia';
                selType.options[6].value='Reptilia';
                selType.options[7].value='Gastropoda';
                selType.options[8].value='Arachnida';
                selType.options[0].selected = true;
            }
        }
    }


    if (name == 'allspec')	{
        document.geographic.selType.options[0].selected = true;
        document.geographic.SpeciesName.value = "";

        if (document.geographic.receivedText.value == "NSW") {
            document.geographic.receivedType.value = "";
            document.geographic.rType.value = "";
            document.geographic.receivedText.value = "";
            document.geographic.receivedValue.value = "";
        }
    }

    if (name == 'threatened') {	 	
        document.geographic.selType.options[0].selected = true;
        document.geographic.SpeciesName.value = "";

        if (document.geographic.receivedText.value == "NSW") {
            document.geographic.receivedType.value = "";
            document.geographic.rType.value = "";
            document.geographic.receivedText.value = "";
            document.geographic.receivedValue.value = "";
        }
    }


    if (name == 'class') {

        if	(document.geographic.selFF[1].checked == true)	{
            alert(floraalert);
            document.geographic.rdSpecies[2].checked = false;
            document.geographic.selFF[1].focus(); 
        }

        else {
            document.geographic.SpeciesName.value = "";
            if (document.geographic.receivedText.value == "NSW")
            {
                document.geographic.receivedType.value = "";
                document.geographic.rType.value = "";
                document.geographic.receivedText.value = "";
                document.geographic.receivedValue.value = "";
            }
        }
    }

    if (name == 'selClass') {
        if	(document.geographic.selFF[1].checked == true)	{
            alert(floraalert)
            document.geographic.rdSpecies[2].checked = false;
            document.geographic.selType.options[0].selected = true;
        }

        else {
            document.geographic.rdSpecies[2].checked = true;
            document.geographic.SpeciesName.value = "";
            if (document.geographic.receivedText.value == "NSW") {
                document.geographic.receivedType.value = "";
                document.geographic.rType.value = "";
                document.geographic.receivedText.value = "";
                document.geographic.receivedValue.value = "";
            }
        }
    }

    if (name == 'scientific') {
        document.geographic.selType.options[0].selected = true;
    }

    if (name == 'speciesN')	{
        document.geographic.rdSpecies[3].checked = true;
    }
}
 


function checkURL(species_url) 	{						
    var speciesType = "";
    if (document.geographic.selFF[0].checked == true) { speciesType = 'FA';	}				
    else if (document.geographic.selFF[1].checked == true) { speciesType = 'FL';	}

    document.links[5].href = species_url 
    + "?rdFF="+speciesType+"&taxon=" 
    + document.geographic.SpeciesName.value;				
}


function display (text) {
    // make sure that the displayed value doesn't change if a popup gets closed without a new selection
    if (text == "keep value") {
        if (document.geographic.receivedText.value == "No area specified yet") {
            var val = document.geographic.receivedText.value;
        }
        else {
            var val = document.geographic.rType.value + "&nbsp;-&nbsp;" + document.geographic.receivedText.value;
        }
    }
    else {
        var val = text;
    }

    if (document.layers) {
        if (!document.output.ol) {
            var ol = document.output.ol = new Layer(window.innerWidth);
            ol.left = document.output.pageX;
            ol.top = document.output.pageY;
            ol.visibility = 'show';
            document.output.visibility = 'hide';	  
        }
	
        with (document.output.ol) {
            document.open();
            document.write("<p>"+val+"</p>");
            document.close();
        }
    }
    else if (document.all)
        document.all.output.innerHTML = val;
    else if (document.getElementById)
        document.getElementById('output').innerHTML = val;
	
    document.geographic.area.blur();
}

function NewWindow(mypage, myname, scroll) {
    //w = 920;
    //h = 600;
	w = 768;
	h = 500;

    //availableWidth = window.screen.availWidth;
    //availableHeight = window.screen.availHeight;

    //if ( availableWidth - 120 < w) { w = availableWidth - 120; }
    //if ( availableHeight -200 < h) { h = availableHeight - 200; }

	// Mods by Ajay to open in center of screen
	var left = Math.floor( (screen.width - w) / 2);
	var top = Math.floor( (screen.height - h) / 2);


    // Netscape 4.x seems to require certain order of parameter to work !!	
    winprops = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=yes,height="+ h + ",width=" + w + ",top=0,left=0'"; 
    win = window.open(mypage,myname,winprops);

    if (parseInt(navigator.appVersion) >= 4) { 
            win.window.focus(); 
    }
}