function byt(id) {
     window.open("byt.php?id="+id, 'TRUE' , "scrollbars=yes,resize=yes,status=yes,width=940,height=550");
}

function printpage(id,projekt_print) {
     //window.open("print.php?id="+id+"&projekt_print="+projekt_print, 'Tlac-bytu' , "scrollbars=yes,resize=yes,status=yes,width=700,height=750");
	//window.open("/konfigurator/", "" , "scrollbars=yes,resize=yes,status=yes,width=700,height=750");
	//alert('print');
	window.open("print.php?id="+id+"&projekt_print="+projekt_print, "", "scrollbars=yes,resize=yes,status=yes,width=700,height=750");
	
}

/* The following function creates an XMLHttpRequest object... */    
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(); 

/* Function called to get the product categories list */
function getFlats(name,id,projekt){
	/* 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', 'internal_request.php?'+name+'='+id+'&projekt='+projekt);
 

	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleFlats; 
	/* 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 handleFlats(){
	/* 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 == 1){ 
		document.getElementById('ajax').innerHTML = '<img style="margin-top:50px;" src="layout/loading.gif" alt="Čakajte prosím." />';
	}
	
	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 = 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. */
		document.getElementById('ajax').innerHTML = response;
	}
}

/* Function called to get the product categories list */
function getOther(projekt){

  http.open('get', 'internal_request.php?others&projekt='+projekt);
	
	http.onreadystatechange = handleOther; 
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleOther(){
	if(http.readyState == 1){ 
		document.getElementById('ajax').innerHTML = '<img style="margin-top:50px;" src="layout/loading.gif" alt="Čakajte prosím." />';
	}
	
	if(http.readyState == 4){ 
		var response = http.responseText;	
		document.getElementById('ajax').innerHTML = response;
	}
}

/* Function called to get the product categories list */
function getMenu(id){
  http.open('get', 'includes/menu_ajax.php?menu='+id);	
	http.onreadystatechange = handleMenu; 
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleMenu(){
	if(http.readyState == 1){ 
		document.getElementById('right').innerHTML = '<img style="margin-top:50px;margin-left:15px;" src="layout/loading.gif" alt="Čakajte prosím." />';
	}
	
	if(http.readyState == 4){ 
		var response = http.responseText;	
		document.getElementById('right').innerHTML = response;
	}
}

/* Function called to get the product categories list */
function submitForm(){
	http.open('post', 'includes/form_ajax.php',true);
	http.onreadystatechange = handleForm; 
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	url="";
	url='submit_form=ok'+
	'&titul='+document.getElementById('titul').value+
  '&meno='+document.getElementById('meno').value+
  '&priezvisko='+document.getElementById('priezvisko').value+
  '&mail='+document.getElementById('mail').value+
  '&tel='+document.getElementById('tel').value+
  '&poznamka='+document.getElementById('poznamka').value;
	http.send(url);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleForm(){
	if(http.readyState == 1){ 
		document.getElementById('report').innerHTML = 'Čakajte prosím';
	}
	
	if(http.readyState == 4){ 
		var response = http.responseText;	
		document.getElementById('report').innerHTML = response;
	}
}

