/*	Zegelin.com
	Call valid include
	Chris Zegelin, started October 2009

*/

// Javascript function to put focus on a specific input box
var FocusNeeded = true;	// set a global flag
function placeFocus(){
	// Set the focus to the 1st screen field
	if (FocusNeeded){
		document.getElementById( 'txtbox1' ).focus();
	}
}

// Javascript to check the number of characters in a box
// Thanks to http://javascript.internet.com and Kojak
function RemainingChars( fn, rn, mc ){
  var len = fn.value.length;
  if( len > mc ){
    fn.value = fn.value.substring( 0, mc );
    len = mc;
  }
  document.getElementById( rn ).innerHTML = mc - len;
}

// Javascript to change window location from a drop down list
function changeLocation( menuObj ){
   var i = menuObj.selectedIndex;

   if( i > 0 ){
      window.location = menuObj.options[i].value;
   }
}


// Javascript to open a popup window
function openPopup( URL, width, height ){
	// To center popup, we need to get the browser window size
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ){
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ){
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && (document.body.clientWidth || document.body.clientHeight) ){
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	// Next calculate left and top
	left = ( myWidth - width ) / 2;
	top = ( myHeight - height ) / 2;
	
	// Create a unique name for the window
	day = new Date();
	id = day.getTime();
	eval( "page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left = " + left + ",top = " + top + "');" );
}

