//SW_TRACE = true; // For tracing AJAX-update performance


function treeNodeDropped(sourceNode,destNode,events){
    if (!destNode && !dropTree) return false;
    if (!sourceNode) return false;
    var srcTree = sourceNode.TreeView.ClientID;
    var trgTree = null;
    if (!destNode) 
        trgTree = dropTree;
    else 
        trgTree = destNode.TreeView.ClientID;
    var treePageSet = '<%= TreePageSet.ClientID %>';
    var treeSpecialPages = '<%= TreeSpecialPages.ClientID %>';
    var treeSite = '<%= TreeSiteStructure.ClientID %>';
    
    if (destNode && sourceNode.DropEnabled == 0 && trgTree == treeSite) return false;
    
    if ((srcTree == treePageSet && trgTree == treeSpecialPages)
        || (srcTree == treeSpecialPages && trgTree == treePageSet)
        || (srcTree == trgTree && (srcTree == treePageSet || srcTree == treeSpecialPages))) return false;

    MakeCallback('<%=CallbackDrop.ClientID%>', srcTree +','+trgTree, sourceNode.Value + ',' + ((destNode)?destNode.Value:''));
    return false;
    
}

agent = navigator.userAgent.toLowerCase();
is_ie = ((agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1));
is_opera = agent.indexOf("opera") != -1;
is_safari = agent.indexOf("safari") != -1;



function doPreview(eventTarget, dialogUrl, func){
    var saveReq=null;
  try{saveReq=isSaveRequired()}catch(e){};
  if (saveReq){
    showApplyChangesDialog(
        function(useraction){
          var canNavigate=true;
          switch(useraction){
            case 1:{
                        canNavigate = ValidateForms();
                if(canNavigate) __doPostBack(eventTarget,"true");
            }break;
            case 0:{
                        if (!func)
                        {
                            __doPostBack(eventTarget,"false");
                        }
                        else
                        {
                            func();
                        }
            }break;
          }
        }
    );
  }
  else{
        if (!func)
        {
            __doPostBack(eventTarget,"false");
        }
        else
        {
            func();
        }
  }
}

var WysiwygFieldsArray = new Array();
function onBeforeSaveWysiwygFieldReqCheck()
{
    for (var key in WysiwygFieldsArray)
	{
        if (key == 'fromString') continue;
		if (WysiwygFieldsArray[key] != getEditorContent(key))
		{
			try{setSaveRequired(true);}catch(e){}
			break;
		}
	}
}

function doNavigate(eventTarget,url,PostBackUrl){
    try{onBeforeSaveReqCheck()}catch(e){};
    try{onBeforeSaveWysiwygFieldReqCheck();}catch(e){};
    var saveReq = null;
  try{saveReq=isSaveRequired();}catch(e){};
  if (saveReq){
     showApplyChangesDialog(
            function(useraction){
                var canNavigate=true;
                switch(useraction){
                  case 1:{
                      canNavigate = ValidateForms();
                      if(canNavigate) {
                          WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, url+"|true", true, null, PostBackUrl, false, true));
                            try{if (Page_ClientValidate && !Page_IsValid) setSaveRequired(true);}catch(e){};
                            try{if (Page_ClientValidate && !Page_IsValid) onClientValidateFailed();}catch(e){};
                        }
                  }break;
                  case 0:{
                            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, url+"|false", false, null, PostBackUrl, false, true));
                  };break;
                }
            });
 
  }
  else{
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, url+"|false", false, "", PostBackUrl, false, true));
  }
  return false;
}

function ValidateForms()
{
  if (typeof(Page_ClientValidate) == 'function' && typeof(Page_Forms) == 'object')
  {
    for (var cur in Page_Forms)
    {
      var vg = Page_Forms[cur];
      if (!Page_ClientValidate(vg))
        return false;
    }
  }

  return true;
}

function doFormNavigate(eventTarget,PostBackUrl){
    try{onBeforeSaveReqCheck()}catch(e){};
    try{onBeforeSaveWysiwygFieldReqCheck();}catch(e){};
    var saveReq=null;
  try{saveReq=isSaveRequired()}catch(e){};
  if (saveReq){
      
    showApplyChangesDialog(
        function(useraction){
          var canNavigate=true;
          switch(useraction){
            case 1:{
                
            canNavigate = ValidateForms();
                        if (canNavigate) {
                            
                            //try{setSaveRequired(false);}catch(e){};
                            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, true, true, "", PostBackUrl, false, true));
                            try{if (Page_ClientValidate && !Page_IsValid) setSaveRequired(true);}catch(e){};
                            try{if (Page_ClientValidate && !Page_IsValid) onClientValidateFailed();}catch(e){};
                        }
            }break;
            case 0: {
                    //Commented out by A.Fioletov.
                            //try{setSaveRequired(false);}catch(e){};
                            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, false, false, "", PostBackUrl, false, true));
            }break;
            case -1:{
                       try{onApplyCanceled();}catch(e){}
            };
          }
        }
    );
  }
  else{
        try{setSaveRequired(false);}catch(e){};
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(eventTarget, false, false, "", PostBackUrl, false, true));
    }
    return false;
}


function openDialog(url, action, init) {
  if (typeof init == "undefined") {
    init = window;  // pass this window object by default
  }
  if (document.all) { // here we hope that Mozilla will never support document.all
    var value = window.showModalDialog(url, init, "dialogHeight:150px; dialogWidth:320px; resizable: no; help: no; status: no; scroll: no; center: yes; "); 
    if (action) {
      action(value);
    }
  } else {
    return openDialog._geckoOpenModal(url, action, init);
  }
};
openDialog._return = null;

openDialog._modal = null;

openDialog._arguments = null;

openDialog._geckoOpenModal = function(url, action, init) {
  var wnd =  window;
  var px = wnd.screenX + wnd.outerWidth;
  var py = wnd.screenY + wnd.outerHeight;
  var x = (px -320)/ 2;
  var y = (py-150) / 2;
  var dlg = window.open(url, "ha_dialog",
            "location=no,directories=no,dialog=yes,modal=yes,toolbar=no,menubar=no,personalbar=no, sidebar=no,width=320,height=150," +
            "scrollbars=no,resizable=no,status=no, outerWidth=320, outerHeight=150, left="+x+", top="+y);
  
  openDialog._modal = dlg;
  openDialog._arguments = init;

  function capwin(w) {
    w.addEventListener("click", openDialog._parentEvent, true);
    w.addEventListener("mousedown", openDialog._parentEvent, true);
    w.addEventListener("focus", openDialog._parentEvent, true);
  };

  function relwin(w) {
    w.removeEventListener("focus", openDialog._parentEvent, true);
    w.removeEventListener("mousedown", openDialog._parentEvent, true);
    w.removeEventListener("click", openDialog._parentEvent, true);
  };

  openDialog._return = function (val) {
    if ((val || val==0) && action) {
      action(val);
    }
    openDialog._modal = null;
  };
};

function sp2Detect(par){
  var mv=navigator.appMinorVersion;
  if(/sp2/i.test(mv)){
    return true;
  }else{
    return false;
  }
}

function validLink(temp){
  var str=temp;
  while(str.match(/http:([^\"]*?)\/preview/)!= null){
    str = str.replace(/http:([^\"]*?)\/preview/,".");
  }
  return str;
}

var winStl = null;
var winProp = null;

function doCloseWindowProp(){
  try{
    winStl.close();
  }catch(e){
  }
  try{
    winProp.close();
  }catch(e){
  }
}

function checkSymbol (value, symbol)
{
    var success = /[\';]/.test(value);
    return success;
}


function checkLengthofTextArea(obj,maxLength)
{
    var o;
  o=obj;

    if(o.value.length>maxLength)
  {
        o.value = o.value.substr(0, maxLength);
    }
    try{setSaveRequired(true);}catch(e){};
}


function doEncodeFields(arrayFields)
{
  var tempField = null;
  for(var i = 0; i < arrayFields.length; i++)
  {
    tempField = document.getElementsByName(arrayFields[i])[0];
    if(tempField) doEncodeField(tempField);
    tempField = null;
  }
}

function doEncodeField(field)
{
  var valueString = field.value;
  if(valueString == null) return false;
  field.value = doEncode(valueString);
}

function doEncode(str)
{
    if(str==null)
        return '';
    toRet = str;
  while(toRet.match(/</ig) != null){
        toRet = toRet.replace(/</ig,'&lt;');
    }
    while(toRet.match(/>/ig) != null){
        toRet = toRet.replace(/>/ig,'&gt;');
    }
    return toRet;
}


function checkImageExtension(inpFile)
{     
    if(    inpFile.value.substr(inpFile.value.length-4,4).toLowerCase()==".gif" 
        || inpFile.value.substr(inpFile.value.length-4,4).toLowerCase()==".png" 
        || inpFile.value.substr(inpFile.value.length-4,4).toLowerCase()==".jpg" 
        || inpFile.value.substr(inpFile.value.length-4,4).toLowerCase()==".bmp"
        || inpFile.value.substr(inpFile.value.length-5,5).toLowerCase()==".jpeg")
    {
        return true;
    }
    else
    {
        return false;
    }
}

function GridViewCheckAll(src,namePart){
  var ch=src.checked;
  var elt=document.getElementsByTagName("input");
  for(var i=0; i<elt.length; i++)
  {
    if(elt.item(i).type.toLowerCase()=='checkbox'  && elt.item(i).id.toLowerCase().indexOf(namePart.toLowerCase())>=0 && !elt.item(i).disabled) elt.item(i).checked=ch;
  }
}
function GridViewIsSelected(namePart){
  var elt=document.getElementsByTagName("input");
  for(var i=0; i<elt.length; i++)
  {
    if(elt.item(i).type.toLowerCase()=='checkbox'  && elt.item(i).id.toLowerCase().indexOf(namePart.toLowerCase())>=0 && !elt.item(i).disabled && elt.item(i).checked) {
        return true;
    }
  }
  return false;
}
function GridViewSelectedCount(namePart){
  var elt=document.getElementsByTagName("input");
  count = 0;
  for(var i=0; i<elt.length; i++)
  {
    if(elt.item(i).type.toLowerCase()=='checkbox'  && elt.item(i).id.toLowerCase().indexOf(namePart.toLowerCase())>=0 && elt.item(i).checked) count++;
  }
  return count;
}

function EnableInputTextElement(namePart, valueNew){
  var elt=document.getElementsByTagName("input");
  for(var i=0; i<elt.length; i++)
  {
    if(elt.item(i).type.toLowerCase()=='text'  && elt.item(i).id.toLowerCase().indexOf(namePart.toLowerCase())>=0) {
        elt.item(i).disabled = valueNew;
    }
  }
}

function GetDropDownListValue(namePart) {
  var elt=document.getElementsByTagName('select');
  for(var i=0; i<elt.length; i++)
  {
    if(elt.item(i).id.toLowerCase().indexOf(namePart.toLowerCase())>=0) {
        return elt.item(i).value;
    }
  }
  
  return '';
}

function resizeToAvailable() {
    window.moveTo(0,0); 
    
    if (is_ie) {
        window.resizeTo(screen.availWidth, screen.availHeight);
    } else {
        window.outerHeight = screen.availHeight; 
        window.outerWidth = screen.availWidth;
    } 
}

var ScrollPositionId = "";

function SetScrollPosition(height, width)
{
  try
  {
    var el = document.getElementById(ScrollPositionId);
    if(el)
    {
      el.value = height + "," + width;
    }
  }catch(e){}
}

function resizeDivContent()
{
    SetScrollPosition();
    var options = document.getElementsByName("inputResizeOption");
    for(var i = 0; i<options.length; i++)
    {   
        var mheight;
        var name = "";
        var height = 200;
        if(/,/.test(options[i].value))
        {
            var option = options[i].value.split(",");
            name = option[0];
            height = parseInt(option[1]);
        }
        var div = document.getElementById(name);
        if(div)
        {
            if (document.body.scrollHeight > document.body.clientHeight)
                mheight = parseInt(document.body.scrollHeight);
            else 
                mheight = parseInt(document.body.clientHeight);

            if (div.scrollHeight > (mheight-height))
            {
                div.style.height=(mheight-height);
                //SetScrollPosition((mheight-height), div.scrollWidth)
            }
            else
            {
                div.style.height = div.scrollHeight;
                //SetScrollPosition(div.scrollHeight, div.scrollWidth)
            }
            SetScrollPosition(document.body.scrollHeight, div.scrollWidth)
        }
    }
}

// This function calcultes best fit count on Wizard Design Step
// Arguments:
// sizeHiddenFieldId - id of hidden input containing comma-separated height and width
function DesignStep_CalculteBestFitCount(sizeHiddenFieldId, defaultCount)
{
    // Const
    var imagePreviewHeight = 140;
    var imagePreviewWidth = 140;
    
    // Prepare variables
    if(!defaultCount)
        defaultCount = 11;
    var result = defaultCount;
    
    // Count
    try{
        // To update size info
        resizeDivContent(); 
        
        var el = document.getElementById(sizeHiddenFieldId);
        var val = el.value;
        if (val){
            var temp = val.split(',');
            if (temp.length == 2){
                var count = defaultCount;
                var height = parseInt(temp[0]) - 190;
                var width = parseInt(temp[1]);
                var countX = Math.floor(width / imagePreviewWidth);
                var countY = Math.floor(height / imagePreviewHeight);
                var countAll = countX * countY;
                if ((countAll - 4) > 0) 
                    count = countAll - 4;
                result = Math.floor(count);
                
//                alert(   "height = " + height + "\n" 
//                        +"width = "+ width +"\n"
//                        +"countX = "+ countX +"\n"
//                        +"countY = "+ countY +"\n"
//                        +"countAll = " + countAll +"\n"
//                        +"RESULT = " + result
//                );
            }
        }
    }catch(ex)
    {
        // Do nothing
    }
    
    return result;
}



function checkUrl(url, errorMessage){
    if (url.replace(/^\s+|\s+$/g,'')=='') return true; 
    var v = new Validator();
    try {
        var res = v.verURL(url,3,false); 
        if (!res)SetErrorMessage(errorMessage,false);
        return res;
    }
    catch(e){}
}

function trimStr(str) {
  return(str.replace(/(^\s*)|(\s*$)/g, ""));
} 

function setElementVisibilty( elementID, isVisible, width )
{
  var el = document.getElementById( elementID );
  if ( is_ie )
    el.style.display = isVisible ? "block" : "none";
  else
    el.style.display = isVisible ? "inline" : "none";
    
  if (width){
	el.style.width = width;
	el.width = width;
  }
}


function AdminPanelCheckToResize() {
    
    if (is_ie) {
        window.attachEvent('onresize', checkAdminPanelSize);
        window.attachEvent('onload', checkAdminPanelSize);
    } 
    else {
        window.addEventListener('resize', checkAdminPanelSize, false);
        window.addEventListener('load', checkAdminPanelSize, false);
    }
}
function checkAdminPanelSize(){
    updateDivSize("DivLeftMenu",true);
    updateDivSize("DivAdminPanel",true);
}
function updateDivSize(id, changeWidth){
    
    
        var div = document.getElementById(id);
        var mheight, mwidth;
        if(div)
        { 
      if( is_opera || is_safari)
      {
        div.style.height = "100%";
        return;
      }

            var iWidth=parseInt(div.scrollWidth);
            var iHeight=parseInt(div.scrollHeight);
            div.style.height=10;
            if (changeWidth) div.style.width=10;

            if(document.all)
            {
                mheight = parseInt(div.parentNode.offsetHeight)-
                          parseInt(div.parentNode.currentStyle.paddingTop)-
                          parseInt(div.parentNode.currentStyle.paddingBottom);
                mwidth = parseInt(div.parentNode.offsetWidth)-
                          parseInt(div.parentNode.currentStyle.paddingLeft)-
                          parseInt(div.parentNode.currentStyle.paddingRight);
            }
            else
            {
                mheight = parseInt(div.parentNode.offsetHeight);
                mwidth = parseInt(div.parentNode.offsetWidth);
                var p=div.parentNode;
                while (true){
                    if (!isNaN(parseInt(p.style.paddingBottom))){
                        mheight-=parseInt(p.style.paddingBottom);
                    }
                    if (!isNaN(parseInt(p.style.paddingTop))){
                        mheight-=parseInt(p.style.paddingTop);
                    }
                    if (!isNaN(parseInt(p.style.paddingLeft))){
                        mwidth-=parseInt(p.style.paddingLeft);
                    }
                    if (!isNaN(parseInt(p.style.paddingRight))){
                        mwidth-=parseInt(p.style.paddingRight);
                    }
                    if (!isNaN(parseInt(p.cellPadding))){
                        mheight-=2* parseInt(p.cellPadding);
                        mwidth-=2* parseInt(p.cellPadding);
                    }
                    if(p=='[object HTMLTableElement]') break;
                    else p=p.parentNode;
                }
                
                          
            }
            if (iHeight> mheight)
            {
                div.style.height=mheight;
            }
            else
            {
                div.style.height = "100%";//div.scrollHeight;
            }
            
            if (changeWidth){
                //alert(div.scrollWidth);
                //alert(mwidth);
                if (iWidth> mwidth)
                {
                    div.style.width=mwidth;
                }
                else{
                    div.style.width="100%";
                }
                //alert(div.style.width);
            }
            
        }
}


function addEvent(obj, evType, fn){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}

function removeEvent(obj, evType, fn){
    if (obj.removeEventListener){
        obj.removeEventListener(evType, fn, false);
        return true;
    } else if (obj.detachEvent){
        var r = obj.detachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}


function showElelement(element, show)
{
	if (null==element) return;
	element.style.display = show ? "" : "none";
}

function enableElement(elem, enabled){
    if(elem) {
        elem.disabled=!enabled;
        if (!enabled){
            if (document.all) elem.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=40)";
            else elem.style.MozOpacity=0.4;
        }
        else{
            if (document.all) elem.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
            else elem.style.MozOpacity=1;
        }
    }
}


function SetContextHelp(ctl){
    if (!ctl) return;
    if (ctl.getAttribute && ctl.getAttribute("ContextHelp")) {
        //SetShortHelp defined in ~/Controls/LeftMenu.ascx
        if(typeof(SetShortHelp)=="function") {
            SetShortHelp(ctl.getAttribute("ContextHelp"));
        }
    } else {
        SetContextHelp(ctl.parentNode);
    }
}
function SetContextHelpOnBody(aEvent) {
    if (aEvent && aEvent.target) {
        elem = aEvent.target;
    } else if(window.event) {
        elem = window.event.srcElement;
    }           
    if(elem) {
        SetContextHelp(elem);
    }  
    
}


function adjustTabStripWidth(tabStrip){
        
    //Tabs should be in one line http://bugs.plesk.ru/show_bug.cgi?id=125484        
    var width = 0;
    
    for (var i=0; i<tabStrip.Tabs.length; i++) {
        var tabDomElement = tabStrip.Tabs[i].DomElement;
        width = width+tabDomElement.clientWidth;      
    }
    if(width!=0)
        tabStrip.DomElement.style.width = width + 5 + "px";
        
}


function RadTabStripFixTabWidth(tabStrip, fixInFF) {  
    if(fixInFF == null) {
        fixInFF = true;
    }
    
    function adjustTabStripWidth_IE(){
        adjustTabStripWidth(tabStrip);
    }
   
    if(is_ie)
        document.onreadystatechange=adjustTabStripWidth_IE;
    else if(fixInFF)
        adjustTabStripWidth(tabStrip);
    
   
    /*http://bugs.plesk.ru/show_bug.cgi?id=125484
    var maxWidth = 100;
    for (var i=0; i<tabStrip.Tabs.length; i++) {
        var tabCaption = tabStrip.Tabs[i].DomElement.firstChild.firstChild;
        if(is_ie || tabCaption.clientWidth !=0) {
            if (tabCaption.clientWidth <= maxWidth)  {
               tabCaption.style.width = maxWidth + "px";
            }
        }        
    } 
    */     
}    

function getEditorContent(editorId) {
    var editor = GetRadEditor(editorId);
    var content = editor.GetHtml(true);
    
    return content;
}

function isContentChanged(prevContentHiddenId, editorId){
    var prevContent = document.getElementById(prevContentHiddenId).value;
    var newContent = getEditorContent(editorId);
    return (newContent != prevContent);
}
  
  

function enterSubmit(ev, submitBtn) {

    try{
        if(ev.keyCode==13){
            var ctl = document.getElementById(submitBtn); 
            if(ctl) {
                ctl.focus();
            }
        }  
    } 
    catch(e){}
}

function onEnterPressed(ev, fun) {
    try{
        if(fun && ev.keyCode==13){
            if(typeof(fun) == 'function'){
                fun();
            }
        }  
    } 
    catch(e){}
}


//used for correct work for buttons with CausesValidation = false
//http://bugs.plesk.ru/show_bug.cgi?id=104891
//begin
var clickedElement = null;
var hookupExecuted = false;

function BodyMouseDown(event) {
    if(!hookupExecuted) {

        HookupControl(document.body);
        hookupExecuted = true;

    }
    if (!event) {
        event = window.event;
    }
    if(event) {
        //debugger
        clickedElement = document.all?event.srcElement:event.target;
       // alert(clickedElement.innerHTML);
    }
}
function ControlOnChange() {
   var i;
   if(typeof(ControlsNotCauseValidation) != 'undefined') {
      for (i = 0; i < ControlsNotCauseValidation.length; i++) 
          if (ElementContains(ControlsNotCauseValidation[i], clickedElement)) return false;
   }
   return true;
}



function ElementContains(ctl, el) {
    if(ctl) {
        if(el == ctl) return true;
        var i;
        for (i = 0; i < ctl.childNodes.length; i++) 
          if (ElementContains(ctl.childNodes[i], el)) return true;
  }
    return false;
    
}


function HookupControl(control) {

    if (typeof(Page_Validators)!= 'undefined') {
        if (typeof(control.tagName) == "string" && (control.tagName == "INPUT" || control.tagName == "TEXTAREA" ||control.tagName == "SELECT")) {  
                if (control.type == "radio") {
                    eventType = "onclick";
                } else {
                    eventType = "onchange";
                }
                //defined at system.web.dll webuivalidation.js
                //control.onchange = "if (!ControlOnChange()) return false; " + control.onchange;
                //control.onchange = "alert(1);";
                //alert(control.onchange);
                ValidatorHookupEvent(control, eventType, "if (!ControlOnChange()) {return false;} ");
                //alert(control.onchange);
        }
        
        var i;
        for (i = 0; i < control.childNodes.length; i++) {
            HookupControl(control.childNodes[i]);
        }
    }
    return;
}
//end

// png utility
function FixAllPngImages(id){
    var element = document.getElementById(id);
    var imgArr = element.getElementsByTagName("img");
    if(imgArr!=null && imgArr.length!=0){
        for(var i=0; i<imgArr.length; i++){
            if(typeof(imgArr[i].FixPng) == 'function'){
                imgArr[i].FixPng();
            }            
        }
    }
}

function OpenSitePreviewWindow(url, message) {
     var wPreview = window.open(url, "preview", "resizable=yes, tolbar=no, status=yes, scrollbars=yes");
     if (null == wPreview)
     {
        alert(message);
     }
     else
     {
        try
        {
            wPreview.moveTo(0, 0);
            wPreview.resizeTo(window.screen.availWidth, window.screen.availHeight);
            wPreview.focus();
        }
        catch(e){}
     } 
}

function OpenSitePreviewWindow1(url, message) {
    try
    {
        if (document.all)
        {
            height = screen.availHeight - 50;
            width = screen.availWidth - 10;
        }
        else
        {
            height = screen.availHeight;
            width = screen.availWidth;
        }
        var wPreview = window.open(url, "preview", "resizable=yes, tolbar=no, status=yes, scrollbars=yes, top=0, left=0,  height="+height+", width="+width);
        if (null == wPreview)
        {
            alert(message);
        }
        else
        {
            wPreview.focus();
        } 
    }
    catch(e){}
}

function SetViewsHeight(viewsId)
{
    var views = document.getElementById(viewsId);
    if (views)
    {
        var td = views.parentNode;
        views.style.height = (td.offsetHeight-2)+"px";
    }
}

// Temporary code is below: ==================================================================================

function ShowFotoliaPurchaseDialog(imageId){
    //5606796 // free picture
    var id = top.ModalBoxId;
    var width="485px";
    var height="562px";
    var args = null;
    top.SetArguments(id, args);
    top.SetHeightWidth(id, height, width);
    top.InitModalBoxControl(id, './EditPage/Fotolia/FotoliaPurchase.aspx?ImageId='+imageId);
}

function HideFotoliaPurchaseDialog(){
    HideModalBoxControl
    var id = top.ModalBoxId;
    top.CloseModalBox(id);
}

