var _NOSCROLL_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,resizable=no,scrollbars=no,top=100,left=100,screenX=100,screenY=100';
var _SCROLL_POPUP_FEATURES = 'location=0,statusbar=1,menubar=0,resizable=yes,scrollbars=yes,top=100,left=100,screenX=100,screenY=100';

function raw_popup(url, target, can_scroll, w_width, w_height) {
  // define base set depending on whether the window can scroll or not
  var features = _SCROLL_POPUP_FEATURES;
  if (can_scroll==false) features = _NOSCROLL_POPUP_FEATURES;
  // define target attr
  if (typeof(target)=='undefined') target = '_blank';
  // add width and height to features
  if (typeof(w_width)=='undefined') w_width = 400;
  if (typeof(w_height)=='undefined') w_height = 300;
  features += ',width='+w_width+',height='+w_height;
  // call the window
  var theWindow = window.open(url, target, features);
  // setTimeout('theWindow.focus();',250);
  return theWindow;
}

function link_popup(src, can_scroll, w_width, w_height) {
  return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', can_scroll, w_width, w_height);
}
function img_popup(src, can_scroll, w_width, w_height) {
  return raw_popup("image.php?i="+escape(src.getAttribute('href')), src.getAttribute('target') || '_blank', can_scroll, w_width, w_height);
}

function toggleDiv( idName )
{
	var el = document.getElementById(idName);
	if (!el) return false;
	
	// default checking is none since the AUTO value is block.
	if (el.style.display=='none') el.style.display = 'block';
	else el.style.display = 'none';
}

function confirmAction( checkMessage, theURL ) { if (confirm(checkMessage)) window.location = theURL; }

function imposeMaxLength(obj, maxLength) {
	if (obj.value.length>maxLength) obj.value = obj.value.substring(0,maxLength);
}

function switchTo( sectionName )
{
	sections.each( function(thisSection, index) {
    	// alert("examining "+thisSection);
    	if (thisSection != sectionName) {
    		// alert(thisSection+" needs hiding");
    		var sec = $(thisSection);
    		// alert("element reference is "+sec);
    		if (sec) sec.style.display = 'none';
    	}
    } );
    $(sectionName).style.display = 'block';
}