// JavaScript Document


/* This is an empty function.  It is redefined in xbrowser_pan.js  to 
	scroll the carousel across the top of the bage when the body loads.  Only the index
	page is linked to xbrowser_scroll.js so only the index page can scroll the carousel.
	All other pages call this version of initpiv(0 which does nothing.
*/

function initcarousel() { 
}

/* customised version of the Macromedia OpenWindow Behaviour
This makes sure that the newly opened window is always 
at the front i.e focussed */

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var newwin = window.open(theURL,winName,features);
  newwin.focus();
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
	  if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
	
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { 
		obj=obj.style; 
		v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
	}
    obj.visibility=v; }
}

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 showOther(theMenu) {
if (theMenu.options[theMenu.selectedIndex].value.toLowerCase() == "other") {
	MM_showHideLayers('selectother','','show') ;
	}
else {
	MM_showHideLayers('selectother','','hide') ;
	}
}
*/

function showOther() {
	var i,m,layer,args=showOther.arguments;

    for (i=0; i<(args.length-1); i=i+2) {
		m = args[i] ;
		layer = args[i+1];
		if ( m.options[m.selectedIndex].value == layer ) { 
				MM_showHideLayers(layer,'','show') ;
		}
		else {
				MM_showHideLayers(layer,'','hide') ;
		}
	}
}



function showOtherMenu(theMenu) {
if (theMenu.options[theMenu.selectedIndex].value == ""  ) {
		MM_showHideLayers('propertyinvestor','','hide') ;
		MM_showHideLayers('cemclient','','hide') ;
		MM_showHideLayers('potentialclient','','hide') ;
}
else {

	if (theMenu.options[theMenu.selectedIndex].value.split("-").length >1 ) {
			var layername = theMenu.options[theMenu.selectedIndex].value.split("-")[0] ;
	
			MM_showHideLayers('first','','hide') ;
			MM_showHideLayers('propertyinvestor','','hide') ;
			MM_showHideLayers('cemclient','','hide') ;
			MM_showHideLayers('potentialclient','','hide') ;
			
			MM_showHideLayers(layername,'','show') ;
			
	//		eval("MM_showHideLayers('" + theMenu.options[theMenu.selectedIndex].value + "','','show')" ) ;
	}
	else {
			MM_jumpMenu('parent',theMenu,0)
		}	
//		theMenu.selectedIndex=0;
	}
}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/*  variables needed for the news scroller */

 
var step
var diff
var scrollspeed=50; //Millisecs

var retval 

function initNews() {
	step=parseFloat(window.newsholder.style.posTop)+parseFloat(window.newsholder.style.posHeight);
	diff=(window.news.style.top-window.news.scrollHeight);
	retval=setInterval("scrollNews();",scrollspeed);
}


function scrollNews()
{
	window.news.style.top = step;
	step-=1;
	if((parseFloat(window.news.style.posTop))<=diff)
	{
		step=parseFloat(window.newsholder.style.posTop)+parseFloat(window.newsholder.style.posHeight);
	}
}

function pauseNews()
{
	clearInterval(retval);
}

function continueNews()
{
	retval = setInterval("scrollNews();",scrollspeed);
}



function setFieldNow() {
	var obj, args=setFieldNow.arguments;
	if ((obj=MM_findObj(args[0]))!=null) {
	  var newdate = new Date() ;
	  var displayDate = newdate.getDate();
	  	if (displayDate < 10 ) { 
			displayDate = "0" + displayDate ;
		}
	  var displayMonth = newdate.getMonth()+1;
	  	if (displayMonth < 10 ) { 
			displayMonth = "0" + displayMonth ;
		}	  
	  var displayYear = newdate.getUTCFullYear();
	  
//	  window.alert(displayDate + "/" + displayMonth + "/" + displayYear ) ;
	  obj.value = displayDate + "/" + displayMonth + "/" + displayYear ;
	}
}



// This shows a preview of the picture to be included with the paragraph
// It also populates the width and height fields with the values taken 
// from the image.

function changePreview(field,imageObj,folder) { 
	
	var previewPicObj = document.getElementById(imageObj) ; 
		
	if (previewPicObj!=null ) 
	{ 	
		if (field == "") { 
			previewPicObj.src = "../images/transparent.gif" ;
		}
		else {
			previewPicObj.src = folder + field ;
		}
	}
}
