/***********************************/
/* Bluewater                       */
/***********************************/

function display_loading_message() {
	window.scrollTo(0,0);
	document.getElementById("load_bg").style.display = "";
	document.getElementById("load_message").style.display = "";
}

function displayElementId(p_element_to_display_id, p_element_to_hide_id) {
	document.getElementById(p_element_to_display_id).style.display = "";
	if (p_element_to_hide_id != "") {
		document.getElementById(p_element_to_hide_id).style.display = "none";
	}	
}


/***********************************/
/* Brokerage                       */
/***********************************/

var bwy_brokerage_yacht_form_xml_http;


function showBrokerageYachtSearch(p_action, p_available_space) { 
	bwy_brokerage_yacht_form_xml_http = showBrokerageYachtSearchHttpObject()
	if (bwy_brokerage_yacht_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	var url = _site_url + "_custom/_content/_brokerage_yachts_search_form.php"
	var params = "action=" + p_action
	params += "&available_space=" + urlencode(p_available_space)
	
	bwy_brokerage_yacht_form_xml_http.onreadystatechange = showBrokerageYachtSearchStateChanged 
	bwy_brokerage_yacht_form_xml_http.open("POST", url, true)
	bwy_brokerage_yacht_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_brokerage_yacht_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_brokerage_yacht_form_xml_http.setRequestHeader("Connection", "close");
	bwy_brokerage_yacht_form_xml_http.send(params);	
}

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

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


/***********************************/
/* Charter                         */
/***********************************/

var bwy_charter_yacht_form_xml_http;


function showCharterYachtSearch(p_action, p_available_space) { 
	bwy_charter_yacht_form_xml_http = showCharterYachtSearchHttpObject()
	if (bwy_charter_yacht_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	var url = _site_url + "_custom/_content/_charter_yachts_search_form.php"
	var params = "action=" + p_action
	params += "&available_space=" + urlencode(p_available_space)
	
	bwy_charter_yacht_form_xml_http.onreadystatechange = showCharterYachtSearchStateChanged 
	bwy_charter_yacht_form_xml_http.open("POST", url, true)
	bwy_charter_yacht_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_charter_yacht_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_charter_yacht_form_xml_http.setRequestHeader("Connection", "close");
	bwy_charter_yacht_form_xml_http.send(params);	
}

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

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


/***********************************/
/* Contact                         */
/***********************************/

var bwy_contact_form_xml_http;
var bwy_enquiry_form_xml_http;

var bwy_contact_form_div = "div_contact_form";


function sendContactEmail(p_action, p_target_div, p_available_space, p_category_id, p_category_email, p_name, p_company, p_email, p_phone, p_country_id, p_address, p_subject, p_message) { 
	bwy_contact_form_xml_http = sendContactEmailHttpObject()
	if (bwy_contact_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	bwy_contact_form_div = p_target_div;
	
	var url = _site_url + "_custom/_content/_contact_form.php"
	var params = "action=" + p_action
	params += "&target_div=" + urlencode(p_target_div)
	params += "&name=" + urlencode(p_name)
	params += "&category_id=" + p_category_id
	params += "&category_email=" + urlencode(p_category_email)
	params += "&company=" + urlencode(p_company)
	params += "&email=" + urlencode(p_email)
	params += "&phone=" + urlencode(p_phone)
	params += "&country_id=" + p_country_id
	params += "&address=" + urlencode(p_address)
	params += "&subject=" + urlencode(p_subject)
	params += "&message=" + urlencode(p_message)
	params += "&available_space=" + urlencode(p_available_space)
	
	bwy_contact_form_xml_http.onreadystatechange = sendContactEmailStateChanged 
	bwy_contact_form_xml_http.open("POST", url, true)
	bwy_contact_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_contact_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_contact_form_xml_http.setRequestHeader("Connection", "close");
	bwy_contact_form_xml_http.send(params);	
}

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

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


function sendEnquiryEmail(p_action, p_available_space, p_category_id, p_category_email, p_name, p_company, p_email, p_phone, p_country_id, p_address, p_subject, p_message, p_yacht) { 
	bwy_enquiry_form_xml_http = sendEnquiryEmailHttpObject()
	if (bwy_enquiry_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	var url = _site_url + "_custom/_content/_enquiry_form.php"
	var params = "action=" + p_action
	params += "&name=" + urlencode(p_name)
	params += "&category_id=" + p_category_id
	params += "&category_email=" + urlencode(p_category_email)
	params += "&company=" + urlencode(p_company)
	params += "&email=" + urlencode(p_email)
	params += "&phone=" + urlencode(p_phone)
	params += "&country_id=" + p_country_id
	params += "&address=" + urlencode(p_address)
	params += "&subject=" + urlencode(p_subject)
	params += "&message=" + urlencode(p_message)
	params += "&available_space=" + urlencode(p_available_space)
	params += "&yacht=" + urlencode(p_yacht)
	
	bwy_enquiry_form_xml_http.onreadystatechange = sendEnquiryEmailStateChanged 
	bwy_enquiry_form_xml_http.open("POST", url, true)
	bwy_enquiry_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_enquiry_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_enquiry_form_xml_http.setRequestHeader("Connection", "close");
	bwy_enquiry_form_xml_http.send(params);	
}

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

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


/***********************************/
/* Links                           */
/***********************************/

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;
}


/***********************************/
/* News                            */
/***********************************/

var bwy_news_form_xml_http;

function showArchivedNews(p_category_id, p_subcategory_id, p_category, p_subcategory) { 
	bwy_news_form_xml_http = showArchivedNewsHttpObject()
	if (bwy_news_form_xml_http == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	var url = _site_url + "_custom/_content/_news_archive.php"
	var params = "action=display"
	params += "&category_id=" + p_category_id
	params += "&subcategory_id=" + p_subcategory_id
	params += "&category=" + urlencode(p_category)
	params += "&subcategory=" + urlencode(p_subcategory)
	
	bwy_news_form_xml_http.onreadystatechange = showArchivedNewsStateChanged 
	bwy_news_form_xml_http.open("POST", url, true)
	bwy_news_form_xml_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	bwy_news_form_xml_http.setRequestHeader("Content-length", params.length);
	bwy_news_form_xml_http.setRequestHeader("Connection", "close");
	bwy_news_form_xml_http.send(params);	
}

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

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


/***********************************/
/* Training                        */
/***********************************/

var training_courses_categories_courses;
var training_class_details;

function trainingShowCategoryCourses(evt, p_category_id) { 
	training_courses_categories_courses = trainingShowCategoryCoursesGetXmlHttpObject()
	if (training_courses_categories_courses == null) {
		alert ("Browser does not support HTTP Request")
		return
	}
 	
	var url = _site_url + "_custom/_content/_training_courses_category_courses_mouseover.php";
	var params = "action=display_details";	
	params += "&category_id=" + p_category_id;	
	
	if (!tooltip_window) return;
	if (t1) clearTimeout(t1);	
	if (t2) clearTimeout(t2);
	tooltip_displayed = true;
	
	if (ns4) {
		tooltip_window.close();
	} else if (ie4||ie5||ns5) {
	}
	t1=setTimeout("tooltip_css.visibility='visible'",100);
	
	training_courses_categories_courses.onreadystatechange = trainingShowCategoryCoursesStateChanged 
	training_courses_categories_courses.open("POST", url, true)
	training_courses_categories_courses.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	training_courses_categories_courses.setRequestHeader("Content-length", params.length);
	training_courses_categories_courses.setRequestHeader("Connection", "close");
	training_courses_categories_courses.send(params);	
}


function trainingShowCategoryCoursesStateChanged() { 
	if (training_courses_categories_courses.readyState == 4 || training_courses_categories_courses.readyState == "complete") { 
		document.getElementById("tooltip_div").style.display = "";
		document.getElementById("tooltip_div").innerHTML = training_courses_categories_courses.responseText;		
	} 
	if (training_courses_categories_courses.readyState == 1 || training_courses_categories_courses.readyState == "loading") { 
		document.getElementById("tooltip_div").style.display = "";
		document.getElementById("tooltip_div").innerHTML = "<div class=\"listing_border\" style=\"background-color: #FFFFFF; padding: 10px;\"><img src=\"../_images/_icons/16x16/icon_clock.gif\" width=\"16\" height=\"16\" align=\"absmiddle\"> Loading ...</div>" ;		
	}
}

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