﻿    function showSelectFields(){
       var elements = document.getElementsByTagName("select");
       for (i=0;i< elements.length;i++){
          elements[i].style.visibility='visible';
       }
    }

    function hideSelectFields(){
       var elements = document.getElementsByTagName("select");
       for (i=0;i< elements.length;i++){
       elements[i].style.visibility='hidden';
       }
    }
    
    function findPos(obj) {
	    var curleft = curtop = 0;
	    if (obj.offsetParent) {
		    curleft = obj.offsetLeft
		    curtop = obj.offsetTop
		    while (obj = obj.offsetParent) {
			    curleft += obj.offsetLeft
			    curtop += obj.offsetTop
		    }
	    }
	    return [curleft,curtop];
    }
    
    function windowSize(offset) {
        if (!offset) var offset = 0;
        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 [myWidth - offset,myHeight - offset];
    }

    function CenterUploadArea(container)
    {
        function offsetParent (element) {
            if (element.offsetParent) return element.offsetParent;
            if (element == document.body) return element;

            while ((element = element.parentNode) && element != document.body)
            if (Element.getStyle(element, 'position') != 'static')
                return element;

            return document.body;
        }  
          
        var uploadContainer = null;
        
        if (CenterUploadArea.container)
        {
            uploadContainer = CenterUploadArea.container;
        }
        else
        {
            if (!container)
            {
                var divs = document.getElementsByTagName ('DIV');
                for (var i=0; i<divs.length; i++)
                {
                    if (divs[i].className == 'RadUploadProgressArea')
                    {
                        uploadContainer = divs[i];
                        break;
                    }
                }
            }
            else
                uploadContainer = document.getElementById (container);
                
            CenterUploadArea.container = uploadContainer;
        }
        
        if (!uploadContainer)
            return;
        
        var posContainer = offsetParent (uploadContainer);
        posContainer.style.position = 'static';
        
        var scrollX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
        var scrollY = window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop;
        
        var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        var windowWidth  = window.innerWidth  || document.documentElement.clientWidth  || document.body.clientWidth;
        
        var x = Math.round (windowWidth/2 - uploadContainer.offsetWidth/2) + scrollX;
        var y = Math.round (windowHeight/2 - uploadContainer.offsetHeight/2) + scrollY;
        
        uploadContainer.style.top = y + 'px';
        uploadContainer.style.left = x + 'px';
        uploadContainer.style.position = 'absolute';
    }
    
    function encodeMyHtml(toEncode) {
       return toEncode.replace(/&/gi, '&').replace(/\"/gi, '"').replace(/</gi, '<').replace(/>/gi, '>');
    }    
    

