
//Adapted from the stock MM behavior and additions by Jaro van Flocken
function n3_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2-50;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function Lvl_openWin(u,n,w,h,l,t,c,f) { //v1.0 4LevelWebs
  var ww=((screen.width-w)/2);if(c==1){l=ww;t=(screen.height-h)/2;}if(c==2){l=ww}
	f+=',top='+t+',left='+l;LvlWin = window.open(u,n,f);LvlWin.focus();
}


// Kindler Chase - www.ncubed.com
function n3_currentLink(param,paramVal) {
	if (!document.getElementById) return; 
	if (!document.getElementsByTagName) return; 
	var url_parts = (location.search.substring(1)).split("?");
	var thisKey
	if (url_parts[0]){ 
		var url_args = url_parts[0].split('&');
		for(var i=0; i<url_args.length; i++){
			var keyval = url_args[i].split('=');
			if (keyval[0].toLowerCase() == param.toLowerCase()) {
				thisKey = keyval[1];
				break;
			}
		}
	}

	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var thisAnchor = anchors[i]; 
		if (thisAnchor.id.toLowerCase() == paramVal.toLowerCase() + thisKey) {
			thisAnchor.className = 'currentLink';
			break;
		}
	} 
}

// No longer used
function n3_confirmAddToCart(){
	var msg = "Have you selected the options for this product?";
	return confirm(msg);
}

function n3_confirm(msg){
	return confirm(msg);
}


// Kindler Chase  n3_showHide ver1.3
// www.ncubed.com
function n3_showHide(theID) {
	if(!document.getElementById){return};
	var theElement = document.getElementById(theID);
	if (theElement.style.display == 'block') {
		theElement.style.display = 'none';
	} else {
		theElement.style.display = 'block';
	}
}


function n3_formFieldTextCount(field, id, maxlimit) {
	if(!document.getElementById){return};
	var theElement = document.getElementById(id);

	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
		theElement.innerHTML = maxlimit - field.value.length + ' characters remaining';
		//countfield.value = field.value.length;
		//countfield.value = maxlimit - field.value.length; //if you want to count backwards
}



function n3_toggleNonUsState(f1, id, f2){
	if(!document.getElementById){return};
	var theElement = document.getElementById(id);

 	f2.value = '';
	var v = f1[f1.selectedIndex].value;
	if (v.toLowerCase() == 'Non-US State'.toLowerCase()){ 
		theElement.style.display = 'block';
	}
	else{
		theElement.style.display = 'none';
	}
}

