function uCase()
{
	vStr = document.getElementById('state').value;
	document.getElementById('state').value = vStr.toUpperCase();
	//vStr = strtoupper(vStr);
	//document.getElementById('state').value = vStr;
}

function calcMP() 
{
	vQty = 0
	vQty += (document.getElementById('facQty').value * 1)
	vQty += (document.getElementById('craftQty').value * 1)
	vQty += (document.getElementById('commQty').value * 1)
	vQty += (document.getElementById('foodQty').value * 1)
	vQty += (document.getElementById('hlProdQty').value * 1)
	vQty += (document.getElementById('hlServQty').value * 1)


	vAmt = document.getElementById('facQty').value * 600;
	document.getElementById('facAmt').value = vAmt.toFixed(2);
	vAmt2 = document.getElementById('craftQty').value * 700;
	document.getElementById('craftAmt').value = vAmt2.toFixed(2);

	vAmt20 = document.getElementById('foodQty').value * 700;
	document.getElementById('foodAmt').value = vAmt20.toFixed(2);


	vAmt3 = document.getElementById('commQty').value * 900;
	document.getElementById('commAmt').value = vAmt3.toFixed(2);
	
	vAmt21 = document.getElementById('hlProdQty').value * 1125;
	document.getElementById('hlProdAmt').value = vAmt21.toFixed(2);
	vAmt22 = document.getElementById('hlServQty').value * 1325;
	document.getElementById('hlServAmt').value = vAmt22.toFixed(2);

	
	vAmt4 = document.getElementById('cornerQty').value * 250;
	document.getElementById('cornerAmt').value = vAmt4.toFixed(2);
	vAmt5 = document.getElementById('2sideQty').value * 200;
	document.getElementById('2sideAmt').value = vAmt5.toFixed(2);
	

	vAmt6 = vAmt + vAmt2 + vAmt3 + vAmt4 + vAmt5 + vAmt20 + vAmt21 + vAmt22;
	document.getElementById('totAmt').value = vAmt6.toFixed(2);
	
	vAmt7 = (document.getElementById('facQty').value * 1);
	// $300
	
	vAmt25 = (document.getElementById('hlProdQty').value * 1) + (document.getElementById('hlServQty').value * 1);
	// $600
	
	vAmt26=(document.getElementById('craftQty').value * 1) + (document.getElementById('foodQty').value * 1);
	// $350
	
	vAmt27=(document.getElementById('commQty').value * 1);
	// $450
	
	//vAmt8 = (vAmt7 + vAmt25 + vAmt26 + vAmt27) * -50;
	vAmt8 = 0; //No discount after March 31
	//document.getElementById('discAmt').value = vAmt8.toFixed(2);
	
	vAmt9 = vAmt6 + vAmt8;
	document.getElementById('fullAmt').value = vAmt9.toFixed(2);
	
	var selection = document.mktSignup.payFull;

	if (selection[1].checked == true) {
	// if (document.getElementById('payFull').value == "full") {
			vAmt10 = (vAmt7 * 300) + (vAmt25 * 600) + (vAmt26 * 350) + (vAmt27 * 450);
			document.getElementById('depAmt').value = vAmt10.toFixed(2); 
			vAmt11 = vAmt9 - vAmt10 
			document.getElementById('balAmt').value = vAmt11.toFixed(2); 
	} else {
			document.getElementById('depAmt').value = vAmt9.toFixed(2); 
			vAmt12 = 0;
			document.getElementById('balAmt').value = vAmt12.toFixed(2); 
			}
}

function calcHL() 
{
	vAmt = document.getElementById('boothQty').value * 1325;
	document.getElementById('boothAmt').value = vAmt.toFixed(2);
	vAmt2 = document.getElementById('twoQty').value * 250;
	document.getElementById('twoAmt').value = vAmt2.toFixed(2);
	vAmt3 = vAmt + vAmt2;
	document.getElementById('totHL').value = vAmt3.toFixed(2);
	vAmt4 = 0;
	document.getElementById('discHL').value = 0;
	vAmt5 = vAmt3 + vAmt4;
	document.getElementById('balHL').value = vAmt5.toFixed(2);
}


function calcFac() 
{
	vAmt = document.getElementById('facQty').value * 600;
	document.getElementById('facAmt').value = vAmt.toFixed(2);
	calcTot();
	calcDisc();	
	calcDep();
	calcBal();
	// payNow2();
	
}

function calcCraft() 
{
	vAmt = document.getElementById('craftQty').value * 700;
	document.getElementById('craftAmt').value = vAmt.toFixed(2);
	calcTot();
	calcDisc();	
	calcDep();
	calcBal();
	// payNow2();
}

function calcComm() 
{
	vAmt = document.getElementById('commQty').value * 900;
	document.getElementById('commAmt').value = vAmt.toFixed(2);
	calcTot();
	calcDisc();	
	calcDep();
	calcBal();
	// payNow2();
}

function calcCorner() 
{
	vAmt = document.getElementById('cornerQty').value * 250;
	document.getElementById('cornerAmt').value = vAmt.toFixed(2);
	calcTot();
	calcDisc();	
	calcDep();
	calcBal();
	// payNow2();
}

function calc2Side() 
{
	vAmt = document.getElementById('2sideQty').value * 200;
	document.getElementById('2sideAmt').value = vAmt.toFixed(2);
	calcTot();
	calcDisc();	
	calcDep();
	calcBal();
	// payNow2();
}

function calcDep() 
{
	if (document.getElementById('payFull').checked) {
		vAmt1 = document.getElementById('facQty').value * 300;
		vAmt2 = document.getElementById('craftQty').value * 300;
		vAmt3 = document.getElementById('commQty').value * 300;
		vAmt = vAmt1 + vAmt2 + vAmt3;
		document.getElementById('depAmt').value = vAmt.toFixed(2);	
	} else {
		vAmt4 = document.getElementById('fullAmt').value * 1;
		document.getElementById('depAmt').value = vAmt4.toFixed(2);
	}
}

function calcDisc() 
{
	vAmt1 = document.getElementById('facQty').value * 50;
	vAmt2 = document.getElementById('craftQty').value * 50;
	vAmt3 = document.getElementById('commQty').value * 50;
	vAmt4 = vAmt1 + vAmt2 + vAmt3;
	vAmt = vAmt4 * -1;
	document.getElementById('discAmt').value = vAmt.toFixed(2);
		
}

function calcTot() 
{
	vAmt1 = document.getElementById('facAmt').value * 1;
	vAmt2 = document.getElementById('craftAmt').value * 1;
	vAmt3 = document.getElementById('commAmt').value * 1;
	vAmt4 = document.getElementById('cornerAmt').value * 1;
	vAmt5 = document.getElementById('2sideAmt').value * 1;
	vAmt = vAmt1 + vAmt2 + vAmt3 + vAmt4 + vAmt5;
	document.getElementById('totAmt').value = vAmt.toFixed(2);
		
}

function calcBal() 
{
	vAmt1 = document.getElementById('totAmt').value * 1;
	vAmt2 = document.getElementById('discAmt').value * 1;
	vAmt3 = document.getElementById('depAmt').value * -1;
	vAmt = vAmt1 + vAmt2 + vAmt3;
	document.getElementById('balAmt').value = vAmt.toFixed(2);
	vAmt4 = vAmt1 + vAmt2;
	document.getElementById('fullAmt').value = vAmt4.toFixed(2);
}

function payNow() 
{
	// alert(document.getElementById('payFull').value);
	
	var selection = document.mktSignup.payFull;

	if (selection[1].checked == true) {
			calcMP();
			document.getElementById('depDiv').style.visibility = 'visible'; 
	} else {
			document.getElementById('depDiv').style.visibility = 'hidden'; 
			calcMP();
			}
}

function payNow2() 
{
	if (document.getElementById('payFull').checked) {
		document.getElementById('depAmt').value = document.getElementById('fullAmt').value;
		document.getElementById('balAmt').value = "0.00"; 
	} else {
		
	}
}




function ParseUSNumber(PhoneNumberInitialString)
  {
    var FmtStr="";
    var index = 0;
    var LimitCheck;

    LimitCheck = PhoneNumberInitialString.length;
    while (index != LimitCheck)
      {
        if (isNaN(parseInt(PhoneNumberInitialString.charAt(index))))
          { }
        else
          { FmtStr = FmtStr + PhoneNumberInitialString.charAt(index); }
        index = index + 1;
      }
    if (FmtStr.length == 10)
      {
        FmtStr = "(" + FmtStr.substring(0,3) + ") " + FmtStr.substring(3,6) + "-" + FmtStr.substring(6,10);
      }
    else
      {
        FmtStr=PhoneNumberInitialString;
        alert("United States phone numbers must have exactly ten digits.");
      }
    return FmtStr;
  }


/* Form Validation */

function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9.]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [There is an error in character number " + eval(charpos+1)+".]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
   