﻿/*Copyright Bridgeline Software, Inc. An unpublished work created in 2007. All rights reserved. 
This software contains the confidential and trade secret information of Bridgeline Software, Inc. 
("Bridgeline").  Copying, distribution or disclosure without Bridgeline's express written permission is prohibited.*/

/*************************** Browser Window Size and Position****************/
/*copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005*/
function pageWidth() {
    return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
   
function pageHeight() {
    return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 

function posLeft() {
    return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 

function posTop() {
    return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
} 

function posRight() {
    return posLeft()+pageWidth();
} 
function posBottom() {
    return posTop()+pageHeight();
}

/*************************** Scroll height & width****************/
function getPageHeightWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight + document.body.offsetTop;
  	}
	return yWithScroll;
}

function getPageWidthWithScroll(){
	if (window.innerWidth && window.scrollMaxX) {// Firefox
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		xWithScroll = document.body.offsetWidth + document.body.offsetLeft;
  	}
	return xWithScroll;
}

/*************************** Image Swap, preload and rollover functions ****************/
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_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_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 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];}
}
//-->
/*************************** Image Swap, preload and rollover functions ****************/
/*
CSS Browser Selector v0.2.7
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
var css_browser_selector = function() {var ua=navigator.userAgent.toLowerCase(),is=function(t){return ua.indexOf(t) != -1;},h=document.getElementsByTagName('html')[0],b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?'gecko ff2':is('firefox/3')?'gecko ff3':is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';var c=b+os+' js'; h.className += h.className?' '+c:c;}();

/*************************** Pop up a modal window  ****************/

function showModal(pageUrl, height, width) {

	var custompagesFolder="";    
	var browser=navigator.appName;
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);   
    
	var tempIframe = document.createElement('iframe');
	tempIframe.id = "modal";
	tempIframe.name = "modal";
	tempIframe.frameBorder = "0";
	tempIframe.scrolling="no";
	tempIframe.height = "1";
	tempIframe.width = "1";
	tempIframe.style.position="absolute";	
	//tempIframe.style.overflow = "hidden";
	tempIframe.allowTransparency=true;	
	//tempIframe.src = custompagesFolder+ pageUrl;
	tempIframe.src = pageUrl;	
	document.body.appendChild(tempIframe);
	//return false;
}
function CenterModal(width,height){
	var elementId = "modal";
	var visibleHeight = pageHeight();
	var visibleWidth = pageWidth();
	element = document.getElementById(elementId); 
	if(element)
	{
	element.width = width;
	element.height = height+0;
	if(element.height > visibleHeight){
		element.style.top = "20px";
	}else{
		element.style.top = (visibleHeight-element.height)/2 + "px";
	}
	element.style.left = (visibleWidth-element.width)/2 + "px";
	
	var totalHeight = getPageHeightWithScroll();
	var totalWidth = getPageWidthWithScroll(); 
	if(!document.getElementById('coverLayer')){
	    var tempCoverDiv = document.createElement('div');
	    tempCoverDiv.id = "coverLayer";
	    tempCoverDiv.style.height=totalHeight+"px";
	    tempCoverDiv.style.width=totalWidth+"px";
		document.body.appendChild(tempCoverDiv);
		getScrollXY();
	    parent.window.scrollTo(0,0);
	}
	 var wrapper=document.getElementById('wrapper');
	  if(wrapper){
	    setTimeout(function(){     
        element.height=(wrapper.offsetHeight) + "px";},50);
    }
}	
}
function closeModal() { 
	var tempIframe = document.getElementById('modal');
	var tempCoverDiv = document.getElementById('coverLayer');
	if(tempIframe) 
	{
	    tempIframe.parentNode.removeChild(tempIframe);
	}
	if(tempCoverDiv)
	{
	    tempCoverDiv.parentNode.removeChild(tempCoverDiv);
	} 
	parent.window.scrollTo(xPos,yPos);	
}
var xPos = 0, yPos = 0;
function getScrollXY() {
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        xPos = window.pageXOffset;
        yPos = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        xPos = document.body.scrollLeft;
        yPos = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        xPos = document.documentElement.scrollLeft;
        yPos = document.documentElement.scrollTop;
    }
}
/*************************** End pop up a modal window  ****************/

