/************************************************************
	The Womens Center Name JavaScript
	Created:				10.20.2005
	Last Modified:	10.20.2005
	Author:					Mariona Jones
************************************************************/

// JAVASCRIPT FUNCTIONS




// Open window script
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')">






// 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 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 -->





/************************************************************
	START target="_blank" replacement script
************************************************************/

//	this function works around the dropping of
//	target="_blank" from XHTML strict

//	the function takes all instances of rel="external" from
//	anchor tags, and causes them to pop a new window

//	in short, use rel="external" instead of target="_blank"
//	to pop a new window :)

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
window.onload = externalLinks;

/************************************************************
	END target="_blank" replacement script
************************************************************/

/************************************************************
	START window launcher code
************************************************************/

var newWin = null; 
function launch_window(strURL, strType, strHeight, strWidth) {

	if (newWin != null && !newWin.closed)
		newWin.close();

	if (screen.width) {
		var win_top = (screen.height - strHeight) / 2;
		var win_left = (screen.width - strWidth) / 2;
	} else {
		win_top = 0;
		win_left = 0;
	}

  if (win_top < 0)
  	win_top = 0;
  if (win_left < 0)
  	win_left = 0;

	var strOptions = "";
	if (strType=="console")
		strOptions = "resizable,height="+strHeight+",width="+strWidth+",top="+win_top+",left="+win_left;
	if (strType=="fixed")
		strOptions = "status,height="+strHeight+",width="+strWidth+",top="+win_top+",left="+win_left;
	if (strType=="elastic")
		strOptions="toolbar,menubar,scrollbars,"+"resizable,location,height="+strHeight+",width="+strWidth+",top="+win_top+",left="+win_left;

	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus(); 
}

//	link example for launch_window
/*
		<a href="page_name.php" onclick="launch_window(this.href,'console',400,200);return false;">linked text</a>
*/

//	include this JavaScript on the launched page(s) to include a close link if needed
/*
		<script language="JavaScript"> 
		<!-- 
		if (window.opener) 
			document.write('<strong><a href="#" onclick="self.close();">' + 'Close this window</a></strong>');
		//--> 
		</script>
*/

/************************************************************
	END window launcher code
************************************************************/


/*********************************/
//        HOW TO ORDER           //
/*********************************/

/* Show / hide specs for label types */

var currentSpecs = ""; // which spec is currently showing.  initialized to begin with no spec showing

function labelTypeSpecs() {
	//alert(document.quoteForm.labelType[1].checked);
	var theForm = document.quoteForm;
	var len = theForm.labelType.length;
	var why = 0;
	for(var i=0; i< len; i++){

		if (theForm.labelType[i].checked) {

	 		// something is checked

			if ((theForm.labelType[i].value == "rollLabels") && (currentSpecs != "rollSpecs")) {
				toggle('rollSpecs');
				
				if (currentSpecs != "") { // check to make sure this isn't the first button clicked
					toggle('sheetSpecs');
				}
				
				currentSpecs = "rollSpecs";
			} else if ((theForm.labelType[i].value == "sheets") && (currentSpecs != "sheetSpecs")) {
				toggle('sheetSpecs');

				if (currentSpecs != "") { // check to make sure this isn't the first button clicked
					toggle('rollSpecs');
				}

				currentSpecs = "sheetSpecs";
			}
		}
	}

}


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

function openWindow(theURL,newWinz,width,height,scrollbar) {
    x = (640 - width)/2, y = (480 - height)/2;
    if (screen) {

        y = (screen.availHeight - height)/2;

        x = (screen.availWidth - width)/2;

    }

        if (screen.availWidth > 1800) { 

        x = ((screen.availWidth/2) - width)/2; 

    } 

    window.open(theURL,newWinz,'width='+width+',height='+height+',directories=0,status=0,screenX='+x+',screenY='+y+',top='+y+',left='+x+',location=0,menubar=0,resizable=0,scrollbars='+scrollbar+',toolbar=0');
}
// end  Open   Window	

