yajax.handleComplaint=function(prob,spec) {
    var id=yajax.currentElement2
    var msg
    if(!id) id=yajax.currentElement1
    
    eval(yajax.shareCode['complaint'])
    if(msg) {
        /*document.getElementById('msg').innerHTML=msg*/
        alert(msg)
    }
    else debug('id,prob,spec',id,prob,spec)
}

function del(a) {
    var id=yajax.escapeYJID(a)
    var e=document.getElementById(id)
    e.parentNode.removeChild(e)
}


function modBasket(e_id,value,price) {
    var id=yajax.escapeYJID(Array('ext',e_id));
    var e=document.getElementById(id);
    e.firstChild.data=(price*value/100.0).toFixed(2)
}

function show_page(url) {
    return(core.popup(url,'',
        { 'width':600,'height':400,'menubar':1,'toolbar':1,
           'status':1,'scrollbars':1,'resizable':1}))
}

function popup(mylink)
{
    return(core.popup(mylink,'',
        { 'width':740,'height':755,'scrollbars':'yes','resizable':1,
        'left':100,'top':60}))
}

yajax.userEvent=function(ev,ev2) {
    target=ev2.target
    if(target.className=='more') {
        var href=target.href+'&pop=1';
		return popup(href)
    }
    else if(target.className=='edit') {
        var href=target.href
		return show_page(href)
    }

}

function login_redirect(ref) {
    if(ref) setTimeout("window.location.href='"+ref+"'",500);
}

/* calendar stuff */
function setHoliday(yajax,field,input) {
    if(isNaN(field)) return
    if(scwTestHoliday(field)) color='red';
    else color='black';
    var control=yajax.getElement([input])
    control.style.color=color
}

function zfill(str,l) {
    if(str.length>=l) return str;
    l=l-str.length
    var zs=''
    while(l>0) {
        zs=zs+'0';
        l=l-1
    }
    return zs+str
}

function copyValue(yajax,infield,outfield,pkey) {
    var el1=document.getElementById(
        yajax.escapeYJID([infield,pkey],'d'))
    var el2=document.getElementById(
        yajax.escapeYJID([outfield,pkey],'d'))
    el2.value=el1.value
}

function cmpDates(dt1,dt2) {
    if(isNaN(dt1)&&isNaN(dt2)) return true;
    if(isNaN(dt1)) return false;
    if(isNaN(dt2)) return false;
    return(dt1.toDateString==dt2.toDateString);
}

function updateTimes(yajax) {
    var outDate=yajax.getField('out')
    var backDate=yajax.getField('back')
    outDate=scwParseDate(outDate)
    backDate=scwParseDate(backDate)

    var err=null
    var today=new Date()
    var backLabel=document.getElementById('backlabel')
    var outLabel=document.getElementById('outlabel')
    outLabel.style.color='black'
    backLabel.style.color='black'

    setHoliday(yajax,outDate,'out')
    setHoliday(yajax,backDate,'back')

    if(!outDate||!backDate) {
        return
    }

    if(!(outDate<=backDate)) {
        throw new YajaxCheckException('date','daterange')
    }
}
/* end of calendar stuff */


yajax.complainWaiting=function() {
    return confirm('The server is having trouble catching up.  Do you wish to leave this page, even though you may \
lose your most recent changes?');
}
// end of funcs

if(yajax.app=='cart/printable'&&yajax.readParam('print')) {
    window.print()
}

