﻿var j$ = jQuery;
//bool conversion method
var $bool = function (test) {
    if (test == null) { return false; }
    if (test == String.empty) { return false; }
    test = test.toString().toLowerCase();
    switch (test) {
        case 'yes':
            return true;
            break;
        case 'no':
            return false;
            break;
        case '1':
            return true;
            break;
        case '0':
            return false;
            break;
        case 'true':
            return true;
            break;
        case 'false':
            return false;
            break;
        case 'on':
            return true;
            break;
        case 'off':
            return false;
            break;
        default:
            throw ('Not able to convert to Boolean');
            break;
    }

}



//element creaters
var $element = function (el) {
    return document.createElement(el);
}
var $attrib = function (a) {
    return document.createAttribute(a);
}
var $CDATA = function (d) {
    return document.createCDATASection(d);
}
var $comment = function (c) {
    return document.createComment(c);
}
var $fragment = function () {
    return document.createDocumentFragment();
}
var $entityReference = function (r) {
    return document.createEntityReference(r);
}
var $processingInstruction = function (target, data) {
    return document.createProcessingInstruction(target, data);
}
var $text = function (t) {
    return document.createTextNode(t);
}
//remove child nodes from container
var $removeChildren = function (el) {
    if (el.hasChildNodes()) {
        var nodes = el.childNodes;
        for (var i = 0; i < nodes.length; i++) {
            nodes[i].parentNode.removeChild(nodes[i]);
        }
    }
}
//creates url date for appending to the end of urls to avoid caching problems
var $urldate = function () {
    var dt = new Date();
    dt = dt.getTime();
    return dt;
}
//short hand convertors
var $int = parseInt;
var $flt = parseFloat;
var $date = Date.parse;
//test for int
var $isInt = function (i) {
    var result = true;
    if (isNaN($int(i))) {
        result = false;
    }
    return result;
}
//short hand dom
var $id = function (name) {
    return document.getElementById(name);
}
//short hand dom
var $name = function (name) {
    if (document.getElementsByName) {
        return document.getElementsByName(name);
    }
    else {
        return null;
    }
}
//short hand dom
var $tags = function (name) {
    if (document.documentElement) {
        return document.documentElement.getElementsByTagName(name);
    }
    else {
        return document.getElementsByTagName(name);
    }

}
//string methods 
//assign empty string 
String.empty = '';
String.Empty = '';
//right trim
String.prototype.rtrim = function () {
    var str = new String();
    str = this;
    return str.replace(/\s$/, '');
}
//left trim 
String.prototype.ltrim = function () {
    var str = new String();
    str = this;
    return str.replace(/^\s/, '');
}
//both trim 
String.prototype.trim = function () {
    var str = new String();
    str = this;
    return str.rtrim().ltrim();
}
//format currency string american only
String.prototype.toCurrency = function () {
    var hasDecimal = false;
    var alpha = new XRegExp('[^0-9\.]', 'g');
    var str = this;

    str = str.replace(alpha, '');
    hasDecimal = str.indexOf('.') > -1 ? true : false;
    var ary = null;
    if (hasDecimal) {
        ary = str.split('.');
        var dec = $.trim(ary[1]);
        if (dec.length > 2) {
            if (parseInt(dec.substr(2, 1)) > 5) {
                ary[1] = dec.substr(0, 1).toString() + (parseInt(dec.substr(1, 1)) + 1).toString();
                str = ary[0] + '.' + ary[1];
            }
            else if (parseInt(dec.substr(2, 1)) < 5) {
                ary[1] = dec.substr(0, 1).toString() + dec.substr(1, 1);
                str = ary[0] + '.' + ary[1];
            }
        }
        else if (dec.length == 1) {
            ary[1] = dec + '0';
            str = ary[0] + '.' + ary[1];
        }
    }
    else {
        str = str + '.00';
    }
    return '$' + str;
}
//Calitalize the first letter of every word.
String.prototype.capitalize = function () { //v1.0
    return this.replace(/\w+/g, function (a) {
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};

//remove first n characters
String.prototype.removefirst = function (howmany) {
    var str = this;
    var l = this.length;
    howmany = howmany > l ? l : howmany;
    str = str.substring(howmany, l);
    return str;
}
//remove last n characters
String.prototype.removelast = function (howmany) {
    var str = this;
    var l = this.length;
    howmany = howmany > l ? l : howmany;
    howmany = l - howmany;
    str = str.substring(0, howmany);
    return str;
}
//bool ends with
String.prototype.endswith = function (s) {
    var pattern = new RegExp("\w*" + s + "$", "i");
    if (pattern.test(this)) {
        return true;
    }
    else {
        return false;
    }
}
//bool starts with
String.prototype.startswith = function (s) {
    var pattern = new RegExp('^' + s + '\w*', 'i');
    if (pattern.test(this)) {
        return true;
    }
    else {
        return false;
    }
}
//replace all occurrences of excepts string and regex
String.prototype.replaceall = function (pattern, replacement) {
    var str = this;
    while (str.indexOf(pattern) > -1) {
        str = str.replace(pattern, replacement);
    }
    return str;
}
//works like .NET string.format
String.format = function (str) {
    var length = arguments.length;
    var target = new String();
    target = arguments[0];

    for (var i = 1; i < length; i++) {
        var j = i - 1;
        var val = "{" + j + "}";
        target = target.replaceall(val, arguments[i].toString());
    }
    return target;
}
//works like .NET string.format except from string obj
//like 'replacevalue{0} now next value {1}'.format('firstvalue',secondvalue');
String.prototype.format = function () {
    var length = arguments.length;
    var target = new String();
    target = this;

    for (var i = 0; i < length; i++) {
        var j = i;
        var val = "{" + j + "}";
        target = target.replaceall(val, arguments[i].toString());
    }
    return target;
}
//string concatenation 
String.concat = function () {
    var str = new String();
    for (var i = 0; i < arguments.length; i++) {
        str += arguments[i].toString();
    }
    return str;
}


//FOREACH METHOD *STILL IN DEVELOPMENT*
var foreach = function (object, callback, args) {
    var name, i = 0, length = object.length;

    if (args) {
        if (length === undefined) {
            for (name in object)
                if (callback.apply(object[name], args) === false)
                    break;
        } else
            for (; i < length; )
                if (callback.apply(object[i++], args) === false)
                    break;

        // A special, fast, case for the most common use of each
    } else {
        if (length === undefined) {
            for (name in object)
                if (callback.call(object[name], name, object[name]) === false)
                    break;
        } else
            for (var value = object[0];
					i < length && callback.call(value, i, value) !== false; value = object[++i]) { }
    }

    return object;
}

//*Utility area
var JK = {};
JK.Validate = {};
JK.Validate = {
    isUrl: function (url) {

        //http://www.foodxchange.com/images/something.jif

        //var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
        //var regexp = /(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
        //var regexp = /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/
        var regexp = /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}[.]*$/

        return regexp.test(url);
    }
};
JK.Util = {};
//returns query string as object with named values
JK.Util = {
    qs: function () {//return query string as object
        var query = window.location.search.substring(1);
        var qsParm = new Object;
        var parms = query.split('&');
        for (var i = 0; i < parms.length; i++) {
            var pos = parms[i].indexOf('=');
            if (pos > 0) {
                var key = parms[i].substring(0, pos);
                var val = parms[i].substring(pos + 1);
                qsParm[key] = val;
            }
        }

        return qsParm;

    },
    //query string to array of name value pairs
    qsToQsObject: function () {
        var query = window.location.search.substring(1);
        var qsParm = new Object;
        var parms = query.split('&');
        var ary = [];
        for (var i = 0; i < parms.length; i++) {
            var pos = parms[i].indexOf('=');
            if (pos > 0) {
                var parm = parms[i].split('=');
                var key = parm[0];
                var val = parm[1];
                qsParm[key] = val;
            }
        }

        return qsParm;

    },
    //search for elements by class
    getElementsByClass: function (searchClass, node, tag) {
        var classElements = new Array();

        node = node ? node : document;
        tag = tag ? tag : '*';

        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
            if (pattern.test(els[i].className)) {
                classElements[j] = els[i];
                j++;
            }
        }
        return classElements;
    }
};
//document.getElementsByClass = JK.Util.getElementsByClass;
//working with data
JK.Data = {};
// same as array find
JK.Data = {
    //objarray is an array of data rows,field is the column to look for, value is the sought value for that column,
    //exact is true false for an exact or contains match. returns the first row that matches
    Find: function (objary, field, value, exact) {
        var pattern = null;
        var length = objary.length;
        for (var i = 0; i < length; i++) {
            if (exact) {
                pattern = new RegExp("^" + value + "$", "i");
                if (pattern.test(objary[i][field])) {
                    return objary[i];
                }
            }
            else {
                pattern = new RegExp(value, "i");
                if (objary[i][field].search(pattern) > -1) {
                    return objary[i];
                }
            }
        }
    },
    // same as array find
    //objarray is an array of data rows,field is the column to look for, value is the sought value for that column,
    //exact is true false for an exact or contains match. an array of rows that can be nested again to refine search
    FindMore: function (objary, field, value, exact) {
        var pattern = null;
        var length = objary.length;
        var outputarray = new Array();
        for (var i = 0; i < length; i++) {
            if (exact) {
                pattern = new RegExp("^" + value + "$", "i");
                if (pattern.test(objary[i][field])) {
                    outputarray.push(objary[i]);
                }
            }
            else {
                pattern = new RegExp(value, "i");
                if (objary[i][field].search(pattern) > -1) {
                    outputarray.push(objary[i]);
                }
            }
        }
        return outputarray;
    }
}

//back to utilities
//pad string function 
JK.Util.padleft = function (str, chr, howmany) {
    str = String(str);
    chr = String(chr);
    if (str.length < howmany) {
        var count = howmany - str.length;
        for (var i = 0; i < count; i++) {
            str = chr + str;
        }
    }
    return str;
}
//cookie methods 
JK.Util.Cookies = {};
JK.Util.Cookies = {
    setCookie: function (name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    },
    getCookie: function (name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return '';
    },
    deleteCookie: function (name) {
        JK.Util.Cookies.setCookie(name, "", -1);
    }
}
//dom manipulation methods
JK.Dom = {};
JK.Dom = {
    //insert element after this element as sibling
    insertAfter: function (referenceNode, newNode) {
        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
    },
    //get object of style settings for this element
    getStyle: function (elem, name) {
        if (elem.style[name]) {
            return elem.style[name];
        }
        else if (elem.currentStyle) {
            return elem.currentStyle[name];
        }
        else if (document.defaultView && document.defaultView.getComputedStyle) {
            name = name.replace(/([A-Z])/g, "-$1");
            name = name.toLowerCase();

            var s = document.defaultView.getComputedStyle(elem, "");
            return s && s.getPropertyValue(name);
        }
        else return null;
    },
    //find the x (horizontal, left ) postion of an element
    pageX: function (elem) {
        return elem.offsetParent ? elem.offsetLeft + JK.Dom.pageX(elem.offsetParent) : elem.offsetLeft;
    },
    //find the Y (vertical, top ) postion of an element
    pageY: function (elem) {
        return elem.offsetParent ? elem.offsetTop + JK.Dom.pageY(elem.offsetParent) : elem.offsetTop;
    },
    //find the horizontal positioning of an element within it's parent
    parentX: function (elem) {
        elem.parentNode == elem.offsetParent ? elem.offsetLeft : JK.Dom.pageX(elem) - JK.Dom.pageX(elem.parentNode);
    },
    //find the vertical positioning of an element within it's parent
    parentY: function (elem) {
        elem.parentNode == elem.offsetParent ? elem.offsetTop : JK.Dom.pageY(elem) - JK.Dom.pageY(elem.parentNode);
    },
    //find the left postion of an element
    posX: function (elem) {
        return $int(JK.Dom.getStyle(elem, "left"));
    },
    //find the top postion of an element
    posY: function (elem) {
        return $int(JK.Dom.getStyle(elem, "top"));
    },
    //set the left ot horizontal position
    setX: function (elem, pos) {
        elem.style.left = pos + "px";
    },
    //set the top ot horizontal position
    setY: function (elem, pos) {
        elem.style.top = pos + "px";
    },
    //a function for adding a number of pixels to the horizontal position
    addX: function (elem, pos) {
        //get the horizontal position and add the offset to it
        setX(posX(elem) + pos);
    },
    //a function for adding a number of pixels to the vertical position
    addY: function (elem, pos) {
        //get the vertical position and add the offset to it
        setY(posY(elem) + pos);
    },
    //get the actual height using the computed css of the element
    getHeight: function (elem) {
        //get the compued css and parse out the usable number
        return $int(JK.Dom.getStyle(elem, 'height'));
    },
    //get the actual width using the computed css of the element
    getWidth: function (elem) {
        //get the compued css and parse out the usable number
        return $int(JK.Dom.getStyle(elem, 'width'));
    },
    //store old style settings for element
    resetCSS: function (elem, prop) {
        var old = {};
        for (var i in prop) {
            old[i] = elem.style[i];
            elem.style[i] = prop[i];
        }
        return old;
    },
    //restore old style settings 
    restoreCSS: function (elem, prop) {
        for (var i in prop) {
            elem.style[i] = prop[i];
        }
    },
    //find the full potential height of an element not the current actual height
    fullHeight: function (elem) {
        if (JK.Dom.getStyle(elem, 'display') != 'none') {
            return elem.offsetHeight || JK.Dom.getHeight(elem);
        }
        var old = JK.Dom.resetCSS(elem, {
            display: '',
            visibility: 'hidden',
            position: 'absolute'
        });
        var h = elem.clientHeight || JK.Dom.getHeight(elem);
        JK.Dom.restoreCSS(elem, old);
        return h;
    },
    //find the full potential width of an element not the current actual width
    fullWidth: function (elem) {
        if (JK.Dom.getStyle(elem, 'display') != 'none') {
            return elem.offsetWidth || JK.Dom.getWidth(elem);
        }
        var old = JK.Dom.resetCSS(elem, {
            display: '',
            visibility: 'hidden',
            position: 'absolute'
        });
        var w = elem.clientWidth || JK.Dom.getWidth(elem);
        JK.Dom.restoreCSS(elem, old);
        return w;
    },
    //mouse horizontal position
    mouseX: function (e) {
        e = e || event;
        return e.pageX || e.clientX + document.body.scrollLeft;
    },
    //mouse vertical position
    mouseY: function (e) {
        e = e || event;
        return e.pageY || e.clientY + document.body.scrollTop;
    },
    //mouse position relative to the current element
    mouseElementX: function (e) {
        (e && e.layerX) || window.event.offsetX;
    },
    //mouse position relative to the current element
    mouseElementY: function (e) {
        (e && e.layerY) || window.event.offsetY;
    },
    //web page height
    pageHeight: function () {
        return document.body.scrollHeight;
    },
    //web page width
    pageWidth: function () {
        return document.body.scrollWidth;
    },
    //for determning where the viewposrt isFinite positioned in the webpage
    scrollX: function () {
        var de = document.documentElement;
        return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft;
    },
    //for determning where the viewposrt isFinite positioned in the webpage
    scrollY: function () {
        var de = document.documentElement;
        return self.pageYOffset || (de && de.scrollTop) || document.body.scrollTop;
    },
    //for determining the size of the viewport
    windowHeight: function () {
        var de = document.documentElement;
        return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    },
    //for determining the size of the viewport
    windowWidth: function () {
        var de = document.documentElement;
        return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    },
    // stop event bubble up
    stopBubble: function (e) {
        if (e && e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            window.event.cancelBubble = true;
        }
    },
    //stop default event response from element
    stopDefault: function (e) {
        if (e && e.preventDefault) {
            e.preventDefault();
        }
        else {
            window.event.returnValue = false;
        }
    }
}
//assign to jquery
jQuery.insertNodeAfter = JK.Dom.insertAfter;
var frag

JK.Bitvalue = {};

function addEvent(obj, eventname, fn) {
    if (obj.attachEvent) {
        obj['e' + eventname + fn] = fn;
        obj[eventname + fn] = function () { obj['e' + eventname + fn](window.event); }
        obj.attachEvent('on' + eventname, obj[eventname + fn]);
    } else
        obj.addEventListener(eventname, fn, false);
}
function removeEvent(obj, eventname, fn) {
    if (obj.detachEvent) {
        obj.detachEvent('on' + eventname, obj[eventname + fn]);
        obj[eventname + fn] = null;
    } else
        obj.removeEventListener(eventname, fn, false);
}
var writemessage = function (msg, obj) {
    var m = $id("message");
    m.innerHTML = msg;
    m.style.display = 'block';
    if (obj)
        obj.style.color = "red";
    setTimeout(
	function () {
	    $id("message").style.display = "none";
	}
	, 3000)
}

//creates select control for data submitted and returns object to give refernce to the created control
var $makeSelect = function (ds, container, controlid, valuecolumn, textcolumn) {
    var select = $element('select');
    select.id = controlid;
    for (var i = 0; i < ds.length; i++) {
        var option = $element('option');
        option.value = ds[i][valuecolumn];
        j$(option).text(ds[i][textcolumn]);
        select.appendChild(option);
    }
    container.appendChild(select);
    return { select: select };
}
//ds - dataset, container is paren to attach to, headerRow id the header columns
var $makeTable = function (ds, container, headerRow, data) {

    var tbl = $element('table');
    var tr = $element('tr');

    for (var i = 0; i < headerRow.length; i++) {
        var th = $element('th');
        $attrib(th).Text(headerRow[i]);
        tr.appendChild(th);
    }

    for (var j = 0; j < ds.length; j++) {
        var tc = $element('tc');
        j$(tc).text(ds[i].name);
        tr.appendChild(tc);
    }

    return { ds: ds, table: tbl };

}
var $removeEmtpyTextNodes = function (parent) {
    var childNodes = parent.childNodes;
    j$(childNodes).each(function () {
        if (this.nodeType == 3 && j$(this).text().trim() == String.Emtpty) {
            this.parentNode.removeChild(this);
        }
    });
}
//check to find if this sibling is there 
//sibling is reference sibling and calssName is the class of the sibling you are looking for
var $removeThisSibling = function (sibling, selector) {
    var childNodes = sibling.parentNode.childNodes;
    j$(childNodes).each(function () {
        if (selector.indexOf('.') > -1) {
            var classname = selector.replace('.', String.Empty);
            if (j$(this).hasClass(classname)) {
                this.parentNode.removeChild(this);
            }
        }
        //		if (this.nodeType == 1 && this.className.toLowerCase() == 'removethis') {
        //			this.parentNode.removeChild(this);
        //		}
    });
}
var $selectToArrayForValue = function (el) {
    var ary = [];
    var length = el.options.length;
    for (var i = 0; i < length; i++) {
        if (el.options[i].selected) {
            ary.push(el.options[i].value);
        }
    }
    return ary;
}
var $selectToArrayForText = function (el) {
    var ary = [];
    var length = el.options.length;
    for (var i = 0; i < length; i++) {
        if (el.options[i].selected) {
            ary.push(jQuery(el.options[i]).text());
        }
    }
    return ary;
}
var $checkboxToArrayForValue = function (name) {
    var ary = [];
    var names = $name(name)
    var length = name.length;
    for (var name in names) {
        if (name.checked) {
            ary.push(name.value);
        }
    }
    return ary;
}
//first arg ument is jquery selector, second is control argument ie:is select control for value or for text
jQuery.formtostring = function (selector, options) {
    var args = arguments;
    var length = args.length;
    var str = String.Empty;
    jQuery(selector).each(function () {
        if (this.type) {
            switch (this.type.toLowerCase()) {
                case 'text':
                    str += "&" + this.id + "=" + this.value;
                    break;
                case 'radio':
                    if (this.checked) {
                        str += "&" + this.id + "=" + true.toString();
                    }
                    else {
                        str += "&" + this.id + "=" + false.toString();
                    }
                    break;
                case 'checkbox':
                    if (this.checked) {
                        str += "&" + this.id + "=" + true.toString();
                    }
                    else {
                        str += "&" + this.id + "=" + false.toString();
                    }
                    break;
                case 'textarea':
                    str += "&" + this.id + "=" + jQuery(this).text();
                    break;
                case 'select-one':
                    if (args[1] == 'value') {
                        str += "&" + this.id + "=" + $selectToArrayForValue(this).toString();
                    }
                    else if (args[1] == 'text') {
                        str += "&" + this.id + "=" + $selectToArrayForText(this).toString();
                    }
                    break;
                case 'select-multiple':
                    if (args[1] == 'value') {
                        str += "&" + this.id + "=" + $selectToArrayForValue(this).toString();
                    }
                    else if (args[1] == 'text') {
                        str += "&" + this.id + "=" + $selectToArrayForText(this).toString();
                    }
                    break;
            }
        }
    });
    return str
};
//fist arg ument is jquery selected, second is control argument ie:is select for value or for text
var $isControlValid = function (el) {
    var tagname = el.tagName.toLowerCase();
    var isValid = false;
    var handleInput = function () {
        var type = el.type.toLowerCase();
        switch (type) {
            case 'text':
                isValid = el.value.trim() != String.Empty ? true : false;
                break;
            case 'radio':
                var name = el.name;
                var names = $name(name);
                isValid = false;
                for (var i = 0; i < names.length; i++) {
                    if (names[i].checked) {
                        isValid = true;
                    }
                }
                break;
            case 'checkbox':
                var name = el.name;
                var names = $name(name);
                isValid = false;
                for (var i = 0; i < names.length; i++) {
                    if (names[i].checked) {
                        isValid = true;
                    }
                }
                break;

        }
    }
    var handleSelect = function () {
        var options = el.options;
        for (var i = 0; i < options.length; i++) {
            if (options[i].selected) {
                isValid = true;
            }
        }
    }

    switch (tagname) {
        case 'input':
            handleInput();
            break;
        case 'select':
            handleSelect();
            break;
        case 'textarea':
            isValid = el.value.trim() != String.Empty ? true : false;
            break;

    }

    return isValid;
}

var $limitTextCounter = function (limitCount, limitNum) {
    if (this.value.length > limitNum) {
        this.value = this.value.substring(0, limitNum);
    } else {
        limitCount.value = limitNum - this.value.length;
    }
}
var $limitText = function (control, limitNum) {
    if (control.value.length > limitNum) {
        control.value = control.value.substring(0, limitNum);
    }
}

//mouse position
var Loadtempv = function () {
    if (document.body) {
        tempX += (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        tempY += (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    }
    else {
        window.setTimeout(Loadtempv, 200);
    }
}

//find where the mouse is
var getMouseXY = function (e) {
    var isOpera = (navigator.userAgent.indexOf('Opera') != -1);
    var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1);

    if (!e) var e = window.event;

    if (e.pageX || e.pageY) {
        tempX = e.pageX;
        tempY = e.pageY;
    }
    else if (e.clientX || e.clientY) {
        tempX = e.clientX;
        tempY = e.clientY;
        if (isIE) {
            if (document.body) {
                tempX += (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
                tempY += (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
            }
            else {
                window.setTimeout(Loadtempv, 200);
            }
        }
    }


    return true;
}
//set moue postion variable and event capture
var IE = document.all ? true : false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0
var x = 0;
var y = 0;
//***********************


var breakQueryString = function () {

}

var $documentElement = {};
var $body = {};

j$(function () {
    $documentElement = document.documentElement;
    $body = document.body;
});
