﻿/********* MISC *****/

function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}

function Right(str, n)
{
      if (n <= 0)
          return "";
      else if (n > String(str).length)
          return str;
      else
   {
          var iLen = String(str).length;
          return String(str).substring(iLen, iLen - n);
      }
}
 

function MenuGoto(menuNum){
    //document.getElementById("homeContent").style.background = 'url(images/dunbar_topbar.jpg) no-repeat top left';
    location.href = "Default.aspx?page=" + menuNum;
    
    
}

function SwapMenuImage(obj, doWhat, img){

    if (doWhat == 'in') {
        obj.style.background = 'transparent url(image/' + img + ')';
       // obj.style.backgound = '#ffffff';

    } else {
        obj.style.background = 'transparent url(image/' + img + ')';

    }
}


/***************************/

//Search
/***************************/


function SimpleSearch(){
    
    var sText = document.getElementById("search_box").value;
    //alert(sText);
    location.href = "default.aspx?page=5&txtSearch=" + sText;
}

function CheckMe(){
    
    
    if (document.getElementById("Checkbox1").checked){
        Select(true, 'CBLListNPs');
    }
    else {
     Select(false, 'CBLListNPs');
    }
}
 function CheckDT(){
    
    // sort this please!
    if (document.getElementById("Checkbox2").checked){
        Select(true, 'CBListDocType');
    }
    else {
        Select(false, 'CBListDocType');
    }
 
}

function Select(Select, who){
    //alert(who);
    //var temp = 'document.getElementById("' + who + '").ID';
    //alert(temp);
    //alert(eval(temp));
    for (var n=0; n < document.forms[0].length; n++) 
        if (document.forms[0].elements[n].type=='checkbox')
            if (Left(document.forms[0].elements[n].name,10) == Left(who, 10))
                document.forms[0].elements[n].checked=Select; 
    return false;
}



