///////////////////////////////////////////////
function submitForm(tURL,tForm,tFormID,tCall) {
tURL="shoppingcartFunctions.aspx?tURL=list&tQty=1&tProdID=" + tFormID + "&tCall=" + tCall;
	document.forms[tForm].action =tURL;
	document.forms[tForm].method="post";
	document.forms[tForm].submit();
}
///////////////////////////////////////////////
function dataValidate1(tURL,tForm,tCharPos,tErrStr,tCall) {
	var tRef, tCustom, tOptions, tFormRef;
	var tColor, tSize, tErr,tAmount;
	var tCharPosLabel1,tCharPosLabel2;

	if(tErrStr=="") {
		tErr="Please select a logo style, color, and size.";
	} else {
		tErr=tErrStr;
	} // end if

	tCustom="";
	tRef="tColor" + tForm;
	tColor=document.getElementById(tRef).value;
	tOptions="color=" + tColor;
	tRef="tSize" + tForm;
	tSize=document.getElementById(tRef).value;
	tOptions=tOptions + ", size=" + tSize;
	tRef="printStyle" + tForm;
	var tLogo;
	tLogo=document.getElementById(tRef).value;
	tOptions=tOptions + ", logo=" + tLogo;

	document.getElementById('os0').value=tOptions;
	document.getElementById('on0').value="Options";

	tRef='SizePrice' + tForm;
	tAmount=parseFloat(document.getElementById(tRef).value);

	tRef="top" + tForm; // tRef is always top or bottom

	if((tCharPos=="topbottom")|| (tCharPos==null)) {
		tCharPosLabel1="top=";
		tCharPosLabel2="bottom=";
	} // end if
	if(tCharPos=="leftright"){
		tCharPosLabel1="left=";
		tCharPosLabel2="right=";
	} // end if

	tCustom=tCharPosLabel1  + document.getElementById(tRef).value;
	if (trim(document.getElementById(tRef).value).length>0) {
		tAmount=tAmount+5;
	} // end if;
	tRef="bottom" + tForm;
	tCustom=tCustom + ", " + tCharPosLabel2  + document.getElementById(tRef).value;
	if (trim(document.getElementById(tRef).value).length>0) {
		tAmount=tAmount+5;
	} // end if;

	tRef="top" + tForm; // tRef is always top or bottom
	if(trim(document.getElementById(tRef).value).length>15){
		alert("Top characters cannot exceed 15 characters.");
		return false;
	} // end if

	tRef="bottom" + tForm; // tRef is always top or bottom
	if(trim(document.getElementById(tRef).value).length>15){
		alert("Bottom characters cannot exceed 15 characters.");
		return false;
	} // end if

	document.getElementById('amount').value=tAmount;
	document.getElementById('os1').value=tCustom;
	document.getElementById('on1').value="Customize";
	document.getElementById('quantity').value=1;

	if ((tColor=='0') || (tSize=='0') || (tLogo=='0')) {
		alert(tErr);
	} else {
	tRef='item_name' + tForm;
	document.getElementById('item_name').value=document.getElementById(tRef).value;
	submitForm(tURL,1,tForm,tCall);
	} // end if
} // end function
/////////////////////////////////////////////////////
function dataValidate2(tURL,tForm,tErrStr,tCall) {
	var tRef, tCustom, tOptions, tFormRef;
	var tColor, tSize, tErr,tAmount;
	if(tErrStr=="") {
		tErr="Please select a logo style, color and size.";
	} else {
		tErr=tErrStr;
	} // end if
	tCustom="";
	tRef='tColor' + tForm;
	tColor=document.getElementById(tRef).value;
	document.getElementById('os0').value=tColor;
	document.getElementById('on0').value="Color";
	tRef='tSize' + tForm;
	tSize=document.getElementById(tRef).value;
	tRef="printStyle" + tForm;
	tOptions="size=" + tSize;

	var tLogo;
	tLogo=document.getElementById(tRef).value;
	tOptions=tOptions + ", logo=" + tLogo;

	document.getElementById('os1').value=tOptions;
	document.getElementById('on1').value="Options";
	document.getElementById('quantity').value=1;

	tRef='SizePrice' + tForm;
	tAmount=document.getElementById(tRef).value;

	document.getElementById('amount').value=tAmount;
	if ((tColor=='0') || (tSize=='0') || (tLogo=='0')) {
		alert(tErr);
	} else {
	tRef='item_name' + tForm;
	document.getElementById('item_name').value=document.getElementById(tRef).value;
	submitForm(tURL,1,tForm,tCall);
	} // end if
} // end function
/////////////////////////////////////////////////////

function trim(inputStr) {
     var begin = 0
     var end = inputStr.length - 1
     var bEmptyString=true;
     // Examine the front of the string.
     // Remove leading blanks or $ signs.
     for (var i = 0; i <inputStr.length; i++){
	  var oneChar = inputStr.charAt(i)
          if (oneChar == " " || oneChar == "$" ){
              continue
          } else {
          bEmptyString=false;
	      begin = i
	      break
	  }
     }
     // Scanning from the end of the string, remove blanks
     for (var j = inputStr.length-1; j >= 0; j--){
	  var lastChar = inputStr.charAt(j)
          if (lastChar == " "){
              continue
          } else {
	      end = j
	      break
	  }
     }
     if (bEmptyString==false) {
		return inputStr.substring(begin,end+1)
     } else {
		return '';
	 } // end if
} // end function
/////////////////////////////////////////////////////

