// JavaScript Document

 
 var intCounter = 0;

window.onload = initialize;

  function initialize() {

	// initialize the DHTML History
	// framework
	dhtmlHistory.initialize();
	
	//winResize()

	
	open_link('Home.html','content')
	
	// subscribe to DHTML history change
	// events
	dhtmlHistory.addListener(historyChange);
	
	        if (dhtmlHistory.isFirstLoad()) {
				dhtmlHistory.add("Home.html","a0");
			}
  }

      function historyChange(newLocation, 
                             historyData) {
			 open_link(newLocation,"content");

      }
	var please_wait = null;

function response(url, target) {
 	if (link.readyState == 4) {
	 	document.getElementById(target).innerHTML = (link.status == 200) ? link.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following errorcode: " + link.status;
	}
}

function set_loading_message(msg) {
 	please_wait = msg;
}

function open_link(url, target) {
 	if ( ! document.getElementById) {
  		return false;
 	}

 	if (please_wait != null) {
  		document.getElementById(target).innerHTML = please_wait;
 	}

 	if (window.ActiveXObject) {
  		link = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) {
  		link = new XMLHttpRequest();
 	}

 	if (link == undefined) {
  		return false;
 	}
	
	if (url.match("#")){
		var newurl = url.split("#");
		link.onreadystatechange = function() { response(url, target); }
		link.open("GET", newurl[0], true);
		link.send(null);
		document.getElementById(target).scrollTop = document.getElementById(newurl[1]).offsetTop;
	} else {
	
 	link.onreadystatechange = function() { response(url, target); }
 	link.open("GET", url, true);
 	link.send(null);
	document.getElementById(target).scrollTop = 0;
	}
	intCounter += 1;
	dhtmlHistory.add(url, intCounter);

 var lastlink1 = url.replace("http://www.dphs.org.uk/content","");
	var loc = lastlink1.split("/");
	var txtLinks = "";
	
	var intcounter1 = loc.length-1;
	
	var lastlink = loc[intcounter1].replace(".html","");
	
	txtLinks = " <img src='images/breadcrumb.gif' /> " + lastlink.replace(/_/g," ");	
	intcounter1 = intcounter1 - 1;
	
	while (intcounter1>0){
	
		if(loc[intcounter1]!="/"){
		txtLinks = " <img src='images/breadcrumb.gif' /> " + "<a href='javascript:void(0)' onclick=open_link('http://www.dphs.org.uk/content/" + loc[intcounter1] + "/" + loc[intcounter1+1].replace("_","") + ".html','content')>" + loc[intcounter1].replace(/_/g," ") + "</a>" + txtLinks;
		intcounter1 = intcounter1 - 1;
		}
	}
	txtLinks ="<a href='javascript:void(0)' onclick=open_link('Home.html','content')>Home</a>" +  txtLinks;
	document.getElementById("bread").innerHTML = txtLinks;
}
  function initMenu() {
  $('#menu ul').hide();
  $('#menu li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
  }
$(document).ready(function() {initMenu();});