// JavaScript Document

/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ALL PAGES =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
var pages=new Array();
pages[0]="submission";
pages[1]="sheet_music";
pages[2]="lessons";
pages[3]="help_alan";
pages[4]="contact2";
pages[5]="contact";
pages[6]="bio";
pages[7]="index";

function showPage(page) {
for(x=0;x<pages.length;x++) {
	document.getElementsByTagName("div")[x].style.visibility="hidden";
//	document.getElementsByTagName("div")[x].style.position="absolute";
	}
	centerDiv()
	document.getElementById(page).style.visibility="visible"
}


function centerDiv() {
for(x=0;x<pages.length;x++) {
	var layerWidth = parseInt(document.getElementsByTagName("div")[x].style.width);
	var mainTableWidth = document.getElementById("mainTable").getAttribute("width");
	var pageWidth = document.body.clientWidth;
	if(pageWidth > mainTableWidth) {
		document.getElementsByTagName("div")[x].style.left = (pageWidth/2) - (mainTableWidth/2) + 50 + 'px';

//		var pageWidth = (document.body.offsetWidth) ? document.body.offsetWidth : window.innerWidth;
//		document.getElementById(div).style.left = ((pageWidth - document.getElementById(div).offsetWidth) /2)+'px';
	}
	else {document.getElementsByTagName("div")[x].style.left = 50 +'px';}
	}
}

/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= FOR INDEX =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

function rollMenu(picID) {
if(picID < 100) {
	document.getElementById(picID).src='images/note_over.gif';
	}
if(picID >= 100) {
	var pic=(picID * 1);
	p=pic-100;
	document.getElementById(p).src='images/note_default.gif';
}

}

/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= FOR CONTACT =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function openNewWindow(popupURL, popupWidth, popupHeight) {
	newWidth = popupWidth;
	newHeight = popupHeight;
	ie_scroll = 0;
	ns_scroll = "no";
	if(newHeight > screen.availHeight) {
		//alert(newHeight+" : "+screen.availHeight);
		newHeight = screen.availHeight - 50;
		ie_scroll = 1;
		ns_scroll = "yes";
	}

	userWidth = ((screen.availWidth) / 2) - (newWidth / 2);
	userHeight = ((screen.availHeight) / 2) - (newHeight / 2);
	
	if (navigator.appName == 'Microsoft Internet Explorer') {
 		newWin = window.open (popupURL, '', 'directories=0, status=0, menubar=0, scrollbars='+ie_scroll+', resizable=1, width='+newWidth+', height='+newHeight);
	}
	else if (navigator.appName == 'Netscape' || navigator.appName == 'Opera') {
		newWin = window.open (popupURL, '', 'toolbar=no, menubar=no, location=no, scrollbars='+ns_scroll+', resizable=yes, width='+newWidth+', height='+newHeight);
	}

	newWin.focus();
	newWin.moveTo(userWidth,userHeight);
}


function MM_findObj(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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AUDIO =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function doFlash() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
+				   'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="742" height="367">'
+      '<param name="wmode" value="opaque" />'
+      '<param name="movie" value="media/index.swf">'
+      '<param name="quality" value="high">'
+      '<embed src="media/index.swf" quality="high" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="742" height="367"></embed>'
+    '</object>');
}
