    var productsSelected = new Array();

		function removeFromCart(element)
		{
			new Effect.SlideUp(element,{afterFinish: function(effect) { removeElement(element) }, duration: 0.4 });
		}

         function setHeight(element)
         {
            var element=$(element);
            element.style.height="auto";
         }
			function removeElement(element)
			{
				remove=$(element);
				remove.parentNode.removeChild(remove);
			}



        function bookToggle(id)
        {
            ele = $(id)
            html=id+"<br><br>"
            if(ele.className == "bookselect")
            {
                prodpush(id)
                ele.className = "bookselected"
            }
            else
            {                
                ele.className = "bookselect"
                prodpull(id);
            }
            
            for (i=0; i<productsSelected.length;i++)
            {
                html+=productsSelected[i]+"<br>"
            }
        }


        function prodpush(id)
        {
            if (id.match(/3-/)) stripNOW();
            productsSelected.push(id);
        }


		function verifyisbn()
    	{	
        	var isbnfield = $('fbookisbn');
			var isbn = isbnfield.value;
			isbn = isbn.replace(/-/g,"");
			isbnfield.value = isbn;
			if ((isbn.length!=10 ) && (isbn.length!=13)) return false;
			return true;
		}





        function addBook()
        {
            
            var notice = "";
            if ($('fbookauthor').value == "") notice+="Book Author is a required field.\r";
            if ($('fbooktitle').value == "") notice+="Book Title is a required field.\r";
            if ($('fbookedition').value == "") notice+="Book Edition is a required field.\r";
            if (($('fbookisbn').value == "") || (!verifyisbn())) notice+="Book ISBN is a required and must be 10 or 13 digits.\r";
            
            if(notice !="")
            {
               alert(notice);
               return false;
            }
			
			

            new Ajax.Updater('selectedProducts', siteRoot+'/products.php?action=add',{asynchronous:true, evalScripts:true, parameters:Form.serialize($('acctrequest')) }); return false;            
         		
            $('fbookauthor').value = "" 
			$('fbooktitle').value = "" 
			$('fbookedition').value = ""
			$('fbookisbn').value = ""

        }
			


				function formSubmit()
				{
					var notice = "";
					var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
					var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";

	    	        // verify representative's name	    
	                if ($('replast').value == "" || $('repfirst').value == "") notice+= "Please enter Representative's name.\n"

	                // check for valid email for rep     
	                repemail = $('repemail').value           
	                // if regex supported
	                if (window.RegExp) 
	                {
	                    var reg1 = new RegExp(reg1str);
	                    var reg2 = new RegExp(reg2str);
	                    if (reg1.test(repemail) || !reg2.test(repemail)) 
	                    {
	                        notice+="Please enter a valid email address for the Representative.\n"
	                    }
	                }
	                else
	                {
	                    //simple check
	                    if (repemail = "") notice+="Please enter a valid email address for the Representative.\n"
	                }

		            // make sure at least one product was entered.
		            	if (!document.acctrequestForm.bookadded) notice+="You must select a product.\n";

	                if(notice !="")
	                {
	                   alert(notice);
	                   return false;
	                }
	                else
	                {
						return true;
	                }
				}

			
			
			
			
			
			
			
			
			
			
			
			