if (typeof(CM_WEBCOMPONENT_MODELTYPESELECTOR) == 'undefined') (function() { // #ifndef

CM_WEBCOMPONENT_MODELTYPESELECTOR = function (strName) {
	this.strName = strName;
	this.arrOnLanguageClick = new Array();
	this.objSendDataHttpRequest = new DHL.NET.HTTPREQUEST();
	this.blnSending = false;
	this.ptCallbackFunction = "";
}

var PUBLIC = CM_WEBCOMPONENT_MODELTYPESELECTOR.prototype;
var PRIVATE = CM_WEBCOMPONENT_MODELTYPESELECTOR.prototype;
var STATIC = CM_WEBCOMPONENT_MODELTYPESELECTOR; 
var SELF = CM_WEBCOMPONENT_MODELTYPESELECTOR; 

PUBLIC.onLanguageClick = function(intLanguageId) {
	this._selectLanguageBox(intLanguageId);
}
PUBLIC.notifyLanguageClick = function(intLanguageId) {
	for(var intI = 0; intI < this.arrOnLanguageClick.length; intI++) {
		this.arrOnLanguageClick[intI](intLanguageId, this);
	}
}
PUBLIC.registerOnLanguageClick = function(ptFunction) {
	this.arrOnLanguageClick.push(ptFunction);
}

PUBLIC._selectLanguageBox = function (intLanguageId) {
	var obj = document.getElementById('lang' + this.strName + parseInt(intLanguageId));
	
	document.getElementById('lang' + this.strName + 583).checked = false;
	document.getElementById('lang' + this.strName + 584).checked = false;
	document.getElementById('lang' + this.strName + 585).checked = false;
	document.getElementById('lang' + this.strName + 586).checked = false;
	document.getElementById('lang' + this.strName + 587).checked = false;
	
	if (obj) {
		obj.checked = true;
	}
}

PUBLIC.changePref = function(intNewLanguageId) {
	var objUrlToSend = new DHL.NET.URL.getCurrent();
	var strAttributes = 'Frm[' + this.strName + '][modelLanguageId]='+intNewLanguageId;

	this.objSendDataHttpRequest.open('POST', objUrlToSend, true);

	this.objSendDataHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	this.objSendDataHttpRequest.setRequestHeader('Content-length', strAttributes.length);
	this.objSendDataHttpRequest.setRequestHeader('Connection', 'close');

	var me = this;
	this.objSendDataHttpRequest.onreadystatechange(function() {
		me.onReceiveData();
	});
	this.objSendDataHttpRequest.send(strAttributes);
	this.ptCallbackFunction = this.callbackChangeModelLanguageId;
	// -------
	this.notifyLanguageClick(intNewLanguageId);
}

PUBLIC.showChoice = function() {
	if(document.getElementById("modelLanguage" + this.strName)) {
		document.getElementById("modelLanguage" + this.strName).style.display="block";
	}
	if(document.getElementById("loadingLanguage" + this.strName)) {
		document.getElementById("loadingLanguage" + this.strName).style.display="none";
	}
}

PUBLIC.hideChoice = function() {
	if(document.getElementById("modelLanguage" + this.strName)) {
		document.getElementById("modelLanguage" + this.strName).style.display="none";
	}
	if(document.getElementById("loadingLanguage" + this.strName)) {
		document.getElementById("loadingLanguage" + this.strName).style.display="block";
	}
}

PUBLIC.onReceiveData = function() {
	if(this.objSendDataHttpRequest.getReadyState() == 4) {
		//response has been received
		this.blnSending = false;
		if(
			this.objSendDataHttpRequest.getStatus() == 200 && 
			this.ptCallbackFunction
		) {
			this.ptCallbackFunction(this.objSendDataHttpRequest.getResponseText());
		}
	}
}

PUBLIC.callbackChangeModelLanguageId = function(intNewModelLanguageId) {
	//alert(intNewModelLanguageId);
}

})();