$(document).ready(initJQuery);
function initJQuery() {
	

	/* show products */
	/*$('#webshopPrevious1').click(webshopPrevious1);
	function webshopPrevious1() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val(),'shopDivWhole','');
	}
	$('#webshopPrevious2').click(webshopPrevious2);
	function webshopPrevious2() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val(),'shopDivWhole','');
	}
	$('#webshopNext1').click(webshopNext1); 
	function webshopNext1() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val(),'shopDivWhole','');
	}
	$('#webshopNext2').click(webshopNext2);
	function webshopNext2() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val(),'shopDivWhole','');
	}
*/
/*  show products */
	/* category */
	$('#webshopPrevious1').click(webshopPrevious1);
	function webshopPrevious1() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopPrevious2').click(webshopPrevious2);
	function webshopPrevious2() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopNext1').click(webshopNext1); 
	function webshopNext1() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopNext2').click(webshopNext2);
	function webshopNext2() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	/* category */
	
	$('#webrpp').change(webrpp);
	function webrpp() {
	$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageCurrentValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');

	}
	
/*Pagination in bottom of products section starts*/

	$('#webshopPrevious11').click(webshopPrevious11);
	function webshopPrevious11() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopPrevious21').click(webshopPrevious21);
	function webshopPrevious21() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopNext11').click(webshopNext11); 
	function webshopNext11() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	$('#webshopNext21').click(webshopNext21);
	function webshopNext21() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('showproducts_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&howmany='+$('#webrpp').val(),'shopDivWhole','');
	}
	/* category */
/*Pagination in bottom of products section starts*/





	/*Normal search  */
	$('#searchPrevious1').click(searchPrevious1);
	function searchPrevious1() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('search_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&searchType='+$('#searchType').val()+'&search='+$('#Key').val(),'searchDivWhole','');
	}
	$('#searchPrevious2').click(searchPrevious2);
	function searchPrevious2() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('search_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&searchType='+$('#searchType').val()+'&search='+$('#Key').val(),'searchDivWhole','');
	}
	$('#searchNext1').click(searchNext1); 
	function searchNext1() {

		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('search_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&searchType='+$('#searchType').val()+'&search='+$('#Key').val(),'searchDivWhole','');
	}
	$('#searchNext2').click(searchNext2);
	function searchNext2() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('search_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&searchType='+$('#searchType').val()+'&search='+$('#Key').val(),'searchDivWhole','');
	}
	
	/* Extend-search*/
	$('#ext_searchPrevious1').click(ext_searchPrevious1);
	function ext_searchPrevious1() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('ext_search_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&searchType='+$('#searchType').val()+'&sr_start='+$('#start').val()+'&sr_upto='+$('#to').val()+'&sr_type='+$('#htype').val()+'&sr_cntry='+$('#cntry').val(),'searchDivWhole','');
	}
	$('#ext_searchPrevious2').click(ext_searchPrevious2);
	function ext_searchPrevious2() {
		$('.previousPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('ext_search_pagination.php','pagingForCategory=1&page='+$('#pagePreviousValue').val()+'&searchType='+$('#searchType').val()+'&sr_start='+$('#start').val()+'&sr_upto='+$('#to').val()+'&sr_type='+$('#htype').val()+'&sr_cntry='+$('#cntry').val(),'searchDivWhole','');
	}
	$('#ext_searchNext1').click(ext_searchNext1); 
	function ext_searchNext1() {

		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('ext_search_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&searchType='+$('#searchType').val()+'&sr_start='+$('#start').val()+'&sr_upto='+$('#to').val()+'&sr_type='+$('#htype').val()+'&sr_cntry='+$('#cntry').val(),'searchDivWhole','');
	}
	$('#ext_searchNext2').click(ext_searchNext2);
	function ext_searchNext2() {
		$('.nextPreloadedImage').html('<img src="images/indicator.gif" width="16" height="16" border="0" />');
		sendToServerByAJAX('ext_search_pagination.php','pagingForCategory=1&page='+$('#pageNextValue').val()+'&searchType='+$('#searchType').val()+'&sr_start='+$('#start').val()+'&sr_upto='+$('#to').val()+'&sr_type='+$('#htype').val()+'&sr_cntry='+$('#cntry').val(),'searchDivWhole','');
	}
	/* Extend-search*/

	
	
	/* delete property */
	/* ajax */
	function sendToServerByAJAX(url,data,divId,mode) {
		$.ajax({
			type:'POST',
			url:url,
			data:data,
			success:function(response) {
				$('#'+divId).html(response);
				
				$('#webshopPrevious1').click(webshopPrevious1);
				$('#webshopPrevious2').click(webshopPrevious2);
				$('#webshopNext1').click(webshopNext1);
				$('#webshopNext2').click(webshopNext2);
				
				$('#webshopPrevious11').click(webshopPrevious11);
				$('#webshopPrevious21').click(webshopPrevious21);
				$('#webshopNext11').click(webshopNext11);
				$('#webshopNext21').click(webshopNext21);
				
				$('#searchPrevious1').click(searchPrevious1);
				$('#searchPrevious2').click(searchPrevious2);
				$('#searchNext1').click(searchNext1);
				$('#searchNext2').click(searchNext2);
				$('#ext_searchPrevious1').click(ext_searchPrevious1);
				$('#ext_searchPrevious2').click(ext_searchPrevious2);
				$('#ext_searchNext1').click(ext_searchNext1);
				$('#ext_searchNext2').click(ext_searchNext2);
				$('#webrpp').change(webrpp);
				
				$('#checkboxIds').val('');
			}
		});
		
		
		
		
		
	}
	/* ajax */
	/* jquery ajax paging ends here */
}

function redirect(){

var Key=document.getElementById('search').value;
var  offer=document.getElementById('offer').checked;
var  products=document.getElementById('products').checked;
var searchType ='';
if((offer) && (products))
{
searchType ='mix';
}
else if( (offer) && !(products))
{
searchType ='offer';
}
else if( !(offer) && (products))
{
searchType ='products';
}
else 
{
searchType ='simple';
}

document.topsearch.submit();
//var url='http://localhost/reisplanet/search.php?searchType='+searchType+'&Key='+str;

//window.location = url; //'http://localhost/reisplanet/search.php?searchType='+searchType+'&Key='+str;
}

function redirect1(){

var start=parseInt(document.getElementById('sr_start').value);
var upto=parseInt(document.getElementById('sr_upto').value);
var country=document.getElementById('sr_cntry').value;
var type=document.getElementById('sr_type').value;
/*if(start=='0'){ 
alert('Selecteer minimale prijs');
start.focus();
start.select();

}else if(upto=='0'){ 
alert('Selecteer maximale prijs');
upto.focus();
upto.select();

}else
*/
if( upto!='0' && start !='0'){
	if(upto < start){
		alert("minimale value must be lower then maximale");
	}
	else{
		document.extend_search.submit();
		}
}else{
	document.extend_search.submit();
}
/*else if(country=='0'){ 
alert('Please select country');
country.focus();
country.select();
} else if(type=='0'){ 

alert('Please select Holiday Type');
type.focus();
type.select();

} */

//alert(start);
//alert(upto);



//var url='http://localhost/reisplanet/extend_search.php?searchType=Ext&start='+start+'&To='+upto+'&type='+type+'&cntry='+country;
//alert(url);
//window.location = url; //'http://localhost/reisplanet/search.php?searchType='+searchType+'&Key='+str;
}

