// 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) {
		if(document.getElementById(id)) { 	
			if (document.getElementById(id).className == "shown") {	 // if div is already open, close it
				document.getElementById(id).className = "hidden"; 
			}
			else {
				document.getElementById(id).className = "shown";
			}
		}
	}
}

//var lists = new Array('stores','shops','offices','industrial');
function showList(id) {
	for (i=1;i<=6;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";
	}
}

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;	
	}
}