function checkbox_chk(x)
{ 
	var tag = ""
	tag = "document.searchpage." + x
	
	if (eval(tag).checked)
	{
		eval(tag).value = 1;
		if (x == "offer_tags1")
		{
			document.searchpage.offer_tags2.checked = true
			document.searchpage.offer_tags3.checked = true
			document.searchpage.offer_tags4.checked = true
			document.searchpage.offer_tags5.checked = true
			document.searchpage.offer_tags6.checked = true
			document.searchpage.offer_tags7.checked = true
			document.searchpage.offer_tags8.checked = true
			document.searchpage.offer_tags9.checked = true
			document.searchpage.offer_tags10.checked = true
			document.searchpage.offer_tags11.checked = true
			document.searchpage.offer_tags12.checked = true
			document.searchpage.offer_tags13.checked = true
			document.searchpage.offer_tags14.checked = true
			document.searchpage.offer_tags15.checked = true
		}
	}
	else
	{
		eval(tag).value = 2;
		if (x == "offer_tags1")
		{
			document.searchpage.offer_tags2.checked = false
			document.searchpage.offer_tags3.checked = false
			document.searchpage.offer_tags4.checked = false
			document.searchpage.offer_tags5.checked = false
			document.searchpage.offer_tags6.checked = false
			document.searchpage.offer_tags7.checked = false
			document.searchpage.offer_tags8.checked = false
			document.searchpage.offer_tags9.checked = false
			document.searchpage.offer_tags10.checked = false
			document.searchpage.offer_tags11.checked = false
			document.searchpage.offer_tags12.checked = false
			document.searchpage.offer_tags13.checked = false
			document.searchpage.offer_tags14.checked = false
			document.searchpage.offer_tags15.checked = false
		}
	}
	
}

function update_city(theForm)
{
  var SelectedCity = "";
  SelectedCity = theForm.shipping_city.options[theForm.shipping_city.selectedIndex].value;
  
  theForm.billing_city.selectedIndex = theForm.shipping_city.selectedIndex;
  
 
  if(theForm.shipping_city.options[theForm.shipping_city.selectedIndex].value == 'Other')
  {  
  	theForm.shipping_city_other.style.visibility = 'visible';
	
 	theForm.billing_city_other.style.visibility = 'visible';
	
	theForm.billing_cnt.value = theForm.no_of_books.value;
  }
  else
  {   
    theForm.shipping_city_other.style.visibility = 'hidden'; // clear both text boxes values 
    theForm.shipping_city_other.value = '';  // and hide them
	
    theForm.billing_city_other.style.visibility = 'hidden'; // clear both text boxes values 
	theForm.billing_city_other.value = '';
	
	theForm.billing_cnt.value = 0;
  }
  
  cal_price();
}


function update_profession(theForm)
{
  var SelectedProfession = "";
  SelectedProfession = theForm.shipping_profession.options[theForm.shipping_profession.selectedIndex].value;
  
  theForm.billing_profession.selectedIndex = theForm.shipping_profession.selectedIndex;
  
 
  if(theForm.shipping_profession.options[theForm.shipping_profession.selectedIndex].value == 'Other')
  {  
  	theForm.shipping_profession_other.style.visibility = 'visible';
	
 	theForm.billing_profession_other.style.visibility = 'visible';
	
	//theForm.billing_cnt.value = theForm.no_of_books.value;
  }
  else
  {   
    theForm.shipping_profession_other.style.visibility = 'hidden'; // clear both text boxes values 
    theForm.shipping_profession_other.value = '';  // and hide them
	
    theForm.billing_profession_other.style.visibility = 'hidden'; // clear both text boxes values 
	theForm.billing_profession_other.value = '';
	
	//theForm.billing_cnt.value = 0;
  }
  
  cal_price();
}

//function update_gender(theForm)
//{
//  var SelectedGender = "";
//  SelectedGender = theForm.shipping_gender.options[theForm.shipping_gender.selectedIndex].value;
//  
//  theForm.billing_gender.selectedIndex = theForm.shipping_gender.selectedIndex;
//   
//  cal_price();
//}


function change_profession(theForm)
{
  var SelectedProfession = "";
  SelectedProfession = theForm.profession.options[theForm.try_profession.selectedIndex].value;
  
  //theForm.bills_profession.selectedIndex = theForm.try_profession.selectedIndex;
  
 
  if(theForm.profession.options[theForm.try_profession.selectedIndex].value == 'Other')
  {  
  	theForm.try_profession_other.style.visibility = 'visible';
  }
  else
  {   
    theForm.try_profession_other.style.visibility = 'hidden'; // clear both text boxes values 
    theForm.try_profession_other.value = '';  // and hide them
  }
}


function update_state(theForm)
{ 
  var SelectedState = "";
  SelectedState = theForm.shipping_state.options[theForm.shipping_state.selectedIndex].value;
  
  if (theForm.bill_addr.checked)
	  theForm.billing_state.selectedIndex = theForm.shipping_state.selectedIndex;
 
  
}

function update_gender(theForm)
{ 
  var SelectedGender = "";
  SelectedGender = theForm.shipping_gender.options[theForm.shipping_gender.selectedIndex].value;
  
  if (theForm.bill_addr.checked)
	  theForm.billing_gender.selectedIndex = theForm.shipping_gender.selectedIndex;
 
  
}
function update_dd(theForm)
{ 
  var SelectedDd = "";
  SelectedDd = theForm.shipping_dd.options[theForm.shipping_dd.selectedIndex].value;
  
  if (theForm.bill_addr.checked)
	  theForm.billing_dd.selectedIndex = theForm.shipping_dd.selectedIndex;
 
  
}
function update_mm(theForm)
{ 
  var SelectedMm = "";
  SelectedMm = theForm.shipping_mm.options[theForm.shipping_mm.selectedIndex].value;
  
  if (theForm.bill_addr.checked)
	  theForm.billing_mm.selectedIndex = theForm.shipping_mm.selectedIndex;
 
  
}
function update_yy(theForm)
{ 
  var SelectedYy = "";
  SelectedYy = theForm.shipping_yy.options[theForm.shipping_yy.selectedIndex].value;
  
  if (theForm.bill_addr.checked)
	  theForm.billing_yy.selectedIndex = theForm.shipping_yy.selectedIndex;
 
  
}


function bill_addr_chk()
{ 	if (document.checkout.bill_addr.checked)
	{ 
		document.checkout.bill_addr.value = 1
		
		document.checkout.addr_chk.value = 1
		document.checkout.billing_fname.disabled = true;
		document.checkout.billing_lname.disabled = true;
//		document.checkout.billing_dob.disabled = true;
		document.checkout.billing_dd.disabled = true;
		document.checkout.billing_mm.disabled = true;
		document.checkout.billing_yy.disabled = true;
		document.checkout.billing_gender.disabled = true;
		document.checkout.billing_profession.disabled = true;
		document.checkout.billing_profession_other.disabled = true;
		document.checkout.billing_address.disabled = true;
		document.checkout.billing_city.disabled = true;
		document.checkout.billing_city_other.disabled = true;
		document.checkout.billing_state.disabled = true;
		document.checkout.billing_zip.disabled = true;
		document.checkout.billing_telephone.disabled = true;
		document.checkout.billing_email.disabled = true;
		
		document.checkout.billing_fname.value = document.checkout.shipping_fname.value
		document.checkout.billing_lname.value = document.checkout.shipping_lname.value
//		document.checkout.billing_dob.value = document.checkout.shipping_dob.value
		document.checkout.billing_dd.value = document.checkout.shipping_dd.value
		document.checkout.billing_mm.value = document.checkout.shipping_mm.value
		document.checkout.billing_yy.value = document.checkout.shipping_yy.value
		document.checkout.billing_gender.value = document.checkout.shipping_gender.value
		document.checkout.billing_profession.value = document.checkout.shipping_profession.value
		document.checkout.billing_profession_other.value = document.checkout.shipping_profession_other.value
		document.checkout.billing_address.value = document.checkout.shipping_address.value
		document.checkout.billing_city.value = document.checkout.shipping_city.value
		document.checkout.billing_city_other.value = document.checkout.shipping_city_other.value
		document.checkout.billing_state.value = document.checkout.shipping_state.value
		document.checkout.billing_zip.value = document.checkout.shipping_zip.value
		document.checkout.billing_telephone.value = document.checkout.shipping_telephone.value
		document.checkout.billing_email.value = document.checkout.shipping_email.value		
	}
	else
	{ 
		document.checkout.billing_fname.disabled = false;
		document.checkout.billing_lname.disabled = false;
		//document.checkout.billing_dob.disabled = false;
		document.checkout.billing_dd.disabled = false;
		document.checkout.billing_mm.disabled = false;
		document.checkout.billing_yy.disabled = false;
		document.checkout.billing_gender.disabled = false;
		document.checkout.billing_profession.disabled = false;	
		document.checkout.billing_profession_other.disabled = false;
		document.checkout.billing_address.disabled = false;
		document.checkout.billing_city.disabled = false;
		document.checkout.billing_city_other.disabled = false;
		document.checkout.billing_state.disabled = false;
		document.checkout.billing_telephone.disabled = false;
		document.checkout.billing_zip.disabled = false;
		document.checkout.billing_email.disabled = false;
		
		document.checkout.bill_addr.value = 2
		
		document.checkout.addr_chk.value = 2

		/*document.checkout.billing_fname.value = ""
		document.checkout.billing_lname.value = ""
		document.checkout.billing_address.value = ""
		document.checkout.billing_city.value = "New Delhi"
		document.checkout.billing_city_other.value = ""
		document.checkout.billing_state.value = ""
		document.checkout.billing_zip.value = ""
		document.checkout.billing_telephone.value = ""
		document.checkout.billing_email.value = ""		*/
		
	}
}


function update_field(x)
{
	field1 = "document.checkout.shipping_" + x;
	
	field2 = "document.checkout.billing_" + x;
	
	if(document.checkout.bill_addr.checked)
		eval(field2).value = eval(field1).value;
	
}



function removeNL(s) {
  /*
  ** Remove NewLine, CarriageReturn and Tab characters from a String
  **   s  string to be processed
  ** returns new string
  */
  r = "";
  for (i=0; i < s.length; i++) {
    if (s.charAt(i) != '\n' &&
        s.charAt(i) != '\r' &&
        s.charAt(i) != '\t') {
      r += s.charAt(i);
      }
    }
  return r;
  
  }


function get_stores()
{
		document.dealers.submitbtn.value = "Submit";
		document.dealers.submit();
}