// remove or alter the following if-statement before use
if(location.hostname!='www.kallery.net' && location.hostname!='kallery.net')
    window.alert('js_validation.js is requested outside of kallery.net');

// browser detection
var lyr = document.layers         ? true:false; // nn4
var all = document.all            ? true:false; // ie4
var dom = document.getElementById ? true:false; // dom
var brwsr_opr = navigator.userAgent.indexOf("Opera")==-1 ? false:true; // opera
var ie_no_opr = (all && !brwsr_opr);
var ie_offst_h_xtr = all ? 15 : 0;

// functions
function Q_pstn(hrzntl,vrtcl) {
    this.x = hrzntl;
    this.y = vrtcl;
}
function Q_get_dcmnt_objct() {
    return (document.compatMode!="BackCompat") ? document.documentElement :
                                                 document.body;
}
function Q_get_cntnt_dmnsn() {
    var dmnsn = new Q_pstn();
    dmnsn.x = ie_no_opr ? Q_get_dcmnt_objct().clientWidth+ie_offst_h_xtr:
                          window.innerWidth+ie_offst_h_xtr;
    dmnsn.y = ie_no_opr ? Q_get_dcmnt_objct().clientHeight:
                          window.innerHeight;
    if(all||dom) {
        dmnsn.x = parseInt(dmnsn.x);
        dmnsn.y = parseInt(dmnsn.y);
    }
    return dmnsn;
}
function Q_get_scrll_dmnsn() {
    var dmnsn = new Q_pstn();
    dmnsn.x = all ? Q_get_dcmnt_objct().scrollLeft : pageXOffset;
    dmnsn.y = all ? Q_get_dcmnt_objct().scrollTop  : pageYOffset;
    if(all||dom) {
        dmnsn.x = parseInt(dmnsn.x);
        dmnsn.y = parseInt(dmnsn.y);
    }
    return dmnsn;
}

function Q_get_evnt_pstn(e) {
    var evnt_pstn = new Q_pstn();
    if(all) {
        evnt_pstn.x = event.clientX+document.body.scrollLeft;
        evnt_pstn.y = event.clientY+document.body.scrollTop ;
    } else {
        evnt_pstn.x = e.pageX;
        evnt_pstn.y = e.pageY;
    }
    return evnt_pstn;
}
function Q_get_objct(id) {
    var objct;
    if(lyr) eval("objct = document."+id+";");
    if(all) eval("objct = document.all."+id+";");
    if(dom) eval("objct = document.getElementById('"+id+"');");
    return objct;
}

function Q_get_lft(objct) {
    if(lyr) return objct.left;
    if(dom) return parseInt(objct.style.left);
    if(all) return objct.style.pixelLeft;
}
function Q_get_top(objct) {
    if(lyr) return objct.top;
    if(dom) return parseInt(objct.style.top);
    if(all) return objct.style.pixelTop;
}
function Q_get_wdth(objct) {
    if(lyr) return objct.width;
    if(dom) return parseInt(objct.style.width);
    if(all) return objct.style.pixelWidth;
}
function Q_get_hght(objct) {
    if(lyr) return objct.height;
    if(dom) return parseInt(objct.style.height);
    if(all) return objct.style.pixelHeight;
}
function Q_get_hght_cntnt(objct) {
    if(lyr) return objct.clip.bottom;
    if(dom) return parseInt(objct.offsetHeight);
    if(all) return objct.scrollHeight;
}

function Q_get_hght_clp(objct) {
    if(lyr) return objct.clip.bottom;
    if(dom) return parseInt(objct.offsetHeight);
    if(all) return objct.style.height;
}

function Q_set_lft(objct,value) {
    if(lyr)   objct.left = value;
    if(all) { objct.style.left = value+"px"; return false; }
    if(dom)   objct.style.left = value+"px";
}
function Q_set_top(objct,value) {
    if(lyr)   objct.top = value;
    if(all) { objct.style.top = value+"px"; return false; }
    if(dom)   objct.style.top = value+"px";
}
function Q_set_wdth(objct,value) {
    if(lyr) objct.width = value;
    if(all) objct.style.pixelWidth = value;
    if(dom) objct.style.width = value+"px";
}
function Q_set_hght(objct,value) {
    if(lyr) objct.height = value;
    if(all) objct.style.pixelHeight = value;
    if(dom) objct.style.height = value+"px";
}
function Q_set_visible(objct) {
    if(lyr) objct.visibility = 'show';
    if(all) objct.style.visibility = 'visible';
    if(dom) objct.style.visibility = 'visible';
}
function Q_set_hidden(objct) {
    if(lyr) objct.visibility = 'hide';
    if(all) objct.style.visibility = 'hidden';
    if(dom) objct.style.visibility = 'hidden';
}

function Q_is_ovr_objct(objct,pstn) {
    var lft_objct  = Q_get_lft(objct) ;
    var top_objct  = Q_get_top(objct) ;
    var wdth_objct = Q_get_wdth(objct);
    var hght_objct = Q_get_hght(objct);
    if(    lft_objct < pstn.x && pstn.x  < (lft_objct+wdth_objct)
        && top_objct < pstn.y && pstn.y  < (top_objct+hght_objct) ) return true;
    else return false;
}
function Q_reload_pg() { window.location.reload(); }
