
//map
//15-7-08 GJP IV 200807-01621 simplified stats collection mmmmmmmmmmmmmmmmmmmmmmm
function phoneclick3(n, fid, lgid, strPhone) {//alert("click3 start");
	if (strPhone!='') { //alert("click3");
		document.getElementById('phone' + n).innerHTML = '<strong>' + strPhone + '</strong>';
		//date as last arg forces refresh and triggers stats counter
		document.getElementById('phoneframe').src = '/phone.asp?click=1&fid=' + fid + '&lgid=' + lgid + '&dt=' + new Date();
		//alert("click3 ok");
	} else {
		document.getElementById('phone' + n).innerHTML = 'Not available';
	}
}
function phoneclick(n, fid, lgid) {
	s = document.getElementById('phoneframe').contentWindow.document.body.innerHTML;
	if (s!='') {
		ph = s.split('|');
		document.getElementById('phone' + n).innerHTML = '<strong>' + ph[n-1] + '</strong>';
		callToServer('/phone.asp?click=1&fid=' + fid + '&lgid=' + lgid );
	} else {
		document.getElementById('phone' + n).innerHTML = 'Not available';
	}
}
//action button
//15-7-08 GJP IV 200807-01621 simplified stats collection mmmmmmmmmmmmmmmmmmmmmmm
function phoneclick4(n, fid, lgid, hasPhone) {//alert("click4 start");
	objPanel = document.getElementById('phonediv' + n);
	if (objPanel.style.visibility == 'hidden' || objPanel.style.display == 'none') 
	{
		//s = document.getElementById('phoneframe').contentWindow.document.body.innerHTML;
		if (hasPhone) 
		{//alert("click4 has phone")
			objPanel.style.display = 'block';
			objPanel.style.visibility = 'visible';
			//callToServer('/phone.asp?click=1&fid=' + fid + '&lgid=' + lgid)
		//date as last arg forces refresh and triggers stats counter
    		document.getElementById('phoneframe').src = '/phone.asp?fid=' + fid + '&lgid=' + lgid + '&dt=' + new Date();
		}//alert("click4 OK")
	}
	else
	{
		objPanel.style.display = 'none';
		objPanel.style.visibility = 'hidden';
	}
}

function phoneclick2(n, fid, lgid) {
	objPanel = document.getElementById('phonediv' + n);
	if (objPanel.style.visibility == 'hidden' || objPanel.style.display == 'none') 
	{
		s = document.getElementById('phoneframe').contentWindow.document.body.innerHTML;
		if (s!='') 
		{
			objPanel.style.display = 'block';
			objPanel.style.visibility = 'visible';
			callToServer('/phone.asp?click=1&fid=' + fid + '&lgid=' + lgid)
		}
	}
	else
	{
		objPanel.style.display = 'none';
		objPanel.style.visibility = 'hidden';
	}
}

function togglemap(a) {
	m = document.getElementById('MapPanel')
	if (m.className == 'googlemap-sml') {
		m.className = 'googlemap-big';
		a.innerHTML = 'Shrink Map';
	} else {
		m.className = 'googlemap-sml';
		a.innerHTML = 'Enlarge Map';
	}
}


function addfav(fid, url) {
	callToServer('/fav.asp?fid=' + fid);
	window.external.AddFavorite(url, document.title);
}

var IFrameObj; // our IFrame object


function callToServer(URL) {
  if (!document.createElement) {return true};
  var IFrameDoc;
  if (!IFrameObj && document.createElement) {
// create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      // This will set the domain that the script is using to be the same domain as the one set in its parent file
      // This was required because the fairfax ads changed the domain to be able to use javascript on our pages
      // This assumes that the newdomain varible is SET!
      // Any page that calls this function now must have the newdomain variable SET.
      tempIFrame.document.domain = document.domain;

      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
	  
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }

  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }


  IFrameDoc = IFrameObj.contentWindow.document;
 
 if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
  IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }


  IFrameDoc.location.replace(URL);

  return false;
}