// ##############################################################################
// #													
// # Author:		D. Weber, M. Derschang
// # Copyright:		Plan Software GmbH, Saarbrücken
// # 
// # Last Change:	2006.07.13 <DW>
// #													
// ##############################################################################


function	exit()
{
    self.close();
};


// Defines the main frames of the EasyKat sys-
// tem. Usually it's just 'top', but if the
// system is embedded into an external IFrame
// environment it has to point to the IFrame
// the EasyKat catalog is running in
var topEasykatFrame = top;
topEasykatFrame.id = 'EKMainFrame';
topEasykatFrame.name = 'EKMainFrame';


// Disables all input controls of the dialog, so
// the user can't trigger any request as long as
// another request is processed. The function is
// only executed if the corresponding "SCREEN_
// GRAYING" parameter isn't set to disabled
function disableInput()
{
    // Flag which represents the parameter status
    // for the current dialog
    var executeFunction = true;
    
	// Fetch the dialog object for retrieving
	// the ident of the current dialog
	var dialogObject = topEasykatFrame.frames["RFrame"].dialog;
	
	// If the system is initialized
	if(dialogObject)
	{
		if(dialogObject.id == "IDD_CONFIG")
			executeFunction = ($F("screenGrayingEnabled") == "true") ? true : false;
		else
			executeFunction = (topEasykatFrame.$F("screenGrayingEnabled") == "true") ? true : false;
	}
    
    if(executeFunction)
    {
        disableDivElement = topEasykatFrame.$('INPUT_DISABLE').show();
        
        if ( topEasykatFrame.is.ie6 )
        {
            var rFrame =  topEasykatFrame.frames['RFrame'];
            
            if(topEasykatFrame.document.body)
                topEasykatFrame.$(topEasykatFrame.document.body).addClassName('hideComboboxes');
            if(rFrame.document.body)
                topEasykatFrame.$(rFrame.document.body).addClassName('hideComboboxes');
        }
    }
}


// Enables all input controls of the dialog again
// after the current request has been completely
// processed
function enableInput()
{
    // Activate the dialog controls only, if the
    // popup blocker is deactivated or no popup
    // check has been done (parameter)
    // ** check currently deactivated **
    //if(topEasykatFrame.$F("popupBlockerChecked") == "true")
    {
        topEasykatFrame.$('INPUT_DISABLE').hide();
        
        if ( topEasykatFrame.is.ie6 )
        {
            topEasykatFrame.$(topEasykatFrame.document.body).removeClassName('hideComboboxes');
            topEasykatFrame.$(topEasykatFrame.frames['RFrame'].document.body).removeClassName('hideComboboxes');
        }
    }
}


// Initializes and opens the CAD4Web window
// which displays the status of the current
// configuration as a CAD drawing and offers
// the downloading or copying these data to
// a CAD development environment
function initCAD4Web()
{
    disableInput();
    
    // Trigger the mapping process of the
    // EasyKat configuration data, and if
    // it's successful, open the Cad4Web
    // window
    setTimeout(function() {
        var result = sendSyncRequest("openCAD4WebWindow", "").evalJSON();
        
        if(result.mappingSuccessful)
        {
            var cad4WebFramework = topEasykatFrame.Cad4Web;
            cad4WebFramework.openCadWin({
                preview: '3D',
                errordisplay: !Boolean(parseInt(topEasykatFrame.$F("cad4WebErrorTabHidden"))),
                measures: true
            });
            
            // Check periodically if the Cad4Web
            // window is initialized, so the con-
            // trols of the dialog can get en-
            // abled again
            var initChecksDone = 0;
            var enableInputCheckInterval = window.setInterval(function() {
                // Count the executions to enable the
                // dialog's controls again after a
                // certain number has been reached
                initChecksDone++;
                
                if(cad4WebFramework.isInitialized() || initChecksDone > 25)
                {
                    window.clearInterval(enableInputCheckInterval);
                    enableInput();
                }
            }, 500);
        }
        else
            enableInput();
    }, 50);
}


// Starts the quick search oder loads the expert
// search dialog from a HTML page the client has
// created
function startSearch(searchType, searchText)
{
    if(searchType.toUpperCase() == "QUICK")
    {
        topEasykatFrame.$("IDC_SEARCH").value = searchText;
        
        disableInput();
        ekSubmit('IDC_EXECUTEQUICKSEARCH', 'RFrame');
    }
    else if(searchType.toUpperCase() == "EXPERT")
    {
        disableInput();
        ekSubmit('IDC_EXPERT_SEARCH', 'RFrame');
    }
}


// Encapsulates the system language changing
// procedure so it can be called by an external
// HTML page created by the client
function changeLanguage(languageIsoCode)
{
    if(languageIsoCode.length == 2)
    {
        topEasykatFrame.$("IDC_COMBO_LANGUAGE").value = languageIsoCode;
        ekSubmit("IDC_COMBO_LANGUAGE");
    }
}


// Function of the dialog IDD_CFGSUMMARY which
// makes the button (table cell) to display the
// shoppingcart dialog visible and hides the but-
// ton (table cell) to add the configured pro-
// duct to the shoppingcart
function toggleShoppingcartButton()
{
    $("IDC_CFGSUMMARY_ADD_SHOPPINGCART").hide();
    $("IDC_CFGSUMMARY_DISPLAY_SHOPPINGCART").show();
}


// Checks the character which was just entered.
// The mode parameter determines which characters
// are allowed. The element parameter contains
// the DOM-element of the edit field to be con-
// trolled by this function. It allows the func-
// tion to delete illegal characters.
// This function does ONLY work in Internet Explorer !
function checkInputChar(mode, element)
{
    // Character which was just entered as keyCode
    var inputKeyCode = window.event.keyCode;
    
    // Edit field content
    var fieldContent = $(element).value;
    
    // The regular expression which matches all
    // illegal characters
    var illegalCharsRegExp;
    
    // Allowed control characters such as
    // backspace or arrow keys
    var allowedKeyCodes;
    
    // Only characters used when specifying
    // prices are allowed to be entered
    if(mode == "pricesOnly")
    {
        illegalCharsRegExp = /[^0-9,\.]/g;
        allowedKeyCodes = [8,9,16,20,37,38,39,40,46,144];
    }
    
    // Only numbers are allowed to be entered
    if(mode == "numbersOnly")
    {
        illegalCharsRegExp = /\D/g;
        allowedKeyCodes = [8,9,16,20,37,38,39,40,46,144];
    }
    
    // Check if it's an allowed control character
    for(var i = 0; i < allowedKeyCodes.length; i++)
    {
        if(allowedKeyCodes[i] == inputKeyCode)
            return;
    }
        
    // Delete all illegal characters from the
    // editfield's content
    $(element).value = fieldContent.replace(illegalCharsRegExp,"");
}


// Function for the dialog IDD_LOGIN which sets an
// onKeyPress observer to both input field. This
// observer ensures that the login request is pro-
// cessed if the enter key is pressed
function setLoginObserver()
{
    // This observe is only needed for IE, so
    // set it onyl if this brwoser is used
    if(is.ie)
    {
        var enterKeyObserver = function() {
            var event = window.event;
            var keyCode = event.keyCode;
            
            if(keyCode == 13)
                loginUser();
        };
        
        $("*.DLGDATA.DLGVARS.EASYKATLIGHT.IDD_LOGIN.IDC_USERNAME_EDIT").observe("keydown", enterKeyObserver);
        $("*.DLGDATA.DLGVARS.EASYKATLIGHT.IDD_LOGIN.IDC_PASSWORD_EDIT").observe("keydown", enterKeyObserver);
    }
}


// Function which is used by all dialogs to check
// for system errors. If an error has occurred,
// its displaying will be initiated. Condition
// for the correct operation of this function is
// the availability of the JavaScript function
// "displayPopupNotice" which processes the dis-
// playing of the error
function checkSystemError()
{
    var systemErrorOccurred = Boolean(parseInt($F("SYSTEM_ERROR_OCCURRED")));
    
    if(systemErrorOccurred)
	{
        displayPopupNotice("");
		$("SYSTEM_ERROR_OCCURRED").value = 0;
	}
    // Check if an old error notice didn't get
    // masked, yet, and make up for it, if ne-
    // cessary
    else
        hidePopupNotice();
}


/**
 * Function for displaying a popup message which provides two
 * buttons to demand a decision from the user. Depending on
 * this desition which gets processed by a handler function
 * either a special event is sent, so the universal obvserver
 * function can react on it or nothing is done except enab-
 * ling all dialog controls again. All arguments have to be
 * passed within an anonymous object.
 *
 * @param noButtonValue {String} - The label of the button
 *		  used to negate the question to be decided
 * @param yesButtonValue {String} - The label of the button
 *		  used to approve the question to be decided
 * @param confirmMessageText {String} - The text of the con-
 *		  firmation massage to display to the user
 * @param noHandler {Function} - Reference to the function
 *		  called if the no button is clicked. It must re-
 *		  turn boolean true to trigger the observer and pro-
 *		  cess the initial event or false to do nothing ex-
 *		  cept enabling the dialog controls again
 * @param yesHandler {Function} - Reference to the function
 *		  called if the yes button is clicked. It must re-
 *		  turn boolean true to trigger the observer and pro-
 *		  cess the initial event or false to do nothing ex-
 *		  cept enabling the dialog controls again
 */
function setupConfirmation(parameter)
{
	disableInput();
	var myDocument = topEasykatFrame.document;
	
	var confirmDialog = myDocument.createElement("table");
	confirmDialog.id = "confirmMessageDialog";
	confirmDialog.className = "easykatLight-confirmMessageDialog";
	topEasykatFrame.confirmCache.ignoreObserver = false;
	
	var yesButton = myDocument.createElement("input");
	yesButton.type = "button";
	yesButton.id = "yesButton";
	yesButton.value = parameter.yesButtonValue;
	$(yesButton).observe("click", function()
	{
		myDocument.body.removeChild(confirmDialog);
		
		if(parameter.yesHandler())
			ekSubmit('confirmDecision');
		else
			enableInput();
	});
	
	var noButton = myDocument.createElement("input");
	noButton.type = "button";
	noButton.id = "noButton";
	noButton.value = parameter.noButtonValue;
	$(noButton).observe("click", function()
	{
		myDocument.body.removeChild(confirmDialog);
		
		if(parameter.noHandler())
			ekSubmit('confirmDecision');
		else
			enableInput();
	});
	
	var messageCell = confirmDialog.insertRow(0).insertCell(0);
	messageCell.id = "messageTextCell";
	messageCell.colSpan = "2";
	messageCell.innerHTML = parameter.confirmMessageText;
	
	var buttonsRow = confirmDialog.insertRow(1);
	
	var yesButtonCell = buttonsRow.insertCell(0);
	yesButtonCell.id = "yesButtonCell";
	yesButtonCell.appendChild(yesButton);
	
	var noButtonCell = buttonsRow.insertCell(1);
	noButtonCell.id = "noButtonCell";
	noButtonCell.appendChild(noButton);
	
	myDocument.body.appendChild(confirmDialog);
}



function getGUIVersion()
{
	return document.isycat.IDC_EASYGUI_VERSION.value;
}

// # ============================================================================
// # Automatically select a node from the MenuTree
// # ============================================================================
function autoSelectTreeNode()
{
    var strTreeNode = document.getElementById('SELECT_TREE_NODE').value;
    if (strTreeNode != "")
    {
    	parent.dialog.IDC_TREE_CLASSES.focusItem(strTreeNode);
    }
}

// # ============================================================================
// # Controls the display of the table containing the preview
// # data of the running configuration as well as the check-
// # box which toggles the display of these data
// #
// # showPreview: true = show the preview data table and the
// #                     checkbox to toggle the preview
// #              false = hide the whole preview data table
// #                      including the checkbox
// # ============================================================================
function displayCfgPreviewArea(showPreview)
{
    if(showPreview)
    {
        topEasykatFrame.$("IDC_CFG_PREVIEW_CHECKBOX_TABLE_BACKGROUND").show();
        topEasykatFrame.$("IDC_CFG_PREVIEW_CHECKBOX_TABLE").show();
		topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE_BACKGROUND").show();
        
        if(topEasykatFrame.$("*.DLGDATA.DLGVARS.EASYKATLIGHT.IDD_CONFIG.PREVIEW_ENABLED").checked)
        {
            topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE").show();
            topEasykatFrame.$("IDC_COMBO_LANGUAGE").hide();
        }
        else
        {
            topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE").hide();
            topEasykatFrame.$("IDC_COMBO_LANGUAGE").show();
        }
    }
    else
    {
        topEasykatFrame.$("IDC_CFG_PREVIEW_CHECKBOX_TABLE_BACKGROUND").hide();
        topEasykatFrame.$("IDC_CFG_PREVIEW_CHECKBOX_TABLE").hide();
        topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE_BACKGROUND").hide();
        topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE").hide();
        topEasykatFrame.$("IDC_COMBO_LANGUAGE").show();
    }
}


// Funktion des Dialogs "IDD_CONFIG" zur Aktualisierung des
// Vorschaubild-Bereichs nach der Änderung eines Merkmals-
// wertes der Konfiguration. Wertet den Zustand der Vorschau-
// anzeige-Combobox aus und startet die Generierung der Daten,
// falls nötig
function refreshCfgPreviewData()
{
    var previewCheckbox = topEasykatFrame.$("*.DLGDATA.DLGVARS.EASYKATLIGHT.IDD_CONFIG.PREVIEW_ENABLED");
    
    // Wenn die Anzeige der Vorschau gewünscht ist (Checkbox
    // angeklickt)
    if(previewCheckbox.checked)
    {
        // Vorschau-Tabelle anzeigen und darunterliegende
        // Sprachauswahl-Combobox verstecken (IE6-BoxModel-Bug)
        topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE").show();
        topEasykatFrame.$("IDC_COMBO_LANGUAGE").hide();
		topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE_BACKGROUND").style.height = "116px";
        
        // Den UserExit_002Request ausführen, um die Vorschau-
        // daten (z.B. HTML-Code oder CAD-Bild) zu laden und
        // zu visualisieren
        userExit_002Request({waitingForPreviewData: 0});
    }
    else
    {
        // Vorschau-Tabelle ausblenden und Sprachauswahl-
        // Combobox wieder anzeigen
		topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE_BACKGROUND").style.height = "60px";
		topEasykatFrame.$("IDC_CFG_PREVIEW_TABLE").hide();
		topEasykatFrame.$("IDC_COMBO_LANGUAGE").show();
        enableInput();
    }
}


function decodeJSON(json) {
    if(json)
        return eval("(" + json + ")");
    else
        return "";
}

// # ============================================================================
// # Generate the breadcrumb display on the basis
// # of the JSON-string received from th server
// # ============================================================================
function generateBreadcrumb()
{
    var breadcrumbData = decodeJSON( $F("breadcrumbData").replace(/'/g, "\"") );
    var breadcrumbDataLength = breadcrumbData.length;
    var breadcrumbImage = topEasykatFrame.$("breadcrumbTablePicture").value;
    
    var breadcrumbDiv = topEasykatFrame.$("IDC_BREADCRUMB_CONTAINER");
    breadcrumbDiv.innerHTML = "";
    
    for(var i = 0; i < breadcrumbDataLength; i++)
    {
        var tempData = "";
        
        if(i > 0)
            tempData = "<img src='" + breadcrumbImage + "'/><span>";
        else
            tempData = "<span style='padding-left: 0px'>";
        
        var breadcrumbPart = breadcrumbData[i];
        
        if(breadcrumbPart.nodeType == "treeNode")
        {
            if(i != breadcrumbDataLength - 1)
                tempData += "<a class='treeNode' href='javascript:navigateToTreeNode(\"" + breadcrumbPart.identifier + "\");'>" + breadcrumbPart.outputName + "</a>";
            else
                tempData += breadcrumbPart.outputName;
        }
        
        else if(breadcrumbPart.nodeType == "dialog")
        {
            if(i != breadcrumbDataLength - 1)
                tempData += "<a class='dialogNode' href='javascript:MyEKParameterSubmit(\"IDC_BREADCRUMB_SWITCH_DIALOG\",\"" + breadcrumbPart.identifier + "\",\"RFrame\");'>" + breadcrumbPart.outputName + "</a>";
            else
                tempData += breadcrumbPart.outputName;
        }
        
        breadcrumbDiv.innerHTML += tempData + "</span>";
    }
}


// # ============================================================================
// #        ****** CURRENTLY NOT IN USE ******
// # Function which is only used by the dialog IDD_PRODUCTS
// # to adjust the position of the "zoom image" icon buttons
// # to the size of the image they're overlaying
// # ============================================================================
function correctZoomImageIconPosition()
{
    // Check if the IE is used as browser control
    var isIExplorer = (navigator.appName.indexOf("Internet Explorer") >= 0) ? true : false;
    
    // Initialize the array of table which have to get
    // processed
    var processTables = [$("PRODUCT_TABLE_TABLE")];
    
    // If there's a fixed columns table and / or fixed
    // lines table, add it to the tables array
    if($("PRODUCT_TABLE_FC_TABLE"))
        processTables.push($("PRODUCT_TABLE_FC_TABLE"));
    if($("PRODUCT_TABLE_FL_TABLE"))
        processTables.push($("PRODUCT_TABLE_FL_TABLE"));
    
    // Iterate over all tables which need to get processed
    for(var i = 0; i < processTables.length; i++)
    {
        var curTable = processTables[i];
        
        for(var j = 1; j < curTable.rows.length; j++)
        {
            // Fetch the current product picture and its
            // zoom image icon
            var productPicture = $(curTable.rows[j].cells[0]).down();
            
            // If the product images are disabled,
            // abort the whole process
            if(!productPicture || productPicture.tagName != "IMG")
                return;
            
            var zoomImageButton = productPicture.next();
            
            // Get the product picture's dimensions
            var picWidth  = productPicture.getWidth();
            var picHeight = productPicture.getHeight();
            
            // Separate routine for Internet Explorer
            if((!picWidth || !picHeight) && isIExplorer)
            {
                picWidth = productPicture.width;
                picHeight = productPicture.height;
            }
            
            //alert("W:" + picWidth + " - H:" + picHeight);
            
            //Adjust the position of the zoom image icon
            zoomImageButton.setStyle({position: 'absolute', top : (picHeight - 22) + 'px', left : (picWidth - 22) + 'px'});
            
            // Create a <DIV>-element, so the images
            // can get positioned relatively to each
            // other and hook it into the DOM tree
            var positioningDiv = $(document.createElement('div'));
            positioningDiv.setStyle({position: 'relative'});
            productPicture.up().appendChild(positioningDiv);
            
            // Move the both images inside the <DIV>
            // element
            positioningDiv.appendChild(productPicture);
            positioningDiv.appendChild(zoomImageButton);
        }
    }
}


// # ============================================================================
// # Resize the width of the product groups table, so no
// # horizontal scrollbar is generated by IE 7 if it's
// # unnecessary
// # ============================================================================
function resizeProdGroupTable()
{
    var prodGroupTable = $("PRODUCT_GROUP_TABLE_TABLE");
    var prodGroupTableDiv = prodGroupTable.up("div");
    
    // IE only
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        // IE 7+ only
        if(document.documentElement && typeof document.documentElement.style.maxHeight != "undefined")
        {
            var tableDimensions = prodGroupTable.getDimensions();
            var tableDivDimensions = prodGroupTableDiv.getDimensions();
            
            if(tableDimensions.width == tableDivDimensions.width && tableDimensions.width > 0)
            {
                if(tableDimensions.height >= tableDivDimensions.height)
                    prodGroupTable.style.width = (tableDimensions.width - 17) + "px";
            }
        }
    }
}


// # ============================================================================
// # Function which is only used by the dialog IDD_PRODUCTS
// # whenever a combobox containing the relational operators
// # for a certain attribute has changed. It toggles the lay-
// # out of the value selection elements of this attribute,
// # so it fits the currently chosen relation. It also for-
// # wards the changed element to another function which
// # checks, if the filter has to be evaluated.
// # 
// # @param isInitialization {Boolean} Optional argument
// # 		which controls the skipping of the filter sub-
// # 		mission check
// # 
// # ============================================================================
function relationComboboxChange(isInitialization)
{
	// Fetch the table cell containing the current filter's
	// HTML elements
	var filterCell = this.parentNode.childNodes;
	
	// If the relation 'range between two boundary values' is
	// chosen
	if(this.value == "LOG_BW")
	{
		filterCell[1].style.display = "none";
		filterCell[2].style.display = "";
		filterCell[3].style.display = "none";
		filterCell[4].style.display = "";
		filterCell[4].style.width = filterCell[2].style.width;
		filterCell[5].style.display = "none";
	}
	// If the relation 'neighborhood (percent value) of a cer-
	// tain value' is chosen
	else if(this.value == "LOG_PC")
	{
		filterCell[1].style.display = "none";
		filterCell[2].style.display = "";
		filterCell[3].style.display = "";
		filterCell[4].style.display = "";
		var newWidth = filterCell[2].style.width;
		filterCell[4].style.width = parseInt(newWidth.substring(0, newWidth.length - 2) - 23) + "px";
		filterCell[5].style.display = "";
	}
	// If any other relation is chosen
	else
	{
		filterCell[1].style.display = "";
		filterCell[2].style.display = "none";
		filterCell[3].style.display = "none";
		filterCell[4].style.display = "none";
		filterCell[4].style.width = filterCell[2].style.width;
		filterCell[5].style.display = "none";
	}
    
	// If the function isn't called during the setup of the
	// filter table, start the filter evaluation check
	if(!(typeof isInitialization == "boolean" && isInitialization))
		checkFilterSubmit.call(this);
}


/**
 *	Used by the dialog IDD_PRODUCT to check, if the current
 *	settings of the product filter are valid. This means
 *	that all data necessary to evaluate a certain criterion
 *	were entered, so a condition can be generated to con-
 *	strain the product range. If the check succeeds, the
 *	filter data are sent to the server to refresh the pro-
 *	duct table
 *
 *	@param The filter element which value has changed. It
 *		   doesn't have to be passed within brackets while
 *		   calling the function because it represents the
 *		   "this" property which is used inside the func-
 *		   tion's body. Doing so, the function can be used
 *		   directly to set the "onchange / onclick" event
 *		   of HTML elements using JavaScript
 */
function checkFilterSubmit()
{
	// Fetch the content of the current filter's HTML ele-
	// ments and initialize a flag used to control the
	// submission of the filter's settings
	var filterCell = this.parentNode.childNodes;
	var evaluateFilter = false;
	
	// Check the filter's consistency
	switch(filterCell[0].value)
	{
		case "LOG_BW":
		case "LOG_PC":
			if(filterCell[2].value != "" && filterCell[4].value != "")
				evaluateFilter = true;
		break;
		default:
			if(filterCell[1].value != "")
				evaluateFilter = true;
		break;
	}
	
	// Evaluate the filter, if necessary
	if(evaluateFilter)
	{
		// Get the currently selected tab and extract the
		// number of the product tab out of it
		var currentProductTab = dialog.IDC_PRODUCT_TABS.getSelected().substring(11);
		
		// Fetch the product filter table from the DOM
		var productFilterTable = document.getElementById("PRODUCT_COMBOBOX_TABLE" + currentProductTab);
		
		// Hide all rows of the product filter table to
		// avoid flickering
		for(var i = 0; i < productFilterTable.rows.length; i++)
			productFilterTable.rows[i].style.display = "none";
		
		// Start the evaluation of the product filter
		getProductTabContent({event: 'filterChanged'});
	}
}


// # ============================================================================
// # Resize a popup window on the base of the size of
// # the image displayed insinde of it
// # ============================================================================
// Dummy function which is needed by the runtime
// engine to interpret the resize command correctly
function EKAT_RESIZE(w,h) {;}

function resizeZoomedImageWindow()
{
    var img_h = document.getElementById("zoomedImage").height;
    var img_w = document.getElementById("zoomedImage").width;
    
    var win_h;
    var win_w;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        win_w = window.innerWidth;
        win_h = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        win_w = document.documentElement.clientWidth;
        win_h = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ))
    {
        //IE 4 compatible
        win_w = document.body.clientWidth;
        win_h = document.body.clientHeight;
    }
    
    var res_w = 0;
    var res_h = 0;
    
    res_h = (img_h) + 30;
    res_w = (img_w) + 30;
    //alert("ImageH: " + img_h + "\nImageW: " + img_w + "\nResH: " + res_h + "\nResW: " + res_w);
    
    // This confusing command is needed by the runtime
    // engine to interpret the resize command correctly
    var hrefCMD = "javascript:void(EKAT_RESIZE(" + res_w + "," + res_h + "))";
    window.location.href = hrefCMD;
}

// # ============================================================================
// # Function of the dialog IDD_FAVORITELIST which
// # toggles the functionality of the "delete posi-
// # tion" button depending on if a row of the ta-
// # ble is selected or not
// # ============================================================================
function checkFavoriteListButtonsStatus()
{
    var favoriteListWidget = dialog.IDC_FAVLIST_TABLE;
	
	// Wenn mindestens eine Zeile in der Tabelle
	// enthalten ist, selektierte Zeile abfragen
	var selectedRow = "";
	
	if(favoriteListWidget.getRowCount() > 0)
    selectedRow = favoriteListWidget.getSelected();
    
    if(selectedRow != "")
        dialog["IDC_POSITION_DELETE_BUT"].enable();
    else
        dialog["IDC_POSITION_DELETE_BUT"].disable();
}

// Funktion des Dialogs IDD_PROJECTLIST zur Korrektur
// der eingetragenen Positionsnummern der Projektlis-
// ten-Tabelle, da nur numerische Zeichen wegen der
// Sortierung zulässig sind. Alle nicht-numerischen
// Zeichen werden entfernt
function correctProjectlistPosNumbers()
{
    // Flag für den Fund nicht-numerischer Zeichen,
    // wodurch eine Fehlermeldung ausgelöst wird
    var nonNumericCharsFound = false;
    
    // Zeilenindex des Positionsnummer-Feldes in der
    // Projektlisten-Tabelle
    var positionFieldIndex = 0;
    
    // Über alle Prositionsnummer-Felder iterieren
    // und nicht-numerische Zeichen entfernen
    var curProjectlistPositionField = "";
    while((curProjectlistPositionField = $("*.PROJECT.POSITIONS.PROJECTLIST_ITEMS[" + positionFieldIndex + "].PRODUCT.POSDATA.POS")) != null)
    {
        // Regulärer Ausdruck zur Prüfung
        // der Daten des Feldes
        var checkExpression = /\d+/g;
        
        // Prüfung durchführen
        var correctPositionNumber = curProjectlistPositionField.value.match(checkExpression);
        
        // Sofern Korrekturen notwendig sind
        if(curProjectlistPositionField.value != correctPositionNumber || correctPositionNumber.length > 1)
        {
            nonNumericCharsFound = true;
            
            // Sofern mindestens eine Zahl gefunden wurde
            if(correctPositionNumber != null)
            {
                // Alle gefundenen Zahlenblöcke zu
                // einer Zahl zusammensetzen
                var completeNumber = "";
                for(var i = 0; i < correctPositionNumber.length; i++)
                    completeNumber += correctPositionNumber[i];
                
                curProjectlistPositionField.value = completeNumber;
            }
            else
                curProjectlistPositionField.value = (positionFieldIndex + 1) * 10;
        }
        
        // Zum nächsten Feld übergehen
        positionFieldIndex++;
    }
    
    // Sofern Korrekturen vorgenommen wurden
    // Fehlermeldung ausgeben
    if(nonNumericCharsFound)
        alert($F("invalidPositionNumbersCorrectedNotice"));
}

// # ============================================================================
// # Adjust the displayed elements of the Control-
// # ButtonsTable of the dialog "IDD_CONFIG" depen-
// # dant on the selected tab and the status of the
// # configuration.
// # ============================================================================
function adjustCfgControlButtonsTable()
{
    // Get the tab currently selected
    var selectedTab = dialog.IDC_EASYKATLIGHTCONFIG_TABS.getSelected();
    
    // Get the current configuration status and level
    var cfgStatus = $("CURRENT_CONFIG_STATUS").value;
    var cfgLevel = $("CURRENT_CONFIG_LEVEL").value;
    
    // Get the ControlButtonsTable element
    // (contains only one row)
    var ctrlButTable = $("IDC_CONTROLBUTTONS_TABLE");
    
    // Store the display information in an array
    // so we can apply them at the end of the
    // process
    var displayInfos = new Array(true, true);
    
    // Set the functionality of the 'Back'-button
    // on the base of the current configuration
    // level
    if(cfgLevel == "0")
    {
        displayInfos[1] = true;
        displayInfos[2] = false;
    }
    else
    {
        displayInfos[1] = false;
        displayInfos[2] = true;
    }
    
    // Configuration-tab selected
    if(selectedTab == "IDC_CONFIG_TABREITER")
    {
        // Configuration is complete
        if(cfgStatus == "COMPLETE")
        {
            displayInfos[7] = false;
            displayInfos[8] = true;
            
            // Show the "forward" button at the
            // bottom of the dialog
            $("IDC_CFG_FORWARD_BOTTOM").show();
        }
        else
        {
            // Hide the "forward" button at the
            // bottom of the dialog
            $("IDC_CFG_FORWARD_BOTTOM").hide();
            
            displayInfos[7] = true;
            displayInfos[8] = false;
        }
        
        displayInfos[3] = true;
        displayInfos[4] = true;
        displayInfos[5] = true;
        displayInfos[6] = false;
        displayInfos[9] = true;
    }
    // List of materials-tab selected
    else if(selectedTab == "IDC_MATLIST_TABREITER")
    {
        displayInfos[3] = false;
        displayInfos[4] = false;
        displayInfos[5] = false;
        displayInfos[6] = true;
        displayInfos[7] = true;
        displayInfos[8] = false;
        displayInfos[9] = true;
    }
    
    // Applying the stored display information
    // to the ControlButtonsTable
    var ctrlTableCells = ctrlButTable.rows[0].cells;
    for(i = 0; i < ctrlTableCells.length; i++)
    {
        if(!displayInfos[i])
            ctrlTableCells[i].style.display = "none";
        else
            ctrlTableCells[i].style.display = "";
    }
}

// # ============================================================================
// # Check if the system is running in internet mode
// # and return true if so and false otherwise
// # ============================================================================
function operateInInternetMode()
{
    if(parent.document.getElementById('systemInInternetMode').value == "true")
        return true;
    else
        return false;
}

// # ============================================================================
// # Check if there's a document specified which
// # has to get opened
// # ============================================================================
function checkDocumentOpen()
{
    var documentFilepath = $("CURRENT_DOCUMENT_TO_OPEN").value;
    //alert("documentOpen: " + documentFilepath);
    if(documentFilepath != "")
        window.open(documentFilepath);
}

// # ============================================================================
// # Initialize Main-Template
// # ============================================================================
function initializeMain()
{
	// # Get Tree-Object:
	var treeObject = document.getElementById('IDC_TREE_CLASSES');
	
	if (treeObject != null)
	{
		// # Set target for tree nodes:
		treeObject.target = 'RFrame';
		
		// # alert("treeObject.selected: "+treeObject.selected);
		createNewHiddenFormField('EKSUBMITEVENTPAR', treeObject.selected); // # Löst das Event zum Setzen des aktuellen Knoten aus.
		ekSubmit(treeObject);
	}

}


// # ============================================================================
// # Destroy the <div>-element which contains the
// # product details table
// #
// # @return boolean value if table got destroyed
// #         or not (it was not found)
// # ============================================================================
function removeDetailsTable()
{
    if(document.getElementById('PRODUCT_DETAILS_TABLE'))
    {
        document.body.removeChild(document.getElementById('PRODUCT_DETAILS_TABLE'));
        return true;
    }
    return false;
}


// # ============================================================================
// # Select a TreeNode from the MenuTree
// # ============================================================================
function navigateToTreeNode(treeIdent)
{
    // Sofern der gewünschte Knoten existiert
    if(topEasykatFrame.document.getElementById(treeIdent))
    {
        // Selektieren des TreeNodes im MenuTree, wenn nicht
        // der Root-Knoten aufgerufen werden soll
        if(treeIdent.toUpperCase() != "ROOT")
        {
            topEasykatFrame.dialog.IDC_TREE_CLASSES.focusItem(treeIdent);
            topEasykatFrame.dialog.IDC_TREE_CLASSES.setSelected(treeIdent);
        }
        
        // Alle Eingabekontrollen des Dialogs deaktivieren
        disableInput();
        
        // Event zum Öffnen der Tabs des TreeIdents auslösen.
        // Wenn der "ROOT"-Knoten aufgerufen werden soll, die
        // Anwendung reinitialisieren.
        if(treeIdent.toUpperCase() == "ROOT")
            topEasykatFrame.ekSubmit("LOGO");
        else
            topEasykatFrame.MyEKParameterSubmit("IDC_NAVIGATE_TO_TREENODE", treeIdent, 'RFrame');
    }
    else
        alert("NavigateToTreeNode: Tree ident '" + treeIdent + "' not found !");
}


// # ============================================================================
// # Exchange an image (mouseOver functionality)
// # ============================================================================
function exchangeGraphic(element)
{
    // Gesamt-URL splitten, um den Dateinamen und die
    // Datei-Endung zu erfassen
    var tokenArray = element.src.split("/");
    var tempStr = tokenArray[tokenArray.length - 1];
    var URLWithoutFilename = element.src.substring(0, element.src.length - tempStr.length);
    tokenArray = tempStr.split(".");
    var ending = tokenArray[tokenArray.length - 1];
    var filename = tempStr.substring(0, tempStr.length - (ending.length + 1));
    
    // Neuer Dateiname, der dem Bild nun zugewiesen wird
    var newFilename = "";
    
    // Neuen Dateinamen in Abhängigkeit vom aktuellen
    // Zustand des Bildes ermitteln
    if(filename.search(/_aktiv/i) >= 0)
        newFilename = filename.substring(0, filename.length - 6) + "." + ending;
    else
        newFilename = filename + "_aktiv." + ending;
    
    element.src = URLWithoutFilename + newFilename;
    element.style.cursor = 'hand';
}


// # ============================================================================
// # Change the cursor to a hand (link on a hyperlink)
// # ============================================================================
function changeCursor(objectID)
{
    var changeObject = document.getElementById(objectID);
    changeObject.style.cursor = 'pointer';
}


// # ============================================================================
// # Open a document which is stored in the common documents folder
// # ============================================================================
function myDocumentOpen(documentName)
{
    if(documentName != "")
        self.open("EKPages/" + documentName, "DocumentWindow", "width=800,height=600");
}


// # ============================================================================
// # Save the selected tablerow of a table to the store
// # with the next submit operation
// # ============================================================================
function setSelectedTableRow(tableId, rowId)
{
    // Im Produkt-Dialog die Dialogvariable
    // aus dem Body des IFrames holen, da
    // diese sonst nicht korrekt ist
    if(dialog.id == "IDD_PRODUCT")
        dialog = document.body.dialog;
    
	dialog.getWidget(tableId).setSubmitValue(rowId);
}


// # ============================================================================
// # Submit an event and an additional parameter, too
// # ============================================================================
function MyEKParameterSubmit(strEKSubmit, strEKSubmitPar, targetFrame)
{
	//alert("MyEKSubmit: " + strEKSubmit + "   " + strEKSubmitPar + "   " + targetFrame);
    createNewHiddenFormField('EKSUBMITEVENTPAR', strEKSubmitPar); // # Setzt den Parameter
    
	// Alle Eingabekontrollen des Dialogs deaktivieren
	disableInput();
	
	if(targetFrame != '')
        ekSubmit(strEKSubmit, targetFrame, 100);
    else
        ekSubmit(strEKSubmit, null, 100);
	
    // Hidden-Feld des Parameters wieder loeschen
	// If FireFox is used, set the whole form control
	// to null to avoid the bug #307415 which lets
	// the form field be accessible even after it has
	// been deleted from the DOM using removeChild
	if(!topEasykatFrame.is.ie)
		document.forms[0].EKSUBMITEVENTPAR = null;
	else
		document.forms[0].EKSUBMITEVENTPAR.value = null;
	
    document.forms[0].removeChild($("EKSUBMITEVENTPAR"));
}


// # ============================================================================
// # Submit an event and two additional parameter, too
// # ============================================================================
function MyEKTwoParamsSubmit(strEKSubmit, strEKSubmitPar1, strEKSubmitPar2, targetFrame)
{
    createNewHiddenFormField('EKSUBMITEVENTPAR', strEKSubmitPar1); // # Setzt den Parameter 1
    createNewHiddenFormField('EKSUBMITEVENTPAR2', strEKSubmitPar2); // # Setzt den Parameter 2
    
	// Alle Eingabekontrollen des Dialogs deaktivieren
	disableInput();
	
	if(targetFrame != '')
        ekSubmit(strEKSubmit, targetFrame, 100);
    else
        ekSubmit(strEKSubmit, null, 100);
    
    // Hidden-Felder der Parameter wieder loeschen
	// If FireFox is used, set the whole form control
	// to null to avoid the bug #307415 which lets
	// the form field be accessible even after it has
	// been deleted from the DOM using removeChild
	if(!topEasykatFrame.is.ie)
	{
		document.forms[0].EKSUBMITEVENTPAR = null;
		document.forms[0].EKSUBMITEVENTPAR2 = null;
	}
	else
	{
		document.forms[0].EKSUBMITEVENTPAR.value = null;
		document.forms[0].EKSUBMITEVENTPAR2.value = null;
	}
	
    document.forms[0].removeChild($("EKSUBMITEVENTPAR"));
    document.forms[0].removeChild($("EKSUBMITEVENTPAR2"));
}


// # ============================================================================
// # Submit an event which needs three additional parameter
// # ============================================================================
function MyEKThreeParamsSubmit(strEKSubmit, strEKSubmitPar1, strEKSubmitPar2, strEKSubmitPar3, targetFrame)
{
    createNewHiddenFormField('EKSUBMITEVENTPAR', strEKSubmitPar1); // # Setzt den Parameter 1
    createNewHiddenFormField('EKSUBMITEVENTPAR2', strEKSubmitPar2); // # Setzt den Parameter 2
	createNewHiddenFormField('EKSUBMITEVENTPAR3', strEKSubmitPar3); // # Setzt den Parameter 2
    
	// Alle Eingabekontrollen des Dialogs deaktivieren
	disableInput();
	
	if(targetFrame != '')
        ekSubmit(strEKSubmit, targetFrame, 100);
    else
        ekSubmit(strEKSubmit, null, 100);
    
    // Hidden-Felder der Parameter wieder loeschen
	// If FireFox is used, set the whole form control
	// to null to avoid the bug #307415 which lets
	// the form field be accessible even after it has
	// been deleted from the DOM using removeChild
	if(!topEasykatFrame.is.ie)
	{
		document.forms[0].EKSUBMITEVENTPAR = null;
		document.forms[0].EKSUBMITEVENTPAR2 = null;
		document.forms[0].EKSUBMITEVENTPAR3 = null;
	}
	else
	{
		document.forms[0].EKSUBMITEVENTPAR.value = null;
		document.forms[0].EKSUBMITEVENTPAR2.value = null;
		document.forms[0].EKSUBMITEVENTPAR3.value = null;
	}
	
    document.forms[0].removeChild($("EKSUBMITEVENTPAR"));
    document.forms[0].removeChild($("EKSUBMITEVENTPAR2"));
	document.forms[0].removeChild($("EKSUBMITEVENTPAR3"));
}


// # ============================================================================
// # Submit an configuration event with three parameters
// # ============================================================================
function MyEKConfigSubmit(strEKSubmit, configObject, imageFilename, treeIdent, artNr, targetFrame)
{
	//alert("MyEKSubmit: " + strEKSubmit + "   " + configObject + "   " + imageFilename + "   " + treeIdent + "   " + targetFrame);
    createNewHiddenFormField('EKSUBMITEVENTPAR', configObject); // # Konfigurationsobjekt
    createNewHiddenFormField('EKSUBMITEVENTPAR1', imageFilename); // # Dateiname des Produktbildes (falls vorhanden)
    createNewHiddenFormField('EKSUBMITEVENTPAR2', treeIdent); // # TreeIdent der Produktgruppe
    createNewHiddenFormField('EKSUBMITEVENTPAR3', artNr); // # Artikelnummer des Produktes (falls verfügbar)
	
	// Alle Eingabekontrollen des Dialogs deaktivieren
	disableInput();
	
    if(targetFrame != '')
        ekSubmit(strEKSubmit, targetFrame, 100);
    else
        ekSubmit(strEKSubmit, null, 100);
}


function	IsLeaf(objTreeNode)
{
	if (objTreeNode == null)	{
		return false;
	}
	var objParent = objTreeNode.parentNode;
	return (objParent != null && objParent.childNodes.length <= 2) ? true : false;
}

// # ============================================================================
// # Handle submit from a special target
// # ============================================================================
function ekSubmitInTarget(element, strTarget, bCreate, AttrList) {
	if (bCreate == true)	{
		window.open('', strTarget, AttrList);
	}

	ekSubmit(element, strTarget);
}

// # ============================================================================
// # Load an external file (e.g. HTML-page) into an IFrame
// # ============================================================================
function showContentInIFrame(frameID, docrefID) {
    var url = document.getElementById(docrefID).docref;
    var wndIFrame = document.frames[frameID];
    if (wndIFrame != null)  {
        wndIFrame.location.href = url;
    }
}



// # ============================================================================
// # CATCH EVENT IN PRODUCT LIST
// # ============================================================================
function ekSubmitProductTable( strEvent, argColumn) {
	objColumn = argColumn;
	
	if (objColumn != null)		
	{
		objRow = objColumn;
		
		while ( (objRow != null) && (objRow.nodeName != 'TR') )
		{
			objRow = objRow.parentNode;
			// #alert("Name: "+objRow.nodeName);
			// #alert("Parent: "+objRow.parentNode);
		}
	}

	if (objRow != null)
		createNewHiddenFormField('EKSUBMITEVENTPAR', objRow.getAttribute('userdata'));
	
	ekSubmit(strEvent, "_top")	
	// ekSubmit("IDC_CHILD_NODE_PRODUCT_TABLE", "_top")	
	//ekSubmitInTarget("IDC_CHILD_NODE_PRODUCT_TABLE", "_top", false, '')	;
	// # alert("Userdata: "+objRow.getAttribute('userdata'));
}


// # ============================================================================
// # DISABLE RIGHT CLICK
// # ============================================================================
function DisableRClick()
{
	addEvent(document, "contextmenu", disablecontextmenu, false);
}


// # ============================================================================
// # DISABLE CONTEXT MENU
// # ============================================================================
function disablecontextmenu(evt)
{
	return false;
}


// # ============================================================================
// # CHANGE STATE
// # ============================================================================
function ChangeActiveState(objSrcRelOpCombo, strTargetCtrl)
{
	if (objSrcRelOpCombo != null)	{

		objCtrl = document.getElementById(strTargetCtrl);
		
		if (objCtrl != null)	{
			if (objSrcRelOpCombo.value == "LOG_BETWEEN")	
			{
				objCtrl.style.visibility = 'visible';
			}
			else	
			{
				objCtrl.style.visibility = 'hidden';
			}
		}
	}
}

// # ============================================================================
// # MOUSE OVER IN TABLE
// # ============================================================================
function	OnDocTabMouseOver(obj)
{
	if (	obj != null && 
			obj.parentNode != null && 
			obj.parentNode.id != "" && 
			obj.parentNode.getAttribute('userdata') != null)	
	{
		makeHandcursor(obj);
		selectRow(obj.parentNode.id);
	}
}


// # ============================================================================
// # Info-Dokument aus dem Konfigurations-Dialog
// # aus aufrufen ("i"-Icon)
// # ============================================================================
function	HandleCfgInfo(strUrl)
{
	var catPos = strUrl.indexOf("/catalog/");
	
    // Hack gegen lokale abs. Pfade
    if(catPos > -1)
    {
		strUrl = strUrl.substring(catPos);
	}
	window.open(strUrl, "InfoWindow", "width=800,height=600,scrollbars=yes");
}


// # ============================================================================
// # Submit mit Parametern für Configuration
// # ============================================================================

/*function ekSubmitCFG(strCfg, strPar1, strPar2, strPar3, strPar4)
{
	$("MATLISTDIRTY").value = 1;
	
	// Disable all input controls of the dialog
    disableInput();
    
    setTimeout(function() {
        if( Ajax.getTransport() )
        {
            var p1=null, p2=null, p3=null, p4=null;
            p1=createNewHiddenFormField('EKSUBMITEVENTPAR1', strPar1);
            p2=createNewHiddenFormField('EKSUBMITEVENTPAR2', strPar2);
            // alert(strPar3);
            if (strPar3 != null)
                p3=createNewHiddenFormField('EKSUBMITEVENTPAR3', strPar3);
            if (strPar4 != null)
                p4=createNewHiddenFormField('EKSUBMITEVENTPAR4', strPar4);
            strTabSubmitValue = strPar2;
            var objRow = $(strPar2);
            if (objRow == null)
                strTabSubmitValue += "_" + strPar3;
            if (getGUIVersion() != "XP")	{
                selectRow(strTabSubmitValue);
            }
            else	{
                dialog["IDC_CONFIG_TAB"].setSubmitValue(strTabSubmitValue);
            }
            
            // var idList = "IDC_CURRENTTYPECODE|IDC_SMMTYP|IDC_PREIS|IDC_RABATT|IDC_MASSE|IDC_HISTORY|IDC_ROOTTYPECODE|CFG_OK|IDC_CONFIG_TAB";
            var idList = "CURRENT_CONFIG_STATUS|CURRENT_CONFIG_LEVEL|CFG_OK|IDC_CONFIG_TAB|IDC_CURRENTTYPECODE|IDC_CFGPRICE|IDC_CFG_SIGNALIMAGE|currentCfgPreviewImageFilename|cfgPreviewNecessary|externalConfigGroupStatus";
    
            updateDialogElement("IDD_CONFIG", strCfg, false, idList);
            
            // Adjust the visible and hidden options of the
            // ControlButtonsTable
            adjustCfgControlButtonsTable("IDC_CONFIG_TABREITER");
            
            // Refresh the preview image of the configuration
            // if an external configuration is loaded
            if($F("isExternalConfig") == "true")
            {
                refreshCfgPreviewImage();
                parent.Cad4Web.updateWin();
            }
            // If the preview image is used without an external
            // configuration running, activate the userExit_002
            // request handler to fetch the specific data
            else if($F("cfgPreviewNecessary") == "true")
                userExit_002Request();
            
            // Enable all input controls of the dialog again
            enableInput();
            
            if(p1) p1.parentNode.removeChild(p1);
            if(p2) p1.parentNode.removeChild(p2);
            if(p3) p1.parentNode.removeChild(p3);
            if(p4) p1.parentNode.removeChild(p4);
        }
        else
        {
            createNewHiddenFormField('EKSUBMITEVENTPAR1', strPar1);
            createNewHiddenFormField('EKSUBMITEVENTPAR2', strPar2);
            // alert(strPar3);
            if (strPar3 != null)
                createNewHiddenFormField('EKSUBMITEVENTPAR3', strPar3);
            if (strPar4 != null)
                createNewHiddenFormField('EKSUBMITEVENTPAR4', strPar4);
            if (getGUIVersion() != "XP")	{
                selectRow(strPar2);
            }
            else	{
                dialog["IDC_CONFIG_TAB"].setSubmitValue(strPar2);
            }
            //alert(strCfg);
            ekSubmit(strCfg);
        }
    }, 5);
}
*/
function    onchangedCFGCombo(objCombo, strCfg, strPar1, strPar2)
{
    var wdgtCombo = dialog[objCombo.id];
    var nIndex = objCombo.selectedIndex;
    // alert(nIndex);
    // alert(wdgtCombo.selected);
    // alert(wdgtCombo.items[nIndex].disabled);
    if (wdgtCombo.items[nIndex].disabled)   {
        wdgtCombo.setSelectedIndex(wdgtCombo.selected);
    }
    else
        ekSubmitCFG(strCfg, strPar1, strPar2);
}

function	ekSubmit2(strEvent, strPar)
{
	createNewHiddenFormField('EKSUBMITEVENTPAR', strPar);
	ekSubmit(strEvent);
}

// # ============================================================================
// # Zeile in Tabelle highlighten
// # ============================================================================

/*
function HySetRowStyle(obj,highlight)
{
	if(!obj)
		return;
	if(!obj.parentNode)
		return;

	var row=document.getElementById(obj.parentNode.id).childNodes;

	for(i=0;i<row.length;i++)
	{
		var cell_obj=row[i];
		if(highlight)
		{
			cell_obj.style.color='red';
			//cell_obj.style.fontWeight='bold';
			cell_obj.style.cursor='hand';
		}
		else
		{
			cell_obj.style.color='black';
			cell_obj.style.fontWeight='normal';
		}
	}
}
*/

function HySetRowStyle(objRow, strClassName)
{
	if(!objRow)
		return;

	objRow.className = strClassName;
}


function	MyEKTableSubmit(strEKSubmit, objCol)
{
	var objRow;
	if (getGUIVersion() != "XP")	{
		if (objCol != null)		{
			objRow = objCol;
			while (objRow != null && objRow.nodeName != 'TR')	{
	//			alert(objRow.nodeName);
				objRow = objRow.parentNode;
			}
		}
		document.isycat[strEKSubmit].value = objRow.id;
	}
	else	{
		if (objCol != null)		{
			objRow = objCol;
			while (objRow != null && objRow.nodeName != 'TR')	{
				objRow = objRow.parentNode;
			}
		}
	}
    if (objRow != null)
	    createNewHiddenFormField('EKSUBMITEVENTPAR', objRow.getAttribute('userdata'));
        alert(obj.getAttribute('userdata'));
	ekSubmit(strEKSubmit);
}

function tableMouseover(evt, strClassName)
{
	var objRow;
	var objTab;
	if (window.event)	{
		objRow = Event.findElement(window.event, "TR");
		objTab = Event.findElement(window.event, "TABLE");
	}
	else	{
		objRow = Event.findElement(evt, "TR");
		objTab = Event.findElement(evt, "TABLE");
	}
	
	var strTabID = objTab.getAttribute("tableid");
	if (objRow.rowIndex >= dialog[strTabID].fixedLines )
		HySetRowStyle(objRow, strClassName);
}

function tableMouseout(evt, strClassName, strAltClassName)
{

	var objRow;
	var objTab;
	if (window.event)	{
		objRow = Event.findElement(window.event, "TR");
		objTab = Event.findElement(window.event, "TABLE");
	}
	else	{
		objRow = Event.findElement(evt, "TR");
		objTab = Event.findElement(evt, "TABLE");
	}
	var strTabID = objTab.getAttribute("tableid");
	if (objRow.rowIndex >= dialog[strTabID].fixedLines )
		HySetRowStyle(objRow, ((objRow.rowIndex & 1) ? strClassName : strAltClassName));
}

function	ShowTreeItem(strElementID, bShow)
{
	var objTreeItem = document.getElementById(strElementID);
	if (objTreeItem != null)	{
		objTreeItem.style.display = (bShow == true) ? "" : "none";
	}
}

function	HandleCtrlRClick(event)
{
	if (/* event.button == 2 && */ event.ctrlKey)	{
//		alert(getElement(event).id);
		createNewHiddenFormField('EKSUBMITEVENTPAR', getElement(event).id);
		ekSubmitInNewWindow('EDIT_DATASOURCE');
		return false;
	}
	return true;
}

function	CheckAndSubmitCFG(strCfg, strPar1, strPar2, objEditCtrl, clsLb, clsUb)
{
	var strFocusId = "";
	if (objEditCtrl != null)	{
		if (clsLb != null)	{
			var bMsg = clsLb.bIncl ? objEditCtrl.value < clsLb.dVal : objEditCtrl.value <= clsLb.dVal;
			if (bMsg)	{
				if (clsLb.strMsg != "")
					alert(clsLb.strMsg);
				objEditCtrl.value = clsLb.bIncl ? clsLb.dVal : "";
				strFocusId = objEditCtrl.id;
				objEditCtrl.focus();
				return;
			}
		}
		if (clsUb != null)	{
			var bMsg = clsUb.bIncl ? objEditCtrl.value > clsUb.dVal : objEditCtrl.value >= clsUb.dVal;
			if (bMsg)	{
				if (clsUb.strMsg != "")
					alert(clsUb.strMsg);
				objEditCtrl.value = clsUb.bIncl ? clsUb.dVal : "";
				strFocusId = objEditCtrl.id;
				objEditCtrl.focus();
				return;
			}
		}
	}
	ekSubmitCFG(strCfg, strPar1, strPar2);
}

function	OpenAndSubmit(strObjId, strDlgID, strExtraAttr)
{
	if (strDlgID == null)
	{
		strDlgID = "IDD_CURRENCY";
	}
	
	// Alle Eingabekontrollen des Dialogs deaktivieren
	disableInput();
	
	window.open("about:blank", strDlgID, ("toolbar=no " + strExtraAttr));
	ekSubmit(strObjId, strDlgID);
};
