
function popit(page,width,height){
	window.open(page,null,"height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no");
}



//AJAX STUFF

var setaction = '';
var setpage = '';
Image1= new Image(16,16);

var loc = new String(document.location);
if (loc.indexOf("https://")!= -1){
	Image1.src = "https://www.vacationrentals411.com/images/ajax-loader.gif";
}else{
	Image1.src = "http://www.vacationrentals411.com/images/ajax-loader.gif";
}

/* The following function creates an XMLHttpRequest object... */
var sendto;

function startLoader(pid){
	if(setaction == ''){
		ID = document.getElementById('loader_' + pid);
		ID.innerHTML = '<img src="http://www.vacationrentals411.com/images/ajax-loader.gif" align="absmiddle" height="16" width="16" />&nbsp; Loading...';
	}else{
		ID = document.getElementById('loader');
		ID.innerHTML = '<img src="http://www.vacationrentals411.com/images/ajax-loader.gif" align="absmiddle" height="16" width="16" />&nbsp; Loading, Please Wait...';
	}
}
function stopLoader(pid){
	if(setaction != ''){
		ID = document.getElementById('loader');
		ID.innerHTML = '&nbsp;';
	}
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 
var http2 = createRequestObject(); 

/* Function called to get the product categories list */


function ajax(action,pid,type){
	startLoader(pid);
	type = typeof(type) != 'undefined' ? type : '';
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', 'http://www.vacationrentals411.com/internal_request.php?action='+action+'&pid='+pid+'&type='+type);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleProducts; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}


/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleProducts(){
	
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
		
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response_string = http.responseText;

		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		var response_array = response_string.split("&&||&&");
		var pid = response_array[0];
		var response = response_array[1];
		
		if(setaction != "showfavs"){
			document.getElementById('loader_' + pid).innerHTML = response;
		}
		showlist();
		if(response == 'Session ended'){
			document.getElementById('mylist').innerHTML = '';
		}
		
	}
}






function showlist(){
	if(setaction == ''){
		var action = 'showlist';
	}else{
		var action = setaction;	
	}
	
	if(setpage == 'vacation'){
		var action = 'showlist_vacation';
	}
	
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item.
	*/
	http2.open('get', 'http://www.vacationrentals411.com/internal_request.php?action=' + action);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http2.onreadystatechange = handleShowlist; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http2.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleShowlist(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http2.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response_string = http2.responseText;
		var response_array = response_string.split("&&||&&");
		var pid = response_array[0];
		var response = response_array[1]; 
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		
		document.getElementById('mylist').innerHTML = response;
		stopLoader();
	}
}

function switchbuttons(){
	var but = document.getElementById('viewbuttons');
	var ser = document.getElementById('psearch');
	var cdrop = document.getElementById('citydrop');
	
	if(ser.style.display=='none'){
		but.style.display='none';
		ser.style.display='block';
		cdrop.style.display="hidden";
	}else{
		ser.style.display='none';
		but.style.display='block';
		cdrop.style.visibility="visible";
	}
}

function setbedrents(number){
	if(number=='4'){
		document.forms['search'].bedrooms.value = '4_m';
	}else{
		document.forms['search'].bedrooms.value = number + '_e';
	}
	document.forms['search'].submit();
}





