/**
 *
 * @access public
 * @return void
 **/
 function montre(id) {
	var div = document.getElementById(id);

	if (div.className=='montre'){
		div.className='cache';
	} else {
		div.className='montre';
	}
}
function chiffre_display(ind){
	chiffre = document.getElementById('chiffre'+ind);
	detail = document.getElementById('detail'+ind);
	if(chiffre.className=='chiffresel'){
		chiffre.className='chiffre';
		detail.className='cache';
	}
	else {
		chiffre.className='chiffresel';
		detail.className='montre';
	}
}
function mel(prefixe,domaine) {
	var adresse;
	adresse = prefixe + "@" + domaine;
  	document.write(adresse);
}

function mail(prefixe,domaine) {
	adresse = prefixe+"@"+domaine;
  	document.write('<a href="mailto:'+adresse+'">'+adresse+'</a>')
}
function mailnoprint(prefixe,domaine){
	adresse = prefixe+"@"+domaine;
  	document.write('<a href="mailto:'+adresse+'"></a>')
}
function favoris() {
	if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4)) {
		window.external.AddFavorite("http://www.slci-espaceimmobilier.com/","SLCI Espace Immobilier" );
	} else {
		window.sidebar.addPanel("Immo de France Lyon","http://www.slci-espaceimmobilier.com/","");
	}
}
function ajaxFileUpload(key,id,type)
	{
		//starting setting some animation when the ajax starts and completes
		$("#loading-"+key).show();



		/*
			prepareing ajax file upload
			url: the url of script file handling the uploaded files
                        fileElementId: the file type of input element id and it will be the index of  $_FILES Array()
			dataType: it support json, xml
			secureuri:use secure protocol
			success: call back function when the ajax complete
			error: callback function when the ajax failed

                */
		$.ajaxFileUpload
		(
			{
				url:'ajax/doajaxfileupload.php?id='+id+'&key='+key+'&type='+type,
				secureuri:false,
				fileElementId:key,
				dataType: 'json',
				success: function (data, status)
				{
					$("#loading-"+key).hide();
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{

							$.fancybox(
								'<span class="error">'+data.error+'</span>',
								{
						        	'autoDimensions'	: false,
									'width'         		: 250,
									'height'        		: 'auto',
									'transitionIn'		: 'none',
									'transitionOut'		: 'none'
								}
							);
							$('#'+key).val('');
						}else
						{
							//alert(data.msg);
							if ($('#info-'+key+' .supp').length==0) {
								$('#info-'+key).append(
									suppbtn = $('<a></a>').addClass('supp')
								);
								suppbtn.html('supprimer ?');
								suppbtn.click(function(){
									$('#info-'+key).hide();
									$('#'+key).show();
									$.get('ajax/supp_piece.php?id='+id+'&key='+key+'&type='+type,function(data){

									});

								});
							}



							$('#info-'+key).show();

							$('#'+key).hide();
							$('#'+key).val('');

						}
					}
				},
				error: function (data, status, e)
				{
					$("#loading-"+key).hide();
					alert(e);
					//console.log(data);
				}
			}
		)

		return false;

	}