<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function OnClientItemClickedHandler(sender, eventArgs) {
    var itemClicked = eventArgs.Item;
    if (itemClicked.ClientID == "ct100_RadPanelBar1_p1")
    {
        // Account menu has been clicked
        var state = itemClicked.Expanded;
        if (state == 'true') {
            itemClicked.Expanded = false;
        } else {
            itemClicked.Expanded = true;
        }
    }
}

function Client_Cancel(editor) {
    if(editor.ContentChanged()) {
        return confirm('Any changes will be lost. Do you want to discard changes?');
    } else {
        return true;
    }
 }
 
 // Copied from article on http://wwww.eggheadcafe.com/articles/20020107.asp by
 // Peter A. Bromberg, Ph.D (emailto:pbromberg@yahoo.com)
 function PageQuery(q) {
    if(q.length > 1) this.q = q.substring(1, q.length);
    else this.q = null;

    this.keyValuePairs = new Array();

    if(q) {
        for(var i=0; i < this.q.split("&").length; i++) {
        this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }
    this.getKeyValuePairs = function() { return this.keyValuePairs; }

    this.getValue = function(s) {
        for(var j=0; j < this.keyValuePairs.length; j++) {
            if(this.keyValuePairs[j].split("=")[0] == s)
                return this.keyValuePairs[j].split("=")[1];
        }
            return false;
    }

    this.getParameters = function() {
        var a = new Array(this.getLength());
        for(var j=0; j < this.keyValuePairs.length; j++) {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }
    
    this.getLength = function() { 
        return this.keyValuePairs.length; 
    } 
}

function queryString(key){
    var page = new PageQuery(window.location.search); 
    return unescape(page.getValue(key)); 
}

function displayItem(key){
    if(queryString(key)=='false') {
        document.write("you didn't enter a ?name=value querystring item.");
    } else {
        document.write(queryString(key));
    }
}

function ImageUpload(editor)
{
  var imageFileName = null;
  var imageFileTitle = null;
  var pathIndex = location.pathname.indexOf("/", 1);
  var webSiteRef = null;
  
  if (pathIndex > -1) {
    webSiteRef = "http://" + location.host + location.pathname.substring(0, pathIndex);
  } else {
    webSiteRef = "http://" + location.host;
  }

  function postback(doc,popup_iframe)
  {
    if(doc != null) // Upload clicked
    {
      if(doc.getElementById("path").value != "")
      {
        var frm = doc.getElementById("fraExecute");

        function onLoad()
        {
          setTimeout(function()
                    {
                     if(frm.detachEvent)
                        frm.detachEvent("onload", onLoad);
                     else
                     if(frm.removeEventListener)
                        frm.removeEventListener("load", onLoad, true);

                     imageFileName = frm.contentWindow.imageFileName;
                     imageFileTitle = frm.contentWindow.imageFileTitle;

                     if(imageFileName == null)
                        alert(frm.contentWindow.imageSaved);

                     popup_iframe.contentWindow.document.getElementById("cancel").onclick();  // emulate Cancel pressed
                    },0);
        }

        if(frm.attachEvent)
           frm.attachEvent("onload", onLoad);
        else
        if(frm.addEventListener)
           frm.addEventListener("load", onLoad, true);

        try{doc.getElementById("frmFile").submit();}
        catch(e)
        {
          alert(e.message);

          if(frm.detachEvent)
             frm.detachEvent("onload", onLoad);
          else
          if(frm.removeEventListener)
             frm.removeEventListener("load", onLoad, true);

         popup_iframe.contentWindow.document.getElementById("cancel").onclick();
        }
        return false;
      }
    }
    else  // Cancel clicked or emulated
    {
      if(imageFileName != null)
      {
        editor.focusEditor();
        editor.InsertHTML("<img src=\""+webSiteRef+"/admin/"+imageFileName+"\" alt=\""+imageFileTitle+"\" title=\""+imageFileTitle+"\" />");
      }
    }
  }

  function init(doc,popup_iframe)
  {
    if(doc != null)
    {
        doc.getElementById("title").value = "";
        if(document.all)
        {
          popup_iframe.style.display = "none";
          doc.getElementById("path").click();
          popup_iframe.style.display = "";
          if(doc.getElementById("path").value == "")
            popup_iframe.contentWindow.document.getElementById("cancel").onclick();
        }
    }
  }

  editor.customPopup("popup_image_upload","image-upload","ImageUpload.aspx",postback,init, false, false);
}

function myOnClick(ev,src,mWidth,mHeight,title,isDouble)
{
  var el;
  if(document.all)
  {
    ev = window.event;
    el = ev.srcElement;
  }
  else
  {
    el = ev.target;
  }
  while(el && (!el.tagName || el.tagName.toUpperCase() != "TD"))
        el=el.parentNode;

//
// Important. Change the Image URL in parent window.
//--------------------------------------------------------
  try
  {
    parent.document.getElementById("selectedSrc").value=src;
    parent.document.getElementById("selectedWidth").value=mWidth;
    parent.document.getElementById("selectedHeight").value=mHeight;
    parent.document.getElementById("selectedAltText").value=title;
  }
  catch(e){}
//--------------------------------------------------------

  document.getElementById("previewFrameText").src = window.location.href+"&imgprop="+el.firstChild.getAttribute("myAttrRel");
  document.getElementById("previewFrame").src = window.location.href+"&imgsrc="+el.firstChild.getAttribute("myAttrRel");
  document.getElementById("previewFrameTitle").src = window.location.href+"&imgtitle="+el.firstChild.getAttribute("myAttrRel");

  if(isDouble)
  {
    // Raise parent's "ok" button click event
    //---------------------------------------
    parent.document.getElementById("ok").onclick();
  }
  else
    ob_t25(el);
  return false;
}

var collapsedId = null;

function ob_OnNodeSelect(id)
{
 if(collapsedId && (collapsedId == id))
 {
   ob_prev_selected.className = "ob_t2";
   document.getElementById("previewFrame").src = "";
   document.getElementById("previewFrameText").src = "";
   document.getElementById("previewFrameTitle").src = "";
   parent.document.getElementById("selectedSrc").value="";
 }
 collapsedId = null;
}

function ob_OnNodeCollapse(id)
{
 collapsedId = id;
}

//----------------------------------------------------------------------
function ob_getChildAt (ob_od, index, expand)
{
        try
        {
                if (ob_od != null && ob_hasChildren(ob_od) && index >= 0)
                {
                        if (!ob_isExpanded(ob_od) && expand) 
                        try
                        {
                                ob_od.parentNode.firstChild.firstChild.onclick();
                        } catch (e) {}
                        return ob_od.parentNode.parentNode.parentNode.parentNode.firstChild.nextSibling.firstChild.firstChild.firstChild.nextSibling.childNodes[index].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling;
                }
        }
        catch (e)
        {
        }

        return null;
}

if(typeof ob_t25 != "function")
  var ob_t25 = function(ob_od) 
  {                    
          // When tree is first loaded - Highlight and Extend selected node.
          if(ob_od==null) {
                  return
          };
          var e, lensrc, s;
          e = ob_od.parentNode.firstChild.firstChild;
          if ((typeof e.src != "undefined") && (e.tagName == "IMG")) {
                  s = e.src.substr((e.src.length - 8), 8);                
                  if ((s == "usik.gif") || (s == "ik_l.gif")) {
                          e.onclick();
                  }
          }
          ob_t22(ob_od);
  }


// End -->