function HideTransLayer(){
	var obj = document.getElementById('TransLayer');
	if(obj != null)
		obj.style.display = 'none';
}

function createRequestObject(){
	var request_o;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}

function getData(url, divId, loadingText, async){
	async = typeof(async) != 'undefined' ? async : true;
	http.open('get', url, async);

	http.onreadystatechange = function(){
			if (http.readyState == 1 && loadingText != ''){
				document.getElementById(divId).innerHTML = loadingText;
			}
			if (http.readyState == 4){ 
				document.getElementById(divId).innerHTML = http.responseText;
			}
		};

	http.send(null);
}

function postData(url, params, divId, loadingText, async){
	async = typeof(async) != 'undefined' ? async : true;

	http.open('post', url, async);

	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function(){
			if (http.readyState == 1 && loadingText != ''){
				document.getElementById(divId).innerHTML = loadingText;
			}
			if (http.readyState == 4){
				document.getElementById(divId).innerHTML = http.responseText;
			}
		};

	http.send(params);
}

function ShowFullScreenLoader(){
	var obj = document.getElementById('FullScreenLoaderFrame');
	if(obj != null){
		obj.style.display = 'block';
	}
	obj = document.getElementById('FullScreenLoader');
	if(obj == null){
		document.getElementById('FullScreenLoaderFrame').innerHTML = '<div class="LayoutLoader"><div style="margin: 5px" id="FullScreenLoader"></div></div>';
	}
}

function HideFullScreenLoader(){
	var obj = document.getElementById('FullScreenLoaderFrame');
	if(obj != null)
		obj.style.display = 'none';
}

function ScrollTransLayers(){
	var top =  f_scrollTop();
	var obj = document.getElementById('FullScreenLoaderFrame');
	if(obj != null)
		obj.style.top = top;

	obj = document.getElementById('TransLayer');
	if(obj != null)
		obj.style.top = top;
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function GoTo(url){
	window.location = url;
}

function getWidth(/* Object */ el, /* boolean */ includePadding, /* boolean */ includeBorder) {
    var width;
    el = (typeof(el) == "string") ? document.getElementById(el) : el;    
    
    if(window.getComputedStyle) { // FF, Safari, Opera
        var style = document.defaultView.getComputedStyle(el, null);
        if(style.getPropertyValue("display") == "none")
            return 0;
        width = parseInt(style.getPropertyValue("width"));
        
        if(/opera/i.test(navigator.userAgent)) {
            // opera includes the padding and border when reporting the width/height - subtract that out
            width -= parseInt(style.getPropertyValue("padding-left"));
            width -= parseInt(style.getPropertyValue("padding-right"));
            width -= parseInt(style.getPropertyValue("border-left-width"));
            width -= parseInt(style.getPropertyValue("border-right-width"));
        }
        
        if(includePadding) {
            width += parseInt(style.getPropertyValue("padding-left"));
            width += parseInt(style.getPropertyValue("padding-right"));
        }
        
        if(includeBorder) {
            width += parseInt(style.getPropertyValue("border-left-width"));
            width += parseInt(style.getPropertyValue("border-right-width"));
        }
    } else { // IE
        if(el.currentStyle["display"] == "none")
            return 0;
        var widthCSS = el.currentStyle["width"];
        var bRegex = /thin|medium|thick/; // regex for css border width keywords
        width = el.offsetWidth; // currently the width including padding + border
        
        if(!includeBorder) {
            var borderLeftCSS = el.currentStyle["borderLeftWidth"];
            var borderRightCSS = el.currentStyle["borderRightWidth"];
            var temp = document.createElement("DIV");
            if(!bRegex.test(borderLeftCSS)) {
                temp.style.width = borderLeftCSS;
                el.parentNode.appendChild(temp);
                width -= Math.round(temp.offsetWidth);
                el.parentNode.removeChild(temp);
            } else if(bRegex.test(borderLeftCSS)) {
                if(el.offsetWidth > el.clientWidth && el.currentStyle["borderLeftStyle"] != "none") {
                    temp.style.width = "10px";
                    temp.style.border = borderLeftCSS + " " + el.currentStyle["borderLeftStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    width -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
            if(!bRegex.test(borderRightCSS)) {
                temp.style.width = borderRightCSS;
                el.parentNode.appendChild(temp);
                width -= Math.round(temp.offsetWidth);
                el.parentNode.removeChild(temp);
            } else if(bRegex.test(borderRightCSS)) {
                if(el.offsetWidth > el.clientWidth && el.currentStyle["borderRightStyle"] != "none") {
                    temp.style.width = "10px";
                    temp.style.border = borderRightCSS + " " + el.currentStyle["borderRightStyle"] + " #000000";
                    el.parentNode.appendChild(temp);
                    width -= Math.round((temp.offsetWidth-10)/2);
                    el.parentNode.removeChild(temp);
                }
            }
        }
        
        if(!includePadding) {
            var paddingLeftCSS = el.currentStyle["paddingLeft"];
            var paddingRightCSS = el.currentStyle["paddingRight"];
            var temp = document.createElement("DIV");
            temp.style.width = paddingLeftCSS;
            el.parentNode.appendChild(temp);
            width -= Math.round(temp.offsetWidth);
            temp.style.width = paddingRightCSS;
            width -= Math.round(temp.offsetWidth);
            el.parentNode.removeChild(temp);
        }
    }
    
    return width;
}

function roundNumber(number) {
	return Math.round(number*1000000)/1000000;
}

function roundNumber2(number) {
	return Math.round(number*100)/100;
}

function CalcNet(name){
	var obj = document.getElementById(name);
	if(obj != null)
	{
		obj.value = roundNumber((obj.value / (100 + 17.5) * 100));
	}
}