var image_path = "images/";
function initPage()
{
	var thumbs = document.getElementById("thumbs");
	allthumbs = [];
	allbigthumbs = [];

	if (thumbs){
		var tnodes = thumbs.getElementsByTagName("a");
		if(tnodes)
		{
			active_img_id = 0;
			for (var i=0; i<tnodes.length; i++)
			{ 
				_parent = tnodes[i].parentNode;
					allthumbs.push(tnodes[i].rel);
					allbigthumbs.push(tnodes[i].rel);
					tnodes[i].href = 'javascript:;';
					tnodes[i]._index = i;
					_parent._index = i;
					if(_parent.className == "active")
					{
						active_img_id = i;
						fullImage(active_img_id);						
					}				
					tnodes[i].onclick = function()
					{
						fullImage(this._index);
					}
			}
		}
	}

	var el = document.getElementById("prev-btn");
	if(el)
	{
		el.href = "javascript:;";
		el.onclick = next;
	}
	var el = document.getElementById("next-btn");
	if(el)
	{
		el.href = "javascript:;";
		el.onclick = previous;
	}	

}

function fullImage(id)
{
//alert(allbigthumbs[id]);
	_img = document.getElementById("img");
	if(_img)
	{
		_img.src = 'http://www.francepropertyshop.com/assets/upload_images/details/' + allthumbs[id];
	}

	_imgl = document.getElementById("large-img");
	if(_imgl)
	{
		if(allbigthumbs[id].length > 0)
		{
			_imgl.href = 'http://www.francepropertyshop.com/assets/upload_images/details/large/' + allbigthumbs[id];
		}
		else
		{
			_imgl.href = "#";	
		}
	}

	old_active_id = active_img_id;
	active_img_id = id;
		
	var thumbs = document.getElementById("thumbs");
	var tnodes = thumbs.getElementsByTagName("li");
	for (var i=0; i<tnodes.length; i++)
	{
		if(tnodes[i]._index >= 0 && tnodes[i]._index == old_active_id)
		{
			tnodes[i].className = "";
		}
		if(tnodes[i]._index >= 0 && tnodes[i]._index == active_img_id)
		{
			tnodes[i].className = "active";			
		}
	}

	Lightbox.init();

}

function next()
{
	i = active_img_id
	if(allthumbs[i-1])
	{
		fullImage(i-1);
	}
	else
	{
		fullImage(allthumbs.length-1);				
	}
}

function previous()
{
	i = active_img_id
	if(allthumbs[i+1])
	{
		fullImage(i+1);
	}
	else
	{
		fullImage(0);				
	}
}

if (window.attachEvent){
	window.attachEvent("onload", initPage);
	}
else if (window.addEventListener){
	window.addEventListener("load", initPage, false);
	}



function bookmarksite()
{
var title = 'France Property Shop';
var url = 'http://www.francepropertyshop.com';
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}