// JavaScript Documentfunction bizdir_add_listing(dbtype) { //Add Form Ajax Call	//Deactivate submit button and display processing message	document.getElementById('bizdir_submit').disabled = true;	var checkboxes = document.getElementById('bizdir_add_form').category;		for(var count=0;count<checkboxes.length;count++){		if(checkboxes[count].checked == true)			checkboxes[count].value = 1;						}			var submit_message = document.getElementById('bizdir_submit_message')	submit_message.className = "bizdir_message";	submit_message.innerHTML = "Submitting Form, Please Wait...";	//Clear inputs with Auto Text	var all_inputs = document.getElementsByTagName('input');	for(var j=0;j<all_inputs.length;j++)		bizdir_clearAutofill(all_inputs[j].id,all_inputs[j].getAttribute('bizdir_autofill'));	var all_textareas = document.getElementsByTagName('textarea');									for(var i=0;i<all_textareas.length;i++)		bizdir_clearAutofill(all_textareas[i].id,all_textareas[i].getAttribute('bizdir_autofill'));	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","AddListing");	mysack.setVar("dbtype",dbtype);	mysack.setVar("cName",document.getElementById("bizdir_cName").value);	mysack.setVar("profile",document.getElementById("bizdir_profile").value);	mysack.setVar("phone",document.getElementById("bizdir_phone").value);	if(dbtype == "licensing"){		mysack.setVar("website",document.getElementById("bizdir_website").value);		mysack.setVar("cEmail",document.getElementById("bizdir_cEmail").value);			mysack.setVar("fax",document.getElementById("bizdir_fax").value);		mysack.setVar("street1",document.getElementById("bizdir_street1").value);		mysack.setVar("street2",document.getElementById("bizdir_street2").value);		mysack.setVar("city",document.getElementById("bizdir_city").value);		mysack.setVar("county",document.getElementById("bizdir_county").value);		mysack.setVar("zip",document.getElementById("bizdir_zip").value);		mysack.setVar("country",document.getElementById("bizdir_country").value);		mysack.setVar("first_name",document.getElementById("bizdir_first_name").value);		mysack.setVar("first_jobtitle",document.getElementById("bizdir_first_jobtitle").value);		mysack.setVar("first_email",document.getElementById("bizdir_first_email").value);		mysack.setVar("first_mobile",document.getElementById("bizdir_first_mobile").value);		mysack.setVar("second_name",document.getElementById("bizdir_second_name").value);		mysack.setVar("second_jobtitle",document.getElementById("bizdir_second_jobtitle").value);		mysack.setVar("second_email",document.getElementById("bizdir_second_email").value);		mysack.setVar("second_mobile",document.getElementById("bizdir_second_mobile").value);		mysack.setVar("licensee", checkboxes[0].value);		mysack.setVar("licensor", checkboxes[1].value);		mysack.setVar("support", checkboxes[2].value);		mysack.setVar("subcategory",document.getElementById("bizdir_subcategory").value);		mysack.setVar("products",document.getElementById("bizdir_products").value);		mysack.setVar("properties",document.getElementById("bizdir_properties").value);		mysack.setVar("licenses",document.getElementById("bizdir_licenses").value);	}	if(dbtype == "retail"){		mysack.setVar("address",document.getElementById("bizdir_address").value);		mysack.setVar("contacts",document.getElementById("bizdir_contacts").value);		}	mysack.onError = function() { //alert('An ajax error occured while adding your listing. Please reload the page and try again.') 	};	//alert('hi');	mysack.runAJAX();//excecute	return true;}function bizdir_search_listings(dbtype) { //Search Ajax Call					var search_term = document.getElementById('bizdir_search_term');	var search_company = document.getElementById('bizdir_search_company');	var search_category = document.getElementById('bizdir_search_category');	var search_country = document.getElementById('bizdir_search_country');	var search_name = document.getElementById('bizdir_search_name');	var search_subcat = document.getElementById('bizdir_search_subcat');	var search_property = document.getElementById('bizdir_search_property');	if((search_term.value == "" || search_term.value == null)&&(search_company.value == "" || search_company.value == null)&&(search_category.value == "" || search_category.value == null)&&(search_country.value == "" || search_country.value == null)&&(search_name.value == "" || search_name.value == null)&&(search_subcat.value == "" || search_subcat.value == null)&&(search_property.value == "" || search_property.value == null))		return;					//Deactivate submit button and display processing message	document.getElementById('bizdir_search').disabled = true;	var submit_message = document.getElementById('bizdir_messages');	submit_message.className = "bizdir_message";	submit_message.innerHTML = "Searching Listings, Please Wait...";	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","SearchListings");	mysack.setVar("dbtype",dbtype);	mysack.setVar("searchTerms",search_term.value);	mysack.setVar("searchCompany",search_company.value);	mysack.setVar("searchCategory",search_category.value);	mysack.setVar("searchCountry",search_country.value);	mysack.setVar("searchName",search_name.value);	mysack.setVar("searchSubcat",search_subcat.value);	mysack.setVar("searchProperty",search_property.value);					//mysack.onError = function() { alert('An ajax error occured while searching. Please reload the page and try again...') };	mysack.runAJAX();//excecute	return true;}function bizdir_change_listings_page(searchTerms,searchCompany,searchCategory,searchCountry,searchName,searchSubcat,searchProperty,offset,dbtype,letter) { //Jump to the appropriate page in the directory Ajax Call	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","ChangePage");	mysack.setVar("offset",offset);	mysack.setVar("dbtype",dbtype);	if(searchTerms != null)		mysack.setVar("searchTerms",searchTerms);	if(searchCompany != null)		mysack.setVar("searchCompany",searchCompany);	if(searchCategory != null)		mysack.setVar("searchCategory",searchCategory);	if(searchCountry != null)		mysack.setVar("searchCountry",searchCountry);	if(searchName != null)		mysack.setVar("searchName",searchName);	if(searchSubcat != null)		mysack.setVar("searchSubcat",searchSubcat);	if(searchProperty != null)		mysack.setVar("searchProperty",searchProperty);	if (letter != null)		mysack.setVar("letter",letter);	//mysack.onError = function() { alert('An ajax error occured!! Please reload the page and try again.') };	mysack.runAJAX();//excecute	return true;}function bizdir_find_listing(dbtype) {	var uniqueID = document.getElementById('unique_id');	var listingID = document.getElementById('listing_id');	if((uniqueID.value == "" || uniqueID.value == null) || (listingID.value == "" || listingID.value == null))											return;					document.getElementById('bizdir_find_btn').disabled = true;	var submit_message = document.getElementById('bizdir_messages');	submit_message.className = "bizdir_message";	submit_message.innerHTML = "Getting Listing, Please Wait...";	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","UpdateListing");	mysack.setVar("dbtype",dbtype);	mysack.setVar("uniqueID",uniqueID.value);	mysack.setVar("listingID", listingID.value);	//mysack.onError = function() { alert('An ajax error occured. Please reload the page and try again.') };	mysack.runAJAX();//excecute	return true;}function bizdir_pending_update() {				//Disable buttons and display message					document.getElementById('bizdir_pending_update').disabled = true;				document.getElementById('bizdir_cancel').disabled = true;	var submit_message = document.getElementById('bizdir_submit_message')	submit_message.className = "bizdir_message";	submit_message.innerHTML = "Submitting update...";	var dbtype = document.getElementById('bizdir_dbtype');	if(dbtype.value == 'licensing'){		var checkboxes = document.getElementById('bizdir_add_form').category;			for(var count=0;count<checkboxes.length;count++){			if(checkboxes[count].checked == true)				checkboxes[count].value = 1;							}	}	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","PendingUpdate");	mysack.setVar("dbtype",document.getElementById("bizdir_dbtype").value);	mysack.setVar("listing_id",document.getElementById("bizdir_listing_id").value);	mysack.setVar("unique_id",document.getElementById("bizdir_unique_id").value);	mysack.setVar("cName",document.getElementById("bizdir_cName").value);	mysack.setVar("profile",document.getElementById("bizdir_profile").value);					mysack.setVar("phone",document.getElementById("bizdir_phone").value);	if(dbtype.value == 'licensing'){		mysack.setVar("website",document.getElementById("bizdir_website").value);		mysack.setVar("cEmail",document.getElementById("bizdir_cEmail").value);				mysack.setVar("fax",document.getElementById("bizdir_fax").value);		mysack.setVar("street1",document.getElementById("bizdir_street1").value);		mysack.setVar("street2",document.getElementById("bizdir_street2").value);		mysack.setVar("city",document.getElementById("bizdir_city").value);		mysack.setVar("county",document.getElementById("bizdir_county").value);		mysack.setVar("zip",document.getElementById("bizdir_zip").value);		mysack.setVar("country",document.getElementById("bizdir_country").value);		mysack.setVar("first_name",document.getElementById("bizdir_first_name").value);		mysack.setVar("first_jobtitle",document.getElementById("bizdir_first_jobtitle").value);		mysack.setVar("first_email",document.getElementById("bizdir_first_email").value);		mysack.setVar("first_mobile",document.getElementById("bizdir_first_mobile").value);		mysack.setVar("second_name",document.getElementById("bizdir_second_name").value);		mysack.setVar("second_jobtitle",document.getElementById("bizdir_second_jobtitle").value);		mysack.setVar("second_email",document.getElementById("bizdir_second_email").value);		mysack.setVar("second_mobile",document.getElementById("bizdir_second_mobile").value);						mysack.setVar("licensee", checkboxes[0].value);		mysack.setVar("licensor", checkboxes[1].value);		mysack.setVar("support", checkboxes[2].value);		mysack.setVar("subcategory",document.getElementById("bizdir_subcategory").value);		mysack.setVar("products",document.getElementById("bizdir_products").value);		mysack.setVar("properties",document.getElementById("bizdir_properties").value);		mysack.setVar("licenses",document.getElementById("bizdir_licenses").value);					}	if(dbtype.value == 'retail'){		mysack.setVar("address",document.getElementById("bizdir_address").value);		mysack.setVar("contacts",document.getElementById("bizdir_contacts").value);		}	mysack.onError = function() { //alert('An ajax error occured while updating the listing. Please reload the page and try again.') 	};	mysack.runAJAX();//excecute	return true;			}function bizdir_cancel_update() {	clearMessage();	//Build SACK Call	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = 'POST';	mysack.setVar("action","CancelUpdate");	mysack.onError = function() { //alert('An ajax error occured while processing your request. Please reload the page and try again.') 	};	mysack.runAJAX();//excecute	return true;}function filter_by_letter(letter, offset) {	var submit_message = document.getElementById('bizdir_messages');	submit_message.className = "bizdir_message";	submit_message.innerHTML = "Filtering Listings, Please Wait...";	//		var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = "POST";	mysack.setVar("action","FilterRetail");	mysack.setVar("letter",letter);	mysack.setVar("offset",offset);	mysack.onError = function() { //alert('An ajax error occured while processing your request. Please reload the page and try again.') 	};	mysack.runAJAX();//excecute	return true;	}function add_to_cart(product, price){	var cart_msg = document.getElementById('cart_msg');	cart_msg.innerHTML = "Adding to cart...";	document.getElementById('add_cart_button').disabled = true;	//	var mysack = new sack();	mysack.requestFile = "/wp-content/plugins/business-directory/requests.php";	mysack.execute = 1;	mysack.method = "POST";	mysack.setVar("action","AddToCart");	mysack.setVar("product",product);	mysack.setVar("price",price);	mysack.setVar("quantity",document.getElementById('product_quantity').value);	mysack.onError = function() { //alert('An ajax error occured while processing your request. Please reload the page and try again.') 	};	mysack.runAJAX();//excecute	return true;}