function conf()
{
  if( confirm( 'Are you sure?' ) ) return true
  else return false;
}
function openAWindow( pageToLoad, winName, width, height, center){

xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) &&(center)){
 xposition = (screen.width - width) / 8;
 yposition = (screen.height - height) / 3;
}

args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only

window.open( pageToLoad, winName, args );
}

function openAWindow2( pageToLoad, winName, width, height, center){

xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) &&(center)){
 xposition = (screen.width - width) / 8;
 yposition = (screen.height - height) / 3;
}

args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=1,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only

window.open( pageToLoad, winName, args );
}



function showAnounce( id ){
        var anounceDiv = document.getElementById('anounce'+id);
        var anounceLink = document.getElementById('anounceLink'+id);
        var linkLeft = getRelLeft( anounceLink );
        var w = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
        w += getBodyWidth();
        var left;
        if( ( linkLeft + 20 + anounceDiv.clientWidth ) < w )
                left = linkLeft + 30;
        else {
                linkLeft = getRelLeft( anounceLink );
                left = linkLeft - 20 - anounceDiv.clientWidth;
        }
        anounceDiv.style.left = left;
        var linkTop = getRelTop( anounceLink );
        var h = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
        h += getBodyHeight();
        var top;
        if( ( linkTop + 20 + anounceDiv.clientHeight ) < h )
                top = linkTop + 30;
        else {
                linkTop = getRelTop( anounceLink );
                top = linkTop - 20 - anounceDiv.clientHeight;
        }
        anounceDiv.style.top = top;
        anounceDiv.style.visibility = 'visible';
        var shadowImg = document.getElementById('anounceBg'+id);
        shadowImg.style.width = anounceDiv.clientWidth + 38;
        shadowImg.style.height = anounceDiv.clientHeight + 35;
        shadowImg.style.top = top - 12;
        shadowImg.style.left = left - 18;
        shadowImg.style.visibility = 'visible';
}

function hideAnounce( id ){
        var anounceDiv = document.getElementById('anounce'+id);
        anounceDiv.style.visibility = 'hidden';
        var shadowImg = document.getElementById('anounceBg'+id);
        shadowImg.style.visibility = 'hidden';
}

function getRelLeft(el) {
        var pos = el.offsetLeft;
        while (el.offsetParent != null) { el = el.offsetParent; pos += el.offsetLeft; if (el.tagName == 'BODY') break; }
        return pos;
}

function getRelTop(el) {
        var pos = el.offsetTop;
        while (el.offsetParent != null) { el = el.offsetParent; pos += el.offsetTop; if (el.tagName == 'BODY') break; }
        return pos;
}

function getBodyHeight() {
        if (self.innerWidth) return self.innerHeight;
        else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientHeight;
        else if (document.body) return document.body.clientHeight;
}

function getBodyWidth() {
        if (self.innerWidth) return self.innerWidth;
        else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
        else if (document.body) return document.body.clientWidth;
}

function startAlignDivs() {
        window.onscroll = alignDivs;
        window.onresize = alignDivs;
        alignDivs();
}

function alignDivs(){
        var viz = document.getElementById('vizDiv');
        var vizBg = document.getElementById('vizLocation');
        viz.style.left = getRelLeft( vizBg );
        hideViz();
        viz.style.visibility = "visible";
}

function showViz(){
        var viz = document.getElementById('vizDiv');
        viz.style.top = 0;
        var vizOpenArrow = document.getElementById('vizOpenArrow');
        vizOpenArrow.src = '/img/viz-arrow-up.gif';
}

function hideViz(){
        var viz = document.getElementById('vizDiv');
        var vizTable = document.getElementById('vizTable');
        viz.style.top = -1 * vizTable.clientHeight + 33;
        var vizOpenArrow = document.getElementById('vizOpenArrow');
        vizOpenArrow.src = '/img/viz-arrow-down.gif';
}

// url encode string
function url_encode( s )
{
  s = new String( s )
  s = s.replace( "#", "%23" )
  s = s.replace( " ", "+" )
  s = s.replace( "/", "%2F" )
  s = s.replace( "?", "%3F" )
  s = s.replace( "=", "%3D" )
  s = s.replace( "&", "%26" )
  return s;
}


function showsubmitdiv()
{
// alert('status of calcsubm is '+document.getElementById('calcsubm').style.visibility);

   if(document.getElementById('calcsubm').style.visibility=='hidden')
   {
   document.getElementById('calcsubm').style.visibility='visible';
   document.getElementById('calcsubm2').style.visibility='hidden' ;
           }
   else if(document.getElementById('calcsubm').style.visibility=='visible')
   {
   document.getElementById('calcsubm').style.visibility='hidden';
   document.getElementById('calcsubm2').style.visibility='visible' ;
  // alert('showit');
           }


        }
