var docClickLoader = new RemoteFileLoader('docClickLoader');
function loadWhere(evt)
{
cancelEvent(evt);
window.scrollTo(0,0);
where();
};
function loadInto(src, destId, evt)
{
 var ok = docClickLoader.loadInto(src.href || src.getAttribute('href'), destId);
 if (ok) cancelEvent(evt);
};
function toggleInto(src, destId, evt)
{
 var dest = document.getElementById(destId);
 if (!dest.contentLoaded)
 {
  var ok = docClickLoader.loadInto(src.href || src.getAttribute('href'), destId);
  if (ok) dest.contentLoaded = true;
 }
 cancelEvent(evt);
 if (!dest.toggleState)
 {
  src.innerHTML = 'Close: ' + src.innerHTML;
  dest.style.display = 'block';
  dest.toggleState = 1;
 }
 else
 {
  src.innerHTML = src.innerHTML.replace(/^Close: /, '');
  dest.style.display = 'none';
  dest.toggleState = 0;
 }
};
addEvent(document, 'click', function(evt)
{
 evt = evt || window.event;
 if (evt.which > 1 || evt.button > 1) return;
 var src = evt.target || evt.srcElement;
 if (src.nodeType && src.nodeType != 1) src = src.parentNode;
 while (src)
 {
  var srcName = (src.nodeName||src.tagName||'').toLowerCase();
  if (srcName == 'a' && src.className && src.className == 'where') return loadWhere(evt);
  if (srcName == 'a' && src.className && src.className.match(/^(load|toggle)into-(.+)$/))
  {
   if (RegExp.$1 == 'load') return loadInto(src, RegExp.$2, evt);
   if (RegExp.$1 == 'toggle') return toggleInto(src, RegExp.$2, evt);
  }
  src = src.parentNode;
 }
}, 1);

function where() {

    var arrayPageSize = getPageSize();
	dh = arrayPageSize[3] - 100;
    dw = arrayPageSize[2] - 100;
	ih = dh - 40;
	iw = dw - 0;
  		var objBody = document.getElementsByTagName("body").item(0);	
		var objOvlay = document.createElement("div");
		objOvlay.setAttribute('id','ovlay');
		objOvlay.style.display = 'none';
		objBody.appendChild(objOvlay);
		var objMap = document.createElement("div");
		objMap.setAttribute('id','map');
		objBody.appendChild(objMap);
		objMap.style.height = dh+'px';
		objMap.style.width = dw+'px';
		var objMapifr = document.createElement("iframe");
		objMapifr.setAttribute('id','ifm');
		objMapifr.setAttribute('src','where/index.php?h='+ih+'&w='+iw);
		objMap.appendChild(objMapifr);
		objMapifr.style.height = ih+'px';
		objMapifr.style.width = iw+'px';
		var objClLnk = document.createElement("a");
		objClLnk.setAttribute('id','bottomNavClose');
		objClLnk.setAttribute('href','#');
		objClLnk.onclick = function() { objMap.parentNode.removeChild(objMap); objOvlay.parentNode.removeChild(objOvlay); return false; }
		objMap.appendChild(objClLnk);
		var objClIm = document.createElement("img");
		objClIm.setAttribute('src', '/inc/img/close.gif');
		objClLnk.appendChild(objClIm);
		Element.setHeight('ovlay', arrayPageSize[1]);
		new Effect.Appear('ovlay', { duration: 0.2, from: 0.0, to: 0.8 });
}
function getPageSize(){
        var xScroll, yScroll;
        if (window.innerHeight && window.scrollMaxY) {	
                xScroll = document.body.scrollWidth;
                yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        } else {
		xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }
        
        var windowWidth, windowHeight;
        if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
        }	
	if(yScroll < windowHeight){
                pageHeight = windowHeight;
        } else { 
                pageHeight = yScroll;
        }
	if(xScroll < windowWidth){	
                pageWidth = windowWidth;
        } else {
                pageWidth = xScroll;
        }
        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
        return arrayPageSize;
}