//PENDX Corporation's Ship-Rate Shopper(TM), JavaScript Code-Behind Version: 2.0.4.0 for StoreFront 6.x

//(c) Copyright 2003 by PENDX Corporation. All rights reserved.

//The contents of this file are proprietary to PENDX Corporation and are protected by
//copyright law and international treaties. Unauthorized reproduction or distribution
//of this program, or any portion of it, may result in severe civil and criminal
//penalties, and will be prosecuted to the maximum extent possible under the law.

function ValidateShipRate() {
	//Validate Ship-To fields.
	var objForm = window.document.forms[0];
	var objResult = ValidShipRateFields(objForm);

	if (objResult.Valid == true){
		objForm.elements['SRS_EventArgument'].value = "valid";
		return true;
	}
	else{
		objForm.elements['SRS_EventArgument'].value = "invalid";
		window.alert(objResult.Message);
		return false;
	}
}
      
function ValidShipRateFields(objForm){
	var Result = new Object();
	Result.Valid = true;
	Result.Message = new String();
		
	//Is the City filled in?
	try{
		if (objForm.elements['txtShipCity'].value.replace(/\s+/, '') == ''){
			Result.Valid = false;
			Result.Message = 'Ship rate calculation requires a valid City, State, Postal Code and Country.\n\nPlease enter City.';
			objForm.elements['txtShipCity'].focus();
			return Result;
		}
	}
	catch(ex){
		//Element does not exist. Proceed with remaining validation.
	}

	//Is the Zip Code filled in?
	try{
		if (objForm.elements['txtShipZip'].value.replace(/\s+/, '') == ''){
			Result.Valid = false;
			Result.Message = 'Ship rate calculation requires a valid City, State, Postal Code and Country.\n\nPlease enter Postal Code.';
			objForm.elements['txtShipZip'].focus();
			return Result;
		}
	}
	catch(ex){
		//Element does not exist. Proceed with remaining validation.
	}
	return Result;
}

function PENDX_PopUp(strHref, intHeight, intWidth, strAttributes) {
	var intScreenHeight;
	var intScreenWidth;
	var strFeatures;
	var hWin;

	intScreenHeight = window.screen.availHeight;
	intScreenWidth = window.screen.availWidth;
	strFeatures = 'HEIGHT=' + intHeight + ',WIDTH=' + intWidth + ',SCREENY=' + (intScreenHeight*.30) + ',SCREENX=' + (intScreenWidth*.33) + ',TOP=' + (intScreenHeight*.30) + ',LEFT=' + (intScreenWidth*.33) + ',';

	if(strAttributes.replace(' ', '') == '') {
		strFeatures = strFeatures + 'TOOLBAR=no,scrollbars=yes,resizable=yes,location=no,status=yes';
	}
	else {
		strFeatures = strFeatures + strAttributes;
	}
	hWin = window.open(strHref,'SRS',strFeatures);
	return hWin;
}
