//-----------------------------------------------------------------------------
// global javascript
//-----------------------------------------------------------------------------
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];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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

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;
}

function emailCheck(emailAddress) {
	var rx
	
	rx = new RegExp("^ *[-a-zA-Z0-9\\_\\.\\-]+@[-a-zA-Z0-9\\_\\.\\-]+\\.[a-zA-Z]{2,6}?$");
	if (rx.exec(emailAddress) == null) {
		alert("Please enter an email address in the form:\nname@burlingtonyoga.com");
		return false;
	} else {
		return true;
	}
}

function openCntrWindow(url, name, w, h, perc) {
  var winX = 0;
  var winY = 0;

  if (parseInt(navigator.appVersion) >= 4) {
    winX = (screen.availWidth - w)*.5;
    winY = (screen.availHeight - h)*.5;
  }
  popupWin = window.open(url, name,'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
}

function OnPageLoad() {
	MM_preloadImages('/images/site_pieces/this_month_a.gif','/images/nav/our_studio_a.gif','/images/nav/classes_a.gif','/images/nav/understanding_a.gif','/images/site_pieces/how_find_a.gif','/images/site_pieces/yoga_glossary_a.gif','/images/site_pieces/find_icon_a.gif','/images/nav/instructors_a.gif','/images/nav/schedule_a.gif','/images/nav/workshops_a.gif','/images/site_pieces/back_top_a.gif', '/images/site_pieces/workshops_more_a.gif');
}

function OpenLocationWindow() {
	window.open('/php/how_to_find_us.htm','how_to_find','location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=360,height=500');
}

function OpenGlossaryWindow() {
	window.open('/php/yoga_glossary.htm','glossary','location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=360,height=500');
}

function DisplayScheduleImage(flash_file, image_file) {
	// set up the content to be placed dynamically on the page
	// customize movie tags and alternate html content below
	if (hasRightVersion && (flash_file != '')) {
			var content = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'WIDTH="270" HEIGHT="287"'
			+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<PARAM NAME="MOVIE" VALUE="' + flash_file + '">'
			+ '<PARAM NAME="PLAY" VALUE="true">'
			+ '<PARAM NAME="LOOP" VALUE="false">'
			+ '<PARAM NAME="QUALITY" VALUE="high">'
			+ '<PARAM NAME="MENU" VALUE="false">'
			+ '<EMBED SRC="' + flash_file + '"'
			+ 'WIDTH="270" HEIGHT="287" align="top"'
			+ 'PLAY="true"'
			+ 'LOOP="false"'
			+ 'QUALITY="high"'
			+ 'MENU="false"'
			+ 'TYPE="application/x-shockwave-flash"'
			+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
			+ '</EMBED>'
			+ '</OBJECT>';
	} else {	
			// flash is too old or we didn't detect the plugin
			var content = '<img src="' + image_file + '" width="270" height="287" align="top" alt="Todays Schedule">';
	}
	document.write(content);	// content
}


var current_ss_image = 0;

function SlideShowImage(i) {
	if (current_ss_image != i) {
		if (current_ss_image > 0) {
			document.getElementById('ss_' + current_ss_image).src = '/images/our_studio/slide_show/pip_i.gif';
		}
		document.getElementById('ss_' + i).src = '/images/our_studio/slide_show/pip_a.gif';
		document.getElementById('sm_feature').src = '/images/our_studio/slide_show/photo_' + i + '.jpg';
		current_ss_image = i;
	}
}

