/// addLoadEvent, for queuing window.onload init functions
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	};
};


//Opens New Window based on rel name
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";
 		}
	}
addLoadEvent(externalLinks);


//Standard sfHover code - additional !document.all to target only IE browsers
label_hover = function() {	
	//if ( (document.getElementById("supplierform")) && ((navigator.userAgent.toLowerCase().indexOf('5.0') != -1) || (navigator.userAgent.toLowerCase().indexOf('6.0') != -1)) ) { /* browser detection for IE5/IE6*/
	var sfEls = document.getElementsByTagName("label")
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+="labelhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("labelhover\\b"), "");
		}
	}	
}
//}
addLoadEvent(label_hover);


function openNewWindow(URLtoOpen, windowName, windowFeatures) {
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}


function doSomething() {
    var aryClassElements = getElementsByClassName( 'expand', document.body );
    for ( var i = 0; i < aryClassElements.length; i++ ) {
		aryClassElements[i].onmouseover=function() {
			this.className+=" active";
		}
		aryClassElements[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("active\\b"), "");
		}		
    }
}

function getElementsByClassName( strClassName, obj ) {
    var ar = arguments[2] || new Array();
    var re = new RegExp("\\b" + strClassName + "\\b", "g");

    if ( re.test(obj.className) ) {
        ar.push( obj );
    }
    for ( var i = 0; i < obj.childNodes.length; i++ )
        getElementsByClassName( strClassName, obj.childNodes[i], ar );
    
    return ar;
}
addLoadEvent(doSomething);



function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
	  e.style.display = 'none';
   else
	  e.style.display = 'block';
}
function hideElements() {
	var act = document.getElementById("local_activities");
	if(act != null){
		act.style.display ='none';
	}
	var din = document.getElementById("local_dining");
	if(din != null){
		din.style.display ='none';
	}
	var acc = document.getElementById("local_accommodation");
	if(acc != null){
		acc.style.display ='none';
	}
}
addLoadEvent(hideElements);

