function logOut()
	{

       //Checks whether we are on the live
       //site or not, and sets the domain 
       //(needed for subdomain cookies)
       //if need be.
        var strHref = window.location.href;
        strHref = strHref.toLowerCase(); 
       
       if (strHref.indexOf(".infobasepublishing") >= 0)
        {
        document.cookie = "InfobaseLoginID"+"=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/; domain=.InfobasePublishing.com";//+ cookie_date.toGMTString();        
		window.location.reload();
        }		
		else
		{
	    document.cookie = "InfobaseLoginID"+"=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";        
		window.location.reload();
		}

     }


function promoCodes(ISBN, GUID)
{

    if (!document.promoForm.promoCode.value)
   { 
    //DO NOT EXECUTE FUNCTION 
    return false;
    }
    else
  {
      var promoCode = document.promoForm.promoCode.value
     
     var xmlHttp;
          try
            {
            // Firefox, Opera 8.0+, Safari
            xmlHttp=new XMLHttpRequest();
            }
          catch (e)
            {
            // Internet Explorer
            try
              {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
              }
            catch (e)
              {
              try
                {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
              catch (e)
                {
                alert("Your browser does not support AJAX!");
                return false;
                }
              }
            }
                       
            xmlHttp.open("GET","../includes/Functions.asp?tempOrder=1&atStep=0&promoCode="+promoCode, true);
            xmlHttp.send(null) 
         
            //RELOAD CART DIV, THIS CAN BE DONE BY PASSING IN A 0 AS THE ISBN, REMEMBER, WE ARE NOT TRYING TO DELETE AN ITEM, ONLY RELOAD THE DIV
            deleteShoppingCartItem(ISBN, GUID)
            //UPDATE SHOPPING CART PRICE IN REAL TIME
            //updateShoppingCartSubTotal(" "," ")
             
  }  

}

function fulfillOrder()
{

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
    xmlHttp.open("GET","../includes/Functions.asp?fulfillOrder=1", true);
    xmlHttp.send(null)

}

//ADD DATA TO TEMPORDERS TABLE

function tempOrderInsertionA()
{

var backorderCancellation = document.bcForm.bc1.value+"/"+document.bcForm.bc2.value+"/"+document.bcForm.bc3.value;

var bookProcessing;

        if (document.bookProcessing.bookProc.value == "Yes")
        {
             bookProcessing = document.bookProcessing.bookProc.value
        }
       else
       {
            bookProcessing = "No"
       } 
 
var attached;
       
       if (document.bookProcessing.attached.value == "Yes")
       {
            attached="Yes"
       }
       else
       {
           attached="No"
       }

var promoCode = document.promoForm.promoCode.value

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        //alert(xmlHttp.responseText) 
       //GET THE IDENTITY COLUMN FROM DB TO PASS TO THE NEXT PAGES FOR MORE INSERTS ON THE SAME COLUMN 
        window.open('ShoppingCart1.asp?pageID=2', '_self') 
        }
      }    

    xmlHttp.open("GET","../includes/Functions.asp?tempOrder=1&atStep=1&backorderCancellation="+backorderCancellation+"&bookProcessing="+bookProcessing+"&attached="+attached+"&promoCode="+promoCode, true);
    xmlHttp.send(null)

//window.open('ShoppingCart1.asp?pageID=2','_self') 

}

//FOR USE WITH THE WISHLIST, WE CAN MOVE THE ENTIRE LIST TO THE SHOPPING CART
function wishlistToShoppingCartAllItems()
{

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        //document.getElementById("table_wrap").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        window.open('https://secure.infobasepublishing.com/ShoppingCart/ShoppingCart1.asp', '_self') 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?allWishListItemsToCart=1", true);
    xmlHttp.send(null)

   }
  
  //FOR USE WITH THE WISHLIST, WE CAN MOVE A SINGLE ITEM TO THE SHOPPING CART
function wishlistToShoppingCartSingleItem(ISBN, Quantity)
{

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        //document.getElementById("table_wrap").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        window.open('https://secure.infobasepublishing.com/ShoppingCart/ShoppingCart1.asp', '_self') 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?singleWishListItemToCart=1&ISBN="+ISBN, true);
    xmlHttp.send(null)

   

}
   

//UPDATE SHIPPING INFO FROM SHOPPING CART PAGE 2
function updateShippingFromCart(institution, contactName, address1, address2, city, state, province, zip, country, phone, fax)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }

    xmlHttp.open("GET","../includes/Functions.asp?institution="+institution+"&contactName="+contactName+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&province="+province+"&zip="+zip+"&country="+country+"&phone="+phone+"&fax="+fax+"&updateShipping=1",true);
    xmlHttp.send(null);

}

//UPDATE BILLING INFO FROM SHOPPING CART PAGE 2
function updateBillingFromCart(institution, contactName, address1, address2, city, state, province, zip, country, phone, fax)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }

    xmlHttp.open("GET","../includes/Functions.asp?institution="+institution+"&contactName="+contactName+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&province="+province+"&zip="+zip+"&country="+country+"&phone="+phone+"&fax="+fax+"&updateBilling=1",true);
    xmlHttp.send(null);

}

//SEND DATA FROM ContactUs.asp?pageID=7 TO FUNCTIONS.ASP FOR PROCESSING
function requestenewsletter()
{

var Contact_Name =  document.enewsletter.Contact_Name.value
var Address = document.enewsletter.Address.value
var Title = document.enewsletter.Title.value
var City = document.enewsletter.City.value
var State= document.enewsletter.State.value
var Zip = document.enewsletter.Zip.value
var Country = document.enewsletter.Country.value
var Phone = document.enewsletter.Phone.value
var Fax =  document.enewsletter.Fax.value
var Email = document.enewsletter.Email.value
var Emailconfirm = document.enewsletter.Emailconfirm.value
var Institution = document.enewsletter.Institution.value


if (Contact_Name == "") 
{
alert("Please fill in contact name. ")
return false;
}

if (Email == "") 
{
alert("Please fill in email. ")
return false;
}


if (Emailconfirm == "") 
{
alert("Please fill in confirmation email. ")
return false;
}


if (!Email.match("@") || !Email.match(".") )  
{
alert("Email is not in the correct format.")
return false;
}

if (!Emailconfirm.match("@") || !Emailconfirm.match(".") )  
{
alert("Confirmation email is not in the correct format.")
return false;
}

if (Emailconfirm != Email )  
{
alert("Confirmation email and email do not match.")
return false;
}

if (Address == "") 
{
alert("Please fill in address. ")
return false;
}
 
if (City == "") 
{
alert("Please fill in city. ")
return false;
}
 
if (State == "") 
{
alert("Please fill in state. ")
return false;
}
 
if (Zip == "") 
{
alert("Please fill in zip. ")
return false;
}

if (Country == "") 
{
alert("Please fill in country. ")
return false;
}

//        for (i=0;  i < document.enewsletter.INST_Type.length; i++)
//        { 
//            if (document.enewsletter.INST_Type[i].checked) 
//               { 
//                 var INST_Type = document.enewsletter.INST_Type[i].value            
//            }
//        }     

var INST_Type = document.enewsletter.INST_Type.options[document.enewsletter.INST_Type.selectedIndex].value;     

//AJAX REQUEST

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("two").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?Contact_Name="+Contact_Name+"&Address="+Address+"&City="+City+"&State="+State+"&Zip="+Zip+"&Country="+Country+"&Title="+Title+"&Phone="+Phone+"&Fax="+Fax+"&Email="+Email+"&enewsletter=1", true);
    xmlHttp.send(null);      

}

//SEND DATA FROM ContactUs.asp?pageID=6 TO FUNCTIONS.ASP FOR PROCESSING
function requestCatalog()
{

var Reference, OnlineDatabases, CareerEducation, ChelseaHouse, Blooms, Clubhouse

//SEE WHICH CATALOGS USER SELECTED, IF THEY SELECTED ANY
if (document.getElementById("Reference").checked  == true )
    {
        Reference = 1;
    }  
else
    {
        Reference = 0;
    }
   
  if (document.getElementById("OnlineDatabases").checked  == true )
    {
        OnlineDatabases = 1;
    }  
else
    {
        OnlineDatabases = 0;
    }    
   
  if (document.getElementById("CareerEducation").checked  == true )
    {
        CareerEducation = 1;
    }  
else
    {
        CareerEducation = 0;
    }    
   
  if (document.getElementById("ChelseaHouse").checked  == true )
    {
        ChelseaHouse = 1;
    }  
else
    {
        ChelseaHouse = 0;
    }    
   
  if (document.getElementById("Blooms").checked  == true )
    {
        Blooms = 1;
    }  
else
    {
        Blooms = 0;
    }    
   
  if (document.getElementById("Clubhouse").checked  == true )
    {
        Clubhouse = 1;
    }  
else
    {
        Clubhouse = 0;
    }   

var companyName =  document.reqCat.R_COMPANYNAME.value
var address = document.reqCat.R_Address.value
var city = document.reqCat.R_CITY.value
var state

if (document.reqCat.R_STATE.selectedIndex == 0)
{
    alert("Please select a state.");
      return false; 
}


state = document.reqCat.R_STATE.options[document.reqCat.R_STATE.selectedIndex].value;
var zipcode = document.reqCat.R_ZIPCODE.value
var country = document.reqCat.R_COUNTRY.value
var contactName = document.reqCat.R_CONTACTNAME.value
var title = document.reqCat.R_TITLE.value
var phone = document.reqCat.R_PHONE.value
var fax =  document.reqCat.R_FAX.value
var email = document.reqCat.R_EMAIL.value
var catalog1
var catalog2
var Permission

if (contactName == "") 
{
alert("Please fill in contact name. ")
return false;
}

if (address == "") 
{
alert("Please fill in address. ")
return false;
}
 
if (city == "") 
{
alert("Please fill in city. ")
return false;
}
 
if (state == "") 
{
alert("Please fill in state. ")
return false;
}
 
if (zipcode == "") 
{
alert("Please fill in zip. ")
return false;
}

if (country == "") 
{
alert("Please fill in country. ")
return false;
}

if (email == "") 
{
alert("Please fill in email. ")
return false;
}

if (!email.match("@") || !email.match(".") )  
{
alert("Email is not in the correct format.")
return false;
}

        for (i=0;  i < document.reqCat.organization.length; i++)
        { 
            if (document.reqCat.organization[i].checked) 
               { 
                 var organization = document.reqCat.organization[i].value
               }
            else
            {
            
            }
        }       
               
        //if (document.reqCat.catalog1.checked == 1)
        //{ 
        //     catalog1="Y"
        //}
       //else
       //{
       //      catalog1="N"
       //} 

         if (document.reqCat.catalog2.checked == 1)
        { 
             catalog2="Y"
        }
       else
       {
            catalog2="N"
       } 

         if (document.reqCat.Permission.checked == 1)
        { 
            Permission="Y"
        }
       else
       {
            Permission="N"
       } 
       
 var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("two").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?R_COMPANYNAME="+companyName+"&R_Address="+address+"&R_CITY="+city+"&R_STATE="+state+"&R_ZIPCODE="+zipcode+"&R_COUNTRY="+country+"&R_CONTACTNAME="+contactName+"&R_TITLE="+title+"&R_PHONE="+phone+"&R_FAX="+fax+"&R_EMAIL="+email+"&catalog1="+catalog1+"&catalog2="+catalog2+"&Permission="+Permission+"&Reference="+Reference+"&OnlineDatabases="+OnlineDatabases+"&CareerEducation="+CareerEducation+"&ChelseaHouse="+ChelseaHouse+"&Blooms="+Blooms+"&Clubhouse="+ Clubhouse+"&reqCat=1", true);
    xmlHttp.send(null);      

}

//CHECK SHIPPING AND BILLING INFO FORMS WITHIN SHOPPING CART
function BillingShippingInfoValidation()
{

      if (!document.shippingInfo.contactName.value || !document.shippingInfo.address1.value || !document.shippingInfo.city.value || !document.shippingInfo.zip.value || !document.shippingInfo.country.value || !document.shippingInfo.phone.value)
        {
              document.getElementById("shippingErrorCart").innerHTML = "Please fill in all required fields"
              return false; 
       } 

      if (!document.billingInfo.contactName.value || !document.billingInfo.address1.value || !document.billingInfo.city.value || !document.billingInfo.zip.value || !document.billingInfo.country.value || !document.billingInfo.phone.value)
        {
          document.getElementById("billingErrorCart").innerHTML = "Please fill in all required fields"
          return false; 
        } 

        //SEND OFF AJAX REQUEST TO FUNCTIONS.ASP TO ADD USER TO NEWSLETTER IF SELECTED
        if(document.getElementById("newsletterSignup").checked == true)
        {
        var xmlHttp;
          try
            {
            // Firefox, Opera 8.0+, Safari
            xmlHttp=new XMLHttpRequest();
            }
          catch (e)
            {
            // Internet Explorer
            try
              {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
              }
            catch (e)
              {
              try
                {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
              catch (e)
                {
                alert("Your browser does not support AJAX!");
                return false;
                }
              }
            }
           
            xmlHttp.open("GET","includes/Functions.asp?newsSignUp=1", true);
            xmlHttp.send(null);
        }

//LETS DUMP THE INFO FROM SHIPPING/BILLING FORMS WITHIN SHOPPING CART INTO DB, USER MAY HAVE CHANGED SOME INFORMATION
updateShippingFromCart(document.shippingInfo.institution.value, document.shippingInfo.contactName.value , document.shippingInfo.address1.value, document.shippingInfo.address2.value, document.shippingInfo.city.value, document.shippingInfo.state.options[document.shippingInfo.state.selectedIndex].value, document.shippingInfo.province.value, document.shippingInfo.zip.value,  document.shippingInfo.country.value, document.shippingInfo.phone.value, document.shippingInfo.fax.value)
updateBillingFromCart(document.billingInfo.institution.value, document.billingInfo.contactName.value , document.billingInfo.address1.value, document.billingInfo.address2.value, document.billingInfo.city.value, document.billingInfo.state.options[document.billingInfo.state.selectedIndex].value, document.billingInfo.province.value, document.billingInfo.zip.value,  document.billingInfo.country.value, document.billingInfo.phone.value, document.billingInfo.fax.value)

//PASSED VALIDATION, LETS GO TO THE NEXT PAGE
window.open('ShoppingCart1.asp?pageID=3','_self')
}


//DUMP ALL DATA FROM BILLING FORM INTO SHIPPING FORM, THIS IS OPTIONAL
function sameAsBilling() {
    //  if (document.SameAsBillform.SameAsBill.checked)
    //{
    // var temp;
    if (document.test.SameAsBill.checked) {

        // document.shippingInfo.accountNumber.value = document.billingInfo.accountNumber.value
        document.shippingInfo.institution.value = document.billingInfo.institution.value
        document.shippingInfo.contactName.value = document.billingInfo.contactName.value
        document.shippingInfo.address1.value = document.billingInfo.address1.value
        document.shippingInfo.address2.value = document.billingInfo.address2.value
        document.shippingInfo.city.value = document.billingInfo.city.value
        document.shippingInfo.province.value = document.billingInfo.province.value
        document.shippingInfo.zip.value = document.billingInfo.zip.value
        document.shippingInfo.country.value = document.billingInfo.country.value
        document.shippingInfo.phone.value = document.billingInfo.phone.value
        document.shippingInfo.fax.value = document.billingInfo.fax.value
        document.shippingInfo.state.value = document.billingInfo.state.options[document.billingInfo.state.selectedIndex].value

        //SEND BILLING INTO TO DB
        //updateBillingFromCart(document.billingInfo.institution.value, document.billingInfo.contactName.value , document.billingInfo.address1.value, document.billingInfo.address2.value, document.billingInfo.city.value, document.billingInfo.state.options[document.billingInfo.state.selectedIndex].value, document.billingInfo.province.value, document.billingInfo.zip.value,  document.billingInfo.country.value, document.billingInfo.phone.value, document.billingInfo.fax.value)

    }
    else {
        //  document.shippingInfo.accountNumber.value = "";
        document.shippingInfo.institution.value = "";
        document.shippingInfo.contactName.value = "";
        document.shippingInfo.address1.value = "";
        document.shippingInfo.address2.value = "";
        document.shippingInfo.city.value = "";
        document.shippingInfo.province.value = "";
        document.shippingInfo.zip.value = "";
        document.shippingInfo.country.value = 1;
        document.shippingInfo.phone.value = "";
        document.shippingInfo.fax.value = "";
        document.shippingInfo.state.value = document.billingInfo.state.options[document.billingInfo.state.selectedIndex].value

    }

}

//AJAX REQUEST TO SEND AND GRAB UPDATES SHIPPING INFORMATION
function shippingInfoUpdate(institution, contactName, address1, address2, city, state, province, zip, country, phone, fax)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("shippingError").innerHTML=xmlHttp.responseText;
       // alert(xmlHttp.responseText) 
        }
      }

    xmlHttp.open("GET","includes/Functions.asp?institution="+institution+"&contactName="+contactName+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&province="+province+"&zip="+zip+"&country="+country+"&phone="+phone+"&fax="+fax+"&updateShipping=1",true);
    xmlHttp.send(null);


}

//AJAX REQUESR TO SEND AND RECIEVE UPDATED BILLING INFORMATION
function billingInfoUpdate(institution, contactName, address1, address2, city, state, province, zip, country, phone, fax)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("billingError").innerHTML=xmlHttp.responseText;
       // alert(xmlHttp.responseText) 
        }
      }

    xmlHttp.open("GET","includes/Functions.asp?institution="+institution+"&contactName="+contactName+"&address1="+address1+"&address2="+address2+"&city="+city+"&state="+state+"&province="+province+"&zip="+zip+"&country="+country+"&phone="+phone+"&fax="+fax+"&updateBilling=1",true);
    xmlHttp.send(null);


}

//IF VALIDATION PASSES, SEND AJAX REQUEST AND DISPLAY UPDATED SHIPPING INFORMATION
function shippingValidation()
{

      if (!document.shippingInfo.contactName.value || !document.shippingInfo.address1.value || !document.shippingInfo.city.value || !document.shippingInfo.zip.value || !document.shippingInfo.country.value || !document.shippingInfo.phone.value)
        {
              document.getElementById("shippingError").innerHTML = "Please fill in all required fields"
              return false; 
       } 

// ONCE DATA PASSES VALIDATION, WE NEED TO SEND ALL THE VARIABLES TO THE SHIPPING INFO AJAX FUNCTION
shippingInfoUpdate(document.shippingInfo.institution.value, document.shippingInfo.contactName.value, document.shippingInfo.address1.value, document.shippingInfo.address2.value, document.shippingInfo.city.value, document.shippingInfo.state.options[document.shippingInfo.state.selectedIndex].value ,document.shippingInfo.province.value, document.shippingInfo.zip.value, document.shippingInfo.country.value, document.shippingInfo.phone.value, document.shippingInfo.fax.value);

}

//IF VALIDATION PASSES, SEND AJAX REQUEST AND DISPLAY UPDATED BILLING INFORMATION
function billingValidation()
{

      if (!document.billingInfo.contactName.value || !document.billingInfo.address1.value || !document.billingInfo.city.value || !document.billingInfo.zip.value || !document.billingInfo.country.value || !document.billingInfo.phone.value)
        {
              document.getElementById("billingError").innerHTML = "Please fill in all required fields"
              return false; 
       } 

billingInfoUpdate(document.billingInfo.institution.value, document.billingInfo.contactName.value, document.billingInfo.address1.value, document.billingInfo.address2.value, document.billingInfo.city.value, document.billingInfo.state.options[document.billingInfo.state.selectedIndex].value ,document.billingInfo.province.value, document.billingInfo.zip.value, document.billingInfo.country.value, document.billingInfo.phone.value, document.billingInfo.fax.value);

}

//MOVE ANY ITEM FROM TO SHOPPING CART
function moveToCart(ISBN, GUID)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
    xmlHttp.open("GET","/includes/Functions.asp?ISBN="+ISBN+"&GUID="+GUID+"&moveToCart=1", true);
    xmlHttp.send(null);

}

//PASSWORD VALIDATION FORM ON MyAccountHome.asp
function updatePasswordValidation(password, GUID)
{

     if (!document.updatePassword.confirmCurrentPassword.value || !document.updatePassword.newPassword.value || !document.updatePassword.confirmNewPassword.value)  
     {
        //        document.getElementById("emptyPassword").innerHTML = "Please fill in all fields";
        //        document.getElementById("confirmPassword").innerHTML = "";  
        //        document.getElementById("newPassword").innerHTML = ""; 
        alert("Please fill in all fields");
        return false; 
     }     

    if(document.updatePassword.confirmCurrentPassword.value != password)
        {
            //            document.getElementById("emptyPassword").innerHTML = "";  
            //            document.getElementById("confirmPassword").innerHTML = "Your password does not match the current password";
            //            document.getElementById("newPassword").innerHTML = "";
            alert("Your password does not match the current password");
            return false;
       }  

    if(document.updatePassword.confirmNewPassword.value != document.updatePassword.newPassword.value)
    {
        //         document.getElementById("emptyPassword").innerHTML = ""; 
        //         document.getElementById("confirmPassword").innerHTML = ""; 
        //         document.getElementById("newPassword").innerHTML = "New and confirm new password do not match";
        alert("New and confirm new password do not match");
        return false; 
    }   
    
//document.getElementById("emptyPassword").innerHTML = ""; 
//document.getElementById("confirmPassword").innerHTML = ""; 
//document.getElementById("newPassword").innerHTML = "";    
    
//PASSED ALL VALIDATION, SET THE NEW PASSWORD    
password = document.updatePassword.confirmNewPassword.value
updateUserPassword(password, GUID); 

}

//AJAX TO UPDATE USER PASSWORD

function updateUserPassword(password, GUID)
{

var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("successPassword").innerHTML=xmlHttp.responseText;
       // alert(xmlHttp.responseText) 
        }
      }

    xmlHttp.open("GET","includes/Functions.asp?Password="+password+"&GUID="+GUID+"&updatePassword=1",true);
    xmlHttp.send(null);

}

function validateLogin()
{        

var emailAddress = document.login.email.value;

	if (!document.login.email.value)       
		{
		//alert("Please enter your email address.");         
		document.getElementById("loginEmail").innerHTML = "Please enter your email address"
		document.getElementById("loginEmailMatch").innerHTML = ""
		document.getElementById("loginPassword").innerHTML = ""
	    return false;         
        }
       
       	if (!emailAddress.match("@") || !emailAddress.match(".") )       
		{
		//alert("Your Email address is not in the correct format.");       
		document.getElementById("loginEmail").innerHTML = ""
		document.getElementById("loginEmailMatch").innerHTML = "Email is not in the correct format"
		document.getElementById("loginPassword").innerHTML = ""
	    return false;         
        } 
       
     	if (!document.login.password.value)       
		{
		//alert("Please enter a password.");     
		document.getElementById("loginEmail").innerHTML = ""
		document.getElementById("loginEmailMatch").innerHTML = ""    
		document.getElementById("loginPassword").innerHTML = "Please enter a password"
	    return false;         
        } 
	
     document.login.submit();

}

function forgotYourPassword()
{

var emailAddress = document.forgotPassword.email.value;

        if (!emailAddress)
       {
       
       document.getElementById("forgotEmail").innerHTML = "Please enter your email address"
       return false;
       }

       	if (!emailAddress.match("@") || !emailAddress.match("."))       
		{
	    document.getElementById("forgotEmail").innerHTML = "Email address is in incorrect format<br>"
	    //document.getElementById("passwordSent").innerHTML = ""
	    //document.getElementById("notExist").innerHTML = "" 
	    return false;         
        } 
       
     document.getElementById("forgotEmail").innerHTML = ""
     document.forgotPassword.submit();
 
}

function clearSignUp()
{
//document.signUp.email.value  = "";
//document.signUp.password.value  = "";
//document.signUp.passwordConfirm.value  = "";
window.location.reload();
}

function validateSignUpLogin()
{

var emailAddress = document.signUp.email.value;

	if (!document.signUp.email.value)       
		{
		//alert("Please enter your email address.");         
	    //document.getElementById("emailError1").style.visibility="visible";
	    document.getElementById("emailError2").innerHTML = "" 
	    document.getElementById("emailError1").innerHTML = "Please enter your email address"
	    return false;         
        }
       
       	if (!emailAddress.match("@") || !emailAddress.match("."))       
		{
		//alert("Your Email address is not in the correct format.");         
	    document.getElementById("emailError1").innerHTML = ""
	    document.getElementById("emailError2").innerHTML = "Email address is in incorrect format"
	    return false;         
        } 
       
     	if (!document.signUp.password.value)       
		{
		//alert("Please enter a password.");    
		document.getElementById("emailError1").innerHTML = ""
	    document.getElementById("emailError2").innerHTML = ""
		
		document.getElementById("password3").innerHTML = ""      
		document.getElementById("password2").innerHTML = "" 
	    document.getElementById("password1").innerHTML = "Please enter a password"
	    return false;         
        } 
	
	    if (!document.signUp.passwordConfirm.value)       
		{
		document.getElementById("emailError1").innerHTML = ""
	    document.getElementById("emailError2").innerHTML = ""
		//alert("Please confirm your password.");         
	    //document.getElementById("password2").style.visibility="visible";  
	    document.getElementById("password1").innerHTML = ""  
	    document.getElementById("password2").innerHTML = "Please confirm your password<br><br>"  
	    document.getElementById("password3").innerHTML = ""   
	    return false;         
        } 
       
        if (document.signUp.password.value != document.signUp.passwordConfirm.value)       
		{
		document.getElementById("emailError1").innerHTML = ""
	    document.getElementById("emailError2").innerHTML = ""
		
		 document.getElementById("password1").innerHTML = ""  
		 document.getElementById("password2").innerHTML = ""  
		 document.getElementById("password3").innerHTML = "Passwords do not match, try again<br><br>"  
		//document.getElementById("password3").style.visibility="visible"; 
		//alert("Your password does not match, please try again.");         
	    return false;         
        }  
	
     document.signUp.submit();

}

function IsNumeric(sText)

{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function quantityForm(quantityNum, i, ISBN, GUID) 
{

 if (!IsNumeric(document.getElementById("quantityNum"+i).value)) 
   { 
      alert('Please enter only numbers in this field') 
      //document.getElementById("quantityNum"+i).focus(); 
      return false; 
      } 

 //IF USER ENTERS NUMBER, THEN WE CALL ALL THE CORRECT FUNCTIONS
updateWishListItem(ISBN, GUID, i); 
countWishListItems(GUID); 
updateSubTotal(ISBN, GUID);
 
return true;

}

function quantityFormShoppingCart(quantityNum, i, ISBN, GUID) 
{

 if (!IsNumeric(document.getElementById("quantityNumCart"+i).value)) 
   { 
      alert('Please enter only numbers in this field') 
      document.getElementById("quantityNum"+i).focus(); 
      return false; 
      } 

 //IF USER ENTERS NUMBER, THEN WE CALL ALL THE CORRECT FUNCTIONS

//updateItem(ISBN, GUID, i); 
//countWishListItems(GUID); 
//updateSubTotal(ISBN, GUID);

updateShoppingCartItem(ISBN, GUID, i); 
updateShoppingCartSubTotal(ISBN, GUID);
 
return true;

}

function validateSearch()
{        
//TRIM OFF WHITE SPACE, IT WILL MAKE SEARCH FAIL
var trimmedString = document.searchForm.searchText.value.replace(/(^\s*|\s*$)/, "");
//var regex= /^[0-9a-zA-Z\s]+$/;
//var match = regex.test(document.searchForm.searchText.value);
     
	if (!trimmedString)      
		{
		alert("Please enter search term(s).");         
	    return false;          
        }
       
     //CHECK SQL NOISE WORDS  
      if(NoiseWords(trimmedString)==1)
     {
        alert("That search term is not allowed.")
        return false;
     }      
	
     document.searchForm.submit();
}

function NoiseWords(trimmedString)
{

str = trimmedString.toLowerCase()
var noisewords = new Array ("1",  "2",  "3", "4", "5" , "6",  "7", "8", "9", "0", "$", "!", "@", "#", "$", "%", "^", "&", "*", "(",  ")",  "-" , "_" , "+" , "=" , "[ " , "]" , "{", "}", "about", "after", "all", "also", "an", "and", "another", "any", "are", "as", "at", "be", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could" ,"did", "do", "does", "each", "else", "for", "from", "get", "got", "has" ,"had", "he", "have" ,"her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "its" ,"just", "like", "make",  "many", "me", "might", "more", "most", "much", "must",  "my", "never",  "now", "of", "on", "only", "or", "other", "our" ,"out", "over", "re", "said", "same", "see", "should", "since" ,"so", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this" ,"those" , "through", "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", "well", "were",  "what", "when", "where", "which", "while", "who" ,"will", "with", "would", "you", "your" ,"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

for (i=0; i<noisewords.length; i++) 
{
    //IF TERM USER ENTERED MATCHES WHATS IN THE ARRAY, SEND A FLAG BACK TO STOP SEARCH EXECUTION
    if(str==noisewords[i])
   {
       noisefound = 1;
       return (noisefound); 
   }   
}

}

//AJAX TO DELETE ITEM FROM WISHLIST
function deleteWishListItem(ISBN, GUID, deleteAll)
{
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("table_wrap").innerHTML=xmlHttp.responseText;
       // alert(xmlHttp.responseText) 
        }
      }

    xmlHttp.open("GET","includes/Functions.asp?ISBN="+ISBN+"&GUID="+GUID+"&deleteItem=1",true);
    xmlHttp.send(null);
    }    function deleteShoppingCartItem(ISBN, GUID)
{
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("table_wrap").innerHTML=xmlHttp.responseText;
       // alert(xmlHttp.responseText) 
        }
      }

    xmlHttp.open("GET","../includes/Functions.asp?ISBN="+ISBN+"&GUID="+GUID+"&deleteShoppingCartItem=1",true);
    xmlHttp.send(null);
    }  //AJAX TO COUNT ITEMS FROM WISHLIST    function countWishListItems(GUID){  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("wishListCount").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }
    xmlHttp.open("GET","includes/Functions.asp?GUID="+GUID+"&countItems=1",true);
    xmlHttp.send(null);}//AJAX TO ADD ITEM FROM WISHLIST  function addToWishList(ISBN)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }

    xmlHttp.open("GET","includes/Functions.asp?ISBN="+ISBN+"&insert=1", true);
    xmlHttp.send(null);
  }function updateWishListItem(ISBN, GUID, i){ var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("totalPrice"+i).innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    //get the number entered into the quantity field
    var quantity = document.getElementById("quantityNum"+i).value
   
if (quantity == 0) //delete item
{

    deleteWishListItem(ISBN, GUID)

}   
else
{
    xmlHttp.open("GET","includes/Functions.asp?GUID="+GUID+"&ISBN="+ISBN+"&Quantity="+quantity+"&updatePrice=1", true);
    xmlHttp.send(null);}}function updateShoppingCartItem(ISBN, GUID, i){ var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("totalPriceCart"+i).innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    //get the number entered into the quantity field
    var quantity = document.getElementById("quantityNumCart"+i).value
   
if (quantity == 0) //delete item
{

    deleteShoppingCartItem(ISBN, GUID)

}   
else
{
    xmlHttp.open("GET","../includes/Functions.asp?GUID="+GUID+"&ISBN="+ISBN+"&Quantity="+quantity+"&updateShoppingCartPrice=1", true);
    xmlHttp.send(null);}}function updateSubTotal(ISBN, GUID){ var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("right_flush").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?GUID="+GUID+"&ISBN="+ISBN+"&updateTotal=1", true);
    xmlHttp.send(null);}function updateShoppingCartSubTotal(ISBN, GUID){ var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("right_flush").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    xmlHttp.open("GET","../includes/Functions.asp?GUID="+GUID+"&ISBN="+ISBN+"&updateShoppingCartTotal=1", true);
    xmlHttp.send(null);}function deleteAllItems(GUID){ var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
   
   xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("table_wrap").innerHTML=xmlHttp.responseText;
        //alert(xmlHttp.responseText) 
        }
      }    

    xmlHttp.open("GET","includes/Functions.asp?GUID="+GUID+"&deleteAll=1", true);
    xmlHttp.send(null);}