

   //-----------------------------------------------------------------------
   // *********************** I M P O R T A N T ***************************
   // The following lines of code create cross browser (ie4 to NS)
   // DHTML layer manuipulation and control and should always be
   // included as the first [head][script language..] variable declarations
   // G.Harstad 2000
   // added  partial NS6 compatibilty T. O'Hara 2/2001
   //-----------------------------------------------------------------------
      //Detect browser type (4+ required)
      var ie4 = document.all;
      var ns = document.layers;
      var gh_dom = document.getElementById;
      
     //BEGIN CROSS BROWSER DOM VARIABLE CREATION
     var doc =  gh_dom ? "document.getElementById('" :ie4 ? "document.all." : "document."
     var sty = gh_dom ? "').style" : ie4 ? ".style" : ""
     var vis = ".visibility="
     var bgcol = ie4 ? ".backgroundColor" : ".backgroundColor"
     //(not correct yet) var fgcol = ie4 ? ".Color" : ".Color"
     
     //Used for getting width & height of a layer
     var getwidth  = gh_dom? ".width" :ie4 ? ".pixelWidth"  : ".clip.width"
     var getheight = gh_dom? ".height" :ie4 ? ".pixelHeight" : ".clip.height"
     
     //used for the differences in showing and hiding a layer
     var show = (ie4||gh_dom) ? "'visible'" : "'show'"
     var hide = (ie4||gh_dom) ? "'hidden'"  : "'hide'"
 //END CROSS BROWSER DOM VARIABLE CREATION
 
 
function demoflaskman()
{
   popWindow('../../boris.bx.net/garry/ge/ge0021omega.html',700,550,'contactwin','no');
}
 
 
  
   //--------------------------------------------------------
   // FUNCTION: togglelayer(lyrname, togval)
   // DESCRIPTION: Toggles a layer's visibility
   // REQUIRES: layers name [string] and 0 or 1 [off or on]  
   // AUTHOR: G.Harstad 2000  
   //--------------------------------------------------------
     function togglelayer(lyrname, togval)
     {   
         var togval2 = (togval == 0) ? hide : show
         eval(doc+lyrname+sty+vis+togval2)
     }
     
    
   //-------------------------------------------------------------
   // FUNCTION: positionlayer(lyrname, topval, leftval)
   // DESCRIPTION: Positions a layer to a new top, left location
   // REQUIRES: layers name [string] and top and left values [int]  
   // AUTHOR: G.Harstad 2000 
   //-------------------------------------------------------------
     function positionlayer(lyrname, topval, leftval)
     {
       eval(doc+lyrname+sty+".top="+topval)
	   eval(doc+lyrname+sty+".left="+leftval)
	   return;
     }
	 
	 
   //----------------------------------------------------------------------------------------
   // FUNCTION: getlyrpos(lyrname, toporleft)
   // DESCRIPTION: Returns a layers top or left value (whichever was passed to the function)
   // EXAMPLE CALL: getlyrpos('mylayer', 'left') [this would return int number of pixels]
   // REQUIRES: layers name [string] and top and left values [int]  
   // AUTHOR: G.Harstad 2000 
   //----------------------------------------------------------------------------------------
     function getlyrpos(lyrname, toporleft)
     {
    	 var toporleft = (toporleft == 'top') ? '.top' : '.left'
       //alert(doc+lyrname+sty+toporleft);
       //alert((eval(doc+lyrname+sty+toporleft)));




         return parseInt(eval(doc+lyrname+sty+toporleft))
     }
	 
    
  
    
    
   //------------------------------------------------------------------------------
   // FUNCTION: slidelayer2(lyrname, newtop, newleft, step)
   // DESCRIPTION: Slides a layer from present position to new absolute top
   //              and left co-ordinates using pixel inc/decrements of 'step'.
   //              This version returns a status of zero when slider has finished.
   // REQUIRES: getlyrpos(), Layers name [string] and new top and left values[ints] 
   // AUTHOR: G.Harstad 2000 NOTE: sendto back not used
   //------------------------------------------------------------------------------
    function slidelayer2(lyrname, newtop, newleft, step, sendtoback)
    {
      if (sendtoback == "") { sendtoback="no"; }//alert('lyrname=['+lyrname+']\nTOP=['+newtop+']\nLEFT=['+newleft+']\nSTEP=['+step+']')
      //status=1;
      jumprange     = 30; //a SNAP-TO pixel area
      completed     = 0;
      var lyrtop    = 191//getlyrpos(''+lyrname, 'top');
		var lyrleft   = getlyrpos(''+lyrname, 'left');
      //alert('[current]\nlyrtop='+lyrtop+'\nlyrleft='+lyrleft);
      //alert('[destination]\nnewtop='+newtop+'\nnewleft='+newleft);
          //----------- TOP ------------------------------
          //new
          var topdiff = Math.abs(lyrtop-newtop)
          //alert(topdiff);
          if(topdiff <= jumprange) { lyrtop = newtop; }
          
            if (lyrtop < newtop)   { lyrtop += step }
            else
            {
              if (lyrtop > newtop) { lyrtop -= step }
              else { completed++ }
            }
            //move the layer TOP pixels
            eval(doc+lyrname+sty+".top="+lyrtop)
          //---------- LEFT ------------------------------ 
          //new
          var leftdiff = Math.abs(lyrleft-newleft)
          //alert(leftdiff);
          if(leftdiff <= jumprange) { lyrleft = newleft; }
          
            if (lyrleft < newleft)   { lyrleft += step }
            else
            {
              if (lyrleft > newleft) { lyrleft -= step }
              else { completed++ }
            }
            //move the layer LEFT pixels
            eval(doc+lyrname+sty+".left="+lyrleft)
      if (completed < 2) { var repeat = setTimeout( "slidelayer2('"+lyrname+"', "+newtop+", "+newleft+", "+step+", '"+sendtoback+"')",1); }
      else
           {
              clearTimeout(repeat)
              //if (sendtoback=="yes") { newzindex(lyrname, 2); }
              //alert('status is now zero');
              //status = 0;
              //return true;
           }
    }
    
    
    
    
   //-------------------------------------------------------------------------------------------
   // FUNCTION: getscreendimension(whichdim)
   // DESCRIPTION: Returns the integer width or height of the current document (frame/browser)
   // EXAMPLE CALL: getscreendimension('width')
   // REQUIRES: Dimension type [string] e.g. 'height' or 'width'.  MUST be run AFTER body loaded 
   // AUTHOR: G.Harstad 2000 
   //--------------------------------------------------------------------------------------------
      //Get screen width and height of client browser window
      function getscreendimension(whichdim)
      {  
         if ((document.all)&&(navigator.userAgent.indexOf('Opera')==-1))//if IE, but not Opera
         { //alert('here%20in%20document.all, where I shouldn\'t be.')
           var screendim = (whichdim=='width') ? "document.body.clientWidth" : "document.body.clientHeight"
           return parseInt(eval(screendim))
         }
         else
         {  //alert('here')
           var screendim = (whichdim=='width') ? "window.innerWidth" : "window.innerHeight"
           return parseInt(eval(screendim))
           //onResize='history.go(0)'
         }
     }

   
    
      
    //custom functions
   
  var presentbutton="";  //just an initialization value
  var presentpopup =""
  var spFlag=false;
   
  function getoffset(){ //function to find out how far from the edge the centered table is
   browserwidth=getscreendimension("width");
  // alert('browser width=' + browserwidth)
      if (browserwidth<=750) { browserwidth=750;
      return 0; }
      else{
        var tableoffset=Math.floor((browserwidth-750)/2);
        //alert(tableoffset);
        if(ns)
        {tableoffset=tableoffset-8}
        if ((navigator.userAgent.indexOf('Gecko')!=-1)&&(spFlag))
          {tableoffset=tableoffset-6}
        if ((document.layers)&&(spFlag))
          {tableoffset=tableoffset-1}
        return tableoffset;}
   }
   function adjustPosition()//function to adjust the position of a visible sublink layer if the window is resized.
   {
    if (spFlag)
      {       
       popupHeight=117
       popupLeft=542
       }
    else
      {
       popupHeight=160
       popupLeft=543
      }
    if (presentbutton!="")//ie, if one is shown
      {
       positionlayer(presentbutton +"2", 161, 3 + getoffset())
       }
    positionlayer('arearisdiv', popupHeight, popupLeft + getoffset())
    positionlayer('logindiv', popupHeight, popupLeft + getoffset())
   }
   
   function exitstage(layername)   //a function to put a layer back offstage
   {
   togglelayer(layername,0);
   positionlayer(layername, 161, 0)
   }
   
   
   function slidesub(buttonname)//function to rollover the image button, turn off all others, and slide in the sublinks
   {
   //turn off the other buttons
   
   
   if (presentbutton!=buttonname){
  
     imgOff('azienda'); exitstage('azienda2',0) //turn off the previous button/layer
     imgOff('attivita');exitstage('attivita2',0)
     imgOff('referenze');exitstage('referenze2',0)
     imgOff('contatti');
    
     
     imgOn(buttonname);
     if (buttonname!='contatti')
      {
       var slidespeed=30
       if ((navigator.userAgent.indexOf('Gecko')!=-1)|| (navigator.userAgent.indexOf('Mac')!=-1))
          {
           slidespeed=50
          }
      
       var thislayer=buttonname + "2";
       positionlayer(thislayer, 161, 750 + getoffset())
       togglelayer(thislayer,1);
       var destination=3
       switch(thislayer)
          {
           case 'azienda2' : destination = -8;break;
           case 'attivita2': destination = -8;break;
           case 'referenze2' : destination = -8;break;
          }
       
       slidelayer2(thislayer, 161, destination + getoffset(), slidespeed)
       presentbutton=buttonname;
        }
      else
        {
         presentbutton="";
        }
       }
     
   }
  
  //function to position the popup forms relatively on the page, 
  //toggle the chosen one, and turn off the other one.
  //Takes care of the images as well
  function toggleForm(divname,xcoord)
    { 
      if (spFlag)
        {popupHeight=117}
      else
        {popupHeight=160}
     
      positionlayer(divname, popupHeight, xcoord + getoffset())
      if (divname==presentpopup)//if we're passed the name of the presently on popup, turn it off, and clear the popup name
         {
          togglelayer(divname,0)
          presentpopup=""
          if (divname=='arearisdiv')//attend to the rollovers
             {
             imgOff('arearis')
             }
          else
             {
             imgOff('login')
             }
         }
       else if (presentpopup=="")//if not, and if the popup is empty, turn it on, and save the name
         {
          togglelayer(divname,1)
          presentpopup=divname;
         }
         else//else the other one is on, turn it off, turn its image off, and turn on the new one
            {
             togglelayer(presentpopup,0)
             togglelayer(divname,1)
             if (presentpopup=='arearisdiv')//attend to the rollovers
                 {
                 imgOff('arearis')
                 }
              else
                 {
                 imgOff('login')
                 }
             presentpopup=divname;
            }
    //alert(presentpopup)
    if (presentpopup!="")
       {
        var thisformname=""
        if (presentpopup=='arearisdiv')
           {
            var thisformname="arearisform.search_string";
           }
        else thisformname="clientlogin.username";
        
        if (ns)
           {
            eval('document.' + presentpopup + '.document.' + thisformname + '.focus()')
            }
         else
           {
            thisformobj=eval('document.' + thisformname)
            //alert(thisformobj.name)
            thisformobj.select()
            thisformobj.focus()
          
           }
        
       }
    
    } 
   
   function popUpFormOff(divname)
     {
     if (divname=='arearisdiv')//attend to the rollovers
         {
         imgOff('arearis')
         }
      else
         {
         imgOff('login')
         }
      togglelayer(divname,0); //turn off the popup
      presentpopup="" //clear out the storage variable
     }
  
   
   
   
   
   //function to submit a form that's within a div. 
   //Takes the name of the form and the name of the div. Takes care of
   //differences between the NS4 and other DOMs. 
   function submitForm(formName, divName)
     {
     if (ns)
       {
        eval('document.' + divName + '.document.' + formName + '.submit()')
        }
     else
       {
        eval('document.' + formName + '.submit()')
       }
     }
     
     //function to popup a window.  Either pass it just the url, and take the default size, or 
     //pass it the url, width, height, windowname, and scrolling/non scrolling (default is non)
     function popWindow(url, width, height, windowName, scrollb) {
      // default width and height for window
      if (!width) { width  = 439; }
      if (!height) { height = 325; }
      if (!scrollb) {scrollb = "no"}
      // positioning of pop-up window
      { leftpos=0
        if (screen) {
        leftpos = screen.width-(width+230)}
     
      //alert("myX=" + myX + "\nmyY=" + myY);
      
      // default window name if not passed to function
      if (!windowName) { windowName = "bxPopup"; }
      wref = window.open (url, windowName,
            "toolbar=no,width=" + width + ",height=" + height + ",directories=no,status=no,scrollbars=" +scrollb + ",resizable=yes,menubar=no,top=50,left="+leftpos);
      wref.focus();
    }
    } 
    
    //gallery-specific popup function
    var daughter = false
    function loadwin(client)
    { leftpos=0
    if (screen) {
    leftpos = screen.width-520}
     newWindow3 = window.open(client,"demo","width=500,height=316,scrollbars=no,left="+leftpos);
    newWindow3.focus(); 
    daughter = true;
    }
   function closewin()
    {
       if ((daughter) && (!newWindow3.closed))
      { newWindow3.close(); }
    }
    
    
    
    
    function searchresults(search_string)
    {
       toggleForm('arearisdiv',542);
       if (ns)
       { var formobj=document.arearisdiv.document.arearisform; }
       else
       { var formobj=document.arearisform; }
       formobj.search_string.value=search_string;
    }


    //function pops up the respective client screenshot and also loads in opening mainpage the gallery
    function thegallery(client_id)
    {
      if(!client_id){ return false; }
      var myurl="../popups/clientpreview.cfm@client_id="+client_id;
      popWindow(myurl,565,450,'ClientInfo','no');
      window.location="clients/gallery.cfm";
      return true
    }
    
    function confirmSubmit(formname)
      {
       thisForm = document.forms[formname];
       var msg  = "By continuing, you confirm that you are over \nthe age of 13 and are legally entitled to send \npersonal information over the Internet."
       if (confirm(msg))
          {thisForm.submit()}
      }
