function sniffIE()
{
    var sAgent = navigator.userAgent

	var isIE = (sAgent.indexOf("MSIE")  > -1)

	return isIE;
}

function getAbsolutePos(el) 
{
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) 
	{
	    var tmp = getAbsolutePos(el.offsetParent);
	    r.x += tmp.x;
	    r.y += tmp.y;
	 }
	 return r;
}

function getClientBounds()
{
    var clientWidth;
    var clientHeight;
    
    if( sniffIE() )
    {
        clientWidth = document.documentElement.clientWidth;
        clientHeight = document.documentElement.clientHeight;
    }
    else
    {
        clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
        clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);
    }
    
    var r = { width: clientWidth, height:clientHeight  };     
    return r;
}

function setFirefoxSpecificAttributesQR()
{
    if (navigator.appName == "Netscape")
    {
        var oQRFundSearchName = document.getElementById('ctl00_ContentPlaceHolder1_aFundQuickrankControl_SearchKey');
        if (oQRFundSearchName != null)
        {
            oQRFundSearchName.style.height = '15px';
            oQRFundSearchName.style.paddingTop = '2px';
        }

        var oQRUnivList = document.getElementById('ctl00_ContentPlaceHolder1_aFundQuickrankControl_lbClientFunds');
        if (oQRUnivList != null)
            oQRUnivList.style.width = '18%';
    }
}

function setFirefoxSpecificAttributesFS()
{

    if (navigator.appName == "Netscape")
    {
        var oleft_part = document.getElementById('left_part_inner');
        if (oleft_part != null)
            oleft_part.style.paddingRight = '5.0%';
    }
}

function getIEVersionNumber() 
{
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) 
        return 0;
    else
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
}

function setIE6SpecificAttributesFS()
{
    if (getIEVersionNumber() == 6)
    {
        var oleft_part = document.getElementById('left_part_inner');
        if (oleft_part != null)
            oleft_part.style.paddingRight = '5.0%';
    }
}

function setIESpecificAttributesXRayEH()
{
    if (navigator.appName == "Microsoft Internet Explorer")
    {
        var oEAButton = document.getElementById('divEqualAllocation');
        if (oEAButton != null)
            oEAButton.style.height = '19px';
        
    }
}

function getURLParameter(name) 
{  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    
    var regexS = "[\\?&]"+ name + "=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    
    if( results == null )    
        return "";  
    else    
        return results[1];
}

// This is to replace the default WebForm_CallbackComplete function 
// which causes errors when used with multiple callbacks (something like that anyway)
function WebForm_CallbackComplete_SyncFixed() {
    for (var i = 0; i < __pendingCallbacks.length; i++) {
        callbackObject = __pendingCallbacks[i];
        if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
			// the callback should be executed after releasing all resources 
			// associated with this request. 
			// Originally if the callback gets executed here and the callback 
			// routine makes another ASP.NET ajax request then the pending slots and
			// pending callbacks array gets messed up since the slot is not released
			// before the next ASP.NET request comes.
			// FIX: This statement has been moved below
			// WebForm_ExecuteCallback(callbackObject);

            if (!__pendingCallbacks[i].async) {
                __synchronousCallBackIndex = -1;
            }
            __pendingCallbacks[i] = null;
            var callbackFrameID = "__CALLBACKFRAME" + i;
            var xmlRequestFrame = document.getElementById(callbackFrameID);
            if (xmlRequestFrame) {
                xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
            }
            // SyncFix: the following statement has been moved down from above;
            WebForm_ExecuteCallback(callbackObject);
        }
    }
}
