// Browser Detection
var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
var NS4 = (document.layers) ? true : false;
var IEmac = ((document.all)&&(isMac)) ? true : false;
var IE4plus = (document.all) ? true : false;
var IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
var IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
var ver4 = (NS4 || IE4plus) ? true : false;
var NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

function ysWindow(theURL,winName) {
	window.open(theURL,winName,'toolbar=yes,location=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=710,height=650');
}

function ys_getFileRelativePath(filePath, pattern) {

  filePath = filePath.substring(filePath.indexOf(pattern) + pattern.length);

  return filePath;

}

function ys_getJsElement(id){
  var obj;
  if(IE4){
    obj = document.all.item(id);
  }
  else {
    obj = document.getElementById(id);
  }
  return obj;
}

function ys_setJsDivVisible(id, visible){

  if(visible == true){

    if(NS6){
      ys_getJsElement(id).style.display = "";
      ys_getJsElement(id).style.visibility = "visible";
    }
    else {
      ys_getJsElement(id).style.display = "";
    }

  }
  else {

    if(NS6){
      ys_getJsElement(id).style.display = "none";
      ys_getJsElement(id).style.visibility = "hidden";
    }
    else {
      ys_getJsElement(id).style.display = "none";
    }
  }

}

function ys_isJsDivVisible(id){
  var visible;
  if(NS6){
    visible = ys_getJsElement(id).style.visibility == "visible";
  }
  else {
    visible = ys_getJsElement(id).style.display != "none";
  }
  return visible;
}

function ys_setFileManagerValues(field, path){
  if (!opener.closed){
    ys_insertFile(field, path);
    opener.focus();
    window.close();
  }
  else {
     alert("Your image could not be inserted because the editing window has been closed.");
  }
}

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
        if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
        {
                window.onload = SafeOnload;
                gSafeOnload[gSafeOnload.length] = f;
        }
        else if  (window.onload)
        {
                if (window.onload != SafeOnload)
                {
                        gSafeOnload[0] = window.onload;
                        window.onload = SafeOnload;
                }
                gSafeOnload[gSafeOnload.length] = f;
        }
        else
                window.onload = f;
}
function SafeOnload()
{
        for (var i=0;i<gSafeOnload.length;i++)
                gSafeOnload[i]();
}
function ys_toggledisabled(id){
  if (ys_getJsElement(id).disabled == true) {
   ys_getJsElement(id).disabled = false;
  } else {
   ys_getJsElement(id).disabled = true;
  }
  return false;
}
function ys_togglestyle(id){
  if (ys_getJsElement(id).style.display == "none") {
   ys_getJsElement(id).style.display = "";
  } else {
   ys_getJsElement(id).style.display = "none";
  }
  return false;
}
function ys_setclass(id,newClass)
{
  ys_getJsElement(id).className = newClass;
  return false;
}

/*
  ------------------------------------
  PVII Menu CSS Express Drop-Down Menu
  by Project Seven Development
  www.projectseven.com
  ------------------------------------
*/
function DropdownNav_ExpMenu(){ //v1.1.0.2 by PVII-www.projectseven.com
 if(navigator.appVersion.indexOf("MSIE")==-1){return;}
 var i,k,g,lg,r=/\s*dropdownnavhvr/,nn='',c,cs='dropdownnavhvr',bv='dropdownnav';
 for(i=0;i<10;i++){g=document.getElementById(bv+nn);if(g){
 lg=g.getElementsByTagName("LI");if(lg){for(k=0;k<lg.length;k++){
 lg[k].onmouseover=function(){c=this.className;cl=(c)?c+' '+cs:cs;
 this.className=cl;};lg[k].onmouseout=function(){c=this.className;
 this.className=(c)?c.replace(r,''):'';};}}}nn=i+1;}
}
