/*---------------------------------------------------*/
/* NeoCMS Core File : js_general.js                  */
/*                                                   */
/* These are general functions                       */
/*                                                   */
/*---------------------------------------------------*/

function action_confirm(question,targeturl) {
// This function asks the user a question and
// if they click OK they directed to targeturl
  if (confirm(question)) {
    document.location = targeturl;
  }
//Usage
//<a href=\"javascript:action_confirm('Are you sure you wish to do that?','test.php');\" title=\"Delete Confirmation\">  
}

function checkAllold(checkname, flag) {
// This function checks or unchecks all the checkboxes named 'checkname'
// flag = 1 checked
// flag = 0 unchecked
  for (i = 0; i < checkname.length; i++) {
    if (flag==1) {
    checkname[i].checked = true;
    } else {
    checkname[i].checked = false;    
    }
  }
}

function checkAll(myForm,mycheckbox,myflag) {
    var theForm = myForm;
    for (i=0; i<theForm.elements.length; i++) {
        if (theForm.elements[i].name==mycheckbox)
            theForm.elements[i].checked = myflag;
    }
}

function externalLinks() {
/* This function allows certain links to open in a   */
/* new window. Those links have a rel attribute set  */
/* to "external".                                    */
if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "tag external")
     anchor.target = "_blank";
  }
}
window.onload = externalLinks;
