function load_client(titel) {
	$('content_right_side').innerHTML = '<div style=\'position:absolute; top:210px; left:155px; font-size:14px; color:#538ac3; \'>Project wordt geladen <img src=img/loader.gif style=\'margin-left:25px;\'></div>';
	new Ajax.Updater(
		'content_right_side',
		'ajax.php',
		{
			method: 'post',
			parameters: 'page=site/client.php&titel='+escape(titel),
			requestHeaders: ['Expires', 'Thu, 17 May 2001 10:17:17 GMT', 'Cache-Control', 'no-cache, must-revalidate', 'Pragma', 'no-cache']
		});
}

function addToSelection(checked,id) {
	act = checked ? 'save' : 'del';
	post = 'act='+act+'&id='+id;
	handler = 'site/searchsession.php';

	new Ajax.Request(
		'ajax.php',
		{
			method : 'post',
			parameters : 'page='+handler+"&"+post,
			onComplete : function(request) {}
		}
	);
	if(act == 'save') {
		selectionIds.push(id);
		$('loadSelectionBut').disabled = false;
	} else if (act=='del') {
		selectionIds = selectionIds.without(id);
		if (selectionIds.length == 0) {
			$('loadSelectionBut').disabled = true;
		}
	}
}

function show_large_image(img) {
	$('model_large').style.backgroundImage = 'url(\''+ img + '\')';
	if($('pdf_form_main_image')) $('pdf_form_main_image').value = img;
}

function removeSelection(checked,id,voorstel) {
	if (checked) return;
	post = 'act=del&id='+id;
	handler='site/searchsession.php';
	new Ajax.Request(
		'ajax.php',
		{
			method : 'post',
			parameters : 'page='+handler+"&"+post,
			onComplete : function(request) {
				countSelect = request.responseText;
				if (voorstel=='1') {
					loadSelectionVoorstel(0);
				} else {
					searchModel(0,1);
				}
			}
		}
	);
	selectionIds = selectionIds.without(id);
	if (selectionIds.length == 0) {
		$('loadSelectionBut').disabled = true;
		location.reload(true);
	}
}

function searchModel(page, load, adv, video) {
	//alert($('searchForm').serialize());
	//alert(adv);return;
	if(adv == 1){
		//alert(adv);
		handler= 'site/advsearchmodellen.php';
	} else {
		handler= 'site/searchmodellen.php';
	}
	if(load != 1) { if($('clearSelectionBut')!= null) $('clearSelectionBut').disabled = true; } 
	if(video == 1) post = 'pagination='+ page +"&load="+ load +'&show_video_models=1';
	else {
		post = 'pagination='+ page +'&load='+ load +'&';
		if($('searchForm')) {
			post += $('searchForm').serialize();
		}
	}
	//alert(post);
	new Ajax.Updater(
		'content_gallery',
		'ajax.php',
		{
			method: 'post',
			parameters : 'page='+handler+"&"+post,
			requestHeaders: ['Expires', 'Thu, 17 May 2001 10:17:17 GMT', 'Cache-Control', 'no-cache, must-revalidate', 'Pragma', 'no-cache']
			
		});
	return;
}

function show_video_models() {
	new Ajax.Updater(
		'content_gallery',
		'ajax.php',
		{
			method: 'post',
			parameters : 'page=site/searchmodellen.php&show_video_models=1',
			requestHeaders: ['Expires', 'Thu, 17 May 2001 10:17:17 GMT', 'Cache-Control', 'no-cache, must-revalidate', 'Pragma', 'no-cache']
			
		});
}

function resetSearchModel() {
	post = 'reset=1';
	handler= 'site/searchmodellen.php';
	new Ajax.Updater(
		'content_gallery',
		'ajax.php',
		{
			method: 'post',
			parameters : 'page='+handler+"&"+post,
			requestHeaders: ['Expires', 'Thu, 17 May 2001 10:17:17 GMT', 'Cache-Control', 'no-cache, must-revalidate', 'Pragma', 'no-cache']
			
		});
}

function clearSelection() {
	post = 'act=delall';
	handler='site/searchsession.php';

	new Ajax.Request(
		'ajax.php',
		{
			method : 'post',
			parameters : 'page='+handler+"&"+post,
			onComplete : function(request) {
				location.reload(true);
			}
		}
	);
	
}

function loadSelection() {
	searchModel(0, 1);
	$('clearSelectionBut').disabled = false;
	$('selectionpdf').show();	
}

function loadSelectionVoorstel(page) {
	handler = 'site/searchmodellen.php';
	load = 1;
	if(load!=1) { if($('clearSelectionBut')!= null) $('clearSelectionBut').disabled = true; } 
	post = 'pagination='+page+"&load="+load+"&voorstel=1";
	new Ajax.Updater(
		'content_gallery',
		'ajax.php',
		{
			method: 'post',
			parameters : 'page='+handler+"&"+post,
			requestHeaders: ['Expires', 'Thu, 17 May 2001 10:17:17 GMT', 'Cache-Control', 'no-cache, must-revalidate', 'Pragma', 'no-cache']
			
		});
	$('clearSelectionBut').disabled = false;
	$('selectionpdf').style.display = '';	
	return;
}


function show_client_case(index) {
	for (i = 0; $('client_project_'+i); i++) {
		$('client_project_'+i).style.display = (i == index ? '' : 'none');
	}
}

function printPage (id, img, name, modelId) {
	img = img.substring(4,(img.length - 1));
	//alert('name: '+modelId);

	var html = '<HTML>\n<HEAD>\n';
	html += '\n</HE' + 'AD>\n<BODY>\n';
		
		//html += '<table style=\'border:solid 2px #6598cd; padding:10px; \' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'><tr><td>';	
		html += '<img src='+img+'>';
		/*
		html += '</td></tr>';
		html += '<tr><td align=\'center\'>';
		html += '<span style=\'font-size:40px; color:#6598cd; font-family:verdana; font-weight:bold; \'>'+name+'</span>';
		html += '<br/>';
		html += '<span style=\'font-size:12px; font-family:verdana; color:#6598cd; \'>Model ID: '+modelId+'</span>';
		html += '</td></tr>';	
		html += '</table>';	
		*/
		
	html += '\n</BO' + 'DY>\n</HT' + 'ML>';

	var printWin = window.open("","printPage");
	printWin.document.write(html);
	printWin.document.close();
	//printWin.print();
}



