﻿
//center an object in a browser window
function CenterDiv(id, zindex)
{  
    var container = document.getElementById(id);
    var width = container.style.width.replace("px","");
    var height = container.style.height.replace("px","");;
    
    
    container.style.zIndex = zindex;
                       
    container.style.top = ((( getInnerWindowHeight() / 2 ) - ( height / 2 )) + getScrollY()) + "px";            
    container.style.left =((( getInnerWindowWidth() / 2 ) -( width / 2 )) + getScrollX()) + "px";            
}    

function refreshPage()
{
    document.aspnetForm.ctl00_btnRefresh.click();
}   

function onOk()
{
    __doPostBack('ctl00$ctl03$lblText','');
}   
        
function CenterDivWidth(id, zindex, width, height)
{  
    var container = document.getElementById(id);
        
    var y = ((( getInnerWindowHeight() / 2 ) - ( height / 2 )) + getScrollY()) + "px";            
    var x = ((( getInnerWindowWidth() / 2 ) -( width / 2 )) + getScrollX()) + "px";        
         
    container.style.position = "absolute";
    container.style.zIndex = zindex;      
    container.style.top = '180px';
    container.style.left = x;
} 




//center an object in a browser window
function MoveTo(id, parent)
{  

    var _parent = document.getElementById(parent);
    var container = document.getElementById(id);
    var parentwidth = _parent.offsetWidth;
    var width = container.offsetWidth;
    var height = container.style.height.replace("px","");;
               
    container.style.marginLeft = ((parentwidth / 2) - (width / 2)) + "px";            
}    

//Get current innerbrowserheight of the browser
function getInnerWindowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }  
  return myHeight;  
}
//Get current innerbrowserwidth of the browser
function getInnerWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;    
  } else if( document.body && document.body.clientWidth) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;   
  }  
  return myWidth;  
}
   
//Get vertical scroll offset
function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop) {
    //DOM compliant
    scrOfY = document.body.scrollTop;    
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    
  }
  return scrOfY;
}

//Get horizontal scroll offset
function getScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageXOffset ) == 'number' ) {
    //Netscape compliant
    scrOfX = window.pageXOffset;
  } else if( document.body && document.body.scrollLeft) {
    //DOM compliant
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft) ) {
    //IE6 standards compliant mode   
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}

// Move an element directly on top of another element (and optionally
// make it the same size)
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

//Ok/Cancel - popup
function confirmPost(message)
{       
    var agree = confirm(message);
    if (agree)
        return true ;
    else
        return false ;
}

function toggleDisplay(Id) 
{
    var div = document.getElementById(Id);            
    div.style.display = ((div.style.display == "block" || div.style.display == '') ? "none" : "block");      
}


// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety =  8;

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
    if(!document.getElementById('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = document.getElementById('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}

<!--
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.0
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 && document.getElementById) x=document.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];}
}
//--> 

function getStyle(el, style) {
   if(!document.getElementById) return;
   
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}

function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}

function openNewWindow(url) {
 popupWin = window.open(url,
 'open_window',
 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=800, height=600, left=0, top=0')
}
			
function CallPrint()
{

        window.focus();

        window.print();

}


function CreateMenu()
{
    $('drop_down_menu').getElements('li.menu').each(function(elem) {
        var list = elem.getElement('ul.links');
        var myFx = new Fx.Slide(list).hide();

        elem.addEvents({
            'mouseenter': function() {
                myFx.cancel();
                myFx.slideIn();
            },
            'mouseleave': function() {
                myFx.cancel();
                myFx.slideOut();
            }
        });
    })
}

function ResizeElements(id)
{
    var content = $(id);
        
    content.getElements('img').each(function(elem) {
                   
        var oldWidth = elem.width;
        var oldHeight = elem.height;
                
        var newWidth = elem.width * 1.25;
        var newHeight = elem.height * 1.25;
        //alert(newWidth + " x " + newHeight + " : " + elem.src);
        elem.width = newWidth;
        elem.height = newHeight;
          
    })
}




  //------------------------------------------------------------
// suppress all error messages and do nothing with them:
//
function noErrorMessages () { return true; }
window.onerror = noErrorMessages;

//------------------------------------------------------------
// advanced: a full error handler

function handleError (err, url, line) {
    if (err.indexOf('is not defined') != -1) {
      alert('Oops, something is not defined.\\n' +
             err + '\n' + url + '\nline no: ' + line);
      return true; // error is handled
    }
    else
      return false; // let the browser handle the error
  }

window.defaultOnError = window.onerror; // store default handler
window.onerror = handleError; // assign own handler

//.. executing my faulty code

window.onerror = window.defaultOnError;  // restore default handler


