
	
	// 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;
			
		//	writecontent(page_request)
		}
		/*
		function writecontent(page_request){
			if (window.location.href.indexOf("http")==-1 || page_request.status==200)
				document.write(page_request.responseText)
			}		
		*/	
		
	
	
// custom code - lightbox window

  // function to determine how far horizontally the browser is scrolled  
  function scrollX() {
  	var de = document.documentElement;
	return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft;
  }
  
  // function to determine how far verticallly the browser is scrolled
  function scrollY() {
  	var de = document.documentElement;
	return self.pageYOffset || (de && de.scrollTop) || document.body.scrollTop;
  }

  // return the height of the veiwport	
  function windowHeight() {
   	var de = document.documentElement;
	return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
  }
  // return the width of the veiwport	
  function windowWidth() {
   	var de = document.documentElement;
	return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
  }
  
  /***** 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
  redirectUrl: url to redirect to after user click Close button.
  *******/
  		
  function showBox(bxContent, bxTitle, w, h, type, redirectUrl, action )
  { 
	if(typeof(bxTitle)=="undefined") 	bxTitle =document.title;
	if(typeof(w)=="undefined") 			w=600;
	if(typeof(h)=="undefined") 			h=480;
	if(typeof(type)=="undefined") 		type=0;	
	if(typeof(redirectUrl)=="undefined") 	redirectUrl="";		
	if(typeof(action)=="undefined") 		action="";			

	var wint=scrollY() + (windowHeight() /2) - (h/2);
	if (wint<0) t=10;

	var winl=scrollX() + (windowWidth()/2) - (w/2);
	if (winl<0) l=10;
   var layer = document.getElementById('layer');
   if (!layer){
 		layer = document.createElement('div');
    	layer.id = 'layer';
   }	
   layer.style.left = '0px';
   layer.style.height= windowHeight() + document.documentElement.offsetHeight  + 'px'; // add document.documentElement.offsetHeight so it will cover whole page in IE
    document.body.appendChild(layer); 
   
    var div = document.getElementById('box');
    if(!div){
		div = document.createElement('div');	
		div.id = 'box';
    }	
    div.style.height = h + 'px';
    div.style.width = w + 'px';
    div.style.top = wint + 'px';
	div.style.left = winl + 'px';

    //div.style.border = '1px solid silver';
    document.body.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-2.png" 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';
		// close button	
	    var a = document.createElement('a');
		a.className = 'button';
	    a.innerHTML = 'Close window';
	    a.href = 'javascript:closeBox(\''+redirectUrl + '\',\'' + action + '\')';

	elft.appendChild(a);		
		
	div.appendChild(elc);
	div.appendChild(elft);		

  }	
  
function removeBox(){
      document.body.removeChild(document.getElementById('layer'));
      document.body.removeChild(document.getElementById('box'));
}  

function closeBox(url, action) {
		  removeBox();	
		  if(url!="" ){		
		    location.replace(url);
		  } else {
 	  	  	if(action!="" )		  	
			   	eval(action);			  
		  }	
}

 
// 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 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";

}



