    var iMMTmpFlightID = -1;
    var sMMActiveLinie = '';
    var bMMBlockSearch = 0;

    function MM_Expert_setPrice(sLinie,sDat1,sDat2) {
    	try {
    		MM_Expert_clearAll(sLinie);
	    	if (sDat1=='' || sDat2=='') {
	    		return false;
	    	}

	    	var sKey = '';
	    	var iLinieID = sLinie;
	    	var sTmp = sLinie+'_'+sDat2+'_'+sDat1;

	    	for(key in aMMKeys) {
				if (key==sTmp) {
					sKey = aMMKeys[key];
					break;
				}
	    	}
            
            var iPrice = 0;
	    	if (sKey!='') {
				sMMActiveLinie = sLinie;
				for(var x=0;x<aMMData.length;x++) {
					if (aMMData[x][0]==sKey) {
						iMMTmpFlightID = aMMData[x][3];
					}
				}
                iPrice = oPriceObject.getPrice(sKey,sLinie);
	    	} else {
                iPrice = 'ERROR';
	    	}

	        //addHTML('id','ddd',0,'A: PRICE: '+iPrice+"\n");
	        if (iPrice!='ERROR' && iPrice != 0) {
	        	//addHTML('id','ddd',0,'B: PRICE: '+iPrice+"\n");
	            MM_Expert_builInfo(iLinieID,iPrice,iMMTmpFlightID);
	            getElem('id','PriceInfoErrorBox'+iLinieID,0).style.display = 'none';
				getElem('id','PriceInfoBox'+iLinieID,0).style.display = 'block';
				//MM_Expert_clearAll(iLinieID);
	            return true;
	        } else {
	            MM_Expert_showError('Hin- und R&uuml;ckflug nicht kombinierbar, bitte andere Kombination w&auml;hlen!',iLinieID);
	            //MM_Expert_clearAll(iLinieID);
	            return true;
	        }
    	} catch(e) { }
    }

    function MM_Expert_getChecked(sLinie,sType) {
    	try {
	    	var aDates = document.getElementsByTagName('input');
	        for (var i=0;i<aDates.length;i++) {
	        	var tmp  = aDates[i].name;
	        	if (tmp.substr(0,7)!='mmLinie') {
	        		continue;
	        	}
	        	if (tmp.length<9) {
	        		continue;
	        	}
	        	var tmp2 = 'mmLinie' + sLinie + sType;
	        	//addHTML('id','ddd',0,'TMP1: '+tmp+' TMP2:'+tmp2+"\n");
	            if (aDates[i].type=='radio' && tmp2==tmp && aDates[i].checked) {
	                return aDates[i].value;
	            }
	        }
    	} catch (e) {
    		alert(e);
    	}
		return '';
    }

    function MM_Expert_builInfo(sLinie,iPrice,iFlightId) {
    	getElem('id','MMFlightID'+sLinie,0).value = iFlightId;
    	var sHtml = ''+iPrice+' &euro;';
        setHTML('id','MMPrice'+sLinie,0,sHtml);
    }

    function MM_Expert_formatPrice(sPrice) {
        if (sPrice.length>3) {
            return sPrice.substr(0,1)+'.'+sPrice.substr(1,3);
        }
        return sPrice;
    }

    function MM_Expert_showError(sText,sLinie) {
        var sHtml = sText;
        setHTML('id','PriceInfoErrorBox'+sLinie,0,sText);
        getElem('id','PriceInfoErrorBox'+sLinie,0).style.display = 'block';
		getElem('id','PriceInfoBox'+sLinie,0).style.display = 'none';
    }

    function MM_Expert_clearAll(sLinie) {
        var aDates = document.getElementsByTagName('input');
        for (var i=0;i<aDates.length;i++) {
        	try {
	        	if (aDates[i].type=='radio' && aDates[i].name.substr(0,7)=='mmLinie') {
	            	if (aDates[i].name!=('mmLinie'+sLinie+'B') &&
	            		aDates[i].name!=('mmLinie'+sLinie+'A')) {
	                	aDates[i].checked = false;
	        		}
	            }
        	} catch (e) {
        		//alert(e);
        		continue;
        	}
        }
        return true;
    }

    function MM_Expert_getRho() {
        var iRho = 0;
        try {
            if (sFromBack=="1") {
                iRho = 1;
            } else {
                iRho = 0;
            }
        } catch(e) {
            iRho = 0;
        }
        return iRho;
    }

    function MM_Expert_next(sLinie) {
        if (sMMActiveLinie!=sLinie) {
            MM_Expert_showError('Bitte w&auml;hlen Sie zuerst einen passenden Flug aus!',sLinie);
            return false;
        } else {
            bMMBlockSearch = 1;
            var sLink = '';
            try {
                if (sLinie=='ZZ') {
                    sLink = sMMLink.replace(/sa=[^&]*/,'sa=HTR');
                    sLink = sLink + '&view=420_0_0_0_0_0_0_0';
                } else {
                    sLink = sMMLink + '&view=420_0_0_0_0_0_0_0&FLid=' + getElem('id','MMFlightID'+sLinie,0).value + '&rho=' + MM_Expert_getRho();
                }
                mmWaitingForNextStepStart(sLinie);
                gotoURL(sLink);
            } catch (e) { }
            return false;
        }
    }

    function MM_Expert_next430(sLinie) {
    	if (bMMBlockSearch==1) {
    		return false;
    	}
        if (sMMActiveLinie!=sLinie) {
            MM_Expert_showError('Bitte w&auml;hlen zuerst einen passenden Flug aus!');
            return false;
        } else {
        	bMMBlockSearch = 1;
            var sLink = '';
            mmWaitingForNextStepStart();
            sLink = sMMLink + '&view=430_0_0_0_0_0_0_0&FLid=' + getElem('id','MMFlightID'+sLinie,0).value + '&rho=' + MM_Expert_getRho();
            gotoURL(sLink);
            return false;
        }
    }


    /********************************************************/
    /** Start Object MM_PriceObject                        **/
    /********************************************************/
    function MM_PriceObject() {
        this.prices = new Array();
        this.push   = MM_PriceObject_push;
        this.getPrice = MM_PriceObject_getPrice;
		this.priceComplete = 0;
		this.setPriceCompleteModus = MM_PriceObject_setPriceCompleteModus;
    }

    function MM_PriceObject_push(iId,iPrice,sLinie,iPriceComplete) {
        this.prices.push(new MM_PricePair(iId,iPrice,sLinie,iPriceComplete));
    }

    function MM_PriceObject_getPrice(iId,sLinie) {
        for (var i=0;i<this.prices.length;i++) {
            if (this.prices[i].key==iId && this.prices[i].linie==sLinie) {
                if(this.priceComplete == 1)
				{
					return this.prices[i].priceComplete;
				}
				else
				{
					return this.prices[i].val;
				}
            }
        }
        return 'ERROR';
    }
	
	function MM_PriceObject_setPriceCompleteModus()
	{
		this.priceComplete = 1;
	}
    /********************************************************/
    /** Ende Object MM_PriceObject                         **/
    /********************************************************/

    function MM_PricePair (iKey,sVal,sLinie,iPriceComplete) {
        this.key = iKey;
        this.val = sVal;
        this.linie = sLinie;
		this.priceComplete = iPriceComplete;
    }

    var sMMExpertInitObjId = '';

    function MM_Expert_init() {
    	if (sMMExpertInitObjId!='') {
    		var aVals = sMMExpertInitObjId.split('#');
			MM_Expert_setPrice(aVals[0],aVals[1],aVals[2]);
    	}
    }
