function BrowserOP() {
   
	this.browserIsOpera = false;
	this.browserIsIE = false;
	this.browserIsFirefox = false;
	this.fullVersion = 0;
	this.version = 0;
	
	if (!this.detectOpera())
		if (!this.detectFirefox())
			this.detectIE();
}

BrowserOP.prototype.isOpera = function() {
	return this.browserIsOpera;
}

BrowserOP.prototype.isFirefox = function() {
	return this.browserIsFirefox;
}

BrowserOP.prototype.isIE = function() {
	return this.browserIsIE;
}

BrowserOP.prototype.getVersion = function() {
	return this.version;
}

BrowserOP.prototype.getFullVersion = function() {
	return this.fullVersion;
}



//return true if the "value" parameter is total number 
// 123 - true
// 1,2 - false
// abcd - false
BrowserOP.prototype.ValidateTotalNumber = function(value) {
	var regExp = new RegExp("^[0-9]+$");
	return regExp.test(value);
}

BrowserOP.prototype.detectFirefox = function() {
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
		this.browserIsFirefox = true;
		this.fullVersion = new Number(RegExp.$1);
		this.version = Math.floor(this.fullVersion);
		return true;
	} else {
		this.browserIsFirefox = false;
		return false;
	}
}

BrowserOP.prototype.detectIE = function() {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		this.browserIsIE = true;
		this.fullVersion = new Number(RegExp.$1);
		this.version = Math.floor(this.fullVersion);
		return true;
	} else {
		this.browserIsIE = false;
		return false;
	}
}

BrowserOP.prototype.detectOpera = function() {
	if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
		this.browserIsOpera = true;
		this.fullVersion = new Number(RegExp.$1);
		this.version = Math.floor(this.fullVersion);
		return true;
	} else {
		this.browserIsOpera = false;
		return false;
	}
}

BrowserOP.prototype.getURLParam = function(paramName) {
	paramName = paramName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regexS = "[\\?&]" + paramName + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return "";
	else
		return results[1];
}

BrowserOP.prototype.isEditMode = function() {
if (this.getURLParam('edit') == 'yes') {
    Ext.override(Ext.Window, {
        animShow: function() {
            this.afterShow();
        },
        animHide: function() {
            this.el.hide();
            this.afterHide();
        }
    });
        return true;
        
    }
    else {
        return false;
    }
}

BrowserOP.prototype.activeEditableElements = function() {
	//this.addStyle('bodyid',"filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;");

}

BrowserOP.prototype.hideElement = function(elementId) {
	var elem = document.getElementById(elementId);
	if (elem)
		elem.style.display = 'none';
}
BrowserOP.prototype.showElement = function(elementId) {
	var elem = document.getElementById(elementId);
	if (elem)
		elem.style.display = 'block';
}

BrowserOP.prototype.createDIV = function(elementId, display) {
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', elementId);
	document.body.appendChild(newdiv);
	if (display)
		this.showElement(elementId);
}

BrowserOP.prototype.removeDIV = function(elementId) {
	var elem = document.getElementById(elementId);
	if (elem) {
		this.hideElement(elementId);
		elem.parentNode.removeChild(elem);
	}
}


BrowserOP.prototype.EditItemOff = function() {
	if (this) {
		var tagtype = this.nodeName.toUpperCase();
		var editid = 'edit_' + this.id;
		var OBrowser = new BrowserOP();
		OBrowser.hideElement('edit');
	}
}

/*
elemId - id of element 
actionType - defines what do we edit: "LINK", "IMG", "HTMLEditor"
buttonPosition - defines on which site button should appear: "left" or "right"
default is to: "left"
proposedPathToSaveFiles - path to propose for user to save files to.
defaultly it is build basing on elemId (path to page images folder)

*/
BrowserOP.prototype.selectEditableelement = function (elemId, actionType,
		buttonPosition, proposedPathToSaveFiles, proposedImageSize) {

    //    //must be here because we need path to root to make request for logged country
    //    if (country == null) {
    //        $.ajax({
    //            url: mako_getPathToRoot(elemId) + "adminPanel/loggedCountry.asp",
    //            type: "POST",
    //            async: false,
    //            dataType: "html",
    //            success: function(resp) {
    //                country = resp;
    //                alert("browser" + country);
    //            }
    //        });
    //    }

    if (arguments.length < 3 || buttonPosition == '') {
        buttonPosition = 'left';
    }
    if (arguments.length < 4 || proposedPathToSaveFiles == '') {
        proposedPathToSaveFiles = mako_getPathToProposedImageFolder(elemId);
    }

    var htmlitem = document.getElementById(elemId);

    buttonIsVisible = false;
    var obj = document.getElementById(elemId);
    var x = 0;
    var y = 0;
    var w = 0;
    var h = 0;
    x = Ext.get(elemId).getX();
    y = Ext.get(elemId).getY();
    w = Ext.get(elemId).getWidth();
    h = Ext.get(elemId).getHeight();

    var borderDiv = document.getElementById('Border' + elemId);
    if (borderDiv) {
        var el = Ext.get('Border' + elemId);
        // el.remove();
        el.setX(x);
        el.setY(y);
        el.setWidth(w);
        el.setHeight(h);

        elButton = Ext.get('Button' + elemId);
        if (elButton) {
            switch (buttonPosition) {
                case 'left':
                    elButton.setX(x);
                    elButton.setY(y - 21);
                    break;
                case 'right':
                    elButton.setX(x + w);
                    elButton.setY(y - 21);
                    break;
                case 'bottomLeft':
                    elButton.setX(x);
                    elButton.setY(y + h);
                    break;
                case 'bottomRight':
                    elButton.setX(x + w);
                    elButton.setY(y + h);
                    break;
            } //END:switch(buttonPosition){
        }

        // var buttonDiv =  Ext.get('Button' + elemId)
        // if(buttonDiv) {
        // buttonDiv.setX(0);
        // buttonDiv.setY(y);
        // }

        return;
    }

    myEl = new Ext.Element(document.createElement('div'));

    Ext.getBody().appendChild(myEl.dom);
    myEl.dom.id = 'Border' + elemId;
    myEl.setStyle('position', 'absolute');
    myEl.setStyle('border', '1px');
    myEl.setStyle('borderStyle', 'solid');
    myEl.setStyle('borderColor', '#FF0000');

    // alert(w);
    myEl.setX(x);
    myEl.setY(y);
    myEl.setWidth(w);
    myEl.setHeight(h);

    var borderDiv = document.getElementById('Border' + elemId);
    // borderDiv.onclick= function(){
    // htmlitem.openEditForm();
    // }

    borderDiv.onmouseout = function () {
        obj.onmouseout();
    }
    borderDiv.onmouseover = function () {
        obj.onmouseover();
    }

    obj.onmouseover = function () {
        var e = window.event;
        try {
            e.cancelBubble = true;
        }
        catch (e) { }
        var el = Ext.get('Button');

        var obj = document.getElementById(elemId);
        var x = 0;
        var y = 0;
        var w = 0;
        var h = 0;
        x = Ext.get(elemId).getX();
        y = Ext.get(elemId).getY();
        w = Ext.get(elemId).getWidth();
        h = Ext.get(elemId).getHeight();

        if (el) {
            el.remove();
        }

        buttonDiv = new Ext.Element(document.createElement('div'));

        Ext.getBody().appendChild(buttonDiv.dom);
        buttonDiv.dom.id = 'Button' + elemId;
        buttonDiv.setStyle('position', 'absolute');
        buttonDiv.setStyle('z-index', '1000');

        // alert(w);
        // buttonDiv.setX(x);
        // buttonDiv.setY(y-21);

        var e = window.event;
        try {
            e.cancelBubble = true;
        }
        catch (e) { }
        var buttonObject = new Ext.Button({
            renderTo: buttonDiv,
            text: 'Edit',
            id: 'Button'
        });

        switch (buttonPosition) {
            case 'left':
                buttonDiv.setX(x);
                buttonDiv.setY(y - 21);
                break;
            case 'right':
                buttonDiv.setX(x + w - buttonDiv.getWidth());
                buttonDiv.setY(y - 21);
                break;
            case 'bottomLeft':
                buttonDiv.setX(x);
                buttonDiv.setY(y + w);
                break;
            case 'bottomRight':
                buttonDiv.setX(x + w - buttonDiv.getWidth());
                buttonDiv.setY(y + w);
                break;
        } //END:switch(buttonPosition){

        buttonObject.getEl().dom.onmouseover = function () {
            buttonIsVisible = true;
        };

        buttonObject.getEl().dom.onclick = function () {
            borderDiv.onclick();
        };

        buttonObject.getEl().dom.onmouseout = function () {
            buttonIsVisible = false;
            obj.onmouseout();
        };
    }

    obj.onmouseout = function () {
        var e = window.event;
        try {
            e.cancelBubble = true;
        }
        catch (e) { }
        var el = Ext.get('Button');

        resizeTask = new Ext.util.DelayedTask(function () {
            if (el) {
                if (buttonIsVisible == false) {
                    el.remove();
                }
            }
        });
        resizeTask.delay(1000);
    }

    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';

    //Create class ImageFlash panel object
    var imgFlashTree = new ImageFlashEditor();
    var imgTree = new ImageEditor();
    var fileTree = new FileEditor();
    var imageLinkTree = new ImageLinkEditor();
    var htmlEditorPanel = new HtmlEditor();
    var linkEditorPanel = new LinkEditor();
    var linkEditorWithIFrame = new LinkEditorWithIFrame();
    var flashTitleEditor = new FlashTitleEditor();
    var flashHeaderEditor = new FlashHeaderEditor();
    var focusEditor = new FocusEditor();
    var listEditorPanel = new ListEditor();
    var iFrameEditorPanel = new IFrameEditor();

    borderDiv.onclick = function () {

        var e = window.event;
        try {
            e.cancelBubble = true;
        }
        catch (e) { }

        var editForm = '';
        var windowObj = '';
        var htmlEditorObj = '';
        var centerPanel = '';
        var southPanel = '';
        Mako.editFormsArray = Array();
        Mako.editFormsArray2 = Array();



        switch (actionType) {
            //#############################################################################################################                                                                   
            case 'IMG':

                var rootPath = mako_getPathToRoot(elemId)
                if (imgTree.treePanel == null) {
                    var imgTreePan = imgTree.FileBrowserPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Image editor",
                        closable: true,
                        width: 800,
                        height: 430,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [imgTreePan]
                    });

                    imgTree.treePanel = null;
                }
                else {
                    return;
                }


                break;
            // #############################################################################################################                                                                             
            case 'FILE':

                var rootPath = mako_getPathToRoot(elemId)
                if (fileTree.treePanel == null) {
                    var fileTreePan = fileTree.FileBrowserPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "File editors",
                        closable: true,
                        width: 400,
                        height: 420,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [fileTreePan]
                    });

                    fileTree.treePanel = null;
                }
                else {
                    return;
                }


                break;
            // #############################################################################################################                                                                            
            case 'IMGFlash':
                var rootPath = mako_getPathToRoot(elemId)
                if (imgFlashTree.treePanel == null) {
                    var trePan = imgFlashTree.FileBrowserPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Image flash editor",
                        closable: true,
                        width: 800,
                        height: 430,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [trePan]
                    });

                    imgFlashTree.treePanel = null;
                }
                else {
                    return;
                }

                break;
            // #############################################################################################################                                                                                                                                 
            case 'LINK':

                var rootPath = mako_getPathToRoot(siteId_forLinkWithIFrame)
                if (linkEditorPanel.panel == null) {
                    var linkPanel = linkEditorPanel.LinkPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Link editor",
                        closable: true,
                        width: 400,
                        height: 200,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [linkPanel]
                    });

                    linkEditorPanel.linkPanel = null;
                }
                else {
                    return;
                }

                break;

            // #############################################################################################################                   
            case 'LINKwithIFrame':

                var rootPath = mako_getPathToRoot(siteId_forLinkWithIFrame)
                if (linkEditorWithIFrame.panel == null) {
                    var linkPanel = linkEditorWithIFrame.LinkPanel2(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Link with iframe editor",
                        closable: true,
                        width: 400,
                        height: 320,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [linkPanel]
                    });

                    linkEditorWithIFrame.linkPanel = null;
                }
                else {
                    return;
                }

                break;

            // #############################################################################################################                                                                                                                                 
            case 'IMGLink':
                var rootPath = mako_getPathToRoot(elemId)
                if (imageLinkTree.treePanel == null) {
                    var trePan = imageLinkTree.FileBrowserPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Image link editor",
                        closable: true,
                        width: 800,
                        height: 400,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'form',
                        cls: 'alignLeft',
                        items: [trePan]
                    });

                    imageLinkTree.treePanel = null;
                }
                else {
                    return;
                }

                break;
            // #############################################################################################################                                               
            case 'HTMLEditor':

                var rootPath = mako_getPathToRoot(elemId)
                if (htmlEditorPanel.panel == null) {
                    var htmlPanel = htmlEditorPanel.HtmlPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "HTML editor",
                        closable: true,
                        width: 600,
                        height: 400,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'fit',
                        cls: 'alignLeft',
                        items: [htmlPanel]
                    });

                    htmlEditorPanel.panel = null;
                }
                else {
                    return;
                }

                break; // HTMLEditor
            // #############################################################################################################                                                                                                                                 
            case 'SCREENSAVER':

                //building subPath to 'screensaverX' element (cuts off first two nodes "root|site")
                // used for mapping in creating editForm
                // after loop elemIdSubPath is like:
                // 'dirs/cars/dirs/clio/pages/clio_screensavers/screensaver1'
                var elemIdArray = elemId.split('|');
                var elemIdSubPath = '';
                for (var i = 2; i < elemIdArray.length; i++) {
                    elemIdSubPath += elemIdArray[i];
                    if ((i + 1) != elemIdArray.length) {
                        //add slash if it is not last element
                        elemIdSubPath += '/';
                    }
                } //END: for(var i = 2; i<elemIdArray.length; i++){

                editForm = new Ext.form.FormPanel(
					{
					    frame: true,
					    method: 'POST',
					    //title: transAddModelForm_title,
					    labelAlign: 'right',
					    labelWidth: 135,
					    width: 440,

					    reader: new Ext.data.XmlReader(
								{
								    record: 'site'
								},
								[
										{
										    name: 'resolution1',
										    mapping: elemIdSubPath + '/linkToFile1/@size'
										}, //mapping is for example: 'dirs/cars/dirs/clio/pages/clio_screensavers/screensaver1/linkToFile1/@size'
										{
										name: 'URLText1',
										mapping: elemIdSubPath + '/linkToFile1'
						},
										{
										    name: 'resolution2',
										    mapping: elemIdSubPath + '/linkToFile2/@size'
										},
										{
										    name: 'URLText2',
										    mapping: elemIdSubPath + '/linkToFile2'
										}]),

					    items: [
								new Ext.form.Hidden({
								    name: 'actionType',
								    id: 'actionTypeId',
								    value: actionType
								}),
								new Ext.form.Hidden({
								    name: 'editedElementPath',
								    id: 'editedElementPathId',
								    value: elemId
								}),

					    //(Img) file
								{ //new
								xtype: 'hidden',
								name: 'sourceOfImgFile',
								id: 'sourceOfImgFileId'
				},
								{
								    xtype: 'hidden',
								    name: 'imageFilePathHidden',
								    id: 'imageFilePathHiddenId'
								},
								{
								    xtype: 'hidden',
								    name: 'proposedPathToSaveImageFile',
								    id: 'proposedPathToSaveImageFileId'
								},
								{ //existing
								    xtype: 'hidden',
								    name: 'pathToImgFromRoot',
								    id: 'pathToImgFromRootId'
								},

					    //(File1) file
								{ //new
								xtype: 'hidden',
								name: 'sourceOfFile1',
								id: 'sourceOfFile1Id'
				},
								{
								    xtype: 'hidden',
								    name: 'screensaverFile1PathHidden',
								    id: 'screensaverFile1PathHiddenId'
								},
								{
								    xtype: 'hidden',
								    name: 'proposedPathToSaveFile1',
								    id: 'proposedPathToSaveFile1Id'
								},
								{ //existing
								    xtype: 'hidden',
								    name: 'pathToFile1FromRoot',
								    id: 'pathToFile1FromRootId'
								},

					    //(File2) file
								{ //new
								xtype: 'hidden',
								name: 'sourceOfFile2',
								id: 'sourceOfFile2Id'
				},
								{
								    xtype: 'hidden',
								    name: 'screensaverFile2PathHidden',
								    id: 'screensaverFile2PathHiddenId'
								},
								{
								    xtype: 'hidden',
								    name: 'proposedPathToSaveFile2',
								    id: 'proposedPathToSaveFile2Id'
								},
								{ //existing
								    xtype: 'hidden',
								    name: 'pathToFile2FromRoot',
								    id: 'pathToFile2FromRootId'
								},

								{
								    layout: 'column',
								    items: [
											{
											    xtype: 'panel',
											    columnWidth: .45,
											    bodyStyle: 'border: 0px; background: transparent;',
											    id: 'fileSelectorImgPanel'
											},
								    //Mako.editSCREENSAVERImgTabPanel, 
											{
											columnWidth: .01
							},
											{
											    columnWidth: .54,
											    layout: 'form',
											    items: [
														new Ext.form.FieldSet(
																{
																    title: transEdit_file1,
																    autoHeight: true,
																    style: 'margin-bottom: 22px;',
																    defaultType: 'textfield',
																    items: [
																			{
																			    fieldLabel: transEdit_resolution,
																			    name: 'resolution1',
																			    width: 190
																			},
																			{
																			    fieldLabel: transEdit_URLText,
																			    name: 'URLText1',
																			    width: 190
																			},
																			{
																			    xtype: 'panel',
																			    columnWidth: .45,
																			    bodyStyle: 'border: 0px; background: transparent;',
																			    id: 'fileSelectorFile1Panel'
																			}
																    //, Mako.editSCREENSAVERFile1TabPanel
																	]
																}),
														new Ext.form.FieldSet(
																{
																    title: transEdit_file2,
																    autoHeight: true,
																    defaultType: 'textfield',
																    items: [
																			{
																			    fieldLabel: transEdit_resolution,
																			    name: 'resolution2',
																			    width: 190
																			},
																			{
																			    fieldLabel: transEdit_URLText,
																			    name: 'URLText2',
																			    width: 190
																			},
																			{
																			    xtype: 'panel',
																			    columnWidth: .45,
																			    bodyStyle: 'border: 0px; background: transparent;',
																			    id: 'fileSelectorFile2Panel'
																			}
																    //, Mako.editSCREENSAVERFile2TabPanel
																	]
																})]
											}]
								}, {
								    layout: 'column',
								    items: [{
								        columnWidth: .45,
								        layout: 'form'
								    }, {
								        columnWidth: .01
								    }, {
								        columnWidth: .54,
								        layout: 'form'
								    }]
								}]
					});

                editForm.addListener('beforeaction', mako_addEntitiesToFormFields);

                editForm
					.addListener('beforeaction', function (formObj, action) {
					    if (action.type == 'submit') {
					        if (!Mako.fileSelectorImgObj.ValidatePanels()) {
					            return false;
					        }
					        if (!Mako.fileSelectorFile1Obj.ValidatePanels()) {
					            return false;
					        }
					        if (!Mako.fileSelectorFile2Obj.ValidatePanels()) {
					            return false;
					        }

					        //(img) file
					        for (var i = 0; i < Mako.fileSelectorImgObj
									.GetPanelData().length; i++) { //this loop should iterate only once
					            var tempFilePath = Mako.fileSelectorImgObj
										.GetPanelData()[i].filePath;
					            if (tempFilePath.indexOf(':') == -1) {
					                //it is existing file
					                tempFilePath = tempFilePath.substring(3,
											tempFilePath.length); // cut off
					                // '../'
					                // from
					                // beggining
					                Ext.getCmp('sourceOfImgFileId').setValue(
											'existing');
					                Ext.getCmp('pathToImgFromRootId').setValue(
											mako_toEntities(tempFilePath));
					            } else {
					                //it is new file
					                Ext.getCmp('sourceOfImgFileId').setValue(
											'new');
					                Ext
											.getCmp('imageFilePathHiddenId')
											.setValue(
													mako_toEntities(tempFilePath));
					                Ext
											.getCmp(
													'proposedPathToSaveImageFileId')
											.setValue(
													mako_toEntities(Mako.fileSelectorImgObj
															.GetPanelData()[i].propFilePath));
					            }
					        }

					        //(File1) file
					        for (var i = 0; i < Mako.fileSelectorFile1Obj
									.GetPanelData().length; i++) { //this loop should iterate only once
					            var tempFilePath = Mako.fileSelectorFile1Obj
										.GetPanelData()[i].filePath;
					            if (tempFilePath.indexOf(':') == -1) {
					                //it is existing file
					                tempFilePath = tempFilePath.substring(3,
											tempFilePath.length); // cut off
					                // '../'
					                // from
					                // beggining
					                Ext.getCmp('sourceOfFile1Id').setValue(
											'existing');
					                Ext
											.getCmp('pathToFile1FromRootId')
											.setValue(
													mako_toEntities(tempFilePath));
					            } else {
					                //it is new file
					                Ext.getCmp('sourceOfFile1Id').setValue(
											'new');
					                Ext
											.getCmp(
													'screensaverFile1PathHiddenId')
											.setValue(
													mako_toEntities(tempFilePath));
					                Ext
											.getCmp('proposedPathToSaveFile1Id')
											.setValue(
													mako_toEntities(Mako.fileSelectorFile1Obj
															.GetPanelData()[i].propFilePath));
					            }
					        }

					        //(File2) file
					        for (var i = 0; i < Mako.fileSelectorFile2Obj
									.GetPanelData().length; i++) { //this loop should iterate only once
					            var tempFilePath = Mako.fileSelectorFile2Obj
										.GetPanelData()[i].filePath;
					            if (tempFilePath.indexOf(':') == -1) {
					                //it is existing file
					                tempFilePath = tempFilePath.substring(3,
											tempFilePath.length); // cut off
					                // '../'
					                // from
					                // beggining
					                Ext.getCmp('sourceOfFile2Id').setValue(
											'existing');
					                Ext
											.getCmp('pathToFile2FromRootId')
											.setValue(
													mako_toEntities(tempFilePath));
					            } else {
					                //it is new file
					                Ext.getCmp('sourceOfFile2Id').setValue(
											'new');
					                Ext
											.getCmp(
													'screensaverFile2PathHiddenId')
											.setValue(
													mako_toEntities(tempFilePath));
					                Ext
											.getCmp('proposedPathToSaveFile2Id')
											.setValue(
													mako_toEntities(Mako.fileSelectorFile2Obj
															.GetPanelData()[i].propFilePath));
					            }
					        }
					    }
					}); // END: editForm.addListener('beforeaction',
                // function(formObj, action){

                windowObj = new Ext.Window({
                    title: '',
                    closable: true,
                    width: 700,
                    height: 544,
                    plain: true,
                    layout: 'fit',
                    items: editForm
                });

                windowObj.addListener('activate', function (Obj) {
                    editForm.getForm().load({
                        url: mako_getPathToRoot(elemId) + 'data/index.asp'
                    });
                });

                windowObj.addListener(
							'show',
							function (formObj) {
							    Mako.Runner.run(transEdit_pleaseWait);
							    Mako.Runner.SCREENSAVER_imgLoaded = false;
							    Mako.Runner.SCREENSAVER_file1Loaded = false;
							    Mako.Runner.SCREENSAVER_file2Loaded = false;
							    Ext.Ajax
										.request({
										    method: 'POST',
										    url: mako_getPathToRoot(elemId) + 'data/index.asp',

										    success: function (response) {
										        //Mako.Runner.run(transEdit_pleaseWait);

										        var editedElementNode = response.responseXML
														.selectNodes(elemId.replace(/\|/gi, '/'))[0];

										        // build tab panel (Img)
										        var existingImgPath = editedElementNode
														.selectNodes('img1')[0].text
														.replace(
																new RegExp(
																		mako_getPathToRoot(
																				elemId)
																				.replace(
																						/\./gi,
																						'\\.'),
																		'gi'),
																'');

										        Mako.fileSelectorImgObj = new MakoTabPanel();
										        var fileSelectorImgPanel = Mako.fileSelectorImgObj
														.CreateTabPanel(
																proposedPathToSaveFiles,
																existingImgPath,
																mako_getPathToRoot(elemId),
																'', true);
										        fileSelectorImgPanel.height = 474; // height
										        // of
										        // TabPanel
										        Mako.fileSelectorImgObj.existingFileDropDown.width = 260; // width
										        // of
										        // dropDownList
										        // Mako.fileSelectorImgObj.newFilePanel.labelWidth
										        // = 80; //default nwe file
										        // label width
										        Mako.fileSelectorImgObj.proposedFilePathTextField.width = 168; // proposed
										        // path
										        // field
										        // width
										        Mako.fileSelectorImgObj.newFileTextField.fieldLabel = transEdit_imageFile; // new
										        // file
										        // field
										        // label
										        Mako.fileSelectorImgObj.newFileTextField.width = 170; // new
										        // file
										        // field
										        // width

										        // add listener to drop down
										        // list
										        Mako.fileSelectorImgObj.existingFileDropDown.store
														.addListener(
																'load',
																function () {
																    Mako.Runner.SCREENSAVER_imgLoaded = true;
																    if (Mako.Runner.SCREENSAVER_imgLoaded
																			&& Mako.Runner.SCREENSAVER_file1Loaded
																			&& Mako.Runner.SCREENSAVER_file2Loaded) {
																        Mako.Runner
																				.stop();
																    }
																});

										        Ext
														.getCmp(
																'fileSelectorImgPanel')
														.add(
																fileSelectorImgPanel);
										        Ext.getCmp(
														'fileSelectorImgPanel')
														.doLayout();

										        // build tab panel (File1)
										        var existingFile1Path = editedElementNode
														.selectNodes('linkToFile1')[0]
														.getAttribute('href')
														.replace(
																new RegExp(
																		mako_getPathToRoot(
																				elemId)
																				.replace(
																						/\./gi,
																						'\\.'),
																		'gi'),
																'');

										        Mako.fileSelectorFile1Obj = new MakoTabPanel();
										        var fileSelectorFile1Panel = Mako.fileSelectorFile1Obj
														.CreateTabPanel(
																proposedPathToSaveFiles,
																existingFile1Path,
																mako_getPathToRoot(elemId),
																'', false);
										        fileSelectorFile1Panel.height = 120; // height
										        // of
										        // TabPanel
										        fileSelectorFile1Panel.style = 'margin-top: 20px;'; // style
										        // of
										        // TabPanel
										        Mako.fileSelectorFile1Obj.existingFileDropDown.width = 320; // width
										        // of
										        // dropDownList
										        Mako.fileSelectorFile1Obj.newFilePanel.labelWidth = 105; // default
										        // nwe
										        // file
										        // label
										        // width
										        Mako.fileSelectorFile1Obj.proposedFilePathTextField.width = 188; // proposed
										        // path
										        // field
										        // width
										        Mako.fileSelectorFile1Obj.newFileTextField.fieldLabel = transEdit_screensaverFile; // new
										        // file
										        // field
										        // label
										        Mako.fileSelectorFile1Obj.newFileTextField.width = 192; // new
										        // file
										        // field
										        // width

										        // add listener to drop down
										        // list
										        Mako.fileSelectorFile1Obj.existingFileDropDown.store
														.addListener(
																'load',
																function () {
																    Mako.Runner.SCREENSAVER_file1Loaded = true;
																    if (Mako.Runner.SCREENSAVER_imgLoaded
																			&& Mako.Runner.SCREENSAVER_file1Loaded
																			&& Mako.Runner.SCREENSAVER_file2Loaded) {
																        Mako.Runner
																				.stop();
																    }
																});

										        Ext
														.getCmp(
																'fileSelectorFile1Panel')
														.add(
																fileSelectorFile1Panel);
										        Ext
														.getCmp(
																'fileSelectorFile1Panel')
														.doLayout();

										        // build tab panel (File2)
										        var existingFile2Path = editedElementNode
														.selectNodes('linkToFile2')[0]
														.getAttribute('href')
														.replace(
																new RegExp(
																		mako_getPathToRoot(
																				elemId)
																				.replace(
																						/\./gi,
																						'\\.'),
																		'gi'),
																'');

										        Mako.fileSelectorFile2Obj = new MakoTabPanel();
										        var fileSelectorFile2Panel = Mako.fileSelectorFile2Obj
														.CreateTabPanel(
																proposedPathToSaveFiles,
																existingFile2Path,
																mako_getPathToRoot(elemId),
																'', false);
										        fileSelectorFile2Panel.height = 120; // height
										        // of
										        // TabPanel
										        fileSelectorFile2Panel.style = 'margin-top: 20px;'; // style
										        // of
										        // TabPanel
										        Mako.fileSelectorFile2Obj.existingFileDropDown.width = 320; // width
										        // of
										        // dropDownList
										        Mako.fileSelectorFile2Obj.newFilePanel.labelWidth = 105; // default
										        // nwe
										        // file
										        // label
										        // width
										        Mako.fileSelectorFile2Obj.proposedFilePathTextField.width = 188; // proposed
										        // path
										        // field
										        // width
										        Mako.fileSelectorFile2Obj.newFileTextField.fieldLabel = transEdit_screensaverFile; // new
										        // file
										        // field
										        // label
										        Mako.fileSelectorFile2Obj.newFileTextField.width = 192; // new
										        // file
										        // field
										        // width

										        // add listener to drop down
										        // list
										        Mako.fileSelectorFile2Obj.existingFileDropDown.store
														.addListener(
																'load',
																function () {
																    Mako.Runner.SCREENSAVER_file2Loaded = true;
																    if (Mako.Runner.SCREENSAVER_imgLoaded
																			&& Mako.Runner.SCREENSAVER_file1Loaded
																			&& Mako.Runner.SCREENSAVER_file2Loaded) {
																        Mako.Runner
																				.stop();
																    }
																});

										        Ext
														.getCmp(
																'fileSelectorFile2Panel')
														.add(
																fileSelectorFile2Panel);
										        Ext
														.getCmp(
																'fileSelectorFile2Panel')
														.doLayout();

										        /*
										        * //set form field values
										        * Ext.getCmp('flashWidth').setValue(editedElementNode.selectNodes('width')[0].text);
										        * Ext.getCmp('flashHeight').setValue(editedElementNode.selectNodes('height')[0].text);
										        * 
										        * if(editedElementNode.getAttribute('isFlash') ==
										        * 'true'){
										        * Ext.getCmp('imageType').setValue('flash');
										        * }else{
										        * Ext.getCmp('imageType').setValue('image');
										        * Ext.getCmp('flashWidth').disable();
										        * Ext.getCmp('flashHeight').disable(); }
										        */
										    },
										    failure: function () {
										        if (Mako.Runner) {
										            Mako.Runner.stop();
										        }
										        alert('Request faild, load data, SCREENSAVER')
										    }
										});
							});

                break;
            // #############################################################################################################                                                                                                                                 
            case 'FlashVideo':

                newVideoTabPanel = new MakoTabPanel();
                pathtoroot = mako_getPathToRoot(elemId);

                if (proposedImageSize == undefined) {
                    proposedImageSize = '625x433';
                }
                videoTabPanel = newVideoTabPanel.CreateTabPanel('', '', pathtoroot,
					proposedImageSize);

                var elemIdArray = elemId.split('|');
                var elemIdSubPath = '';
                for (var i = 2; i < elemIdArray.length; i++) {
                    elemIdSubPath += elemIdArray[i];
                    if ((i + 1) != elemIdArray.length) {
                        //add slash if it is not last element
                        elemIdSubPath += '/';
                    }
                } //END: for(var i = 2; i<elemIdArray.length; i++){ 

                editForm = new Ext.form.FormPanel({
                    frame: true,
                    method: 'POST',
                    //title: transEdit_flashVideoWindowTitle,
                    labelAlign: 'center',
                    labelWidth: 190,
                    hidden: true,
                    width: 500,
                    defaultType: 'textfield',

                    items: [new Ext.form.Hidden({
                        name: 'actionType',
                        id: 'actionTypeId',
                        value: actionType
                    }), new Ext.form.Hidden({
                        name: 'editedElementPath',
                        id: 'editedElementPathId',
                        value: elemId
                    }), new Ext.form.TextField({
                        name: 'flashVideoFilePathHidden',
                        id: 'flashVideoFilePathHiddenId',
                        allowBlank: false
                        // value:'C:\\Documents and
                        // Settings\\blazej.grzelinski\\Pulpit\\5.jpg'
                    }), new Ext.form.Hidden({
                        name: 'proposedPathToSaveFlashVideoFile',
                        id: 'proposedPathToSaveFlashVideoFileId',
                        value: proposedPathToSaveFiles
                    }), {
                        id: "hiddenWidth",
                        fieldLabel: transEdit_width,
                        name: 'width',
                        width: 190
                    }, {
                        id: "hiddenHeight",
                        fieldLabel: transEdit_height,
                        name: 'height',
                        width: 190
                    }]
                });

                editFormNotSubmited = new Ext.form.FormPanel({
                    frame: true,
                    layout: 'form',
                    labelWidth: 150,
                    defaultType: 'textfield',

                    reader: new Ext.data.XmlReader({
                        record: 'site'
                    }, [{
                        name: 'flashWidth',
                        mapping: elemIdSubPath + '/width'
                    }, {
                        name: 'flashHeight',
                        mapping: elemIdSubPath + '/height'
                    }]),

                    items: [videoTabPanel, {
                        xtype: 'label',
                        text: 'Video properies',
                        labelStyle: 'font-size:12x; width:190px'
                    }, {
                        id: "videoWidth",
                        fieldLabel: transEdit_width,
                        labelStyle: 'font-size:11px; width:190px',
                        name: 'flashWidth',
                        width: 190

                    }, {
                        id: "videoHeight",
                        fieldLabel: transEdit_height,
                        labelStyle: 'font-size:11px; width:190px',
                        name: 'flashHeight',
                        width: 190
                    }]
                })

                editForm.addListener('beforeaction', function () {

                    newVideoTabPanel.ValidatePanels();
                    Ext.getCmp('hiddenWidth').setValue(
						Ext.getCmp('videoWidth').getValue());
                    Ext.getCmp('hiddenHeight').setValue(
						Ext.getCmp('videoHeight').getValue());
                    Ext.getCmp('flashVideoFilePathHiddenId').setValue(
						newVideoTabPanel.GetPanelData()[0].filePath);
                });

                editForm.addListener('beforeaction', mako_addEntitiesToFormFields);

                windowObj = new Ext.Window({
                    title: transEdit_flashVideoWindowTitle,
                    closable: true,
                    width: 540,
                    height: 400,
                    plain: true,
                    layout: 'fit',
                    items: [editFormNotSubmited, editForm]
                });

                windowObj.addListener('activate', function (formObj) {

                    editFormNotSubmited.getForm().load({
                        url: mako_getPathToRoot(elemId) + 'data/index.asp'
                    });
                    // alert(mako_getPathToRoot(elemId)+'data/index.asp');
                });

                break;
            // #############################################################################################################                                             
            case 'FLASHTitle':

                var rootPath = mako_getPathToRoot(elemId)
                if (flashTitleEditor.panel == null) {
                    var flashTitlePanel = flashTitleEditor.FlashTitlePanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Flash title editor",
                        closable: true,
                        width: 600,
                        height: 150,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'fit',
                        cls: 'alignLeft',
                        items: [flashTitlePanel]
                    });

                    flashTitlePanel.panel = null;
                }
                else {
                    return;
                }


                break;
            // #############################################################################################################                                                                                                                                 
            case 'FLASHHeader':

                var siteId = mako_getSiteId(elemId);
                var XPathToFlashHeaderNode = mako_getXPathToFlashHeaderNode(siteId.replace(/\|/g, '/')) + '/flashHeader';

                var rootPath = mako_getPathToRoot(elemId)
                if (flashHeaderEditor.panel == null) {
                    var flashHeaderPanel = flashHeaderEditor.FlashHeaderPanel(rootPath, XPathToFlashHeaderNode);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Flash header editor",
                        closable: true,
                        width: 600,
                        height: 150,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'fit',
                        cls: 'alignLeft',
                        items: [flashHeaderPanel]
                    });

                    flashHeaderEditor.panel = null;
                }
                else {
                    return;
                }

                break;
            // #############################################################################################################                                                                                                                                 

            case 'FocusItem':

                var siteId = mako_getSiteId(elemId);

                var rootPath = mako_getPathToRoot(elemId)
                if (focusEditor.panel == null) {
                    var focusPanel = focusEditor.FocusPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "Focus editor",
                        closable: true,
                        width: 600,
                        height: 700,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'fit',
                        cls: 'alignLeft',
                        items: [focusPanel]
                    });

                    focusEditor.panel = null;
                }
                else {
                    return;
                }

                break;
            // #############################################################################################################                                                                                                                                 

            // #############################################################################################################                                                                                                                                 
            case 'FlashSpots':
                var siteId = mako_getSiteId(elemId);
                var XPathToFlashSpots = siteId.replace(/\|/g, '/') + '/flashSpots';
                var XPathToFlashSpotsParent = siteId.replace(/\|/g, '/');

                var fmSpots = Ext.form;



                var rootPath = mako_getPathToRoot(elemId)
                //var fileTreePan = fileTree.FileBrowserPanel(rootPath, elemId);
                path = rootPath
                elemPath = elemId;
                allowedExtensions = '.png.jpg.jpeg';

                treePanel = new Ext.tree.TreePanel({
                    useArrows: true,
                    animate: false,
                    border: false,
                    height: 360,
                    bodyCssClass: 'FlashSpotTreeBody',
                    autoScroll: true,
                    enableDD: false,
                    iconCls: '',
                    containerScroll: true,
                    dataUrl: path + 'adminPanel/aspx/FileTreeLoader.aspx?dataFolder=' + country + '&allowedExtensions=' + allowedExtensions,
                    root: {
                        nodeType: 'async',
                        text: 'Country files',
                        visible: false,
                        id: 'rootNode'
                    },
                    listeners: {
                        click: function (n) {
                            if (n.attributes.leaf == true) {
                                //FileEditor.prototype.FileInfo(n);
                            }
                        },
                        dblclick: function (n) {

                        }
                    }

                });

                treePanel.getRootNode().expand();

                var spotsCm = new Ext.grid.ColumnModel([{
                    id: 'DealerText',
                    width: 230,
                    header: flashHostSpotsColumn1title,
                    dataIndex: 'DisplayText',
                    css: 'background-color: #f3faf8; vertical-align:middle;',
                    align: 'center',
                    sortable: false,
                    editor: new fmSpots.TextField({
                        value: '',
                        allowBlank: true
                    })
                }, {
                    header: flashHostSpotsColumn2title,
                    width: 230,
                    dataIndex: 'URLAddress',
                    sortable: false,
                    hideable: true,

                    css: 'background-color: #f3faf8; vertical-align:middle;',
                    editor: new fmSpots.TextField({
                        value: '',
                        allowBlank: false
                    })
                }]);

                var spots = Ext.data.Record.create([{
                    name: 'DisplayText',
                    type: 'string'
                }, {
                    name: 'URLAddress',
                    type: 'string'
                }]);

                var spotsStore = new Ext.data.SimpleStore({
                    fields: ['DisplayText', 'URLAddress'],
                    autoLoad: false
                });

                spotsGrid = new Ext.grid.EditorGridPanel({
                    store: spotsStore,
                    cm: spotsCm,
                    header: true,
                    title: 'Edit links',
                    headerAsText: true,
                    hideHeaders: false,
                    enableColumnHide: false,
                    width: 480,
                    height: 250,
                    frame: true,
                    clicksToEdit: 1,
                    listeners: {
                        'afteredit': function (curObj) {
                        }
                    }
                });

                var titleText = new Ext.form.TextField({
                    fieldLabel: 'Flash title',
                    width: 350,
                    inputType: 'text'
                });

                var subTitleText = new Ext.form.TextField({
                    fieldLabel: 'Flash subtitle',
                    width: 350,
                    inputType: 'text'
                });

                var yText = new Ext.form.TextField({
                    fieldLabel: 'yPos',
                    width: 350,
                    inputType: 'text'
                });

                var xText = new Ext.form.TextField({
                    fieldLabel: 'xPos',
                    width: 350,
                    inputType: 'text'
                });

                var imageText = new Ext.form.Hidden({
                    name: 'imageText'
                });

                var fieldsPanel = new Ext.form.FormPanel({
                    width: 480,
                    height: 140,
                    frame: true,
                    layout: 'form',
                    items: [titleText, subTitleText, xText, yText, imageText]
                })


                var windowObj = new Ext.Window(
					{
					    title: flashHostSpotsEditorTitle,
					    width: 900,
					    height: 450,
					    resizable: false,
					    closable: false,
					    modal: true,
					    plain: true,
					    buttonAlign: 'right',
					    listeners: {
					        'close': function (p) {
					            clickedDealer = 0;
					        }
					    },
					    items:
                        [{
                            layout: 'column',
                            items: [{
                                title: 'Background Image',
                                columnWidth: .45,
                                align: 'left',
                                items: treePanel
                            }, {
                                title: 'Spots properties',
                                columnWidth: .55,
                                autoScroll: false,
                                labelWidth: 80,
                                height: 387,
                                bodyStyle: 'padding:5px;',
                                defaultType: 'textfield',
                                items: [fieldsPanel, spotsGrid]
                            }]
                        }],
					    buttons: [
								{
								    xtype: 'button',
								    text: saveButton,
								    handler: function () {

								        PostXml = new ActiveXObject(
												"Msxml2.DOMDocument.3.0");
								        root = PostXml
												.createElement("flashSpots");
								        spots = PostXml.createElement("spots");
								        title = PostXml.createElement("title");
								        pathImage = PostXml.createElement("path");
								        subTitle = PostXml
												.createElement("subTitle");

								        title.text = titleText.getValue();
								        subTitle.text = subTitleText.getValue();
								        pathImage.text = imageText.getValue();

								        spots.setAttribute("x", xText.getValue());
								        spots.setAttribute("y", yText.getValue());


								        if (treePanel.getSelectionModel().getSelectedNode() != null) {
								            var imageUrl = path + country + treePanel.getSelectionModel().getSelectedNode().id.replace("|", "//");
								            pathImage.text = imageUrl;
								            //alert(imageUrl);
								        }

								        root.appendChild(title);
								        root.appendChild(subTitle);
								        root.appendChild(pathImage);

								        root.appendChild(spots);

								        for (var i = 0; i < spotsStore
												.getCount(); i++) {

								            dispText = spotsStore.getAt(i).get(
													'DisplayText');
								            urlAddr = spotsStore.getAt(i).get(
													'URLAddress');

								            childElement = PostXml
													.createElement("spot");

								            childElement.text = dispText;
								            childElement.setAttribute("url",
													urlAddr);
								            spots.appendChild(childElement);

								        }

								        Ext.Ajax
												.request({
												    params: {
												        xmlData: mako_toEntities(root.xml),
												        editedElementPath: XPathToFlashSpotsParent
												    },
												    method: 'POST',
												    url: mako_getPathToRoot(elemId) + 'data/saveXMLAddition.asp',
												    success: function (response) {
												        if (response.responseText != "") {
												            Ext.MessageBox
																	.show({
																	    title: invalidLink_MessageBoxTitle,
																	    msg: "File with the name "
																				+ response.responseText
																				+ " already exist",
																	    buttons: Ext.MessageBox.OK,
																	    icon: 'ext-mb-error'
																	});
												            return;
												        } else {
												            windowObj.close();

												        }
												        window.location
																.reload(true);
												    },
												    failure: function () {
												        alert("faild")
												    }
												});
								    }

								}, {
								    xtype: 'button',
								    text: closeButton,
								    handler: function () {
								        windowObj.close();
								    }
								}]
					});
                //load index.xml
                Ext.Ajax.request({
                    method: 'POST',
                    url: mako_getPathToRoot(elemId) + 'data/index.asp',

                    success: function (response) {

                        var flashSpotsNode = response.responseXML.selectNodes(XPathToFlashSpots + '/spots')[0];
                        titleText.setValue(response.responseXML.selectNodes(XPathToFlashSpots + '/title')[0].text);
                        subTitleText.setValue(response.responseXML.selectNodes(XPathToFlashSpots + '/subTitle')[0].text);

                        imageText.setValue(response.responseXML.selectNodes(XPathToFlashSpots + '/path')[0].text);

                        yText.setValue(flashSpotsNode.getAttribute("y"));
                        xText.setValue(flashSpotsNode.getAttribute("x"));

                        for (var i = flashSpotsNode.childNodes.length - 1; i >= 0; i--) {
                            var p = new spots(
	                                    {
	                                        DisplayText: flashSpotsNode.childNodes[i].text, URLAddress: flashSpotsNode.childNodes[i].getAttribute("url")
	                                    });
                            spotsStore.insert(0, p);
                        }
                    },
                    failure: function () {
                        alert('Request faild')
                    }
                });

                windowObj.show();
                break;
            // #############################################################################################################                                                                                                                                 

            case 'ListEditor':

                var XPathToList = elemId.replace(/\|/g, '/');
                var listNodeName = XPathToList.split('/');
                listNodeName = listNodeName[listNodeName.length - 1];


                var rootPath = mako_getPathToRoot(elemId);
                if (listEditorPanel.panel == null) {
                    var listPanel = listEditorPanel.ListPanel(rootPath, elemId);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: "List editor",
                        closable: true,
                        width: 350,
                        height: 350,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        //layout: 'form',
                        cls: 'alignLeft',
                        items: [listPanel]
                    });

                    listEditorPanel.listPanel = null;
                }
                else {
                    return;
                }

                break;



            // #############################################################################################################                                                                                                                                

            case 'IFRAME':

                var XPathToList = elemId.replace(/\|/g, '/');
                var listNodeName = XPathToList.split('/');
                listNodeName = listNodeName[listNodeName.length - 1];


                var rootPath = mako_getPathToRoot(elemId);
                //alert(rootPath);
                if (iFrameEditorPanel.panel == null) {
                    var iFramePanel = iFrameEditorPanel.IFramePanel(rootPath, elemId, actionType);
                    windowObj = new Ext.Window({
                        modal: true,
                        title: iframeEditorWindowTitle,
                        closable: true,
                        width: 550,
                        height: 300,
                        animatre: false,
                        resizable: false,
                        plain: true,
                        layout: 'fit',
                        cls: 'alignLeft',
                        items: [iFramePanel]
                    });

                    iFrameEditorPanel.iFramePanel = null;
                }
                else {
                    return;
                }

                break;
        } //END: switch(actionType){

        // #############################################################################################################
        if (actionType != "FlashSpots") {
            var submit = windowObj.addButton({
                text: transEdit_save,
                handler: function () {
                    if (actionType != "LINKwithIFrame" && actionType != "LINK") {
                        isDirtyRequest = Ext.Ajax.request({
                            async: false,
                            headers: { 'Content-type': 'application/x-www-form-urlencoded', 'charset': 'utf-8' },
                            //headers: { 'Content-Type': 'application/xml' },
                            url: path + 'adminPanel/aspx/DirtyMarker.ashx',
                            success: function (response) {
                                SaveData();
                            },
                            failure: function (response) {
                                Ext.Msg.alert('Error occurred', 'Error message: ' + response.statusText);
                            },
                            params: { page: mako_getSiteId(elemId), pathToRoot: rootPath, countryName: country }
                        })
                    }
                    else {
                        SaveData();
                    }

                    function SaveData() {
                        
                        if (editForm == "") {
                            if (actionType == "IMGFlash") {

                                if (!imgFlashTree.ValidateProperties()) {
                                    Ext.Msg.alert('Invalid properties values', 'Flash Width and Flash Height must be a number');
                                    return;
                                }
                                params = { actionType: actionType, editedElementPath: elemId, filePath: imgFlashTree.GetSelectedFile(), flashWidth: imgFlashTree.GetFlashWidth(), flashHeight: imgFlashTree.GetFlashHeight(), imageType: imgFlashTree.SelectedFileType(), isLeaf: imgFlashTree.IsSelectedLeaf(), altText: imgTree.AltTagText(), linkURL: imgFlashTree.GetLinkURL(), linkTarget: imgFlashTree.GetLinkTarget(), autoStart: imgFlashTree.GetAutoStart() };
                                imgFlashTree.Save(params);
                            }

                            if (actionType == "IMG") {
                                params = { actionType: actionType, editedElementPath: elemId, filePath: imgTree.GetSelectedFile(), altText: imgTree.AltTagText(), isLeaf: imgTree.IsSelectedLeaf(), width: imgTree.ImageWidth(), height: imgTree.ImageHeight() };
                                imgTree.Save(params);
                            }

                            if (actionType == "FILE") {
                                //alert(fileTree.IsSelectedLeaf());                                
                                params = { actionType: actionType, editedElementPath: elemId, filePath: fileTree.GetSelectedFile(), isLeaf: fileTree.IsSelectedLeaf(), fileName: fileTree.GetName() };
                                fileTree.Save(params);
                            }

                            if (actionType == "IMGLink") {
                                params = { actionType: actionType, editedElementPath: elemId, filePath: imgTree.GetSelectedFile(), linkUrl: imageLinkTree.Url(), targetWindow: imageLinkTree.Target(), isLeaf: imgTree.IsSelectedLeaf() };
                                imageLinkTree.Save(params);
                            }


                            if (actionType == "HTMLEditor") {
                                params = { actionType: actionType, editedElementPath: elemId, HTMLTextHidden: htmlEditorPanel.GetHtmlText() };
                                htmlEditorPanel.Save(params);
                            }

                            if (actionType == "LINK") {
                                params = { actionType: actionType, editedElementPath: elemId, URLText: linkEditorPanel.GetText(), URLAddress: linkEditorPanel.GetUrl(), URLTitle: linkEditorPanel.GetTitle() };
                                linkEditorPanel.Save(params);
                            }

                            if (actionType == "LINKwithIFrame") {
                                params = { actionType: actionType, editedElementPath: elemId, URLText: linkEditorWithIFrame.GetText(), URLAddress: linkEditorWithIFrame.GetUrl(), URLCheckBox: linkEditorWithIFrame.GetCheckBoxValue(), URLTitle: linkEditorPanel.GetTitle(),
                                    GreyBoxTitle: linkEditorWithIFrame.GetGreyBoxTitle(), GreyBoxCloseText: linkEditorWithIFrame.GetGreyBoxCloseText(), GreyBoxWidth: linkEditorWithIFrame.GetGreyBoxWidth(), GreyBoxHeight: linkEditorWithIFrame.GetGreyBoxHeight()
                                };
                                linkEditorWithIFrame.Save(params);
                            }

                            if (actionType == "FLASHTitle") {
                                params = { actionType: actionType, editedElementPath: elemId, textFirstLine: flashTitleEditor.GetFirstLine(), textSecondLine: flashTitleEditor.GetSecondLine() };
                                flashTitleEditor.Save(params);
                            }

                            if (actionType == "FLASHHeader") {
                                params = { actionType: actionType, editedElementPath: mako_getXPathToFlashHeaderNode(siteId.replace(/\|/g, '/')) + '/flashHeader', textFirstLine: flashHeaderEditor.GetFirstLine(), textSecondLine: flashHeaderEditor.GetSecondLine() };
                                flashHeaderEditor.Save(params);
                            }

                            if (actionType == "FocusItem") {
                                params = { actionType: actionType, editedElementPath: elemId, SmallImage: focusEditor.FirstImgPanel(), BigImage: focusEditor.SecondImgPanel(), HTMLTextFirst: focusEditor.FirstColumn(), HTMLTextSecond: focusEditor.SecondColumn(), LinkText: focusEditor.LinkText(), Title: focusEditor.TitleText(), Subtitle: focusEditor.SubtitleText(), BackgroundColor: focusEditor.ColorsField() };
                                focusEditor.Save(params);
                            }
                            if (actionType == "ListEditor") {
                                params = { actionType: actionType, editedElementPath: elemId, xmlData: listEditorPanel.createXml(listNodeName), listNodeName: listNodeName }
                                listEditorPanel.Save(params);
                            }
                            if (actionType == "IFRAME") {
                                //alert(iFrameEditorPanel.GetAddress());
                                params = { actionType: actionType, editedElementPath: elemId, IFrameAddress: iFrameEditorPanel.GetAddress(), IFrameWidth: iFrameEditorPanel.GetWidth(), IFrameHeigth: iFrameEditorPanel.GetHeigth() }
                                iFrameEditorPanel.Save(params);
                            }

                            return;
                        }



                        editForm.getForm().submit({ url: mako_getPathToRoot(elemId) + 'data/saveXML.asp', success: function (form, action) {
                            document.location = (window.location.href.indexOf('#') == -1 ? window.location.href : window.location.href.replace(new RegExp('#', 'gi'), ''));
                        },
                            failure: function (form, action) {
                            }

                        });
                    }
                }
            });

            windowObj.addButton({
                id: 'closeButton',
                text: 'Close',
                handler: function () {
                    windowObj.close();
                    windowObj = null;
                }
            });
        }
        windowObj.show(this);

        return false;
    }; // END: htmlitem.onclick= function(){

}                                        //END: BrowserOP.prototype.selectEditableelement = function(elemId, actionType){

var OBrowser = new BrowserOP();

