// JavaScript Document

function changephoto(param, i, nbimages){

    if (param=='<'){
        id='property' + i + '_photo2';if(!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block'){
		document.getElementById(id).style.display='none';
		id='property' + i + '_photo1';document.getElementById(id).style.display='block';
	}}
	id='property' + i + '_photo3';if (!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block'){
		document.getElementById(id).style.display='none';
		id='property' + i + '_photo2';document.getElementById(id).style.display='block';
	}}
	id='property' + i + '_photo4';if (!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block'){
		document.getElementById(id).style.display='none';
		id='property' + i + '_photo3';document.getElementById(id).style.display='block';
	}}
	id='property' + i + '_photo5';if (!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block'){
		document.getElementById(id).style.display='none';
		id='property' + i + '_photo4';document.getElementById(id).style.display='block';
	}}
    }
    else{
	id='property' + i + '_photo1';
	if(document.getElementById(id).style.display=='block' && nbimages>1){
		document.getElementById(id).style.display='none';
		id='property' + i + '_photo2';document.getElementById(id).style.display='block';return false;
	}
	id='property' + i + '_photo2';if(!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block' && nbimages>2){
		document.getElementById('property' + i + '_photo2').style.display='none';
		id='property' + i + '_photo3';document.getElementById(id).style.display='block';return false;
	}}
	id='property' + i + '_photo3';if(!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block' && nbimages>3){
		document.getElementById('property' + i + '_photo3').style.display='none';
		id='property' + i + '_photo4';document.getElementById(id).style.display='block';return false;
	}}
	id='property' + i + '_photo4';if(!document.getElementById(id)){}else{
	if(document.getElementById(id).style.display=='block' && nbimages>4){
		document.getElementById('property' + i + '_photo4').style.display='none';
		id='property' + i + '_photo5';document.getElementById(id).style.display='block';return false;
	}}
    }
}

var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function element(id)
{
	if(ie4)	// Explorer 4
		return document.all[id];
	else	// Explorer 5+ Netscape 6+ and Mozilla and Firefox
		return document.getElementById(id);
}


function initTurnTool(id)
{
	var tntInstalled = isTurnToolInstalled();
	tntInstalled=false;
	if (tntInstalled==false){
    		montreoverlay();	my_window_back = document.all ? document.all['windowback'] : document.getElementById ? document.getElementById('windowback') : ""
    		my_window_back.style.visibility = "visible";
    
    		my_window = document.all ? document.all['similarproducts'] : document.getElementById ? document.getElementById('similarproducts') : ""
    		my_window.style.visibility = "visible";
  	}
	else{
		web="http://" + '<?php echo $_SERVER["SERVER_NAME"]; ?>/' + "3Dwindow.php?propertyid=" + id;
		window.open(web, 'NEW', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1000,height=700');

	}

}

function isTurnToolInstalled()
{
	var tntInstalled = false;
	if (ie4||ie5)
	{
		try
		{
			var xObj = new ActiveXObject("TNT.TNTCtrl");
			if (xObj)
			{
				tntInstalled = true;
			}
		}
		catch (e)
		{
		}
	}
	else
	{
		if(navigator.plugins.namedItem("TurnTool XPCOM Plugin"))
		{
			tntInstalled = true;
		}
	}
	return tntInstalled;
}

function installTurnTool()
{
	if (ie4||ie5)
	{
		window.location.href = "http://www.turntool.com/ViewerInstall.exe";
	}
	else
	{
		var xpi = {'TurnTool Viewer Installation':'http://www.turntool.com/ViewerInstall.xpi'};
		InstallTrigger.install(xpi,installFinish);
	}
}

function installFinish(url, result)
{
	window.location.href = window.location;
}

var checkCounter = 0;
function checkRefresh()
{
	var tntInstalled = isTurnToolInstalled();
	if(tntInstalled==false)
	{
		checkCounter++;
		if (checkCounter>20)
		{
			checkCounter=0;
			installTurnTool();
		}
		setTimeout('checkRefresh()',500);
	}
	else
	{
		window.location.href = window.location;
	}
}


function changeplan(plan){
	if(plan==2){
	document.getElementById("3Dplay").style.display="none";
	document.getElementById("3Dplay2").style.display="block";
	}
	if(plan==1){
	document.getElementById("3Dplay").style.display="block";
	document.getElementById("3Dplay2").style.display="none";
	}

}
