window.onload = extLinks;

function extLinks() { 
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.onclick = function() {
		extPop(this.href);
		return false;
		}; 
	} 
}
function extPop(url) {
newWin = window.open(url,"_blank","top=0,left=0,height="+screen.availHeight+",width="+screen.availWidth+",location,scrollbars,directories,menubar,resizeable,status,toolbar");
}

function bulletChangeOver(el){
      var el = document.getElementById(el).style;
      el.listStyleImage = "url('./images/but_dot_on.gif')";      
    }
    
    function bulletChangeOut(el){
      var el = document.getElementById(el).style;
      el.listStyleImage = "url('./images/but_dot.gif')";      
    }
    
        // Dynamic Iframe loader
    function loadIframe(theURL) {
    	document.getElementById("mainContent").src=theURL;
    }
    
    // resizes Iframe according to content
    function resizeMe(obj){ 
    docHeight = document.body.scrollHeight;
     obj.style.height = (docHeight - 150) + 'px';
     } 


var bullet_on = document.createElement('img');
bullet_on.setAttribute('src','./images/dot_on.gif');

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getCentreOfClientView(){
	var x = '';
	var y = '';
	x = f_scrollLeft( ) + (f_clientWidth( )/2);
	y = f_scrollTop( ) + (f_clientHeight( )/2);
	return new Array(x, y);
}

 //return the first child node with the matching name.
 //Will illeterate through all childs.
 function getChildByName(parent_in, child_name, type_filter){
 	var children = parent_in.childNodes;
 	var found = false;
	for (var i=0; i < children.length; i++) {
		//alert('type _filter = '+type_filter+' children.type = '+children[i].tagName);
	
		if(type_filter != undefined && children[i].tagName == type_filter.toUpperCase()){		
			//alert('child id = '+children[i].id);
			//alert('child name = '+children[i].getAttribute("name"));
			//alert('child to match = '+child_name);
			
			if (children[i].getAttribute("name") && children[i].getAttribute("name") == child_name) {
				return children[i];
				found = true;
				break;
			}
		}
		if(!found){
			if(children[i].childNodes.length > 0){
				var node = getChildByName(children[i], child_name, type_filter);
				if(node && node.getAttribute("name") == child_name){
					return node;
					break;
				}
			}
		}
	}

}


function setContentWidth(){
  var holder = document.getElementById('content_width');
  var size = parent.getCentreOfClientView( );
  holder.value = (size[0] - 80);
  
  //document.body.style.width = (size[0] - 80)+'px';
}

function setPageContent( ){
  var ww = parent.document.getElementById('content_width');
  document.getElementById('external_content').style.width = ww.value+'px';
  alert(document.getElementById('external_content').style.width);
  initLightbox( );
  //document.body.style.width = ww.value+'px';
}

