function swapImageOn(name) {
	if (name == 'freetrial') {
		var divelement = document.getElementById("free_trial");
		divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial_on.jpg')";	
	}
	if (name == 'quality') {
		var divelement = document.getElementById('quality');
		var classname = divelement.className;
		if (classname == 'low') {
			divelement.className = 'low_on';
		}
		if (classname == 'high') {
			divelement.className = 'high_on';
		}
		//divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial_on.jpg')";	
	}
}
					
function swapImageOff(name) {
	if (name == 'freetrial') {
		var urllocation = document.location.toString().split("/");
		var selected = urllocation.pop();
		if(urllocation.pop() != 'free-day-trial') {
			var divelement = document.getElementById("free_trial");
			divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial.jpg')";
		}
	}
	
	if (name == 'quality') {
		var divelement = document.getElementById('quality');
		var classname = divelement.className;
		if (classname == 'low_on') {
			divelement.className = 'low';
		}
		if (classname == 'high_on') {
			divelement.className = 'high';
		}
		//divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial_on.jpg')";	
	}
	
}

function gotoLowHighRes(lang) {
	var divelement = document.getElementById('quality');
	var classname = divelement.className;
	if (classname == 'low_on') {
		var url = '/'+lang+'/intro-video-low/';
	}
	if (classname == 'high_on') {
		var url = '/'+lang+'/intro-video-high/';
	}
	//var divelement = getElementById('quality');
	var links = document.getElementsByTagName('a'); 
	links[0].className = 'selected';
	
	document.location = url;
}

function gotoFreeTrial() {
	document.location = '/free-day-trial/';
	var divelement = document.getElementById("free_trial");
	divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial_on.jpg')";
}

function checkFreeTrial() {
	pic1= new Image(118,71); 
	pic1.src="/themes/nautilus/images/freetrial_on.jpg"; 
	pic2= new Image(80,81); 
	pic2.src="/themes/nautilus/images/high_res_on.gif"; 
	pic3= new Image(80,81); 
	pic3.src="/themes/nautilus/images/low_res_on.gif"; 
	
	var urllocation = document.location.toString().split("/");
	var selected = urllocation.pop();
	var domainname = document.domain.toString().split(".");
	var domain = domainname.pop();
	
	if (domain == 'uk') {
		var divelement = document.getElementById("free_trial");
		divelement.style.display = "block";
	}
	
	if(urllocation.pop() == 'free-day-trial') {
		var divelement = document.getElementById("free_trial");
		divelement.style.backgroundImage = "url('/themes/nautilus/images/freetrial_on.jpg')";
	}
	
	if(urllocation.pop() == 'intro-video-low') {
		var links = document.getElementsByTagName('a'); 
		links[0].className = 'selected';
	}
	
	var content = document.getElementById('content_clubs');
	if(document.getElementById('content_clubs')) {
		content.innerHTML = '';
	}
	var selectlist = document.getElementById('select_clubs');
	if (document.getElementById('select_clubs')) {
		selectlist.style.visibility = 'visible';
	}
	var introtext = document.getElementById('introtext');
	if(document.getElementById('introtext')){
		introtext.style.visibility = 'visible';
	}
}

function gotoHome(lang) {
	document.location = "/"+lang+"/intro-video-high";
}

function submitForm() {
//document.form_clubs.submit();
}

function checkdomain() {
	var domainname = document.domain.toString().split(".");
	var domain = domainname.pop();
	if (domain == 'uk') {
		document.location = 'http://www.nautilustreadclimber.co.uk/en/intro-video-high/';
	}
	if (domain == 'nl') {
		document.location = 'http://www.nautilustreadclimber.nl/ne/intro-video-high/';
	}
	if (domain == 'au') {
		document.location = 'http://www.nautilustreadclimber.com.au/ae/intro-video-high/';
	}
	if (domain == 'de') {
		document.location = 'http://www.nautilustreadclimber.de/de/intro-video-high/';
	}
	if (domain == 'it') {
		document.location = 'http://www.nautilustreadclimber.it/it/intro-video-high/';
	}
	if (domain == 'ch') {
		document.location = 'http://www.nautilustreadclimber.ch/cd/intro-video-high/';
	}
	if (domain == 'cn') {
		document.location = 'http://www.nautilustreadclimber.cn/cn/intro-video-high/';
	}
	if (domain == 'be') {
		document.location = 'http://www.nautilustreadclimber.be/bf/intro-video-high/';
	}
}



//AJAX

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}


// var http_request = false;
//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest(lang) {
	var poststr = "region=" + encodeURI(document.getElementById("select_clubs").value)+"&lang="+ lang;
	makePOSTRequest('/webinc/php/searchSuggest.php', poststr, lang);
}

function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = handleSearchSuggest;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

//Called when the AJAX response is returned.
function handleSearchSuggest() {
	if (http_request.readyState == 4) {
		
		var ss = document.getElementById('content_clubs');
		ss.innerHTML = '';
		var str = http_request.responseText.split("\n");
		
		ss.innerHTML += str;
		/*for(i=0; i < str.length - 1; i++) {
			//Build our element string.  This is cleaner using the DOM, but
			//IE doesn't support dynamically added attributes.
			var suggest = str[i];
			ss.innerHTML += suggest;
		}*/
	}
}
