/* Copyright (c) 2002-2007 RichHall.com. All Rights Reserved. */

//Redirect old pages to new site

var loc=String(location.href);

if(loc.match(/\/enroll\//i)) location.replace( 'http://grayschoolofmusic.com/forms/enroll' );

else if(loc.match(/textonly\.html.*$/i)) location.replace( 'http://grayschoolofmusic.com/books/handbook' );

else if(loc.match(/credits\.html.*$/i)) location.replace( 'http://grayschoolofmusic.com/pages/notices' );

else if(loc.match(/summer\.html.*$/i)) location.replace( 'http://grayschoolofmusic.com/pages/programs/#summer' );

else if(loc.match(/rates\.html.*$/i)) location.replace( 'http://grayschoolofmusic.com/pages/tuition' );

else if(loc.match(/activities\.html.*$/i)) location.replace( 'http://grayschoolofmusic.com/pages/calendar' );

else if(loc.match( /delaney/i )) location.replace( 'http://grayschoolofmusic.com/people/lemke' );

else if(loc.match( /henderson/i )) location.replace( 'http://grayschoolofmusic.com/people/hansen' );

else if( loc.match( /(benson|dumas|flanagin|hollabaugh|mccormack|murphy|myers|newkurt|nieves|sargent|snoots|somervell|westover|wong|zaitseva)/i ) ) location.replace( 'http://grayschoolofmusic.com/groups/faculty' );

else if(loc.match(/about\.shtml.*/i)) location.replace(loc.replace( /^.*\/([^\/]+)\/about\.shtml.*$/, 'http://grayschoolofmusic.com/people/$1' ));

else if(loc.match(/\.html.*$/i)) location.replace(loc.replace( /^.*\/([^\/]+)\.html$/, 'http://grayschoolofmusic.com/pages/$1' ));

else location.replace('http://grayschoolofmusic.com');


function go_prev(){
	find_order();
  self.location.href=document.prev;
}

function go_next(){
	find_order();
  self.location.href=document.next;
}

function find_order(){
	var d=document, a=d.links, l=a.length, e=l-1, h=location.href, r=h.indexOf('/',9), u='..'+h.substring(r,h.length), c, p=false, n=false, i=0, s=0, f=e, q=[];
	//Get all Teacher links
	for(i=0;i<l;i++)if(a[i].href && a[i].title && (a[i].title.indexOf('Teacher')>-1))q.push(a[i].href);
   // if results don't make sense, abort and return false for failure
	if(q.length<3){
		document.prev='../../';
		document.next='../../forms/enroll/';
		return false;
	}
	i=0, f=q.length-1;
	while( (!p) && (!n) && (i<=f) ){ 
	  c=q[i]||'';
		if(c&&c==h){
			p=(i>1?q[i-1]:q[f]);
			n=(i<f?q[i+1]:q[0]);
		}
		i++;
	}
	document.prev=p||'../../';
	document.next=n||'../../forms/enroll/';
	return p&&n;
}

//Older find_order():
/*
function find_order(){
	var d=document, a=d.links, l=a.length, e=l-1, h=location.href, r=h.indexOf('/',9), u='..'+h.substring(r,h.length), c, p=false, n=false, i=0, s=0, f=e;
	while((s<l) && a[s].href!='javascript:go_prev();')s++; //find where to start looking
	while((f>-1) && a[f].href!='javascript:go_next();')f--; //find where to finish looking
	i = ++s; e=f-1; // find beginning and ending links
	if((i>=e)||(e<0)||(s>l)){ // if results don't make sense, abort with meaningful results and return false for failure
		document.prev='../../';
		document.next='../../forms/enroll/';
		return false;
	}
	while( (!p) && (!n) && (i<f) ){ 
	  c=(a[i].href?a[i].href:false);
		if(c&&c==h){
			p=(i>s?a[i-1].href:'../');
			n=(i<e?a[i+1].href:'../enroll/');
		}
		i++;
	}
	document.prev=(p?p:'../');
	document.next=(n?n:'../enroll/');
	return p&&n;
}
*/

function go_select(s){
  self.location.href=s.options[s.selectedIndex].value;
}

function music_open() {
  document.music = window.open( "/bgmusic.php", "music", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=512,height=256" );
}

function music_show() {
  if (document.music) {
    document.music.focus();
  } else {
    // music_open();
    top.blur();
  }
}

function music_hide() {
  if (document.music) document.music.blur();
  top.focus();
}

/* Fireworks 4.0  Dreamweaver 4.0 target.  Created Sat Jan 19 17:12:20 GMT-0600 2002 */

function MM_findObj(n, d) { //v3.0
  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=MM_findObj(n,d.layers[i].document); return x;
}
function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(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 = MM_findObj(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 = MM_findObj(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];
      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") {
    if ((nbArr = document[grpName]) != null)
      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 = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_preloadImages() { //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=MM_preloadImages.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];}}
}
