		function createRequestObject() {
				var ro;
				var browser = navigator.appName;
				if(browser == "Microsoft Internet Explorer"){
						ro = new ActiveXObject("Microsoft.XMLHTTP");
				}else{
						ro = new XMLHttpRequest();
				}
				return ro;
		}
		var http = createRequestObject();
		function ajax_page(pages_id,position_top) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=page&pages_id='+pages_id+'&t='+expdate);
			change_div_content('inline_popup_print_link','Please follow this link for a <a href=\"/?pages_id='+pages_id+'\">Printable version of this page</a>');
			if (position_top > 0) {
				change_div_position_top('inline_popup',position_top);
			}
			http.onreadystatechange = handleResponse;
			http.send(null);
		}
		function ajax_offer(pages_id,offers_id) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=page&pages_id='+pages_id+'&offers_id='+offers_id+'&t='+expdate);
			http.onreadystatechange = handleResponse;
			http.send(null);
		}
		function get_accom_info(chalets_id) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=chalet/accomm_info&chalets_id='+chalets_id+'&t='+expdate);
			change_div_content('inline_popup_print_link','Please follow this link for a <a href=\"/?pages_id=64&chalets_id='+chalets_id+'\">Printable version of this page</a>');
			http.onreadystatechange = handleResponse;
			http.send(null);
		}
		function get_plans_and_tour(chalets_id) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=chalet/plans_and_tour&chalets_id='+chalets_id+'&t='+expdate);
			change_div_content('inline_popup_print_link','Please follow this link for a <a href=\"/?pages_id=64&chalets_id='+chalets_id+'\">Printable version of this page</a>');
			http.onreadystatechange = handleResponse;
			http.send(null);
		}
		function get_location_map(chalets_id) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=chalet/location_map&chalets_id='+chalets_id+'&t='+expdate);
			http.onreadystatechange = handleResponse;
			http.send(null);
		}		
		function get_offers_and_discounts(chalets_id) {
			half_fade('container',500);
			var futdate = new Date()
			var expdate = futdate.getTime()
			http.open('get', 'http://www.skival.co.uk/index.php?ajax=chalet/offers_and_discounts&chalets_id='+chalets_id+'&t='+expdate);
			http.onreadystatechange = handleResponse;
			http.send(null);
		}		
		function handleResponse() {  
			if(http.readyState == 4){
				var response = http.responseText;
				change_div_content('inline_popup_content',response);
				show_fade('inline_popup',500);
			}
		}
		function show_zoomed_image (image_path) {
			var html = '<div class="inline_zoomed_image_div"><img src="'+image_path+'"></div>';
			change_div_content('inline_image_popup_content',html);
			half_fade('container',500);
			show_fade('inline_image_popup',500);
		} 
		function show_html(main_html) {
			var html = main_html;
			change_div_content('inline_popup_content',html);
			half_fade('container',500);
			show_fade('inline_popup',500);
		}
		function change_div_content(id,html) {	
			document.getElementById(id).innerHTML = html;
		}
		function change_div_position_top(id,value) {	
			document.getElementById(id).style.top = value;
			scroll(0,value);
		}
	
		//change the opacity for different browsers 
		function changeOpac(opacity, id) { 
				var object = document.getElementById(id).style; 
				object.opacity = (opacity / 100); 
				object.MozOpacity = (opacity / 100); 
				object.KhtmlOpacity = (opacity / 100); 
				object.filter = "alpha(opacity=" + opacity + ")"; 
		} 
				
		function opacity(id, opacStart, opacEnd, millisec) { 
				if (millisec<499) {
					var steps = 50;
				} else {
					var steps = 100;
				}
				//speed for each frame 
				var speed = Math.round(millisec / steps); 
				var timer = 0; 
		
				//determine the direction for the blending, if start and end are the same nothing happens 
				if(opacStart > opacEnd) { 
						for(i = opacStart; i >= opacEnd; i--) { 
								setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
								timer++; 
						} 
				} else if(opacStart < opacEnd) { 
						for(i = opacStart; i <= opacEnd; i++) 
								{ 
								setTimeout("changeOpac("+i+",'"+id+"')",(timer * speed)); 
								timer++; 
						} 
				} 
				if (opacEnd == 0) {	
					setTimeout(" hide_div('"+id+"'); ",700);
				}
		} 


		function toggle_fade(id,millisec) { 
			 //if an element is invisible, make it visible, else make it ivisible 
				if(document.getElementById(id).style.opacity < 1 || document.getElementById(id).style.display != 'block') { 
					if (document.getElementById(id).style.display == 'none') {
						changeOpac(0,id); 
						show_div(id);
					}
					opacity(id, 0, 100, millisec); 
				} else { 
					opacity(id, 100, 0, millisec); 
				} 
		} 
		function show_fade(id,millisec) { 
		 //if an element is invisible, make it visible, else make it ivisible 
			if (document.getElementById(id).style.opacity < 1 || document.getElementById(id).style.display != 'block') {
				if (document.getElementById(id).style.display != 'block') {
					changeOpac(0,id); 
					show_div(id);
				} else {
					//alert('not hidden:'+document.getElementById(id).style.display);
				}
				opacity(id, document.getElementById(id).style.opacity, 100, millisec); 
			} else {
				//alert("didn't get it");
			}
		} 
		function hide_fade(id,millisec) { 
			if(document.getElementById(id).style.opacity != 0) { 
				opacity(id, 100, 0, millisec); 
			}
		} 
		function half_fade(id,millisec) { 
			if(document.getElementById(id).style.opacity != 0) { 
				opacity(id, 100, 50, millisec); 
			}
		} 
		function half_fade_up(id,millisec) { 
			if(document.getElementById(id).style.opacity != 0) { 
				opacity(id, 50, 100, millisec); 
			}
		} 
