function isEmpty(inputStr) 
{	if (inputStr == null || inputStr == "") return true;
	return false;
}    

function open3DWindow(url,target,basicpartnumber)
{
windowHandle = window.open(url + '?target=' + escape(target) + '&basicpartnumber=' + basicpartnumber, 'newwin','height=350,width=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=0,left=0');

if (windowHandle.opener == null)
        windowHandle.opener = window;

        windowHandle.focus();
}
function so_open3DWindow(url,target,basicpartnumber)
{
windowHandle = window.open(url + '?target=' + escape(target) + '&basicpartnumber=' + basicpartnumber, 'newwin','height=600,width=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=0,left=0');

if (windowHandle.opener == null)
        windowHandle.opener = window;

        windowHandle.focus();
}




function checkFields (partnumber,qty) {
	
	if (isEmpty(partnumber.value)) {
		alert('Please enter a part number.');
		partnumber.focus();
		return false;
	}
	var partNumNoHyphen = partnumber.value.replace(/-/g,'');
	partNumNoHyphen = partNumNoHyphen.replace(/P/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/M/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/S/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/ /i,'');
		//alert(partNumNoHyphen.length);
		//alert(partNumNoHyphen);
	if (partNumNoHyphen.length > 16){
		alert('Part Number is greater than 16 digits. \nPlease check the number and try again.');
		partnumber.value=''
		partnumber.focus();
		return false;
	}else{
	partnumber.value = partnumber.value.replace(/ /g,'');	
	if (isEmpty(qty.value)||checkNumber(qty.value)||checkInteger(qty.value)) {
		alert('Please enter a valid quantity');
		qty.value="";
		qty.focus();
		return false;
	}
	}
	
	return true;
}

function checkPN_16digits (part) {
	
	if (isEmpty(part.value)) {
		alert('Please enter a part number.');
		part.focus();
		return false;
	}
	
	var partNumNoHyphen = part.value.replace(/-/g,'');
	partNumNoHyphen = partNumNoHyphen.replace(/P/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/M/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/S/i,'');
	partNumNoHyphen = partNumNoHyphen.replace(/ /i,'');
		
	if (partNumNoHyphen.length > 16){
		alert('The part number must be 16 digits or less, not including hyphens.');
		//partnumber.value=''
		part.focus();
		return false;
	//}else{
	//part.value = part.value.replace(/ /g,'');	
	//if (isEmpty(qty.value)||checkNumber(qty.value)||checkInteger(qty.value)) {
	//	alert('Please enter a valid quantity');
	//	qty.value="";
	//	qty.focus();
		//return false;
	//}
	}
	
	return true;
}


function confirmThisAction(msg){

	return confirm(msg);
	
}

function toggleAllCheckBoxes(selectall,theForm){
	
	for(i=0;i<theForm.elements.length;i++){
  		if(theForm.elements[i].type=='checkbox')theForm.elements[i].checked= selectall.checked;
	}
	
}

