
	
	// ajax to include external file
	
		
		/***********************************************
		* Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
		* This notice MUST stay intact for legal use
		* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
		***********************************************/
		
		//To include a page, invoke ajaxinclude("***.htm") in the BODY of page
		//Included file MUST be from the same domain as the page displaying it.
		
		//var rootdomain="http://"+window.location.hostname
		
		function ajaxinclude(url) {
		var page_request = false
			if (window.XMLHttpRequest) // if Mozilla, Safari etc
				page_request = new XMLHttpRequest()
			else if (window.ActiveXObject){ // if IE
				try {
					page_request = new ActiveXObject("Msxml2.XMLHTTP")
					} 
				catch (e){
					try{
						page_request = new ActiveXObject("Microsoft.XMLHTTP")
						}
						catch (e){}
					}
			}
			else
				return false
			page_request.open('GET', url, false) //get page synchronously 
			page_request.send(null)
			if (window.location.href.indexOf("http")==-1 || page_request.status==200)
				return page_request.responseText;
			}		
		
		
// Determine browser and version.
	function Browser() {
		var ua, s, i;
		
		this.isIE    = false;
		this.isNS    = false;
		this.version = null;
		
		ua = navigator.userAgent;
		
		s = "MSIE";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isIE = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}
		
		s = "Netscape6/";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}
		
		// Treat any other "Gecko" browser as NS 6.1.
		s = "Gecko";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = 6.1;
			return;
		}
	}
	
	
// custom code - lightbox window
/*

  	scrollX - to determine how far horizontally the browser is scrolled  
	scrollY - to determine how far verticallly the browser is scrolled
    windowHeight - the height of the veiwport	
	windowWidth - the width of the veiwport	
  
  /***** function to create the lightbox  
  bxContent : url of the external document or text message 
  bxTitle: title of the box
  w, h of the box
  type: 0 - normal message text
  		1 - external document - call ajaxinclude to pull the external page
  redirectUrl: url to redirect to after user click Close button.
  action: action to take after close the light box.
  confirm: CONFIRM if it acts like a confirm() function
  
  scrollX : to determine how far horizontally the browser is scrolled  
  scrollY : to determine how far verticallly the browser is scrolled
  windowHeight : the height of the veiwport	
  windowWidth : the width of the veiwport	
  
  
  *******/
  		

  function showBox(bxContent, bxTitle, w, h, type, redirectUrl, action, toConfirm )
  { 
  var survey = false;	
	if(typeof bxContent =="undefined") bxContent="";  
	if(typeof bxTitle =="undefined" || bxTitle =='')  bxTitle=document.title.split("|")[0];
	if(bxTitle.indexOf("?") > -1) survey = true;
	if(typeof w =="undefined") w=450;
	if(typeof h =="undefined") h=270;
	if(typeof type=="undefined")type=0;;	
	if(typeof redirectUrl =="undefined") redirectUrl="";		
	if(typeof action=="undefined") action="";	
	if(typeof toConfirm=="undefined") toConfirm="";

	if (action!="")
		action = unescape(action);
	
	var de = document.documentElement;
	var db = document.body;
	var scrollX = (self.pageXOffset || (de && de.scrollLeft) || db.scrollLeft);
	var scrollY = (self.pageYOffset || (de && de.scrollTop) || db.scrollTop);
	var windowHeight = (self.innerHeight || (de && de.clientHeight) || db.clientHeight);
	var windowWidth	= (self.innerWidth || (de && de.clientWidth) || db.clientWidth);
	var wint = scrollY + (windowHeight /2) - (h/2) ;
	var winl = scrollX + (windowWidth/2) - (w/2);
	var browser = new Browser();	
	var layer = document.getElementById('layer');
    var div = document.getElementById('box');	
	
	
	this.removeBox = function (){
      db.removeChild(document.getElementById('layer'));
      db.removeChild(document.getElementById('box'));
	}  	
	
	this.closeBox = function () {
		  removeBox();	
		  if(redirectUrl!=""){		
		    location.replace(redirectUrl);
		  } else {
 	  	  	if(action!="")		  	
			   	eval(action);			  
		  }	
	}
	
	if (!layer){
		 layer = document.createElement('div');
	    layer.id = 'layer';
	}	
	layer.style.left = '0px';
	layer.style.height= windowHeight + de.offsetHeight  + 'px'; // add document.documentElement.offsetHeight so it will cover whole page in IE
    db.appendChild(layer); 
	
    if(!div){
		 div = document.createElement('div');	
	    div.id = 'box';
	}	
    div.style.height = h + (browser.isNS ? 36: 0) + 'px';
    div.style.width = w + 'px';
    div.style.top = wint + 'px';
	div.style.left = winl + 'px';
	div.innerHTML = '<b class="hdCorner"><b class="Corner1"><b></b></b><b class="Corner2"><b></b></b><b class="Corner3"></b></b>';	
		div.innerHTML += '<span class="x1"><span class="x1a"></span></span><span class="x2"><span class="x2a"></span></span>';

    db.appendChild(div); 
	
	// heading
	var elhd = document.createElement('div');     
	elhd.className = 'hd';
	elhd.innerHTML = '<div style="float: left;">'+bxTitle + '</div><div style="float: right; padding-right:5px;"><a href="javascript:;" onclick="removeBox()"><img src="' +imageWWWPath+ '/close-black.gif" id="imgClose" align="absmiddle"></a></div><div class="clear"></div>';
	div.appendChild(elhd);	
	
    var elc = document.createElement('div');
	elc.className = 'content'
	elc.id = 'pcont'
	
	elc.style.height =  (h - 28 - 38) + "px";  // content's height =  h - header - footer

//	elc.innerHTML = ((type==0) ? '<p>'+bxContent+'</p>' :  '<div class="small" style="text-align: right;"><a href="" onclick="printSelection(document.getElementById(\'pcont\'));return false">print</a></div>' + ajaxinclude(bxContent) ); //+ '<br><br>' ;	
	elc.innerHTML = ((type==0) ? '<p>'+bxContent+'</p>' :   ajaxinclude(bxContent) ); //+ '<br><br>' ;	
	
	// footer
	var elft = document.createElement('div');
	elft.className = 'ft';
	if(toConfirm.toUpperCase()!="CONFIRM"){
			// close button
      if(!survey)
      {	
		    var a = document.createElement('a');
  			a.className = 'button';
  	    a.innerHTML = 'Close window';
  	    a.href = 'javascript:closeBox();';
  		  elft.appendChild(a);
      }		
	} else {

		// OK button	
   		var okbtn = document.createElement('a');
		okbtn.className = 'button';
		okbtn.id="YesBtn"		
	    okbtn.innerHTML = 'Yes';
 	    okbtn.href = 'javascript:closeBox();';
		elft.appendChild(okbtn);		

		// No button	
	    var nobtn = document.createElement('a');
		nobtn.className = 'button';
		nobtn.id="NoBtn"
	    nobtn.innerHTML = 'No';
	    nobtn.href = 'javascript:removeBox()';
		elft.appendChild(nobtn);	
	}	

			
	div.appendChild(elc);
	div.appendChild(elft);		
	div.innerHTML += '<b class="ftCorner"><b class="Corner5"></b><b class="Corner4"></b><b class="Corner3"></b><b class="Corner2"><b></b></b><b class="Corner1"><b></b></b></b>';		

  }	
  
  /* --------------------------------------------------
	Update Showbox
-------------------------------------------------- */
	function updateShowbox(bxContent, bxTitle, w, h, type, redirectUrl, action, toConfirm ) {
		
		if(typeof bxContent =="undefined") bxContent="";  
	if(typeof bxTitle =="undefined" || bxTitle =='')  bxTitle=document.title.split("|")[0]
	if(typeof w =="undefined") w=450;
	if(typeof h =="undefined") h=270;
	if(typeof type=="undefined")type=0;;	
	if(typeof redirectUrl =="undefined") redirectUrl="";		
	if(typeof action=="undefined") action="";	
	if(typeof toConfirm=="undefined") toConfirm="";

	if (action!="")
		action = unescape(action);
	
	var de = document.documentElement;
	var db = document.body;
	var scrollX = (self.pageXOffset || (de && de.scrollLeft) || db.scrollLeft);
	var scrollY = (self.pageYOffset || (de && de.scrollTop) || db.scrollTop);
	var windowHeight = (self.innerHeight || (de && de.clientHeight) || db.clientHeight);
	var windowWidth	= (self.innerWidth || (de && de.clientWidth) || db.clientWidth);
	var wint = scrollY + (windowHeight /2) - (h/2) ;
	var winl = scrollX + (windowWidth/2) - (w/2);
	var browser = new Browser();	
	var layer = document.getElementById('layer');
    var div = document.getElementById('box');	
	
	
	this.removeBox = function (){
      db.removeChild(document.getElementById('layer'));
      db.removeChild(document.getElementById('box'));
	}  	
	
	this.closeBox = function () {
		  removeBox();	
		  if(redirectUrl!=""){		
		    location.replace(redirectUrl);
		  } else {
 	  	  	if(action!="")		  	
			   	eval(action);			  
		  }	
	}
	
	if (!layer){
		 layer = document.createElement('div');
	    layer.id = 'layer';
	}	
	layer.style.left = '0px';
	layer.style.height= windowHeight + de.offsetHeight  + 'px'; // add document.documentElement.offsetHeight so it will cover whole page in IE
    db.appendChild(layer); 
	
    if(!div){
		 div = document.createElement('div');	
	    div.id = 'box';
	}	
    div.style.height = h + (browser.isNS ? 36: 0) + 'px';
    div.style.width = w + 'px';
    div.style.top = wint + 'px';
	div.style.left = winl + 'px';
	div.innerHTML = '<b class="hdCorner"><b class="Corner1"><b></b></b><b class="Corner2"><b></b></b><b class="Corner3"></b></b>';	
		div.innerHTML += '<span class="x1"><span class="x1a"></span></span><span class="x2"><span class="x2a"></span></span>';

    db.appendChild(div); 
	
	// heading
	var elhd = document.createElement('div');     
	elhd.className = 'hd';
	elhd.innerHTML = '<div style="float: left;">'+bxTitle + '</div><div style="float: right; padding-right:5px;"><a href="javascript:;" onclick="removeBox()"><img src="' +imageWWWPath+ '/close-black.gif" id="imgClose" align="absmiddle"></a></div><div class="clear"></div>';
	div.appendChild(elhd);	
	
    var elc = document.createElement('div');
	elc.className = 'content'
	elc.id = 'pcont'
	
	elc.style.height =  (h - 28 - 38) + "px";  // content's height =  h - header - footer

//	elc.innerHTML = ((type==0) ? '<p>'+bxContent+'</p>' :  '<div class="small" style="text-align: right;"><a href="" onclick="printSelection(document.getElementById(\'pcont\'));return false">print</a></div>' + ajaxinclude(bxContent) ); //+ '<br><br>' ;	
	elc.innerHTML = ((type==0) ? '<iframe name="showBoxFrame" src="'+bxContent+'" width="100%" height="100%" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="auto"></iframe>' :   ajaxinclude(bxContent) ); //+ '<br><br>' ;	
	
	// footer
	var elft = document.createElement('div');
	elft.className = 'ft';
	if(toConfirm.toUpperCase()!="CONFIRM"){
			// close button	
		    var a = document.createElement('a');
			a.className = 'button';
	    a.innerHTML = 'Close window';
	    a.href = 'javascript:closeBox();';
		elft.appendChild(a);		
	} else {

		// OK button	
   		var okbtn = document.createElement('a');
		okbtn.className = 'button';
		okbtn.id="YesBtn"		
	    okbtn.innerHTML = 'Yes';
 	    okbtn.href = 'javascript:closeBox();';
		elft.appendChild(okbtn);		

		// No button	
	    var nobtn = document.createElement('a');
		nobtn.className = 'button';
		nobtn.id="NoBtn"
	    nobtn.innerHTML = 'No';
	    nobtn.href = 'javascript:removeBox()';
		elft.appendChild(nobtn);	
	}	

			
	div.appendChild(elc);
	div.appendChild(elft);		
	div.innerHTML += '<b class="ftCorner"><b class="Corner5"></b><b class="Corner4"></b><b class="Corner3"></b><b class="Corner2"><b></b></b><b class="Corner1"><b></b></b></b>';
	}
  
 
// function to print only a div content 
function printSelection(node){

  var content=node.innerHTML
  var pwin=window.open('','print_content','width=100,height=100');
  pwin.resizeTo(1,1);

  pwin.document.open();
  pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();
 
  setTimeout(function(){pwin.close();},1000);

}  

	// function to center the light box as the user scrolls the window
	function adjustBox(){
			var obj = document.getElementById('box');
			if (!obj) return;
		
		var de = document.documentElement;
		var db = document.body;	
		var scrollX = (self.pageXOffset || (de && de.scrollLeft) || db.scrollLeft);
		var scrollY = (self.pageYOffset || (de && de.scrollTop) || db.scrollTop);
		var windowHeight = (self.innerHeight || (de && de.clientHeight) || db.clientHeight);
		var windowWidth	= (self.innerWidth || (de && de.clientWidth) || db.clientWidth);
	
			var w= Number(obj.style.width.substr(0,obj.style.width.length-2) );
			var h= Number(obj.style.height.substr(0,obj.style.height.length-2) );
			
		var t=scrollY + (windowHeight /2) - (h/2);
			if (t<0) t=0;
	
		var l=scrollX + (windowWidth/2) - (w/2);
			if (l<0) l=0;
		
			obj.style.top = t+"px";
			obj.style.left = l+"px";
	
	}



	function showBoxAlert(alertText, postAlertAction) {
		var alertTextFinal = '<div align="center">'+
			'	<p>'+ cleaner(alertText) +'</p>'+
			//'	<p style="margin-top: 1.5em;"><input type="button" value="continue" onclick="hideTheBox();'+ (typeof(postAlertAction)=="undefined" && postAlertAction!='' ? postAlertAction : '') +'" class="button"></p>'+
			'</div>';
		var alertW = Math.ceil(alertTextFinal.length * 1.5);
		if(alertW < 300) alertW=300;
		var alertH = Math.ceil(alertW / 3);
		if(alertH < 150) alertH=140;
		
		showBox(alertTextFinal, 'Canadian Opera Company', alertW, alertH);
	}
	
	function showBox_img(imgfile, title, w, h){
		imgfile ='<img src="/evenue/linkID=coc/images/' +imgfile+'">'; 
		//log(imgfile);
		showBox(imgfile, title, w, h);
	}

