//Main Script Functions

function sF(act)
{
  //add the current extents to every request
  var strExtents = "&BOX=" + parent.map.reddimap.MapFrame.cuesta_getExtents();
  act += strExtents;

  if(navigator.appName != "Netscape")
	{document.all("b1").style.cursor = "wait";}
  if((document.Myapp.FrameSupport.value == "on") || (document.Myapp.FrameSupport.value == "ON"))
	{document.Myapp.target='main';}
  else
  	{document.Myapp.target='_self';}
  document.Myapp.action=act;
  document.Myapp.submit();
}

//added by Monica Socol
//March 10, 2004
function submitComm(comm, selDiv, msg, act)
{ // selDiv is the geography selected at step2
  // comm is the community picked from the list
  //msg is the message displayed if the 2 are equal (you can not compare a community with itself)
  
  if (comm.length >0)	
  {
	  if (selDiv == comm)	
	  { alert(msg); }
	  else
	  {  sF(act); }
   }	  
}

function sW(act)
{
  document.Mywelcome.action=act;
  document.Mywelcome.submit();
}


function sFMap(act)
{
  //add the current extents to every request
  var strExtents =  "&BOX=" + parent.map.reddimap.MapFrame.cuesta_getExtents();
  act += strExtents;

  if(navigator.appName != "Netscape")
	{document.all("b2").style.cursor = "wait";}
  if((document.Mymap.MapFrameSupport.value == "on") || (document.Mymap.MapFrameSupport.value == "ON"))
	{document.Mymap.target='map';}
  document.Mymap.action=act;
  document.Mymap.submit();
}


function submitFrame(act)
{
  //add the current extents to every request
  var strExtents =  "&BOX=" + parent.map.reddimap.MapFrame.cuesta_getExtents();
  act += strExtents;

  if((document.Myapp.FrameSupport.value == "on") || (document.Myapp.FrameSupport.value == "ON"))
  	{document.Myapp.target='map';}
  document.Myapp.action=act;
  document.Myapp.submit();
}


function deduceFrameSupport()
{
  if (top != self)
    document.Myapp.FrameSupport.value = "on";
  else
    document.Myapp.FrameSupport.value = "off";	
}


function deduceFrameSupportMap()
{
  if (top != self)
    document.Mymap.MapFrameSupport.value = "on";
  else
    document.Mymap.MapFrameSupport.value = "off";	
}


//Spawns separate pages for each report selected
function submitReports(sURL, noRepAlert)
{
  //var strExtents = "&BOX=" + parent.map.reddimap.MapFrame.cuesta_getExtents();
  var strExtents =   parent.map.reddimap.MapFrame.cuesta_getExtents();
  var checkedItems = 0, alreadySelected = 0, sValue = "", dropValue = "";
  for (var x=0; x < document.Myapp.elements.length; x++)
  {
    if ((document.Myapp.elements[x].type == "select-one") && ((document.Myapp.elements[x-1].type == "checkbox") && (document.Myapp.elements[x-1].checked == true)))
    {
      checkedItems++;
      if(alreadySelected <= checkedItems-1)
      {
	sValue = document.Myapp.elements[x-1].name;
	dropValue = document.Myapp.elements[x].options[document.Myapp.elements[x].selectedIndex].value;
	
	alreadySelected++;
	if(navigator.appName != "Netscape")
	{

	  document.Myreport.target="_blank";
	  document.Myreport.action=sURL;
	  document.Myreport.REP_ID.value=sValue;
	  document.Myreport.REP_FORMAT.value=dropValue;
          document.Myreport.BOX.value=strExtents;
	  //document.Myapp.action=sURL+"&REP_ID="+sValue+"&REP_FORMAT="+dropValue
	  document.Myreport.submit();
	}
	else
	  window.open(sURL+"&REP_ID="+sValue+"&REP_FORMAT="+dropValue+"&BOX="+strExtents, "", "width=650,height=450,outerwidth=700,outerheight=500,resizable,status,scrollbars,menubar");
      }
    }
  }
  if(checkedItems == 0)
	alert(noRepAlert);
}


function Change(MainURL)
{
  parent.main.location=MainURL;
  //	parent.map.location="/MapSection.jsp?lang";
}


//Pops up content specific help page.
function popup(url)
{
  helpWindow = window.open(url, "", "width=486,height=350,left=0,top=0,screenX=0,screenY=0, outerwidth=500,outerheight=375,resizable,status,scrollbars"); 
}

//Pops up Diagram help page.
function popupDiagram(url)
{
  helpWindow = window.open(url, "", "width=950,height=550,left=0,top=0,screenX=0,screenY=0, outerwidth=500,outerheight=375,resizable,status,scrollbars"); 
}

//End Main Script Functions