
function MenuObjIndex(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MenuObjIndex(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MenuGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MenuGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MenuObjIndex(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MenuObjIndex(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MenuObjIndex(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MenuObjIndex(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }

}



function MenuPreloadImages() { //v3.0
  var d=document; 
  if(d.images)
  	{ 
	 if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MenuPreloadImages.arguments; 
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0)
    { 
	  d.MM_p[j]=new Image; 
	  d.MM_p[j++].src=a[i];
    }
 
   }
}

function initiate() {
	MenuPreloadImages('menu/images/home2.jpg','menu/images/home4.jpg','menu/images/home3.jpg','menu/images/alted2.jpg','menu/images/alted4.jpg','menu/images/alted3.jpg','menu/images/community2.jpg','menu/images/community4.jpg','menu/images/community3.jpg','menu/images/earlychildhood2.jpg','menu/images/earlychildhood4.jpg','menu/images/earlychildhood3.jpg','menu/images/schools2.jpg','menu/images/schools4.jpg','menu/images/schools3.jpg','menu/images/truancy2.jpg','menu/images/truancy4.jpg','menu/images/truancy3.jpg','menu/images/contactus2.jpg','menu/images/contactus4.jpg','menu/images/contactus3.jpg','menu/images/faqs2.jpg','menu/images/faqs4.jpg','menu/images/faqs3.jpg','menu/images/media2.jpg','menu/images/media4.jpg','menu/images/media3.jpg','menu/images/privacy2.jpg','menu/images/privacy4.jpg','menu/images/privacy3.jpg','menu/images/charter2.jpg','menu/images/charter4.jpg','menu/images/charter3.jpg');
	//init(); other stuff goes here
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function dynamicLayout(){
    var browserWidth = getBrowserWidth();

    //Load Thin CSS Rules
    if (browserWidth < 750){
        changeLayout("thin");
    }
    //Load Wide CSS Rules
    if ((browserWidth >= 750) && (browserWidth <= 950)){
        changeLayout("wide");
    }
    //Load Wider CSS Rules
    if (browserWidth > 950){
        changeLayout("wider");
    }
}

// changeLayout is based on setActiveStyleSheet function by Paul Sowdon 
// http://www.alistapart.com/articles/alternate/
function changeLayout(description){
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++){
	   if(a.getAttribute("title") == description){a.disabled = false;}
	   else if(a.getAttribute("title") != "default"){a.disabled = true;}
   }
}

function getBrowserWidth(){
    if (window.innerWidth){
        return window.innerWidth;}  
    else if (document.documentElement && document.documentElement.clientWidth != 0){
        return document.documentElement.clientWidth;    }
    else if (document.body){return document.body.clientWidth;}      
        return 0;
}
//addEvent() by John Resig
function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
      obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
      obj["e"+type+fn] = fn; 
      obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
      obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 
} 

//Run dynamicLayout function when page loads and when it resizes.
//addEvent(window, 'load', dynamicLayout);
//addEvent(window, 'resize', dynamicLayout);

function alertSize() {
  var myWidth = 0, myHeight = 0;
  var num;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    num = 1;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    num = 2;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    num = 3;
  }
  window.alert( num + ' Width = ' + myWidth );
  window.alert( num + ' Height = ' + myHeight );
}

function calcHeight(id)
{
  //find the height of the internal page
  var the_height=
    document.getElementById(id).contentWindow.
      document.body.scrollHeight;
  //change the height of the iframe
  document.getElementById(id).height=
      (the_height+50);
}


