function AddToSFCart(){
	var objForm = window.document.forms[0];
	var strNewLocation = 'http://www.everybodiesposters.com/AddToCart.aspx';
	
	if (Validate(objForm) == true){
		strNewLocation += '?SeriesName=' + escape(objForm.elements['SeriesName'].value);
		strNewLocation += '&SizeAttribute=' + escape(objForm.elements['SizeAttribute'].options[objForm.elements['SizeAttribute'].selectedIndex].text);
		strNewLocation += '&ColorAttribute=' + escape(objForm.elements['ColorAttribute'].options[objForm.elements['ColorAttribute'].selectedIndex].text);
		strNewLocation += '&Qty=' + objForm.elements['quantity'].value;
		window.location = strNewLocation;
	}
	return false;
}

function AddToSFCart2(formName){
	var objForm = window.document.forms[formName];
	var strNewLocation = 'http://www.everybodysposters.com/AddToCart.aspx';
	
	if (Validate(objForm) == true){
		strNewLocation += '?SeriesName=' + escape(objForm.elements['SeriesName'].value);
		strNewLocation += '&SizeAttribute=' + escape(objForm.elements['SizeAttribute'].value);
		strNewLocation += '&ColorAttribute=N/A';
		strNewLocation += '&Qty=' + objForm.elements['quantity'].value;
		window.location = strNewLocation;
	}
	return false;
}

function Validate(objForm){
	var Result = CheckRequiredFields(objForm);
	if(Result.Valid == false){
		window.alert(Result.Message.toString());
		return false;
	}
	else{
		return true;
	}
}

function CheckRequiredFields(objForm){
	//Has all of the required information been supplied?
	var Result = new Object();
	Result.Valid = true;
	Result.Message = new String();
		
	//Is Size selected?
	try{
		if (objForm.elements['SizeAttribute'].selectedIndex < 0){
			Result.Valid = false;
			Result.Message = 'Please select a size.';
			objForm.elements['SizeAttribute'].focus();
			return Result;
		}
	}
	catch(ex){
		//Element does not exist. Proceed with remaining validation.
	}
	
	//Is Color selected?
	try{
		if (objForm.elements['ColorAttribute'].selectedIndex < 0){
			Result.Valid = false;
			Result.Message = 'Please select a color.';
			objForm.elements['ColorAttribute'].focus();
			return Result;
		}
	}
	catch(ex){
		//Element does not exist. Proceed with remaining validation.
	}

	//Is Quantity entered?
	try{
		if (isNaN(objForm.elements['quantity'].value) == true){
			Result.Valid = false;
			Result.Message = 'Please enter a quantity.';
			objForm.elements['quantity'].focus();
			return Result;
		}
		else{
			objForm.elements['quantity'].value = Math.round(objForm.elements['quantity'].value);
		}
	}
	catch(ex){
		//Element does not exist. Proceed with remaining validation.
	}

	return Result;
}

