/*******************************************************
		PROJECT: Catering Capers
		CREATED: 12-13-04
		AUTHOR: Brad Simpson ( me@bradsimpson.com )

*******************************************************/





/*********************************/
//         OPEN WINDOW           //
/*********************************/

function NewWindow(mypage, myname, w, h, scroll, resize, tool, statusBar) {
if(screen.width){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
}else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;	
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize+', toolbar='+tool+', status='+statusBar+''
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// Usage: <a href="#" onclick="NewWindow('page.php','popup','430','280','yes','yes','no', 'no')">






/*********************************/
//          SWAP IMAGES          //
/*********************************/

// INITIALIZE / LOAD IMAGES
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


// SWAP IMAGES
function changeImages() {
	//preloadFlag = true;
	//add this to the following IF statement's condition if you want to make sure the images are preloaded--> && preloadFlag = true;
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
//call with changeImages('nameOfImage', 'image source');








/*********************************/
//       PRELOAD IMAGES          //
/*********************************/

var preloadFlag = false;
function preloadImages() {

	if (document.images) {
		totalImages = preloadImages.arguments.length;
		pic = new Array(totalImages);
		for(var i=0; i<totalImages; i++) {
			pic[i] = newImage(preloadImages.arguments[i]);
		}

		preloadFlag = true;
	}
}

// EXAMPLE:
// <body onload="preloadImages('../m/b-home-over.jpg','../m/b-about-over.jpg')">











/*********************************/
//      TOGGLE VISIBILITY        //
/*********************************/

function toggle( targetId ){
  if (document.getElementById){

  		target = document.getElementById( targetId );

  		if (target.style.display == "none"){
  			target.style.display = "";
		} else {
			target.style.display = "none";
		}
  	}
}













/*********************************/
//    AUTO TAB NUMBER FIELDS     //
/*********************************/

<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://members.xoom.com/cyanide_7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- // IMPLEMENTATION (Phone number example)
/*
	(<input type="text" size="3" maxlength="3" onkeyup="return autoTab( this, 3, event );" />) <input type="text" maxlength="3" size="3" onkeyup="return autoTab( this, 3, event );" />-<input type="text" size="4" maxlength="4"  onkeyup="return autoTab( this, 4, event );" />

*/

<!-- Begin

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
				return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
				else i++;
				return index;
	}

	return true;

}

//  End -->




