function confirmDelete(datatype)
{
    return confirm("Are you sure you wish to delete this " + datatype + "?");
}

function confirmRemove(datatype)
{
    return confirm("Are you sure you wish to remove this " + datatype + " from this section?");
}

function sort(field, order)
{
    document.frmSort.orderby_field.value = field;
    document.frmSort.orderby_direction.value = order;
    document.frmSort.submit();
}

function moveRow(id, direction) {
    //document.frmPersist.action = document.frmPersist.action+'#placeholder_'+id;
    document.frmPersist.id.value = id;
    document.frmPersist.mode.value = 'move_'+ direction;
    document.frmPersist.submit();
}

function jumpToPage( daPage, searchTerm, srvUri ) {

    target = srvUri + "?current_page=" + daPage
    if ( searchTerm != "" ) {
        target = target + "&amp;search_terms=" + searchTerm
    }
    target = target + "&amp;mode=results"

    window.location.href = target;
}

function goto_select_url( object, new_win )
{
    targ = object.options[object.selectedIndex].getAttribute('target');

    if ( targ == ""  )
    {
        window.location.href = object.options[object.selectedIndex].value;
    }
    else
    {
        newWindow = window.open('', targ, '')
        newWindow.location.href = object.options[object.selectedIndex].value;
        newWindow.focus();
    }
}

/*
nifty javascript corners from http://www.html.it/articoli/nifty/index.html
*/

function NiftyCheck()
{
    if(!document.getElementById || !document.createElement)
        return(false);
    var b=navigator.userAgent.toLowerCase();
    if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
        return(false);
    return(true);
}

function Rounded(selector,bk,color,size){
    var i;
    var v=getElementsBySelector(selector);
    var l=v.length;
    for(i=0;i<l;i++){
        AddTop(v[i],bk,color,size);
        AddBottom(v[i],bk,color,size);
        }
}

function RoundedTop(selector,bk,color,size){
    var i;
    var v=getElementsBySelector(selector);
    for(i=0;i<v.length;i++)
        AddTop(v[i],bk,color,size);
}

function RoundedBottom(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className==selclass){
        objlist.push(v[i]);
        }
    }
return(objlist);
}


