function bojax(url, container) {
    var req = false;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("Your browser does not support Ajax.");
        return false;
    }

    req.onreadystatechange = function() {
        loadPage(req, container)
    }
    req.open('GET', url, true)
    req.send(null)
}
function loadPage(req, container) {
    if (req.readyState == 4 && req.status == 200) {
        document.getElementById(container).innerHTML = req.responseText;
    }
}
function loadPWRC() {
	bojax('http://www.exheat.com/show_html.php?show_html=pwrc', 'create-account');
}
function loadCANA() {
	bojax('http://www.exheat.com/show_html.php?show_html=cana', 'create-account');
}
function loadflag(country) {
	document.getElementById("cute-flag").innerHTML="<img src=\"_img/_flags/" + country + ".png\" class=\"flag-border\" />";
}
function goBpage(brochure,page) {
	bojax("http://www.exheat.com/download-brochure-pages.php?b=" + brochure + "&p=" + page, "brochure-preview");
}

function startUpload(){
 document.getElementById('upload_process').style.visibility = 'visible';
 return true;
}

function stopUpload(success,file){
var result = '';
 if (success == 1){
  document.getElementById('upload_process').innerHTML = 'Your CV has been sent, <a href=\"_uploads/' + file + '\">' + file + '</a>';
 }
 if(success == 2){
  document.getElementById('upload_process').innerHTML = 'The file must be a <strong>.docx</strong> / <strong>.doc</strong> / <strong>.rtf</strong> / <strong>.pdf</strong>';
 }
 if(success == 0){
  document.getElementById('upload_process').innerHTML = 'There was an error during file upload, the web admin has been notified';
 }
 return true;
}

function submitENQ(){
	var email = document.getElementById('email').value;
	var uri = document.getElementById('uri').value;
	var safe = 'http://www.exheat.com/product-interest.php?email=' + email + '&uri=' + uri;

    bojax(safe,'enquiry');
}
function loadagentlist(country) {
	bojax("http://www.exheat.com/agent.php?agent_type=1&country=" + country, "agents");
}
function loaddistributorlist(country) {
	bojax("http://www.exheat.com/agent.php?agent_type=0&country=" + country, "distributors");
}
function showPP(page){
    document.getElementById('pi-content').innerHTML = '<span style="width:445px;height:265px;background: #E8E9EC url(_img/load-profile.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/profile.php?format=plain&page=" + page, "pi-content");
}
function loadNews(page,type){
	window.location.hash='load-news';
    document.getElementById('load-news').innerHTML = '<span style="width:100px;height:100px;background: url(_img/load-white.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/news.php?type=" + type + "&html_url=" + page, "load-news");
}
function loadAccountEdit(page){
    document.getElementById('edit-account').innerHTML = '<span style="width:100px;height:100px;background: url(_img/load-white.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/edit-account-forms.php?edit=" + page, "edit-account");
}

function submitAccountDetails(){
	var email_address = document.getElementById('email_address').value;
	var name = document.getElementById('name').value;
	var jobtitle = document.getElementById('jobtitle').value;
	var companyname = document.getElementById('companyname').value;
	var telephone = document.getElementById('telephone').value;
	bojax("http://www.exheat.com/edit-account-forms.php?edit=account-details&update_account_details=true&email_address=" + email_address + "&name=" + name + "&jobtitle=" + jobtitle + "&companyname=" + companyname + "&telephone=" + telephone, "edit-account");
	
	
}

function submitDeliveryAddress(){
	var delivery_address_line1 = document.getElementById('delivery_address_line1').value;
	var delivery_address_line2 = document.getElementById('delivery_address_line2').value;
	var delivery_address_line3 = document.getElementById('delivery_address_line3').value;
	var delivery_town_city = document.getElementById('delivery_town_city').value;
	var delivery_postcode = document.getElementById('delivery_postcode').value;
	var country = document.getElementById('country').value;
    document.getElementById('edit-account').innerHTML = '<span style="width:100px;height:100px;background: url(_img/load-white.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/edit-account-forms.php?edit=delivery-address&update_delivery_address=true&delivery_address_line1=" + delivery_address_line1 + "&delivery_address_line2=" + delivery_address_line2 + "&delivery_address_line3=" + delivery_address_line3 + "&delivery_town_city=" + delivery_town_city + "&delivery_postcode=" + delivery_postcode + "&country=" + country, "edit-account");
}

function submitInvoiceAddress(){
	var billing_address_line1 = document.getElementById('billing_address_line1').value;
	var billing_address_line2 = document.getElementById('billing_address_line2').value;
	var billing_address_line3 = document.getElementById('billing_address_line3').value;
	var billing_town_city = document.getElementById('billing_town_city').value;
	var billing_postcode = document.getElementById('billing_postcode').value;
	var country = document.getElementById('country').value;
    document.getElementById('edit-account').innerHTML = '<span style="width:100px;height:100px;background: url(_img/load-white.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/edit-account-forms.php?edit=invoice-address&update_invoice_address=true&billing_address_line1=" + billing_address_line1 + "&billing_address_line2=" + billing_address_line2 + "&billing_address_line3=" + billing_address_line3 + "&billing_town_city=" + billing_town_city + "&billing_postcode=" + billing_postcode + "&country=" + country, "edit-account");
}

function submitInvoiceFromDeliveryAddress(){
    document.getElementById('edit-account').innerHTML = '<span style="width:100px;height:100px;background: url(_img/load-white.gif) no-repeat center center;display:block;"></span>';
	bojax("http://www.exheat.com/edit-account-forms.php?edit=invoice-address&update_invoice_address_copy_delivery=true", "edit-account");
}