    
    function OpenAddControlWindow(instanceID, inctanceType)
    {
        window.open("AddControl.aspx?inctance_id=" + instanceID + "&inctance_type=" + inctanceType ,"addControl", "height=400,width=350,status=yes,toolbar=no");
    }
    
    function OpenEditControlWindow(instanceID, inctanceType, controlID)
    {
        window.open("AddControl.aspx?inctance_id=" + instanceID + "&inctance_type=" + inctanceType + "&control_id=" + controlID,"editControl", "height=400,width=350,status=yes,toolbar=no");
    }
    
    
    
    function SetBarPosition()
    {
        var obj = document.getElementById("LoadBar");
        obj.style.left=Number(document.body.clientWidth  + document.body.scrollLeft) / 2;
        obj.style.top = Number(document.body.clientHeight + document.body.scrollTop)  / 2 + 100;
    }
    
    function eControlToolbar_PostBack(sender, eventargs)
    {
        //__doPostBack(sender, eventargs);
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(sender, eventargs, false, eventargs, "", false, true)) 
    }
    
    function eSlider_PostBack()
    {

        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("slider", "slider_clientdrag", false, "slider_clientdrag", "", false, true)) 
    }
    
    function ShowImage(dialogClientID, dialogImageControlClientID, dialogCommentsControlClientID, ImageURL, ImageComments)
    { 
        $get(dialogImageControlClientID).style.display="block";
        $get(dialogImageControlClientID).src = ImageURL;
        im = new Image();
        im.src = ImageURL;
        $get(dialogCommentsControlClientID).innerHTML = ImageComments;
        setTimeout("ShowModalDialog('"+dialogClientID+"','"+ dialogImageControlClientID+"','"+
                ImageURL+"')",200);
    }



    function ShowImage2(dialogImageControlClientID, dialogCommentsControlClientID, ImageURL, ImageComments)
    {   
        $get(dialogImageControlClientID).style.display="block";
        $get(dialogImageControlClientID).src = ImageURL;
        $get(dialogCommentsControlClientID).innerHTML = ImageComments;
    }
    
    function ShowImage3(extenderID, dialogImageControlClientID, dialogCommentsControlClientID, ImageURL, ImageComments)
    { 
        $get(dialogImageControlClientID).style.display="block";
        $get(dialogImageControlClientID).src = ImageURL;
        $get(dialogCommentsControlClientID).innerHTML = ImageComments;
        AjaxControlToolkit.Animation.SequenceAnimation.play($get(extenderID));
    }
    
    function AddBeheviour(controlID, viewerID)
    {
        /*    Sys.Application.add_init(function() {
            $create(AjaxControlToolkit.Animation.AnimationBehavior, {"OnClick":"{\"AnimationName\":\"Sequence\",\"AnimationChildren\":[{\"AnimationName\":\"StyleAction\",\"AnimationTarget\":\"" + viewerID + "_flyout\",\"Attribute\":\"position\",\"Value\":\"absolute\",\"AnimationChildren\":[]},{\"AnimationName\":\"StyleAction\",\"AnimationTarget\":\"" + viewerID + "_flyout\",\"Attribute\":\"overflow\",\"Value\":\"auto\",\"AnimationChildren\":[]},{\"AnimationName\":\"ScriptAction\",\"Script\":\"Cover($get(\\u0027btnClose\\u0027), $get(\\u0027flyout\\u0027), true);\",\"AnimationChildren\":[]},{\"AnimationName\":\"StyleAction\",\"AnimationTarget\":\"" + viewerID + "_flyout\",\"Attribute\":\"display\",\"Value\":\"block\",\"AnimationChildren\":[]},{\"AnimationName\":\"Parallel\",\"AnimationTarget\":\"" + viewerID + "_flyout\",\"Duration\":\".3\",\"Fps\":\"25\",\"AnimationChildren\":[{\"AnimationName\":\"Resize\",\"AnimationChildren\":[]},{\"AnimationName\":\"Move\",\"relative\":\"false\",\"duration\":\"0.2\",\"fps\":\"40\",\"horizontalScript\":\"getX(\\u0027" + controlID + "\\u0027)\",\"verticalScript\":\"getY(\\" + controlID + "\\u0027)\",\"AnimationTarget\":\"" + viewerID + "_info\",\"AnimationChildren\":[]},{\"AnimationName\":\"Color\",\"PropertyKey\":\"backgroundColor\",\"StartValue\":\"#AAAAAA\",\"EndValue\":\"#FFFFFF\",\"AnimationChildren\":[]}]},{\"AnimationName\":\"ScriptAction\",\"Script\":\"Cover($get(\\u0027flyout\\u0027), $get(\\u0027info\\u0027), true);\",\"AnimationChildren\":[]},{\"AnimationName\":\"StyleAction\",\"AnimationTarget\":\"" + viewerID + "_info\",\"Attribute\":\"display\",\"Value\":\"block\",\"AnimationChildren\":[]},{\"AnimationName\":\"FadeIn\",\"AnimationTarget\":\"" + viewerID + "_info\",\"Duration\":\".2\",\"AnimationChildren\":[]},{\"AnimationName\":\"StyleAction\",\"AnimationTarget\":\"" + viewerID + "_flyout\",\"Attribute\":\"display\",\"Value\":\"none\",\"AnimationChildren\":[]},{\"AnimationName\":\"Parallel\",\"AnimationTarget\":\"" + viewerID + "_info\",\"Duration\":\".5\",\"AnimationChildren\":[{\"AnimationName\":\"Color\",\"PropertyKey\":\"color\",\"StartValue\":\"#FF5400\",\"EndValue\":\"#a9ca44\",\"AnimationChildren\":[]},{\"AnimationName\":\"Color\",\"PropertyKey\":\"borderColor\",\"StartValue\":\"#FF5400\",\"EndValue\":\"#a9ca44\",\"AnimationChildren\":[]}]},{\"AnimationName\":\"Parallel\",\"AnimationTarget\":\"" + viewerID + "_info\",\"Duration\":\".5\",\"AnimationChildren\":[{\"AnimationName\":\"Color\",\"PropertyKey\":\"color\",\"StartValue\":\"#a9ca44\",\"EndValue\":\"#FF5400\",\"AnimationChildren\":[]},{\"AnimationName\":\"Color\",\"PropertyKey\":\"borderColor\",\"StartValue\":\"#a9ca44\",\"EndValue\":\"#FF5400\",\"AnimationChildren\":[]},{\"AnimationName\":\"FadeIn\",\"AnimationTarget\":\"" + viewerID + "_btnCloseParent\",\"MaximumOpacity\":\".9\",\"AnimationChildren\":[]}]}]}","id": viewerID + "_aExtender"}, null, null, $get(controlID));*/
    }
    
    function getX(elemID)
    {
        return 100;
    }
    
    function getY(elemID)
    {
        var l = Sys.UI.DomElement.getLocation($get(elemID));
        return (l.y-200);
    }

    function ShowModalDialog(dialogClientID, dialogImageControlClientID,  ImageURL)
    {
        //Sys.UI.DomElement.setLocation(document.getElementById(dialogImageControlClientID), 0, 0);
         $find(dialogClientID).show();  
    }
   

    
    
    function SetFileUploadValues (parentCommentsControlID, parentFileUrlControlID, parentFileSizeControlID, parentFileOriginalNameControlID, fileComments, fileHTMLPath, fileSize, fileOriginalName)
    {
        
        parent.$get(parentFileUrlControlID).value=fileHTMLPath;
        try
        {
            parent.$get(parentCommentsControlID).value=fileComments;   
        } 
        catch(ex)
        {}        
        try
        {
            parent.$get(parentFileSizeControlID).value=fileSize;
        } 
        catch(ex)
        {}
        
        try
        {
            parent.$get(parentFileOriginalNameControlID).value= fileOriginalName;
        } 
        catch(ex)
        {}
        try
        {
            parent.SaveAll()
        }
        catch(ex)
        {}
        
    }


    function FCKUpdateLinkedField(id)
    {
       try
        {
            if(typeof(FCKeditorAPI) == "object")
            {
                FCKeditorAPI.GetInstance(id).UpdateLinkedField();
            }
        }
        catch(err)
        {
        }
    }
    
    
    /* ---------------------------- */
    
    function SaveAll()
    {
        UpdateFCKFields();
        __doPostBack('ctl00$ContentPlaceHolder1$btnSaveEdit_Emulation','');
    }
    
    
    function DeleteFile(fileName)
    {
        __doPostBack("deletefile",fileName);
    }   
    
    function UpdateFCKFields()
    {
        for (i=0; i<document.forms[0].elements.length; i++)
        {
            if (document.forms[0].elements[i].type=="hidden")
            {
                if (document.forms[0].elements[i].id.indexOf("fck")>=0)
                {
                    try
                    {
                        FCKUpdateLinkedField(document.forms[0].elements[i].id);
                    }
                    catch(ex)
                    {}
                }
            }
        }
        return true;
    }