function Ajax(objTargetCulture) {    


    //vatriables
    var culture;


    //constructor	
	this.Constructor = Constructor;
	function Constructor() {
	    String.prototype.trim = function(){ return this.replace( /^\s*/, "" ).replace( /\s*$/, "" )};
	    String.prototype.toInt = function(){ return parseInt(this,10)};
        String.prototype.startsWith = function(str) {return this.indexOf(str)==0;}
        String.prototype.endsWith = function(str) {return (this.length-str.length)==this.lastIndexOf(str);}
        String.prototype.HTMLEncode = function(str) {return this.replace(/</g, "&lt;" ).replace(/>/g, "&gt;" );}        
        String.prototype.replaceString = function (oldS, newS) {var fullS = this;for (var i = 0; i < fullS.length; i++) {if (fullS.substring(i, i + oldS.length) == oldS) {fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fullS.length);}}return fullS;}        
        String.prototype.reverse = function() {var s = ""; var i = this.length; while (i>0) {s += this.substring(i-1,i); i--; } return s;}        
        String.prototype.capitalize = function(str) {return this.substr(0,1).toUpperCase() + this.substr(1).toLowerCase();}
        Number.max = function (a,b) {return a<b?b:a;}
        Number.min = function (a,b) {return a>b?b:a;}	    
        Array.prototype.indexOf = function(s) {for (var x=0;x<this.length;x++) if(this[x] == s) return x;return false;}
        Array.prototype.removeAt = function(index) {return this.splice(index,1);}
        Math.mod = function(val,mod) {if (val < 0) {while(val<0) val += mod;return val;} else {return val%mod;}}
        culture = objTargetCulture;
	}
	
	
	//properties
	this.getCulture = getCulture;
	function getCulture() {
	    return culture;
	}
	
	//metodes
	this.createXmlHttpRequest = createXmlHttpRequest;
    function createXmlHttpRequest (){
    	var objXmlHttpRequest;
    	/*@cc_on @*/
    	/*@if (@_jscript_version >= 5)
    	  try {
    	  objXmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP")
    	 } catch (e) {
    	  try {
    	    objXmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP")
    	  } catch (E) {
    	   objXmlHttpRequest=false
    	  }
    	 }
    	@else
    	 objXmlHttpRequest=false
    	@end @*/
    	if (!objXmlHttpRequest) {
    		try {
    			objXmlHttpRequest = new XMLHttpRequest();
    		} catch (e) {
    			objXmlHttpRequest = false
    		}
    	}
    	return objXmlHttpRequest;
    }    
    this.downloadFile = downloadFile;
    function downloadFile(aUrl, asyncHandler, strLoadingDivId) {
        var objHttpRequest = createXmlHttpRequest();    	
	    objHttpRequest.open("GET", aUrl + "?" + (new Date()).getTime(), (asyncHandler!=null));
    	if (!asyncHandler) {
        	objHttpRequest.send(null);
    	    var result = objHttpRequest.responseText;
    	    return result;
        } else {
        	objHttpRequest.onreadystatechange = function() {
        		if (objHttpRequest.readyState==4) {
    		        asyncHandler (objHttpRequest.responseText);
    		        if (strLoadingDivId) setTimeout(hideLoadingMessage, 200);
        		}
        	};
        	if (strLoadingDivId) showLoadingMessage(document.getElementById(strLoadingDivId));
        	objHttpRequest.send(null);
       }
    }    
    this.getAbsoluteLeft = getAbsoluteLeft;
    function getAbsoluteLeft(refObj){
        if (refObj==null) return 0;
    	xPos = refObj.offsetLeft;
        try {
        	parentObj = refObj.offsetParent;
    	    while(parentObj != null) {
    	        if (parentObj.style.position=="absolute") {
    	            xPos += 0;
    	        } else {
    	            xPos += parentObj.offsetLeft;
    	        }	        
    	        parentObj=parentObj.offsetParent;
            }
    	} catch(E) {;}
    	return xPos;
    }
    this.getRelativeLeft = getRelativeLeft;
    function getRelativeLeft(refObj) {
    	return refObj.offsetLeft + refObj.offsetParent.offsetLeft + refObj.offsetParent.offsetParent.offsetLeft;
    }
    this.getAbsoluteTop = getAbsoluteTop;
    function getAbsoluteTop(refObj){
        if (refObj==null) return 0;
        yPos = refObj.offsetTop;
        try {	    
    	    parentObj=refObj.offsetParent;
    	    while(parentObj != null) {
    	    	if (parentObj.style.position=="absolute") {
    	            yPos += 0;
    	        } else {
    	            yPos += parentObj.offsetTop;
    	        }	        
    	        parentObj=parentObj.offsetParent
            }
    	} catch(E) {;}
    	return yPos;
    }   
    this.getAbsoluteHeight = getAbsoluteHeight;
    function getAbsoluteHeight(refObj) {
        if (refObj==null) return 0;
        if (refObj.clientHeight != 0) return refObj.clientHeight;
        return refObj.offsetHeight;
    }
    function getAbsoluteWidth(refObj) {
        if (refObj==null) return 0;
        if (refObj.clientWidth != 0) return refObj.clientWidth;
        return refObj.offsetWidth;
    }
    this.getOpacity = getOpacity;
    function getOpacity(obj) {
        if (document.all) {
            if (obj.filters.length>0) {
                for (var i=0; i<obj.filters.length; i++) {
                    if (obj.filters[i].opacity!="undefined") return obj.filters[i].opacity;
                }
            }
            return 100;
        } else  {
            return (obj.style.opacity=="" ? 100 : obj.style.opacity * 100);
        }
    }
    this.setOpacity = setOpacity;
    function setOpacity(obj, opacity) {
      opacity = (opacity == 100) ? 99.999 : opacity;            
      obj.style.filter = "alpha(opacity:"+opacity+")";                      // IE/Win      
      obj.style.KHTMLOpacity = opacity/100;                                 // Safari<1.2, Konqueror      
      obj.style.MozOpacity = opacity/100;                                   // Older Mozilla and Firefox      
      obj.style.opacity = opacity/100;                                      // Safari 1.2, newer Firefox and Mozilla, CSS3
    }
    this.fadeTo = fadeTo;
    function fadeTo(objId, opacity, increment) {
        var obj = document.getElementById(objId);
        var currentOpacity = getOpacity(obj);
        //alert(currentOpacity)
        //return ;
        if (increment>0) {
            currentOpacity += increment;
            if (currentOpacity >= opacity) {
                setOpacity(obj, opacity);
            } else {
                setOpacity(obj, currentOpacity);
                window.setTimeout("objAjax.fadeTo('"+objId+"',"+opacity+","+increment+")", 25);
            }        
        } else {
            currentOpacity -= increment;
            if (currentOpacity <= opacity) {
                setOpacity(obj, opacity);
            } else {
                setOpacity(obj, currentOpacity);
                window.setTimeout("objAjax.fadeTo('"+objId+"',"+opacity+","+increment+")", 25);
            }        
        }
    }
    this.fadeOut = fadeOut;
    function fadeOut(objId,opacity) {
        var obj = document.getElementById(objId);
        obj.setAttribute("fade", "fadeOut");
        if (opacity >= 0) {
            setOpacity(obj, opacity);
            opacity -= 10;
            window.setTimeout("objAjax.fadeOut('"+objId+"',"+opacity+")", 25);
        } else {
            obj.setAttribute("fade", null);
        }
    }
	this.showLoadingMessage = showLoadingMessage;
	function showLoadingMessage(objDIVParent) {
	    var objDIV = document.getElementById("divLoading");
	    if (!objDIV) {
	        objDIV = document.createElement("DIV");
	        objDIV.innerHTML = "<img src='images/loading.gif'/><br /><span>&nbsp;&nbsp;" + (culture=="ca" ? "Carregant" : (culture=="es" ? "Cargando" : "Loading")) + "...</span>";
	        objDIV.id = "divLoading";
	        objDIV.className = "loading";
	        objDIV.setAttribute("numberOfCalls", 1);	        
	        objDIV.style.display = "none";
	        document.body.appendChild(objDIV);
        } else {
            objDIV.setAttribute("numberOfCalls", parseInt(objDIV.getAttribute("numberOfCalls"),10)+1);
        }
        if (objDIVParent) {
            objDIV.style.position = "absolute";
            objDIV.style.left = getAbsoluteLeft(objDIVParent) + parseInt(getAbsoluteWidth(objDIVParent)/2,10) - 40 + "px";
            objDIV.style.top = getAbsoluteTop(objDIVParent) + parseInt(getAbsoluteHeight(objDIVParent)/2,10) - 35 + "px";
            objDIV.style.display = "block";
        } else {
            objDIV.style.display = "none";
        }
	}
	this.hideLoadingMessage = hideLoadingMessage;
	function hideLoadingMessage() {
	    var objDIV = document.getElementById("divLoading");
	    if (objDIV) {
            var numberOfCalls = parseInt(objDIV.getAttribute("numberOfCalls"),10);
            numberOfCalls--;
            objDIV.setAttribute("numberOfCalls", numberOfCalls);
            if (numberOfCalls==0) objDIV.style.display = "none";
	    }
	}
	this.getStringTagContents = getStringTagContents;
	function getStringTagContents(html, tagName) {
	    var i = html.toLowerCase().indexOf("<" + tagName);
	    i = html.indexOf(">", i);
	    var j = html.toLowerCase().indexOf("</" + tagName);
	    html = html.substr(i+1, j-i-1);
	    return html;
	}

    //call constructor
    Constructor();	
}

