// JavaScript Document
function zoom(urlRedirect) {
	window.open( urlRedirect, "zoomView", "width=700,height=560,toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1" )
	return false;
}

function showAccountControls(){
	document.getElementById('userAccountControls').style.display = 'block';	
}
function hideAccountControls(){
	document.getElementById('userAccountControls').style.display = 'none';	
}

function hideShowSubnav(navKey, actionTaken){
	if(actionTaken == 'show'){
		var displayValue = 'block';	
	}else{
		var displayValue = 'none';
	}
	
	if(navKey == 'MyAccount'){
		document.getElementById('subNav_MyAccount').style.display = displayValue;
	}
}


function hideShowNewProf(hideShow){
	if(hideShow == 1){
		document.getElementById('profileNew').style.display = 'block';	
		document.getElementById('profileExisting').style.display = 'none';
		document.getElementById('profileNewTxt').value = 'Myself';
	}else if(hideShow == 0){
		document.getElementById('profileNew').style.display = 'none';	
		document.getElementById('profileExisting').style.display = 'block';
		document.getElementById('profileNewTxt').value = '';
	}
}


function isEmail(entry){ 
	var rex= /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,5})(\]?)$/; 
	return rex.test(entry)
}

function validateForm_contactUs(){
	var trueFalse = true;
	
	if(document.getElementById('name').value == ''){
		alert("Please enter your name");
		trueFalse = false;
		document.getElementById('name').focus();
	}else if(document.getElementById('email').value == ''){
		alert("Please enter your email address");
		trueFalse = false;
		document.getElementById('email').focus();
	}else if(isEmail(document.getElementById('email').value) == false){
		alert("Please enter a valid email address");
		trueFalse = false;
		document.getElementById('email').focus();
		document.getElementById('email').select();
	}else if(document.getElementById('comments').value == ''){
		alert("Please enter a comment");
		trueFalse = false;
		document.getElementById('comments').focus();
	}
	
	return trueFalse;
}

function validateForm_customClothsStep04(){
	var trueFalse = true;
	
	if(document.getElementById('profileID')){
		// if profiles already exist alert('1');
		if(document.getElementById('profileNew').style.display != 'none' && document.getElementById('profileNewTxt').value == ''){
			alert("Please enter a name for this profile");
			trueFalse = false;
			document.getElementById('profileNewTxt').focus();
		}
	}else if(document.getElementById('profileNewTxt')){
		// this is the first new profile alert('2');
		if(document.getElementById('profileNewTxt').value == ''){
			alert("Please enter a name for this profile");
			trueFalse = false;
			document.getElementById('profileNewTxt').focus();
		}
	}
	
	//alert('end of line');
	
	return trueFalse;
}

function hideShowStateValue(countryIn,countryFieldName){
	if(countryFieldName == 'shipCountry'){
		document.getElementById('shipStateRegion').style.display = 'none';
		document.getElementById('shipStateRegionUS').style.display = 'none';
		document.getElementById('shipStateRegionCan').style.display = 'none';
		
		document.getElementById('shipStateRegion').value = '';
		document.getElementById('shipStateRegionUS').selectedIndex = 0;
		document.getElementById('shipStateRegionCan').selectedIndex = 0;
		
		if(countryIn == 'US' || countryIn == 'UM'){
			document.getElementById('shipStateRegionUS').style.display = 'block';
		}else if(countryIn == 'CA'){
			document.getElementById('shipStateRegionCan').style.display = 'block';
		}else{
			document.getElementById('shipStateRegion').style.display = 'block';
		}	
	}else{
		document.getElementById('stateRegion').style.display = 'none';
		document.getElementById('stateRegionUS').style.display = 'none';
		document.getElementById('stateRegionCan').style.display = 'none';
		
		document.getElementById('stateRegion').value = '';
		document.getElementById('stateRegionUS').selectedIndex = 0;
		document.getElementById('stateRegionCan').selectedIndex = 0;
		
		if(countryIn == 'US' || countryIn == 'UM'){
			document.getElementById('stateRegionUS').style.display = 'block';
		}else if(countryIn == 'CA'){
			document.getElementById('stateRegionCan').style.display = 'block';
		}else{
			document.getElementById('stateRegion').style.display = 'block';
		}	
	}
}

function changeMeasurementUnits(unitTypeIn){

	if(unitTypeIn == 'Metric'){
		// collar / neck
		document.getElementById('metCollarNeckMeasurement').disabled = false;
		document.getElementById('metCollarNeckMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metCollarNeckMeasurement').selectedIndex = 0;
		document.getElementById('impCollarNeckMeasurement').disabled = true;
		document.getElementById('impCollarNeckMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impCollarNeckMeasurement').selectedIndex = 0;
		// shoulder
		document.getElementById('metShoulderMeasurement').disabled = false;
		document.getElementById('metShoulderMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metShoulderMeasurement').selectedIndex = 0;
		document.getElementById('impShoulderMeasurement').disabled = true;
		document.getElementById('impShoulderMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impShoulderMeasurement').selectedIndex = 0;
		// right and left sleeves
		if(document.getElementById('metSleevesMeasurement').disabled == false
			|| document.getElementById('impSleevesMeasurement').disabled == false){
			document.getElementById('metSleevesMeasurement').disabled = false;
			document.getElementById('metSleevesMeasurement').style.backgroundColor = '#fff';
			document.getElementById('metSleevesMeasurement').selectedIndex = 0;
			document.getElementById('impSleevesMeasurement').disabled = true;
			document.getElementById('impSleevesMeasurement').style.backgroundColor = '#ccc';
			document.getElementById('impSleevesMeasurement').selectedIndex = 0;
		}
		// chest
		document.getElementById('metChestMeasurement').disabled = false;
		document.getElementById('metChestMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metChestMeasurement').selectedIndex = 0;
		document.getElementById('impChestMeasurement').disabled = true;
		document.getElementById('impChestMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impChestMeasurement').selectedIndex = 0;
		// waist
		document.getElementById('metWaistMeasurement').disabled = false;
		document.getElementById('metWaistMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metWaistMeasurement').selectedIndex = 0;
		document.getElementById('impWaistMeasurement').disabled = true;
		document.getElementById('impWaistMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impWaistMeasurement').selectedIndex = 0;
		// hips
		document.getElementById('metHipsMeasurement').disabled = false;
		document.getElementById('metHipsMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metHipsMeasurement').selectedIndex = 0;
		document.getElementById('impHipsMeasurement').disabled = true;
		document.getElementById('impHipsMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impHipsMeasurement').selectedIndex = 0;
		// length
		document.getElementById('metLengthMeasurement').disabled = false;
		document.getElementById('metLengthMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metLengthMeasurement').selectedIndex = 0;
		document.getElementById('impLengthMeasurement').disabled = true;
		document.getElementById('impLengthMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impLengthMeasurement').selectedIndex = 0;
		// around waist
		document.getElementById('metAroundWristMeasurement').disabled = false;
		document.getElementById('metAroundWristMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metAroundWristMeasurement').selectedIndex = 0;
		document.getElementById('impAroundWristMeasurement').disabled = true;
		document.getElementById('impAroundWristMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impAroundWristMeasurement').selectedIndex = 0;
		// length from neck to waist
		document.getElementById('metLenNeckToWaistMeasurement').disabled = false;
		document.getElementById('metLenNeckToWaistMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metLenNeckToWaistMeasurement').selectedIndex = 0;
		document.getElementById('impLenNeckToWaistMeasurement').disabled = true;
		document.getElementById('impLenNeckToWaistMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impLenNeckToWaistMeasurement').selectedIndex = 0;
		// arm hole
		document.getElementById('metArmHoleMeasurement').disabled = false;
		document.getElementById('metArmHoleMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metArmHoleMeasurement').selectedIndex = 0;
		document.getElementById('impArmHoleMeasurement').disabled = true;
		document.getElementById('impArmHoleMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impArmHoleMeasurement').selectedIndex = 0;
		// best fitting collar
		document.getElementById('metBestFitCollarMeasurement').disabled = false;
		document.getElementById('metBestFitCollarMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metBestFitCollarMeasurement').selectedIndex = 0;
		document.getElementById('impBestFitCollarMeasurement').disabled = true;
		document.getElementById('impBestFitCollarMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impBestFitCollarMeasurement').selectedIndex = 0;
		// best fitting sleeve
		document.getElementById('metBestFitSleeveMeasurement').disabled = false;
		document.getElementById('metBestFitSleeveMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metBestFitSleeveMeasurement').selectedIndex = 0;
		document.getElementById('impBestFitSleeveMeasurement').disabled = true;
		document.getElementById('impBestFitSleeveMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impBestFitSleeveMeasurement').selectedIndex = 0;
		// body weight
		document.getElementById('metBodyWeightMeasurement').disabled = false;
		document.getElementById('metBodyWeightMeasurement').style.backgroundColor = '#fff';
		document.getElementById('metBodyWeightMeasurement').selectedIndex = 0;
		document.getElementById('impBodyWeightMeasurement').disabled = true;
		document.getElementById('impBodyWeightMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('impBodyWeightMeasurement').selectedIndex = 0;
	}else{
		// collar / neck
		document.getElementById('metCollarNeckMeasurement').disabled = true;
		document.getElementById('metCollarNeckMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metCollarNeckMeasurement').selectedIndex = 0;
		document.getElementById('impCollarNeckMeasurement').disabled = false;
		document.getElementById('impCollarNeckMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impCollarNeckMeasurement').selectedIndex = 0;
		// shoulder
		document.getElementById('metShoulderMeasurement').disabled = true;
		document.getElementById('metShoulderMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metShoulderMeasurement').selectedIndex = 0;
		document.getElementById('impShoulderMeasurement').disabled = false;
		document.getElementById('impShoulderMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impShoulderMeasurement').selectedIndex = 0;
		// right and left sleeves
		if(document.getElementById('metSleevesMeasurement').disabled == false
			|| document.getElementById('impSleevesMeasurement').disabled == false){
			document.getElementById('metSleevesMeasurement').disabled = true;
			document.getElementById('metSleevesMeasurement').style.backgroundColor = '#ccc';
			document.getElementById('metSleevesMeasurement').selectedIndex = 0;
			document.getElementById('impSleevesMeasurement').disabled = false;
			document.getElementById('impSleevesMeasurement').style.backgroundColor = '#fff';
			document.getElementById('impSleevesMeasurement').selectedIndex = 0;
		}
		// chest
		document.getElementById('metChestMeasurement').disabled = true;
		document.getElementById('metChestMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metChestMeasurement').selectedIndex = 0;
		document.getElementById('impChestMeasurement').disabled = false;
		document.getElementById('impChestMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impChestMeasurement').selectedIndex = 0;
		// waist
		document.getElementById('metWaistMeasurement').disabled = true;
		document.getElementById('metWaistMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metWaistMeasurement').selectedIndex = 0;
		document.getElementById('impWaistMeasurement').disabled = false;
		document.getElementById('impWaistMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impWaistMeasurement').selectedIndex = 0;
		// hips
		document.getElementById('metHipsMeasurement').disabled = true;
		document.getElementById('metHipsMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metHipsMeasurement').selectedIndex = 0;
		document.getElementById('impHipsMeasurement').disabled = false;
		document.getElementById('impHipsMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impHipsMeasurement').selectedIndex = 0;
		// length
		document.getElementById('metLengthMeasurement').disabled = true;
		document.getElementById('metLengthMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metLengthMeasurement').selectedIndex = 0;
		document.getElementById('impLengthMeasurement').disabled = false;
		document.getElementById('impLengthMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impLengthMeasurement').selectedIndex = 0;
		// around waist
		document.getElementById('metAroundWristMeasurement').disabled = true;
		document.getElementById('metAroundWristMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metAroundWristMeasurement').selectedIndex = 0;
		document.getElementById('impAroundWristMeasurement').disabled = false;
		document.getElementById('impAroundWristMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impAroundWristMeasurement').selectedIndex = 0;
		// length from neck to waist
		document.getElementById('metLenNeckToWaistMeasurement').disabled = true;
		document.getElementById('metLenNeckToWaistMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metLenNeckToWaistMeasurement').selectedIndex = 0;
		document.getElementById('impLenNeckToWaistMeasurement').disabled = false;
		document.getElementById('impLenNeckToWaistMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impLenNeckToWaistMeasurement').selectedIndex = 0;
		// arm hole
		document.getElementById('metArmHoleMeasurement').disabled = true;
		document.getElementById('metArmHoleMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metArmHoleMeasurement').selectedIndex = 0;
		document.getElementById('impArmHoleMeasurement').disabled = false;
		document.getElementById('impArmHoleMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impArmHoleMeasurement').selectedIndex = 0;
		// best fitting collar
		document.getElementById('metBestFitCollarMeasurement').disabled = true;
		document.getElementById('metBestFitCollarMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metBestFitCollarMeasurement').selectedIndex = 0;
		document.getElementById('impBestFitCollarMeasurement').disabled = false;
		document.getElementById('impBestFitCollarMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impBestFitCollarMeasurement').selectedIndex = 0;
		// best fitting sleeve
		document.getElementById('metBestFitSleeveMeasurement').disabled = true;
		document.getElementById('metBestFitSleeveMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metBestFitSleeveMeasurement').selectedIndex = 0;
		document.getElementById('impBestFitSleeveMeasurement').disabled = false;
		document.getElementById('impBestFitSleeveMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impBestFitSleeveMeasurement').selectedIndex = 0;
		// body weight
		document.getElementById('metBodyWeightMeasurement').disabled = true;
		document.getElementById('metBodyWeightMeasurement').style.backgroundColor = '#ccc';
		document.getElementById('metBodyWeightMeasurement').selectedIndex = 0;
		document.getElementById('impBodyWeightMeasurement').disabled = false;
		document.getElementById('impBodyWeightMeasurement').style.backgroundColor = '#fff';
		document.getElementById('impBodyWeightMeasurement').selectedIndex = 0;
	}
}

function registerBillingToShipping(isItChecked,formName){
	var formRoot = eval('document.'+formName);
	if(isItChecked){
		formRoot.shipFirstName.value = formRoot.firstName.value;
		formRoot.shipLastName.value = formRoot.lastName.value;
		formRoot.shipCountry.selectedIndex = formRoot.country.selectedIndex;
		formRoot.shipCountry.focus();
		formRoot.billingAsShipping.focus();
		hideShowStateValue(formRoot.shipCountry[formRoot.shipCountry.selectedIndex].value,'shipCountry');
		formRoot.shipAddress1.value = formRoot.address1.value;
		formRoot.shipAddress2.value = formRoot.address2.value;
		formRoot.shipCity.value = formRoot.city.value;
		
		formRoot.shipStateRegion.value = formRoot.stateRegion.value;
		formRoot.shipStateRegionUS.selectedIndex = formRoot.stateRegionUS.selectedIndex;
		formRoot.shipStateRegionCan.selectedIndex = formRoot.stateRegionCan.selectedIndex;
		
		formRoot.shipZip.value = formRoot.zip.value;
		formRoot.shipPhone.value = formRoot.phone.value;
		/*document.getElementById('shipFirstName').value = document.getElementById('firstName').value;
		document.getElementById('shipLastName').value = document.getElementById('lastName').value;
		document.getElementById('shipCountry').selectedIndex = document.getElementById('country').selectedIndex;
		hideShowStateValue(document.getElementById('shipCountry')[document.getElementById('shipCountry').selectedIndex].value,'shipCountry');
		document.getElementById('shipAddress1').value = document.getElementById('address1').value;
		document.getElementById('shipAddress2').value = document.getElementById('address2').value;
		document.getElementById('shipCity').value = document.getElementById('city').value;
		
		document.getElementById('shipStateRegion').value = document.getElementById('stateRegion').value;
		document.getElementById('shipStateRegionUS').selectedIndex = document.getElementById('stateRegionUS').selectedIndex;
		document.getElementById('shipStateRegionCan').selectedIndex = document.getElementById('stateRegionCan').selectedIndex;
		
		document.getElementById('shipZip').value = document.getElementById('zip').value;
		document.getElementById('shipPhone').value = document.getElementById('phone').value;
		*/
	}else{
		formRoot.shipFirstName.value = '';
		formRoot.shipLastName.value = '';
		formRoot.shipCountry.selectedIndex = 251;
		formRoot.shipCountry.focus();
		formRoot.billingAsShipping.focus();
		hideShowStateValue(formRoot.shipCountry[formRoot.shipCountry.selectedIndex].value,'shipCountry');
		formRoot.shipAddress1.value = '';
		formRoot.shipAddress2.value = '';
		formRoot.shipCity.value = '';
		
		formRoot.shipStateRegion.value = '';
		formRoot.shipStateRegionUS.selectedIndex = 0;
		formRoot.shipStateRegionCan.selectedIndex = 0;
		
		formRoot.shipZip.value = '';
		formRoot.shipPhone.value = '';
		/*document.getElementById('shipFirstName').value = '';
		document.getElementById('shipLastName').value = '';
		//document.getElementById('shipCountry').selectedIndex = 224;
		document.getElementById('shipCountry').selectedIndex = 251;
		hideShowStateValue(document.getElementById('shipCountry')[document.getElementById('shipCountry').selectedIndex].value,'shipCountry');
		document.getElementById('shipAddress1').value = '';
		document.getElementById('shipAddress2').value = '';
		document.getElementById('shipCity').value = '';
		
		document.getElementById('shipStateRegion').value = '';
		document.getElementById('shipStateRegionUS').selectedIndex = 0;
		document.getElementById('shipStateRegionCan').selectedIndex = 0;
		
		document.getElementById('shipZip').value = '';
		document.getElementById('shipPhone').value = '';*/
	}
}

function checkAllBoxes(pgForm,checkValue){
	if(pgForm == 'requestToCart'){
		if(document.frmAddRequestToCart.fabric){
			if(document.frmAddRequestToCart.fabric.length){
				for(i=0; i<document.frmAddRequestToCart.fabric.length; i++){
					document.frmAddRequestToCart.fabric[i].checked = checkValue;
				}
			}else{
				document.frmAddRequestToCart.fabric.checked = checkValue;	
			}
		}
	}
}

function showHideAddressBook(action){
	document.getElementById('addessBookDisplay').style.display = action;
}

function resetMeasurementsLink(incomingValue){
	document.getElementById('viewMeasurementsLink').href='my-profiles.cfm?id='+incomingValue+'&anc=1#measurements';
	
}

function selectShippingOption(shippingOption){
	if(shippingOption == 'priority'){
		document.getElementById('economyPricingPrice').style.display='none';
		document.getElementById('economyPricingShipCharge').style.display='none';
		document.getElementById('priorityPricingPrice').style.display='block';
		document.getElementById('priorityPricingShipCharge').style.display='block';
	}else if(shippingOption == 'economy'){
		document.getElementById('economyPricingPrice').style.display='block';
		document.getElementById('economyPricingShipCharge').style.display='block';
		document.getElementById('priorityPricingPrice').style.display='none';
		document.getElementById('priorityPricingShipCharge').style.display='none';
	}
}