function popitup(theURL,winName,features) { //Quirksmode.org
  newwindow=window.open(theURL,winName,features);
  if(window.focus){newwindow.focus()}
  return false;

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);

}

function hello(){
    alert("hello");
}

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                  ? document.forms[the_form].elements['selected_db[]']
                  : document.forms[the_form].elements['selected_tbl[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function


function checkstr(passedVal){
        if(passedVal ==""){
          return false
        }
        return true
}


function isSelected(passedVal){
        if(passedVal ==""){//"choose one" has no val associated with it!
              return false
        }
        return true
}

function isEmpty(passedVal){
   //if(passedVal =="0"){//"choose one" has no val associated with it. Well maybe it has!!!
           if (!isNum(passedVal)){
              return false
        }
        return true
}


function isNum(passedVal){
        if(passedVal== ""){
          return false
        }
        for (i=0; i<passedVal.length; i++){
          if (passedVal.charAt(i) < "0") {
                return false
          }
          if (passedVal.charAt(i) > "9") {
                return false
          }
        }
        return true
}


function toggleMenu(szDivID) // 1 visible, 0 hidden
{
  //changed to this type of script so it works with othe browsers.
  //use display rather than visibility as IE doesnt shrink the space with visibility
  //based on script by from  Manish Hatwalne  http://www.geocities.com/technofundo/tech/js/showhide.html
  //added the toggle states 150304 so this works with mozila and opera

 //found this doesnt work for ie5.5. 210504. This was due to not having the return statements in
 //which caused the page to reload

    if(document.layers)           //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
       document.layers[szDivID+"a"].visibility != iState ? "show" : "hide";
       return false
    }
    else if(document.getElementById)          //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        //if(obj.style.display =="block")iState = 1;
        //else iState = 0;
        iState = 0;
        obj.style.display = iState ? "none" : "block";
        var obj = document.getElementById(szDivID+"a");
        obj.style.display = iState ?  "block" : "none" ;

       return false
    }
    else if(document.all)        // IE 4
    {
        document.all[szDivID].style.display = "block" ? "none" : "block";
        document.all[szDivID+"a"].style.display = "block" ?  "block" : "none" ;
        return false
    }
    else
    return true
}


function paste_address(form){
 //paste the address results into form
var l_rpsgb = document.getElementById('val_urn');
var l_address1 = document.getElementById('val_address1');
var l_address2 = document.getElementById('val_address2');
var l_address3 = document.getElementById('val_address3');
var l_address4 = document.getElementById('val_address4');
var l_address5 = document.getElementById('val_address5');
//var l_address5 = document.getElementById('label_address5');
var l_postTown = document.getElementById('val_postTown');
var l_postCounty = document.getElementById('val_postCounty');
var l_postCode = document.getElementById('val_postCode');

//var l_address1 = l_address.value;


form.rpsgb.value = l_rpsgb.innerText;
form.address1.value = l_address1.innerText;
form.address2.value = l_address2.innerText;
form.address3.value = l_address3.innerText;
form.address4.value = l_address4.innerText;
//form.address5.value = l_address5.innerText;
form.postTown.value = l_postTown.innerText;
form.postCounty.value = l_postCounty.innerText;
//form.postCode.value = l_postCode.innerText;



}





