menu_status = new Array();
var last_expanded = '';

function showHide(id) {
	var obj = document.getElementById(id);	
	var status = obj.className;
	
	if (status == 'hide') {
		if (last_expanded != '') {
			var last_obj = document.getElementById(last_expanded);
			last_obj.className = 'hide';
		}
		
		obj.className = 'show';	
		last_expanded = id;
	} else {
		obj.className = 'hide';
	}
} 


// Popout a new window with a image file in it, and size the pop-up to the images true dimensions
function PopupPic(sPicURL) {
	window.open( "pop-to-fit.html?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
} 

// Popout a new window with URL and size params
function launch(URL, width, height){
	var winLeft = (screen.width - width) / 2;
	var winUp = (screen.height - height) / 2;

	newWindow = window.open(URL,"newwindow","width="+width+",height="+height+",top="+winUp+",left="+winLeft+",scrollbars=yes,toolbar=no,menubar=no,status=no,resizable=yes");
	newWindow.focus();
}

function disableRightClick(e) {
  if(!document.rightClickDisabled) // initialize

  {

    if(document.layers) 

    {

      document.captureEvents(Event.MOUSEDOWN);

      document.onmousedown = disableRightClick;

    }

    else document.oncontextmenu = disableRightClick;

    return document.rightClickDisabled = true;

  }

  if(document.layers || (document.getElementById && !document.all))

  {

    if (e.which==2||e.which==3)
    {
      return false;
    }

  }

  else
  {
    return false;
  }
}

disableRightClick();


function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
		/*var pageWidth='100%';
	    var pageHeight='100%'; DOES NOT WORK IN IE6*/
		/*
		var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
		*/
		/* WORKS IN IE 6, but creates scrollbars */
		var pageWidth = (screen.availWidth - 21)+'px';
        var pageHeight = screen.availHeight+'px';				
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}

// Handles all the items needed to show the "Get in touch..." block over the site's content
function triggerGetBailBlock(action) {
	if (action == 'show') { 
		grayOut(true); 	// First gray out the screen			
		showHide('getBailNowForm', 1); // show the hidden layer which contains the content for this section
	} else if (action == 'hide') {	
		showHide('getBailNowForm', 1);	// hide the top "get in touch" layer		
		grayOut(false); 	// remove the grayed out layer		
	}
}

// This method validates a form
function validateBailForm(myform) {
	if (!isFilled(myform.defendents_name)) {	
		alert("Please enter the Defendant's name");
		myform.defendents_name.focus();
		return false;	
	} else if (!isFilled(myform.jail_or_city_defendant_is_in)){
		alert("Please enter the Jail or City the Defendant is in");
		myform.jail_or_city_defendant_is_in.focus();
		return false;
	} else if (!isFilled(myform.applicant_name)){
		alert("Please enter your name");
		myform.applicant_name.focus();
		return false;	
	} else if (!isFilled(myform.city_you_live_in)){
		alert("Please enter the City you live in");
		myform.city_you_live_in.focus();
		return false;	
	} else if (!isFilled(myform.applicant_phone)){
		alert("Please enter your Phone number");
		myform.applicant_phone.focus();
		return false;			
	} else {
	    return true;
	}
}

// This method validates a form
function validateBailFormEspanol(myform) {
	if (!isFilled(myform.defendents_name)) {	
		alert("Entre por favor el nombre de la persona arrestada");
		myform.defendents_name.focus();
		return false;	
	} else if (!isFilled(myform.jail_or_city_defendant_is_in)){
		alert("Entre por favor la carcel o ciudad donde se encuetra la persona");
		myform.jail_or_city_defendant_is_in.focus();
		return false;
	} else if (!isFilled(myform.applicant_name)){
		alert("Entre por favor tu nombre");
		myform.applicant_name.focus();
		return false;	
	} else if (!isFilled(myform.city_you_live_in)){
		alert("Entre por favor la ciudad donde vives");
		myform.city_you_live_in.focus();
		return false;	
	} else if (!isFilled(myform.applicant_phone)){
		alert("Entre por favor tu telefono");
		myform.applicant_phone.focus();
		return false;			
	} else {
	    return true;
	}
}

function isFilled(elm) {
	if (elm.value == "" || elm.value == " " || elm.value == null) 
		return false;
	else 
		return true;
}