// Used for pages with strict doctypes (i.e. no target="_blank")
// Automagically adds them back in to links with rel="external"

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.target = "_blank";  }
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "subscribe") {
      var subscribeURL = anchor.getAttribute('href');
      anchor.onkeypress = function(){window.open(this.href, 'SubscribeWindow', 'toolbar=no,menubar=no,height=300,width=430,location=no,scrollbars=yes,resizable=no,status=no,left=30,top=30'); return false; }
      anchor.onclick = function(){window.open(this.href, 'SubscribeWindow', 'toolbar=no,menubar=no,height=300,width=430,location=no,scrollbars=yes,resizable=no,status=no,left=30,top=30'); return false; }
      }
  }
}
window.onload = externalLinks;

var ie = document.all; // IE Test
// Gets around the problem of having multiple onload handlers ----------------------------------
// http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
// http://www.quirksmode.org/js/events_advanced.html

function addEvent(obj, evType, fn) {

    // W3C type of event registration model
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    // MS event registration model
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    // Bad browsers that cant do either
    } else {
        return false;
    }
}


// DISPLAY OR HIDE CERTAIN ELEMENTS BY ID
function showItem(id) {
	if (document.getElementById) {
	i = document.getElementById(id);
		if(i) { i.style.display = (i.style.display == "block") ? "none" : "block"; }
	}
}
function displayItem(id) {
	if (document.getElementById) {
	i = document.getElementById(id);
		if(i) { i.visibility = (i.visibility == "visible") ? "hidden" : "visible"; }
	}
}
function rollOver(id,file) { 
	if (document.getElementById) {
	i = document.getElementById(id);
		if(i) { i.src = file; }
	}
}

function mapRoll(i,r,o) {
	if (document.getElementById) {
		list_obj = document.getElementById("map_" + i);
		if (o) { 
			list_obj.className = "map_link selected " + r;
		}
		else { 
			list_obj.className = "map_link " + r; 
			return; 
		}	
	}
}

function swapSrc(id,src) {
	if(!document.getElementById) { return; }
	i = document.getElementById(id);
	if(i.src.match("_over.gif")) { i.src = i.src.replace(/_over/,""); }
	else { i.src = i.src.replace(/.gif/,"_over.gif"); }
}




//var lists = new Array('stores','shops','offices','industrial');
function showList(id) {
	for (i=1;i<=4;i++) {
		hideDiv = "nav_"+i;
		if(document.getElementById(hideDiv)){
			document.getElementById(hideDiv).className = "hidden";
		}
	}
	showItem(id);
}
function hideList(id) {
	if(document.getElementById(id)) {
		document.getElementById(id).className = "hidden";
	}
}

var blit={
	dc:function(i){var o="",c1,c2,c3,e1,e2,e3,e4,j=0,k="gNAkZGdEiV3jM7QXORxrfJKvzps";i=i.replace(/[^A-Za-z0-9+\/=]/g,"");k+="1ucwTyU092H4l658I+tDmPYBonbLqSaWehCF/=";while(j<i.length){e1=k.indexOf(i.charAt(j++));e2=k.indexOf(i.charAt(j++));e3=k.indexOf(i.charAt(j++));e4=k.indexOf(i.charAt(j++));c1=(e1<<2)|(e2>>4);c2=((e2&15)<<4)|(e3>>2);c3=((e3&3)<<6)|e4;o=o+String.fromCharCode(c1);if(e3!=64){o=o+String.fromCharCode(c2);}if(e4!=64){o=o+String.fromCharCode(c3);}}return o;
	}
};
	//.slice(0,o.length-1)

function showDiv(id) {
	if (document.getElementById) {

		for (i=1;i<=3;i++) {
			hidediv = "prop_"+i;
			hidenav = "propshow_"+i;
			if(document.getElementById(hidediv)){ document.getElementById(hidediv).className = "hide"; }
			if(document.getElementById(hidenav)){ document.getElementById(hidenav).className = ""; }
		}

	showdiv = "prop_"+id;
	shownav = "propshow_"+id;
	if(document.getElementById(showdiv)){ document.getElementById(showdiv).className = "show";}
	if(document.getElementById(shownav)){ document.getElementById(shownav).className = "selected";}
		

	}
}

/**/
var text = new Array ();
text[0] = new Array ('b','BOLD');
text[1] = new Array ('i','ITALIC');
text[2] = new Array ('u','UNDERLINE');
function addFormat(style,field) {
	if(document.getElementById) {
		for(s=0;s<text.length;s++){
			if (style == text[s][0]) {
				stext = text[s][1];
				break;
			}
		}
		var tags = ("["+style+"]"+stext+"[/"+style+"]");
		document.getElementById(field).value += tags;	
	}
}
function addLink(field,val) {
	if(document.getElementById) {
		var tags = ("[link="+val+"]TEXT[/link]");
		document.getElementById(field).value += tags;	
	}
}

function popPDF(id,type) {
	href = ("?page=downloads&id=" + id + "&type=" + type);
	popup = window.open(href,'Downloads','width=500,height=600');
}
function popMap(id) {
	href = ("?page=gmap&id=" + id);
	popup = window.open(href,'GoogleMap','width=500,height=640,resizable=yes');
}
