var bwy_link_form_xml_http;


function sendLinkSuggestion(p_action, p_contact_name, p_contact_email, p_website_name, p_website_url, p_website_category_id, p_website_description) { 
	bwy_link_form_xml_http = sendLinkSuggestionHttpObject()
	if (bwy_link_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = _site_url + "_custom/_content/_links_suggest_form.php"
	var params = "action=" + p_action
	params += "&contact_name=" + urlencode(p_contact_name)
	params += "&contact_email=" + urlencode(p_contact_email)
	params += "&website_name=" + urlencode(p_website_name)
	params += "&website_url=" + urlencode(p_website_url)
	params += "&website_description=" + urlencode(p_website_description)
	params += "&website_category_id=" + p_website_category_id
	
	bwy_link_form_xml_http.onreadystatechange = sendLinkSuggestionStateChanged 
	bwy_link_form_xml_http.open("POST", url, true)
	bwy_link_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_link_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_link_form_xml_http.setRequestHeader("Connection", "close");
	bwy_link_form_xml_http.send(params);	
}

function sendLinkSuggestionStateChanged() {
	if (bwy_link_form_xml_http.readyState == 4 || bwy_link_form_xml_http.readyState == "complete") { 
		document.getElementById("div_link_suggest_form").innerHTML = bwy_link_form_xml_http.responseText 
	} 
	if (bwy_link_form_xml_http.readyState == 1 || bwy_link_form_xml_http.readyState == "Loading") { 
		document.getElementById("div_link_suggest_form").innerHTML = "<div class=\"loading_box\"><img src=\"" + _site_url + "_images/_internet/loading.gif\" width=\"32\" height=\"32\" align=\"absmiddle\"></div>";
	}
}

function sendLinkSuggestionHttpObject() {
	var bwy_link_form_xml_http = null;
	try {
		// Firefox, Opera 8.0+, Safari
		 bwy_link_form_xml_http = new XMLHttpRequest();
	} catch (e) {
		//Internet Explorer
		try {
			bwy_link_form_xml_http = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			bwy_link_form_xml_http = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return bwy_link_form_xml_http;
}
