
$('#cartography_link').click( function() {
	popupImage = window.open($(this).attr('href'),'_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1, width=500, height=500, left=100, top=25');
	return false;
 	} );

if ($("#max").val() != undefined)
{
num=1;
delay=7000;

function showPictSlide (idimg)
	{
	$("#big_pict_slide").attr({ src: $("#"+idimg).attr("href")});
	$("#credits_img").html($("#"+idimg).attr("alt"));
	$("#big_pict_link").attr({ href: 600 + '.' + $("#"+idimg).attr("href").substring(11, 150).replace("\/", ".")});
	}

function neext () {
	if (num == $("#max").val())
		{
		num = 1;
		}
	else
		{
		num = 1*num+1;
		}
	showPictSlide (num);
};

mon_timer = setInterval("neext()",delay);
}


$("#quick_search").focus( function() { 
	if ($("#quick_search").attr('value')!="") 
		{
		$("#quick_search").attr({value:''});  
		}
	} );


function selectItem (li)
	{
		alert(sValue);
	}


function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	//alert("The value you selected was: " + sValue);
	$("#"+tablee).val(sValue);
	alert('yo');

}

function findGlossaryValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	window.location=$("#lg").val()+'.glossary.'+sValue+'.html';
	
}


	function formatItem(row) {
		return row[0];
	}
	function formatResult(row) {
		return row[0];
	}

$("#search_streets").autocomplete(
	"fonctions/search_streets.php",
	{
		delay:10,
		minChars:2,
		matchSubset:1,
		matchContains:1,
		maxItemsToShow:18,
		width:207,
		cacheLength:10,
		selectFirst: false,
		autoFill:false,
		extraParams: {lg:$("#lg").val(),cp:$("#search_cities").val()}
	}
);

$("#search_streets").result(function(event, data, formatted) {
		if (data)
			{
			$("#street").val(data[1]);
			$("#search_streets").addClass('no_blank');
			}
	});





$("#search_number").focus( function() { 
	if ($("#search_number").attr('value')!="") 
		$("#search_number").attr({value:''});  
	} );	

$("#search_architects").autocomplete(
	"fonctions/search_architects.php",
	{
		delay:10,
		minChars:2,
		matchSubset:1,
		matchContains:1,
		maxItemsToShow:12,
		width:257,
		cacheLength:10,
		onItemSelect:selectItem,
		onFindValue:findValue,
		formatItem: formatItem,
		formatResult: formatResult,
		autoFill:false,
		extraParams: {lg:$("#lg").val()}
	}
);


$("#search_architects").result(function(event, data, formatted) {
		if (data)
			{
			$("#architect").val(data[1]);
			$("#search_architects").addClass('no_blank');
			}
	});



$("#search_glossary").autocomplete(
	"fonctions/search_glossary.php",
	{
		delay:10,
		minChars:2,
		matchSubset:1,
		matchContains:1,
		maxItemsToShow:12,
		width:204,
		cacheLength:10,
		onItemSelect:selectItem,
		onFindValue:findValue,
		formatItem: formatItem,
		formatResult: formatResult,
		autoFill:false,
		extraParams: {table:'glossary',field:'name_'+$("#lg").val(),retour:'name_'+$("#lg").val()}
	}
);

$("#search_glossary").result(function(event, data, formatted) {
		if (data)
			{
			if ($("#lg").val()=='fr')
				window.location='fr.glossaire.definition.'+data[1]+'.html';
			else
				window.location='nl.glossarium.definition.'+data[1]+'.html';
			}
	});


$("#search_glossary").focus( function() { 
	if ($("#search_glossary").attr('value')!="") 
		{
		$("#search_glossary").attr({value:''});  
		}
	} );


$("#from").focus( function() { 
	if ($("#from").attr('value')!="") 
		{
		$("#from").attr({value:''});
		}
	} );

$("#to").focus( function() { 
	if ($("#to").attr('value')!="") 
		{
		$("#to").attr({value:''});
		}
	} );



function afficheMaxi(chemin,titre)
	{
	popupImage = window.open("include/zoom.php?zoom="+chemin,'_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1, width=500, height=700, left=100, top=25');
	}

function affichePage(id)
	{
	popupImage = window.open("include/page.php?id="+id,'_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1, width=460, height=500, left=100, top=25');
	}

var result = $("#current_result").val();

if (result > 0)
{
showResults (result);
}
else
{
$("#next").hide();
$("#previous").hide();		
}
function showResults (resu)
	{
	$(".result_items").hide();
	if (resu<4)
		{
		min=1;
		max=7;	
		}
	else
		{
		min = resu-3;
		max = (resu*1)+3;
		}
	for (i=min; i<=max; i++)
		{
			$("#result_"+i).css({display:'inline'});
		}
	if (min<2)
		$("#previous").hide();
	else
		$("#previous").show();	
	if (max>=$("#number_result").val())
		$("#next").hide();	
	else
		$("#next").show();	
	}

$("#show_credits").click( function() {$("#credits").toggle();});
$("#next").click( function() {showResults(max);});
$("#previous").click( function() {showResults(min);});

$(document).ready(function(){


function showPicti (idimg)
	{
	$("#big_pict").attr({ src: $("#"+idimg).attr("href")});
	$("#big_pict_link").attr(
							 { href: 600 + '.' + $("#"+idimg).attr("href").substring(11, 150).replace("\/", ".")}
							 );
	$("#credits_img").html($("#prev_"+idimg).attr("alt"));
	//alert('legende : '+$("#prev_"+idimg).attr("alt"));
	}
	
$(".zoom").click(function() {	
	afficheMaxi($(this).attr('href'),'zoom');
	return false;
});
	
$(".mini").click(function() {
	num = $(this).attr("id");
	showPicti (num);
	return false;
});

if($.browser.msie)
{
	//$("img:not(.mini)").attr({alt: "" });
	$("img").attr({ title: ""});
}

$("a.listed").children('img').after('<span>'+$("a.listed").children('img').attr('alt')+'</span>');
$("a.listed").click(function() {
	return false;
});



$(".inner_illustration").each(function () {
    $(this).children('a').children('img').after('<span>Zoom</span><br>'+$(this).children('a').children('img').attr('alt')+'<br>');
	$(this).children('a').children('a').children('span').remove();
    });


$("a[@href^=\"http\"]").attr("target", "_blank");

$('.insert_ban').focus( function() { 
	$(this).select();
	});


var verif_hauteur = $('#previews').height();
if (verif_hauteur > 100)
	{
	var cpt=0;
	$('#previews').children('.mini').each(function(){ 
		if (cpt==18)
			$('#voirtout').insertAfter(this);
		if (cpt > 18)
			$(this).hide();
		cpt++;
		});	
	}

$('#voirtout').click(function() {
	$('#previews').children('.mini').show();
	$(this).hide();
	return false;
});


});


