
var ie = (document.all) ? true : false;


function bodyVisible()
{

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
  	x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images)
	{
	if(!d.MM_p)
		d.MM_p=new Array();
		
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0)
		{
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		}
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null)
		{
			document.MM_sr[j++]=x;
			if(!x.oSrc)
				x.oSrc=x.src;
			x.src=a[i+2];
		}
}

function checkRequiredFields(form)
{
	strA = Array();
	if (form.name.value == "")
		strA.push('name');
	if (form.phone.value == "")
		strA.push('phone');
	if (form.email.value == "")
		strA.push('email');
	if (form.message.value == "")
		strA.push('message');
	
	if ( strA.length )
	{
		window.alert( "Please enter your " + strA.join(", ") + "." );
		return false;
	}
	// ** END **
	return true ;
}
function doLoadGalleryItem( path )
{
	var b = document.getElementById? document.getElementById('myframe'): document.all? document.all['myframe']: null;
	if ( b )
	{
		b.setAttribute('src',path );
		b.setAttribute('width','350px');
	}
}
function oResize()
{
	var d = document.getElementById? document.getElementById('bufferframe'): document.all? document.all['bufferframe']: null;
	var f = document.getElementById? document.getElementById('footer'): document.all? document.all['footer']: null;
	var b = document.getElementById? document.getElementById('buffer'): document.all? document.all['buffer']: null;
	var v = document.getElementById? document.getElementById('bufferview'): document.all? document.all['bufferview']: null;

	var dbl0 = document.getElementById? document.getElementById('bl0'): document.all? document.all['bl0']: null;
	var dbl1 = document.getElementById? document.getElementById('bl1'): document.all? document.all['bl1']: null;

/*	if ( b && v )
	{
		if ( b.contentDocument )
			v.innerHTML = b.contentDocument.innerHTML;
		else
			v.innerHTML = window.frames['buffer'].document.body.innerHTML;
		
	}
*/	


	if ( typeof winHeight != 'unknown' && typeof winHeight != 'undefined' )
	{
		var wh = winHeight();
		var fh = f.offsetHeight;
		
		
	
		if ( f && b && dbl0 && dbl1 )
		{
	//		d.style.height = ( winHeight() - 10 ) + 'px';
	//		doResizeDivH( b, wh - fh, 5 );
		if ( dbl0.offsetHeight && dbl1.offsetHeight )
		{
			var blHeight0 = (dbl0.offsetHeight + dbl1.offsetHeight) ;
			var blHeight1 = (winHeight()) - ( topOffset( b ) );
			var blHeight = Math.max( blHeight0, blHeight1 ) - ( f.offsetHeight + 5 );
	/*		alert ( dbl0.offsetHeight );
			alert ( dbl1.offsetHeight );
			alert ( blHeight );
		*/
			b.style.height = blHeight + 'px';
		}
//			doResizeDivH( b, footerTop - fh, 5 );
		}
	}
}
function adjustIFrameSize (iframeWindow)
{
	alert( 'adjustIFrameSize' );
	var iframeElement = document.getElementById? document.getElementById(iframeWindow.name): document.all? document.all[iframeWindow.name]: null;
	var f = document.getElementById? document.getElementById('footer'): document.all? document.all['footer']: null;

	if (iframeWindow.document.height) {
		//var iframeElement = document.getElementById(iframeWindow.name);
		
//		doResizeDivH( iframeElement, winHeight() - f.offsetHeight, 20 );
		iframeElement.style.height = iframeWindow.document.offsetHeight + 'px';
//		iframeElement.style.width = iframeWindow.document.width + 'px';
	}
	else if (document.all)
	{
		if (iframeWindow.document.compatMode &&	iframeWindow.document.compatMode != 'BackCompat') 
		{

			iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
//			iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
		}
		else
		{

			iframeElement.style.height = iframeWindow.document.body.scrollHeight + 5 + 'px';
//			iframeElement.style.width = iframeWindow.document.body.scrollWidth + 5 + 'px';
		}
	}
}

function bopen( srcname )
{
	var bufr = document.getElementById? document.getElementById('buffer'): document.all? document.all['buffer']: null;
	
	if ( bufr )
	{
			bufr.style.visibility = 'hidden';
			bufr.setAttribute('src',srcname);
	}
}

function setBanner( idx )
{
	doToggleVisibility( ('b' + idx), 'bHolder' );
	var f = document.getElementById? document.getElementById('floater'): document.all? document.all['floater']: null;
	if ( f )
	{
		f.style.top = ( 100 - ( idx * 50 ) ) + 'px';
	}
}

function bbopen( srcname, idx )
{
	setBanner( 1 );
	loadVertMenu( idx );	
	
	doToggleVisibilityInv( "c", idx );
	bopen( srcname );	
}

function openSingleImage( propid )
{
	var bufr = parent.document.getElementById? parent.document.getElementById('buffer'): parent.document.all? parent.document.all['buffer']: null;
	bufr.setAttribute('src','propimage.php?src=' + document.images.prop_photo.src + '&propid=' + propid );
}


function bufferSizeLocal()
{
//	alert( typeof bufferSize );
	if ( typeof bufferSize != 'unknown' && typeof bufferSize != 'undefined' )
		bufferSize('buffer');
}


var numCat = 10;

function loadVertMenu( idx )
{
	doToggleVisibility( ('nv' + idx), 'nvHolder' );
}


function loadSubMenu( idx )
{
	for ( i = 1; i <= numCat; i++ )
		subMenuSetVis( "m", i, ( i == idx ? 'visible' : 'hidden' ) );
}

function unloadSubMenu( idx )
{
	subMenuSetVis( "m", idx, 'hidden' );
}
    		
function subMenuSetVis( pfx, idx, vis )
{
	var tmp = document.getElementById? document.getElementById(pfx + idx): document.all? document.all[pfx + idx]: null;
	if ( tmp )
	{
		tmp.style.visibility = vis;
		if ( pfx == 'nv' )
		{
			tmp.style.height = ( vis == 'visible' ? 'auto' : '0px' );
	//		alert( vis == 'visible' );
		}
	}
}

function alignSubMenuA()
{
	var tmpM, tmpN;

	var maxX, minX;
	
	minX = 0;
	maxX = 800;
	tmpM = document.getElementById? document.getElementById("c" + 1): document.all? document.all["c" + 1]: null;
	if ( tmpM != null )
	{
		minX = leftOffset(tmpM);
	}
	tmpM = document.getElementById? document.getElementById("c" + (numCat)): document.all? document.all["c" + (numCat)]: null;
	if ( tmpM != null )
	{
		maxX = leftOffset(tmpM) + tmpM.offsetWidth;
	}

	for ( i = 1; i <= numCat; i++ )
	{
		tmpM = document.getElementById? document.getElementById("c" + i): document.all? document.all["c" + i]: null;
		tmpN = document.getElementById? document.getElementById("m" + i): document.all? document.all["m" + i]: null;
		if ( tmpM != null && tmpN != null )
		{
		/**/
			wTop = tmpM.offsetWidth;
			wBot = tmpN.offsetWidth;
			
			mTop = wTop / 2;
			mBot = wBot / 2;

			lTop = leftOffset( tmpM );
			
			// ensure doesn't clip on left
			lBot = Math.max( minX + 10, ( lTop + mTop ) - mBot );
			
			// ensure doesn't clip on right
			lBot = Math.min( maxX - wBot - 10, lBot );
			
			tmpN.style.left = lBot + 'px';
			
		}
	}
}


function doToggleVisibility( srcid, dstid )
{
//	window.alert( srcid );
	var d = document.getElementById? document.getElementById(dstid): document.all? document.all[dstid]: null;
	
	if ( !d ){ window.alert( 'no d' ); return; }
	
	d.style.visibility = 'hidden';
	d.style.height = '0px';
	
	// hide siblings
	for( i = 0; i < d.childNodes.length; i++ )
	{
//		window.alert( d.childNodes[i].getAttribute('id') );
		if ( d.childNodes[i].nodeName.toLowerCase() == 'div' )
		{
			if ( d.childNodes[i].getAttribute('id') == srcid )
			{
				d.childNodes[i].style.visibility = 'visible';
				d.childNodes[i].style.height = 'auto';
			}
			else
			{
				d.childNodes[i].style.visibility = 'hidden';
				d.childNodes[i].style.height = '0px';
			}
		}
	}
//	d.style.height = '0px';
	d.style.height = 'auto';
	d.style.visibility = 'visible';
	
/*	d = document.getElementById? document.getElementById('bufferframe'): document.all? document.all['bufferframe']: null;
	if ( d )
	d.style.height = 'auto';	
	*/
}
function doToggleVisibilityInv( divid, idx )
{
	/*
	for( i = 0; i < 10; i++ )
	{
		tmp = divid + i;
		d = document.getElementById? document.getElementById(tmp): document.all? document.all[tmp]: null;
		if ( d != null )
			if ( d.nodeName.toLowerCase() == 'div' )
			{
				if ( d.getAttribute('id') == divid + idx )
				{
					d.style.visibility = 'hidden';
					d.style.width = '0px';
				}
				else
				{
					d.style.visibility = 'visible';
					d.style.width = 'auto';
				}
			}
	}
	*/
}

function ignite()
{
	bufferSizeLocal();
	alignSubMenuA();
}

window.onload = ignite;
window.onresize = bufferSizeLocal;
