
var zoomMax = 12;
var zoomMin = 8;

function fitImage(img, width, height)
{
	var imgRatio = img.width / img.height;
	var ratio = width / height;
	if(imgRatio > ratio)
	{
		if(img.width > width)
		{
			img.width = width;
			//img.height = width / imgRatio;
		}
	}
	else
	{
		if(img.height > height)
		{
			img.height = height;
			//img.width = height * imgRatio;
		}
	}
}


function debug(str, append)
{
	if(!$('debug'))
	{
		var debug = document.createElement("div");
		debug.id = "debug";
		document.appendChild(debug);
	}

	if(append) $('debug').innerHTML += str;
	else $('debug').innerHTML = str;
}

function addOver(o, img)
{
	o.onload = function(){}

	var imag = new Image(); imag.src = img;

	o.baseSrc = o.src
	o.onmouseout = function(){o.src = o.baseSrc;}
	o.onmouseover = function(){o.src = img;}

}

function logClick(url)
{
	var params = {
		parameters: "sLink=" + url,
		asynchronous: false
	};
	new Ajax.Request('click.php', params);
}

window.onload = function()
{

}

var mainOnLoad = window.onload;

function fitImage(img, width, height)
{
	var imgRatio = img.width / img.height;
	var ratio = width / height;
	if(imgRatio > ratio)
	{
		if(img.width > width) img.width = width;
	}
	else
	{
		if(img.height > height) img.height = height;
	}
}

function favoris()
{
	var descr = "Ximmo, Tout l'immobilier";
	var link = "http://www.ximmo.be";
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{
		window.sidebar.addPanel(descr, link,"");
	}
	else
	{
		window.external.AddFavorite(link, descr);
	}
}

function showHideChmout()
{
	if($('chmout').visible())
	{
		//new Effect.BlindUp('chmout');
		$('chmout').hide();
	}
	else
	{
		//new Effect.BlindDown('chmout');
		$('chmout').show();
	}
}

function playMp3(file)
{
	var inner = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="150" height="20" id="dewplayer" align="middle">';
	inner += '<param name="allowScriptAccess" value="sameDomain" />';
	inner += '<param name="movie" value="dewplayer.swf?son='+file+'&amp;autostart=1&amp;bgcolor=F6F2F3" />';
	inner += '<param name="quality" value="high" />';
	inner += '<param name="bgcolor" value="F6F2F3" />';
	inner += '<embed src="dewplayer.swf?son='+file+'&amp;autostart=1&amp;bgcolor=F6F2F3" quality="high" bgcolor="F6F2F3" width="159" height="20" name="dewplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
	inner += '</object>';

	$('playerDiv').innerHTML = inner;
	Element.show('playerDiv');
	return false;
}

function clearDefaultFieldValue(o, isPasswd)
{
	var newItem = document.createElement("input");
	newItem.style.color = "#000";
	newItem.value = "";

	if(isPasswd != null) newItem.type = "password";
	else newItem.type = "text";

	propsToCopy = new Array("id", "name", "className");
	for (var i = 0; i < propsToCopy.length; i++)
	{
		newItem[propsToCopy[i]] = o[propsToCopy[i]];
	}
	o.parentNode.insertBefore(newItem, o);
	o.parentNode.removeChild(o);
	newItem.focus();
}

