// ====================================================
var dpExplorerTimer;
var dpWinTop;
var dpWinDiv;

var dpImgHtml;
var dpFirstSSTick = false;


var dpImgCache = new Image();
dpImgCache.onload = function() {
 // When the cache finishes loading, swap the main img with it
 //document.dpImg.src = dpImgCache.src;
 	document.getElementById('dpImage').innerHTML =  dpImgHtml;
 	var imgHeight = document.getElementById('dpImg').offsetHeight;
	var containerHeight = document.getElementById('dpImage').offsetHeight;

	var margin = parseInt((containerHeight  - imgHeight ) / 2);
	//alert( containerHeight + ':' +   imgHeight + ':' + margin);
	//document.getElementById('dpImage').style.marginTop = margin + 'px';
}

function domPopup(){

     //alert( navigator.appName + '\n' + navigator.appVersion);
	this.dpWinSize='FS';  	// FullScreen    FixedWidth   ImageWidth       MIW  SS=StyleSheet

    	// review
	this.winTop=0;
	this.winLeft=0;
	this.winHeight=0;
	this.winWidth=0;
     this.dpSelectEnabled = false;

     this.winWidthFactor = .8 ;
	this.winHeightFactor = .9;
   	//this.dpFixedWindowSize = true;
     this.dpAdjustWindowSize = true;

 	this.view = dpView;
 	this.setSSData = dpSetSSData;
 	this.ssView = dpSSView;
 	this.maxImgWidth=0;
 	this.maxImgHeight = 0;
 	this.winWidthAdjust = 60;
	this.winHeightAdjust = 100;
	this.winMinFactor  = .4;
 	this.ssMaxImgWidth=0;
     this.ssMaxImgHeight=0;


 	this.nextImage = dpNextImage;
	this.prevImage = dpPrevImage;
	this.startShow = dpStartShow;
	this.stopShow = dpStopShow;
	this.setShowControls = dpSetShowControls;
	this.ssTick  = dpSSTick;
     this.ssUpdateTicker  = dpSSUpdateTicker;
     this.ssEnabled = false;
	this.showRunning = false;
	this.dpShowTimer = null;
	this.ssTickCounter = 0;
	this.ssLastTick = 10;
	this.showInterval = 500;


}
var dp = new domPopup;

// ====================================================
function dpStartShow(){
	if (! this.dpShowTimer ){
       	this.ssTickCounter = 0;
		var pThis = this;
		var f = function(){pThis.ssTick();}
		this.dpShowTimer = window.setInterval(f,  this.showInterval);
		this.showRunning = true;
		this.setShowControls();
		dpFirstSSTick = true;
		this.nextImage(true );    // to set buttons!


	}
}
// ====================================================
function dpSetShowControls(){
	if (this.showRunning){
		el =  document.getElementById('dpRunShow');
		if (el) el.style.display = 'none';
		el =  document.getElementById('dpStopShow');
		if (el) el.style.display = 'inline';
	}
	else{
		el =  document.getElementById('dpRunShow');
		if (el) el.style.display = 'inline';
		el =  document.getElementById('dpStopShow');
		if (el) el.style.display = 'none';
	}

}
// ====================================================
function dpSSTick(){
    	if (this.ssTickCounter == this.ssLastTick ){
     	this.ssTickCounter = 0;
		this.nextImage();
     }
     else{
           this.ssTickCounter++;
     }
     this.ssUpdateTicker();
}
// -------------------------------------
function dpSSUpdateTicker(){
	var elTicker = document.getElementById('dpSSTicker');
	var divWidth = Math.floor(100/  this.ssLastTick ) *    this.ssTickCounter  + "%";
     if (elTicker)  elTicker.style.width = divWidth;

}
// ====================================================
function dpStopShow(){
  	if ( this.dpShowTimer ){
		clearInterval(  this.dpShowTimer );
		this.dpShowTimer = null;
		this.showRunning = false;
		this.setShowControls();
		--this.dpCurrentImage;
		this.nextImage();

	}
}
// ====================================================
function dpSetSSData( dirPath, arFiles, arTitles, arSizes, arText){
     this.ssEnabled = true;
	this.ssDir = dirPath;
	this.ssFiles = arFiles;
	var arTitleAndCaptions =  new Array;
	var titleAndText;
     for (var i=1; i < this.ssFiles.length; i++){
       	titleAndText='';
       	if (arTitles && arTitles[i].length) titleAndText =arTitles[i];
       	if (arText && arText[i].length) titleAndText += '|' + arText[i];
          arTitleAndCaptions[i] = titleAndText ;
 	}
	this.ssCaptions = arTitleAndCaptions;
	this.ssSizes = arSizes;
	this.ssLastSlide =  arFiles.length-1;
	if (this.ssLastSlide > 1 ) this.dpSelectEnabled = true;

     this.dpLastImage =this.ssLastSlide;
	for (var i=1; i < this.ssSizes.length; i++){
          arSizes =  this.ssSizes[i].split(',');
          if (arSizes[0]>this.maxImgWidth) this.maxImgWidth = parseInt(arSizes[0]);
		if (arSizes[1]>this.maxImgHeight) this.maxImgHeight = parseInt(arSizes[1]);
 	}
 	if ( this.dpWinSize!='FS') this.dpWinSize = 'MIW';

 	//alert( this.maxImgWidth + ':' + this.maxImgHeight);
}
// ====================================================
function dpSSView( slideIndex){
  	if (slideIndex<1 )slideIndex=  this.ssLastSlide;
  	else if  (slideIndex > this.ssLastSlide )slideIndex=  1;
  	this.ssIndex =  slideIndex;
	imgURL = this.ssDir   + '/' +    this.ssFiles[slideIndex];
	caption =   this.ssCaptions[slideIndex];
	arSizes =  this.ssSizes[slideIndex].split(',');
	var imgWidth = arSizes[0];
	var imgHeight = arSizes[1];
     //alert(imgURL + ' : ' + imgWidth + ' : ' + imgHeight + ' : ' + caption  );
     this.dpCurrentImage = slideIndex;
     this.view(imgURL,imgWidth,imgHeight,caption );
}
// ====================================================
function dpView(imgURL,imgWidth,imgHeight,text ,imgID){
var scW; var scH;
var imgHtml;  var html;
var capHeight;

 	var arText = text.split('|');
     var title = arText[0];
     var caption = arText[1];

     this.maxImgHeight = imgHeight;
	this.maxImgWidth = imgWidth;
 	// If we were passed an image ID it should be like idname_imgno_maximgs
 	// and we can use that for the slide show
 	if (imgID ){
     	var arImgID= imgID.split('_');
     	this.dpImageIDName =  arImgID[0];
		this.dpCurrentImage = parseInt(arImgID[1]);
     	this.dpLastImage = parseInt(arImgID[2]);
		if (! this.dpSelectEnabled ){
            	var linkID;
          	var  elLink;
          	var arLinkData;
          	var onClickStr;
          	this.maxImgWidth =0;
			this.maxImgHeight =0;
			for (var f=1; f <= this.dpLastImage; f++){
                   	linkID =   'a_' + f +  '_' + this.dpLastImage;
				elLink = document.getElementById(linkID);
				onClickStr =  elLink.onclick + '';
				arLinkData =  onClickStr.split(',');
				var thisImgWidth = parseInt(arLinkData[1]);
				var thisImgHeight = parseInt(arLinkData[2]);
				if ( this.maxImgWidth <  thisImgWidth)this.maxImgWidth =  thisImgWidth;
				if ( this.maxImgHeight <  thisImgHeight)this.maxImgHeight =  thisImgHeight;
           	}
  		}

		if (this.dpLastImage > 1 ) {
          	this.dpSelectEnabled = true;
			if ( this.dpWinSize!='FS' && this.dpWinSize!='PC') this.dpWinSize = 'MIW';
		}
  	}

  	// Make sure the image width & height are ints!
	imgWidth = parseInt(imgWidth);
     imgHeight = parseInt(imgHeight);

 	// Get the available screen size
	if( typeof( window.innerHeight ) == 'number' ) scH = window.innerHeight; //Non-IE   - FF etc
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    		//IE 6+ in 'standards compliant mode'
    		scH = document.documentElement.clientHeight;
  	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {	//IE 4 compatible
    		scH = document.body.clientHeight;
	}
 	scH = f_clientHeight();
     scW = f_clientWidth();

	if ( this.maxImgWidth >parseInt(scW - 100))this.maxImgWidth =  parseInt(scW- 100);
	if ( this.maxImgHeight >parseInt(scH- 100))this.maxImgHeight = parseInt(scH- 100);

	// Figure out the max image height and width we can get in the popup window
	var maxH = this.maxImgHeight; //parseInt(scH*.8);
	var maxW = this.maxImgWidth; //parseInt(scW*.8);
	//alert( 'maxH: ' + this.maxImgWidth + '  maxW: ' + maxW );
	var factor;
	// and re-factor the image dimensions to fit
	if (imgHeight>maxH) {
       	factor = maxH/imgHeight;
       	imgHeight=parseInt(imgHeight*factor);;
       	imgWidth=parseInt(imgWidth*factor);;
 	}
	if (imgWidth>maxW) {
       	factor = maxW/imgWidth;
       	imgHeight=parseInt(imgHeight*factor);;
       	imgWidth=parseInt(imgWidth*factor);;
 	}

	var arScroll = libGetScrollXY();
	var scrollTop = arScroll[1];

     switch (this.dpWinSize){
		case 'MIW':      // Max Img Width - used by SLide SHow
			//alert(   this.dpWinSize + ' maxImgWidth: ' + this.maxImgWidth + ' maxImgHeight: ' + this.maxImgHeight);
			this.winWidth =  this.maxImgWidth ;//   + this.winWidthAdjust;;
	     	this.winHeight = this.maxImgHeight ;//  + this.winHeightAdjust;  ;
     		// not too big!
	      	if (this.winWidth > (scW*.85))  this.winWidth = parseInt(scW*.85);
		 	if (this.winHeight >  scH )  this.winHeight =  scH ;
			// and not too small!!
	    		if (this.winWidth < 600)  this.winWidth = 600;
			//if (this.winHeight < 400)  this.winHeight = 400 ;
	    		//if (this.winWidth < (scW*this.winMinFactor))  this.winWidth = parseInt(scW*this.winMinFactor);
			//if (this.winHeight < (scH*this.winMinFactor))  this.winHeight = parseInt(scH*this.winMinFactor);
			break;

		case 'DW':   	// Image (Dynamic) Width
		case 'IW':

			//alert( 'IW/DW: ' + ' imgWidth: ' + imgWidth + ' imgHeight: ' + imgHeight);
			this.winWidth =  imgWidth ;//  + this.winWidthAdjust;;
	     	this.winHeight = imgHeight ;//  + this.winHeightAdjust;  ;

     		// not too big!
	     	if (this.winWidth > (scW*.85))  this.winWidth = (scW*.85);
			if (this.winHeight > (scH*.85))  this.winHeight = (scH*.85);
			// and not too small!!
	    		 if (this.winWidth < (scW*this.winMinFactor))  this.winWidth = (scW*this.winMinFactor);
			 if (this.winHeight < (scH*this.winMinFactor))  this.winHeight = (scH*this.winMinFactor);
			break;
		case 'FW': // Fixed popup size
			this.winWidth =  parseInt(scW *.85);
     		this.winHeight =  parseInt(scH * .85);

			break;
		case 'PC' :
    			this.winWidth =   scW -50;
	     	this.winHeight =  scH  -50;
			this.winLeft=25;
			this.winTop=25;
			break;
		case 'SS':
			break;
     	case 'FS':  	// Full Screen;
     	default:
    			this.winWidth =   scW ; //-12;
	     	this.winHeight =  scH; //  -44;
			this.winLeft=0; //5;
			this.winTop=0; //5;
			break;
     }
	if (this.dpWinSize != 'FS'){
		// Modify height to accomodate toolbar
	     this.winHeight += 70; ;
	     this.winWidth += 70; ;
		// Modify height to accomodate title & caption
		if (text.length > 0){
		    	charsPerLine = Math.round(this.winWidth/6);
			lines=Math.round(text.length/charsPerLine + .5);
			textHeight = (30 * lines);
			this.winHeight += textHeight ;
		}
	}
	// Figure out the max image height and width we can get in the popup window
	var maxH = parseInt(this.winHeight*.8);
	var maxW = parseInt(this.winWidth*.8);
	var factor;

	// and re-factor the image dimensions to fit
/*	if (imgHeight>maxH) {
       	factor = maxH/imgHeight;
       	imgHeight=parseInt(imgHeight*factor);;
       	imgWidth=parseInt(imgWidth*factor);;
 	}
	if (imgWidth>maxW) {
       	factor = maxW/imgWidth;
       	imgHeight=parseInt(imgHeight*factor);;
       	imgWidth=parseInt(imgWidth*factor);;
 	}
*/
     this.winLeft=Math.round((scW-this.winWidth)/2);
	this.winTop=Math.round((scH-this.winHeight)) / 2;

	var debugMsg ='Image:  imgW=[' + imgWidth         + '] imgH=[' + imgHeight         + ']'   ;
	debugMsg += '\nWindow: winW=[' + this.winWidth    + '] winH=[' + this.winHeight    + '] winSize=[' + this.dpWinSize + '] winLeft=[' + this.winLeft + '] winTop=[' + this.winTop + ']';
	debugMsg += '\nMax:    maxW=[' + maxW + '] maxH=[' + maxH + ']' ;

	//alert(debugMsg);

	dpWinTop  =this.winTop;
	// Look for an existing popup div
	var dpWinIsOpen = document.getElementById('domPopup');
     // If popup doesnt exist, create it
	if (! dpWinIsOpen) {
       	dpWinDiv = document.createElement('div');;
		dpWinDiv.setAttribute('id', 'domPopup');
		document.body.appendChild(dpWinDiv);


	 //alert (  "Settings WS:" + this.dpWinSize + "\nImage W: " + imgWidth + " H:" + imgHeight + "\nPopup T:" +   this.winTop +" L:" + this.winLeft +" W:" + this.winWidth +" H:" + this.winHeight);

		// Positioning
	     if( document.all  ) dpWinDiv.style.position = "absolute";  	// For IE we use absolute and adjust it via a timer
		else dpWinDiv.style.position = "fixed";   // or else we use 'proper' fixed positioning

		dpWinDiv.style.width = this.winWidth + 'px';
	   	dpWinDiv.style.height = this.winHeight + 'px';
		dpWinDiv.style.left = this.winLeft + 'px';
	     dpWinDiv.style.top = this.winTop + 'px';

	}
	// Fix for IE Select elements showing through the 'popup'
	if( document.all  ) dpSelectToggle(false);

	// HTML
	html  ='<div id="dpHeader" >';

	// PREV - TITLE - NEXT

	html += '<table id="dpToolBar" ><tr>';
	if(this.dpSelectEnabled) {
       	// BACK
       	if (this.dpCurrentImage>1   )html +='<td class="dpCellPrev" align="center"><a id="dpPrevImg"  title="Previous Image" href="#"  onclick="dp.prevImage();return false;">Back</a></td>';
     	else html +='<td class="dpCellPrev" align="center"><a id="dpPrevImg" class="dpADisabled" title="Previous Image" href="#"  onclick="return false;">Back</a></td>';

	}
    	html  +='<td align="center" class="dpCellClose">';
	html += '<a id="dpClose" href="#" onclick="dpRemovePopUp();return false;">Close Viewer</a>';
	html += '</td>';

	if(this.dpSelectEnabled){
          	// PLAY/STOP
		html +='<td class="dpCellPlay" align="center">';	// NEXT
		html +='<a href="#" title="Run Slideshow"  id="dpRunShow" onclick="dp.startShow();return false;">Start SlideShow</a>';	// NEXT
		html +='<a href="#" title="Stop Slideshow" id="dpStopShow" onclick="dp.stopShow();return false;">Stop SlideShow</a>';	// NEXT
		html +='</td>';	// NEXT

 		// NEXT
       	if (this.dpCurrentImage < this.dpLastImage )html +='<td class="dpCellNext" align="center"><a href="#" title="Next Image"  id="dpNextImg" onclick="dp.nextImage();return false;">Next</a></td>';	// NEXT
 		else html +='<td class="dpCellNext" align="center">&nbsp;</td>'; 	// NEXT
	}
	html += '</tr></table></div>';// CLose dpHeader

     html += '<div id="dpImgContainer" > ';
	// TITLE
	//if(this.dpSelectEnabled)  title = 'Image ' + this.dpCurrentImage + ' of ' + this.dpLastImage + ': ' + title;
	if(this.dpSelectEnabled)  title =   this.dpCurrentImage + ' of ' + this.dpLastImage + ': ' + title;
	if(title) html += '<div id="dpTitle">' + title + '</div>';
	// CAPTION
	if(caption) html += '<div id="dpCaption">' + caption  + '</div>';


	// IMAGE  CONTAINER

	if(this.dpSelectEnabled)html += '<div id="dpSSTicker" ></div> ';
	html += '<div id="dpImage"> </div>';

     html += '</div>';
     //html += '</div>';

	// IMAGE
    	dpImgHtml = '<img id="dpImg" width="' + imgWidth + '" height="' + imgHeight  + '" src="' + imgURL + '">';

	var ldMarginTop  =   imgHeight/ 2 - 16;
	dpImgLoadingHtml = '<div id="dpImgLoading" style="margin-top:' + ldMarginTop + 'px;"></div>';

	
	document.getElementById('domPopup').innerHTML = html;
	this.setShowControls();
	if (dpFirstSSTick ) document.getElementById('dpImage').innerHTML =  dpImgHtml;
	else {
		document.getElementById('dpImage').innerHTML =  dpImgLoadingHtml;
     	dpFirstSSTick = false;
     	dpImgCache.src = imgURL;
	}
	

	// Fix for IE Fixed Pos prob
	if( document.all  ) dpExplorerTimer = window.setInterval(dpExplorerFix, 100);

	return (false);
}
// ====================================================
function dpViewFlash(flashURL){
var scW; var scH;

var html;

     scH = f_clientHeight();
     scW = f_clientWidth();

	// Figure out the max image height and width we can get in the popup window
	var flHeight = parseInt(scH*.66);
	var flWidth =  parseInt(scW*.66);

	this.winWidth =  flWidth  ;
    	this.winHeight = flHeight   ;

	this.winLeft=Math.round((scW-this.winWidth)/2);
	this.winTop=Math.round(scH-this.winHeight) / 2;


	// Look for an existing popup div
	var dpWinIsOpen = document.getElementById('domPopup');
     // If popup doesnt exist, create it
	if (! dpWinIsOpen) {
       	dpWinDiv = document.createElement('div');;
		dpWinDiv.setAttribute('id', 'domPopup');
		document.body.appendChild(dpWinDiv);

		// Positioning
	     if( document.all  ) dpWinDiv.style.position = "absolute";  	// For IE we use absolute and adjust it via a timer
		else dpWinDiv.style.position = "fixed";   // or else we use 'proper' fixed positioning

		dpWinDiv.style.width = this.winWidth + 'px';
	   	dpWinDiv.style.height = this.winHeight + 'px';
		dpWinDiv.style.left = this.winLeft + 'px';
	     dpWinDiv.style.top = this.winTop + 'px';

	}
	// Fix for IE Select elements showing through the 'popup'
	if( document.all  ) dpSelectToggle(false);

	// HTML
	html  =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ';
	html += ' width="' + flWidth + '" height="' + flHeight + '">';
	html += ' <param name=movie value="' . flashURL +  '">';
	html += ' <param name=quality value=high>';
	html += ' <embed src="' + flashURL +  '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ';
	html += ' width="' + flWidth + '" height="' + flHeight + '">';
	html += ' </embed> ';
	html += ' </object>';

	
	document.getElementById('domPopup').innerHTML = html;

	// Fix for IE Fixed Pos prob
	if( document.all  ) dpExplorerTimer = window.setInterval(dpExplorerFix, 100);

	return (false);
}
// -------------------------------------
function dpNextImage(init){
  	//if (this.showRunning) this.stopShow();
  	init = init || false;
  	if (this.ssEnabled )  {
       	  var imgIndex = (init)? this.ssIndex   : this.ssIndex + 1 ;
		  this.ssView( imgIndex );
     }
  	else{
	  	if (init) var nextImageNo =  this.dpCurrentImage;
	  	else var nextImageNo =  ++this.dpCurrentImage;
	  	if ( nextImageNo   >  this.dpLastImage  ) nextImageNo = 1;
	  	var nextLinkID =   'a_' + nextImageNo +  '_' + this.dpLastImage;
		var elLink = document.getElementById(nextLinkID);
		if (elLink) elLink.onclick();
		//else alert( nextLinkID + ' not found');
	  }
}
// -------------------------------------
function dpPrevImage(){
  	//if (this.showRunning) this.stopShow();
 	if (this.ssEnabled )   this.ssView( this.ssIndex - 1 );
  	else{
	  	var prevImageNo =  --this.dpCurrentImage;
	  	if ( prevImageNo   < 1  ) prevImageNo = this.dpLastImage;
	  	var prevLinkID =   'a_' + prevImageNo +  '_' + this.dpLastImage;
		var elLink = document.getElementById(prevLinkID);
		if (elLink) elLink.onclick();
	  }
}

// -------------------------------------
function dpSetImage(){
      document.getElementById('dpImage').innerHTML = dpImgHtml;
}
// -------------------------------------
function dpExplorerFix(){
     var el = document.getElementById('domPopup');
     if (el){
 		var arScroll = libGetScrollXY();
	  	var scrollTop = arScroll[1];
	  	//alert(this.winTop  + '-' + scrollTop)
        	el.style.top = (dpWinTop  + scrollTop ) + 'px';
     }
     else clearInterval(dpExplorerTimer)
}
// -------------------------------------
function dpRemovePopUp( ) {
     dpCloseDiv();
     return;
}
// -------------------------------------
function dpCloseDiv(){
	if ( dp.showRunning )  dp.stopShow();
	if( document.all  ) dpSelectToggle(true);
  	if (dpExplorerTimer) clearInterval(dpExplorerTimer);
  	var el = document.getElementById('domPopup');
  	if(el) document.body.removeChild(el);
  	onkeypress=null;
}
// -------------------------------------
function dpSelectToggle(show){
	var theform =  document.forms[0];
	if (theform){
       	for (i=0; i<theform.elements.length; i++){
			if (theform.elements[i].type=="select-one" ){
	            	el = theform.elements[i];
	            	if (show) libElShow(el);
	            	else libElHide(el);
			}
		}
	}
}
// -------------------------------------
function libGetScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant
		scrOfY = window.pageYOffset;
    		scrOfX = window.pageXOffset;
	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
  	}
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	var myArray = [];
  	myArray[0]=   scrOfX;myArray[1]=   scrOfY;
  	return (myArray);    //return [ scrOfX, scrOfY ];
}
// ==============================
function libElHide(el){
if (document.getElementById || document.all) el.style.visibility = 'hidden';
else if (document.layers)  el.visibility = 'hidden';
}
// ==============================
function libElShow(el){
if (document.getElementById || document.all) {
	el.style.visibility = 'visible';
	//el.style.display = 'block';
}
else if (document.layers)  el.visibility = 'visible';
}

function getScrollerWidth () {
var inner = document.createElement('p');
inner.style.width = '100%';
inner.style.height = '200px';

var outer = document.createElement('div');
outer.style.position = 'absolute';
outer.style.top = '0px';
outer.style.left = '0px';
outer.style.visibility = 'hidden';
outer.style.width = '200px';
outer.style.height = '150px';
outer.style.overflow = 'hidden';
outer.appendChild (inner);

document.body.appendChild (outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if (w1 == w2) w2 = outer.clientWidth;

document.body.removeChild (outer);

return (w1 - w2);
};
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

