//** AnyLink CSS Menu v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm
//** January 19', 2009: Script Creation date

//**May 23rd, 10': v2.21: Fixes script not firing in IE when inside a frame page

if (typeof dd_domreadycheck == "undefined") //global variable to detect if DOM is ready
    var dd_domreadycheck = false

var anylinkcssmenu = {

    menusmap: {},
    preloadimages: [],
    effects: { delayhide: 200, shadow: { enabled: true, opacity: 0.3, depth: [5, 5] }, fade: { enabled: true, duration: 500} }, //customize menu effects

    dimensions: {},

    getoffset: function (what, offsettype) {
        return (what.offsetParent) ? what[offsettype] + this.getoffset(what.offsetParent, offsettype) : what[offsettype]
    },

    getoffsetof: function (el) {
        el._offsets = { left: this.getoffset(el, "offsetLeft"), top: this.getoffset(el, "offsetTop"), h: el.offsetHeight }
    },

    getdimensions: function (menu) {
        this.dimensions = { anchorw: menu.anchorobj.offsetWidth, anchorh: menu.anchorobj.offsetHeight,
            docwidth: (window.innerWidth || this.standardbody.clientWidth) - 20,
            docheight: (window.innerHeight || this.standardbody.clientHeight) - 15,
            docscrollx: window.pageXOffset || this.standardbody.scrollLeft,
            docscrolly: window.pageYOffset || this.standardbody.scrollTop
        }
        if (!this.dimensions.dropmenuw) {
            this.dimensions.dropmenuw = menu.dropmenu.offsetWidth
            this.dimensions.dropmenuh = menu.dropmenu.offsetHeight
        }
    },

    isContained: function (m, e) {
        var e = window.event || e
        var c = e.relatedTarget || ((e.type == "mouseover") ? e.fromElement : e.toElement)
        while (c && c != m) try { c = c.parentNode } catch (e) { c = m }
        if (c == m)
            return true
        else
            return false
    },

    setopacity: function (el, value) {
        el.style.opacity = value
        if (typeof el.style.opacity != "string") { //if it's not a string (ie: number instead), it means property not supported
            el.style.MozOpacity = value
            if (el.filters) {
                el.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + value * 100 + ")"
            }
        }
    },

    showmenu: function (menuid) {
        var menu = anylinkcssmenu.menusmap[menuid]
        clearTimeout(menu.hidetimer)
        this.getoffsetof(menu.anchorobj)
        this.getdimensions(menu)
        var posx = menu.anchorobj._offsets.left + (menu.orientation == "lr" ? this.dimensions.anchorw : 0) //base x pos
        var posy = menu.anchorobj._offsets.top + this.dimensions.anchorh - (menu.orientation == "lr" ? this.dimensions.anchorh : 0)//base y pos
        if (posx + this.dimensions.dropmenuw + this.effects.shadow.depth[0] > this.dimensions.docscrollx + this.dimensions.docwidth) { //drop left instead?
            posx = posx - this.dimensions.dropmenuw + (menu.orientation == "lr" ? -this.dimensions.anchorw : this.dimensions.anchorw)
        }
        if (posy + this.dimensions.dropmenuh > this.dimensions.docscrolly + this.dimensions.docheight) {  //drop up instead?
            posy = Math.max(posy - this.dimensions.dropmenuh - (menu.orientation == "lr" ? -this.dimensions.anchorh : this.dimensions.anchorh), this.dimensions.docscrolly) //position above anchor or window's top edge
        }
        if (this.effects.fade.enabled) {
            this.setopacity(menu.dropmenu, 0) //set opacity to 0 so menu appears hidden initially
            if (this.effects.shadow.enabled)
                this.setopacity(menu.shadow, 0) //set opacity to 0 so shadow appears hidden initially
        }
        menu.dropmenu.setcss({ left: posx + 'px', top: posy + 'px', visibility: 'visible' })
        if (this.effects.shadow.enabled)
            menu.shadow.setcss({ left: posx + anylinkcssmenu.effects.shadow.depth[0] + 'px', top: posy + anylinkcssmenu.effects.shadow.depth[1] + 'px', visibility: 'visible' })
        if (this.effects.fade.enabled) {
            clearInterval(menu.animatetimer)
            menu.curanimatedegree = 0
            menu.starttime = new Date().getTime() //get time just before animation is run
            menu.animatetimer = setInterval(function () { anylinkcssmenu.revealmenu(menuid) }, 20)
        }
    },

    revealmenu: function (menuid) {
        var menu = anylinkcssmenu.menusmap[menuid]
        var elapsed = new Date().getTime() - menu.starttime //get time animation has run
        if (elapsed < this.effects.fade.duration) {
            this.setopacity(menu.dropmenu, menu.curanimatedegree)
            if (this.effects.shadow.enabled)
                this.setopacity(menu.shadow, menu.curanimatedegree * this.effects.shadow.opacity)
        }
        else {
            clearInterval(menu.animatetimer)
            this.setopacity(menu.dropmenu, 1)
            menu.dropmenu.style.filter = ""
        }
        menu.curanimatedegree = (1 - Math.cos((elapsed / this.effects.fade.duration) * Math.PI)) / 2
    },

    setcss: function (param) {
        for (prop in param) {
            this.style[prop] = param[prop]
        }
    },

    setcssclass: function (el, targetclass, action) {
        var needle = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "ig")
        if (action == "check")
            return needle.test(el.className)
        else if (action == "remove")
            el.className = el.className.replace(needle, "")
        else if (action == "add" && !needle.test(el.className))
            el.className += " " + targetclass
    },

    hidemenu: function (menuid) {
        var menu = anylinkcssmenu.menusmap[menuid]
        clearInterval(menu.animatetimer)
        menu.dropmenu.setcss({ visibility: 'hidden', left: 0, top: 0 })
        menu.shadow.setcss({ visibility: 'hidden', left: 0, top: 0 })
    },

    getElementsByClass: function (targetclass) {
        if (document.querySelectorAll)
            return document.querySelectorAll("." + targetclass)
        else {
            var classnameRE = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "i") //regular expression to screen for classname
            var pieces = []
            var alltags = document.all ? document.all : document.getElementsByTagName("*")
            for (var i = 0; i < alltags.length; i++) {
                if (typeof alltags[i].className == "string" && alltags[i].className.search(classnameRE) != -1)
                    pieces[pieces.length] = alltags[i]
            }
            return pieces
        }
    },

    addEvent: function (targetarr, functionref, tasktype) {
        if (targetarr.length > 0) {
            var target = targetarr.shift()
            if (target.addEventListener)
                target.addEventListener(tasktype, functionref, false)
            else if (target.attachEvent)
                target.attachEvent('on' + tasktype, function () { return functionref.call(target, window.event) })
            this.addEvent(targetarr, functionref, tasktype)
        }
    },

    domready: function (functionref) { //based on code from the jQuery library
        if (dd_domreadycheck) {
            functionref()
            return
        }
        // Mozilla, Opera and webkit nightlies currently support this event
        if (document.addEventListener) {
            // Use the handy event callback
            document.addEventListener("DOMContentLoaded", function () {
                document.removeEventListener("DOMContentLoaded", arguments.callee, false)
                functionref();
                dd_domreadycheck = true
            }, false)
        }
        else if (document.attachEvent) {
            // If IE and not an iframe
            // continually check to see if the document is ready
            if (document.documentElement.doScroll && window == window.top) (function () {
                if (dd_domreadycheck) return
                try {
                    // If IE is used, use the trick by Diego Perini
                    // http://javascript.nwbox.com/IEContentLoaded/
                    document.documentElement.doScroll("left")
                } catch (error) {
                    setTimeout(arguments.callee, 0)
                    return;
                }
                //and execute any waiting functions
                functionref();
                dd_domreadycheck = true
            })();
        }
        if (document.attachEvent && parent.length > 0) //account for page being in IFRAME, in which above doesn't fire in IE
            this.addEvent([window], function () { functionref() }, "load");
    },

    addState: function (anchorobj, state) {
        if (anchorobj.getAttribute('data-image')) {
            var imgobj = (anchorobj.tagName == "IMG") ? anchorobj : anchorobj.getElementsByTagName('img')[0]
            if (imgobj) {
                imgobj.src = (state == "add") ? anchorobj.getAttribute('data-overimage') : anchorobj.getAttribute('data-image')
            }
        }
        else
            anylinkcssmenu.setcssclass(anchorobj, "selectedanchor", state)
    },


    setupmenu: function (targetclass, anchorobj, pos) {
        this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body
        var relattr = anchorobj.getAttribute("rel")
        var dropmenuid = relattr.replace(/\[(\w+)\]/, '')
        var menu = this.menusmap[targetclass + pos] = {
            id: targetclass + pos,
            anchorobj: anchorobj,
            dropmenu: document.getElementById(dropmenuid),
            revealtype: (relattr.length != dropmenuid.length && RegExp.$1 == "click") ? "click" : "mouseover",
            orientation: anchorobj.getAttribute("rev") == "lr" ? "lr" : "ud",
            shadow: document.createElement("div")
        }
        menu.anchorobj._internalID = targetclass + pos
        menu.anchorobj._isanchor = true
        menu.dropmenu._internalID = targetclass + pos
        menu.shadow._internalID = targetclass + pos
        menu.shadow.className = "anylinkshadow"
        document.body.appendChild(menu.dropmenu) //move drop down div to end of page
        document.body.appendChild(menu.shadow)
        menu.dropmenu.setcss = this.setcss
        menu.shadow.setcss = this.setcss
        menu.shadow.setcss({ width: menu.dropmenu.offsetWidth + "px", height: menu.dropmenu.offsetHeight + "px" })
        this.setopacity(menu.shadow, this.effects.shadow.opacity)
        this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function (e) { //MOUSEOVER event for anchor, dropmenu, shadow
            var menu = anylinkcssmenu.menusmap[this._internalID]
            if (this._isanchor && menu.revealtype == "mouseover" && !anylinkcssmenu.isContained(this, e)) { //event for anchor
                anylinkcssmenu.showmenu(menu.id)
                anylinkcssmenu.addState(this, "add")
            }
            else if (typeof this._isanchor == "undefined") { //event for drop down menu and shadow
                clearTimeout(menu.hidetimer)
            }
        }, "mouseover")
        this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function (e) { //MOUSEOUT event for anchor, dropmenu, shadow
            if (!anylinkcssmenu.isContained(this, e)) {
                var menu = anylinkcssmenu.menusmap[this._internalID]
                menu.hidetimer = setTimeout(function () {
                    anylinkcssmenu.addState(menu.anchorobj, "remove")
                    anylinkcssmenu.hidemenu(menu.id)
                }, anylinkcssmenu.effects.delayhide)
            }
        }, "mouseout")
        this.addEvent([menu.anchorobj, menu.dropmenu], function (e) { //CLICK event for anchor, dropmenu
            var menu = anylinkcssmenu.menusmap[this._internalID]
            if (this._isanchor && menu.revealtype == "click") {
                if (menu.dropmenu.style.visibility == "visible")
                    anylinkcssmenu.hidemenu(menu.id)
                else {
                    anylinkcssmenu.addState(this, "add")
                    anylinkcssmenu.showmenu(menu.id)
                }
                if (e.preventDefault)
                    e.preventDefault()
                return false
            }
            else
                menu.hidetimer = setTimeout(function () { anylinkcssmenu.hidemenu(menu.id) }, anylinkcssmenu.effects.delayhide)
        }, "click")
    },

    init: function (targetclass) {
        this.domready(function () { anylinkcssmenu.trueinit(targetclass) })
    },

    trueinit: function (targetclass) {
        var anchors = this.getElementsByClass(targetclass)
        var preloadimages = this.preloadimages
        for (var i = 0; i < anchors.length; i++) {
            if (anchors[i].getAttribute('data-image')) { //preload anchor image?
                preloadimages[preloadimages.length] = new Image()
                preloadimages[preloadimages.length - 1].src = anchors[i].getAttribute('data-image')
            }
            if (anchors[i].getAttribute('data-overimage')) { //preload anchor image?
                preloadimages[preloadimages.length] = new Image()
                preloadimages[preloadimages.length - 1].src = anchors[i].getAttribute('data-overimage')
            }
            this.setupmenu(targetclass, anchors[i], i)
        }
    }

}

// -------------------------------------------------------------------
// Ajax XML Ticker (txt file source)
// Author: Dynamic Drive (http://www.dynamicdrive.com)
// -------------------------------------------------------------------
//**Feb 17th, 2010 (v1.1): Adds ability to periodically refetch contents of external file. Fixed IE clearType font issue

////////////No need to edit beyond here//////////////

function createAjaxObj() {
    var httprequest = false
    if (window.XMLHttpRequest && !window.ActiveXObject) { // if Mozilla, Safari etc
        httprequest = new XMLHttpRequest()
        if (httprequest.overrideMimeType)
            httprequest.overrideMimeType('text/xml')
    }
    else if (window.ActiveXObject) { // if IE
        try {
            httprequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                httprequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) { }
        }
    } //end IE
    return httprequest
}

// -------------------------------------------------------------------
// Main Ajax Ticker Object function
// ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
// -------------------------------------------------------------------

function ajax_ticker(xmlfile, divId, divClass, delay, fadeornot) {
    this.xmlfile = xmlfile //Variable pointing to the local ticker xml file (txt)
    this.tickerid = divId //ID of ticker div to display information
    var delay = (typeof delay == "number") ? [delay] : delay //convert parameterif string into array [delay, refetchdelay]
    this.delay = delay[0] //Delay between msg change, in miliseconds.
    this.refetchdelay = delay[1] //Delay between refetching of Ajax contents
    this.mouseoverBol = 0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
    this.pointer = 0
    this.opacitystring = (typeof fadeornot != "undefined") ? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); opacity: 1" : ""
    if (this.opacitystring != "") this.delay += 500 //add 1/2 sec to account for fade effect, if enabled
    this.opacitysetting = 0.2 //Opacity value when reset. Internal use.
    this.messages = [] //Arrays to hold each message of ticker
    this.ajaxobj = createAjaxObj()
    document.write('<div id="' + divId + '" class="' + divClass + '"><div style="' + this.opacitystring + '">Initializing ticker...</div></div>')
    this.getXMLfile()
}

// -------------------------------------------------------------------
// getXMLfile()- Use Ajax to fetch xml file (txt)
// -------------------------------------------------------------------

ajax_ticker.prototype.getXMLfile = function () {
    this.ajaxobj = createAjaxObj() //recreate Ajax object (IE seems to require it)
    if (this.ajaxobj) {
        var instanceOfTicker = this
        var url = this.xmlfile + "?bustcache=" + new Date().getTime()
        this.ajaxobj.onreadystatechange = function () { instanceOfTicker.initialize() }
        this.ajaxobj.open('GET', url, true)
        this.ajaxobj.send(null)
    }
}

// -------------------------------------------------------------------
// initialize()- Initialize ticker method.
// -Gets contents of xml file and parse it using JavaScript DOM methods 
// -------------------------------------------------------------------

ajax_ticker.prototype.initialize = function () {
    if (this.ajaxobj.readyState == 4) { //if request of file completed
        if (this.ajaxobj.status == 200 || window.location.href.indexOf("http") == -1) { //if request was successful
            this.contentdiv = document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
            var xmldata = this.ajaxobj.responseText
            this.contentdiv.style.display = "none"
            this.contentdiv.innerHTML = xmldata
            if (this.contentdiv.getElementsByTagName("div").length == 0) { //if no messages were found
                this.contentdiv.innerHTML = "<b>Error</b> fetching remote ticker file!"
                return
            }
            var instanceOfTicker = this
            document.getElementById(this.tickerid).onmouseover = function () { instanceOfTicker.mouseoverBol = 1 }
            document.getElementById(this.tickerid).onmouseout = function () { instanceOfTicker.mouseoverBol = 0 }
            clearTimeout(this.fadetimer1) //clear timers
            clearTimeout(this.pausetimer)
            clearTimeout(this.rotatetimer)
            this.mouseoverBol = 0
            this.messages = [] //reset messages[] to blank array (in the event initialize is being called again)
            //Cycle through XML object and store each message inside array
            for (var i = 0; i < this.contentdiv.getElementsByTagName("div").length; i++) {
                if (this.contentdiv.getElementsByTagName("div")[i].className == "message")
                    this.messages[this.messages.length] = this.contentdiv.getElementsByTagName("div")[i].innerHTML
            }
            this.contentdiv.innerHTML = ""
            this.contentdiv.style.display = "block"
            this.rotatemsg()
            if (this.refetchdelay > 5000) //if refetch data delay is greater than 5 seconds
                setTimeout(function () { instanceOfTicker.getXMLfile() }, this.refetchdelay)
        }
    }
}

// -------------------------------------------------------------------
// rotatemsg()- Rotate through ticker messages and displays them
// -------------------------------------------------------------------

ajax_ticker.prototype.rotatemsg = function () {
    var instanceOfTicker = this
    if (this.mouseoverBol == 1) //if mouse is currently over ticker, do nothing (pause it)
        this.pausetimer = setTimeout(function () { instanceOfTicker.rotatemsg() }, 100)
    else { //else, construct item, show and rotate it!
        if (this.contentdiv.filters) //In IE, reapply filter attribute each time
            this.contentdiv.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + (this.opacitysetting * 100) + ")";
        this.fadetransition("reset")
        this.contentdiv.innerHTML = this.messages[this.pointer]
        this.fadetimer1 = setInterval(function () { instanceOfTicker.fadetransition('up', 'fadetimer1') }, 100) //FADE EFFECT- PLAY IT
        this.pointer = (this.pointer < this.messages.length - 1) ? this.pointer + 1 : 0
        this.rotatetimer = setTimeout(function () { instanceOfTicker.rotatemsg() }, this.delay) //update container periodically
    }
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

ajax_ticker.prototype.fadetransition = function (fadetype, timerid) {
    var contentdiv = this.contentdiv
    if (fadetype == "reset")
        this.opacitysetting = 0.2
    if (contentdiv.filters && contentdiv.filters[0]) {
        if (typeof contentdiv.filters[0].opacity == "number") //IE6+
            contentdiv.filters[0].opacity = this.opacitysetting * 100
        else //IE 5.5
            contentdiv.style.filter = "alpha(opacity=" + this.opacitysetting * 100 + ")"
    }
    else if (contentdiv.style.opacity != "undefined") {
        contentdiv.style.opacity = this.opacitysetting
    }
    else
        this.opacitysetting = 1
    if (fadetype == "up")
        this.opacitysetting += 0.1
    if (fadetype == "up" && this.opacitysetting >= 1) {
        if (contentdiv.style && contentdiv.style.removeAttribute)
            contentdiv.style.removeAttribute('filter') //fix IE clearType problem
        clearInterval(this[timerid])
    }
}


/****************************************************
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win = null;
function NewWindow(mypage, myname, w, h, scroll, pos) {
    if (pos == "random") { LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; }
    if (pos == "center") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; }
    else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win = window.open(mypage, myname, settings);
}

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects = ""
var rootdomain = "http://" + window.location.hostname

function ajaxpage(url, containerid) {
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
    else if (window.ActiveXObject) { // if IE
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e) {
            try {
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e) { }
        }
    }
    else
        return false
    page_request.onreadystatechange = function () {
        loadpage(page_request, containerid)
    }
    page_request.open('GET', url, true)
    page_request.send(null)
}

function loadpage(page_request, containerid) {
    if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1))
        document.getElementById(containerid).innerHTML = page_request.responseText
}

function loadobjs() {
    if (!document.getElementById)
        return
    for (i = 0; i < arguments.length; i++) {
        var file = arguments[i]
        var fileref = ""
        if (loadedobjects.indexOf(file) == -1) { //Check to see if this object has not already been added to page before proceeding
            if (file.indexOf(".js") != -1) { //If object is a js file
                fileref = document.createElement('script')
                fileref.setAttribute("type", "text/javascript");
                fileref.setAttribute("src", file);
            }
            else if (file.indexOf(".css") != -1) { //If object is a css file
                fileref = document.createElement("link")
                fileref.setAttribute("rel", "stylesheet");
                fileref.setAttribute("type", "text/css");
                fileref.setAttribute("href", file);
            }
        }
        if (fileref != "") {
            document.getElementsByTagName("head").item(0).appendChild(fileref)
            loadedobjects += file + " " //Remember this object as being already added to page
        }
    }
}

/***********************************************
* SDMenu - © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function SDMenu(id) {
    if (!document.getElementById || !document.getElementsByTagName)
        return false;
    this.menu = document.getElementById(id);
    this.submenus = this.menu.getElementsByTagName("div");
    this.remember = true;
    this.speed = 3;
    this.markCurrent = true;
    this.oneSmOnly = false;
}
SDMenu.prototype.init = function () {
    var mainInstance = this;
    for (var i = 0; i < this.submenus.length; i++)
        this.submenus[i].getElementsByTagName("span")[0].onclick = function () {
            mainInstance.toggleMenu(this.parentNode);
        };
    if (this.markCurrent) {
        var links = this.menu.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++)
            if (links[i].href == document.location.href) {
                links[i].className = "current";
                break;
            }
    }
    if (this.remember) {
        var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
        var match = regex.exec(document.cookie);
        if (match) {
            var states = match[1].split("");
            for (var i = 0; i < states.length; i++)
                this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
        }
    }
};
SDMenu.prototype.toggleMenu = function (submenu) {
    if (submenu.className == "collapsed")
        this.expandMenu(submenu);
    else
        this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function (submenu) {
    var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
    var links = submenu.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++)
        fullHeight += links[i].offsetHeight;
    var moveBy = Math.round(this.speed * links.length);

    var mainInstance = this;
    var intId = setInterval(function () {
        var curHeight = submenu.offsetHeight;
        var newHeight = curHeight + moveBy;
        if (newHeight < fullHeight)
            submenu.style.height = newHeight + "px";
        else {
            clearInterval(intId);
            submenu.style.height = "";
            submenu.className = "";
            mainInstance.memorize();
        }
    }, 30);
    this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function (submenu) {
    var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
    var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
    var mainInstance = this;
    var intId = setInterval(function () {
        var curHeight = submenu.offsetHeight;
        var newHeight = curHeight - moveBy;
        if (newHeight > minHeight)
            submenu.style.height = newHeight + "px";
        else {
            clearInterval(intId);
            submenu.style.height = "";
            submenu.className = "collapsed";
            mainInstance.memorize();
        }
    }, 30);
};
SDMenu.prototype.collapseOthers = function (submenu) {
    if (this.oneSmOnly) {
        for (var i = 0; i < this.submenus.length; i++)
            if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
                this.collapseMenu(this.submenus[i]);
    }
};
SDMenu.prototype.expandAll = function () {
    var oldOneSmOnly = this.oneSmOnly;
    this.oneSmOnly = false;
    for (var i = 0; i < this.submenus.length; i++)
        if (this.submenus[i].className == "collapsed")
            this.expandMenu(this.submenus[i]);
    this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function () {
    for (var i = 0; i < this.submenus.length; i++)
        if (this.submenus[i].className != "collapsed")
            this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function () {
    if (this.remember) {
        var states = new Array();
        for (var i = 0; i < this.submenus.length; i++)
            states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
        var d = new Date();
        d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
        document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
    }
};

/*
* jQuery clueTip plugin
* Version 1.0.6  (January 13, 2010)
* @requires jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Full list of options/settings can be found at the bottom of this file and at http://plugins.learningjquery.com/cluetip/
* Examples can be found at http://plugins.learningjquery.com/cluetip/demo/
*
*/
(function ($) {
    $.cluetip = { version: '1.0.6' }; var $cluetip, $cluetipInner, $cluetipOuter, $cluetipTitle, $cluetipArrows, $cluetipWait, $dropShadow, imgCount; $.fn.cluetip = function (js, options) {
        if (typeof js == 'object') { options = js; js = null; }
        if (js == 'destroy') { return this.removeData('thisInfo').unbind('.cluetip'); }
        return this.each(function (index) {
            var link = this, $this = $(this); var opts = $.extend(true, {}, $.fn.cluetip.defaults, options || {}, $.metadata ? $this.metadata() : $.meta ? $this.data() : {}); var cluetipContents = false; var cluezIndex = +opts.cluezIndex; $this.data('thisInfo', { title: link.title, zIndex: cluezIndex }); var isActive = false, closeOnDelay = 0; if (!$('#cluetip').length) {
                $(['<div id="cluetip">', '<div id="cluetip-outer">', '<h3 id="cluetip-title"></h3>', '<div id="cluetip-inner"></div>', '</div>', '<div id="cluetip-extra"></div>', '<div id="cluetip-arrows" class="cluetip-arrows"></div>', '</div>'].join(''))
[insertionType](insertionElement).hide(); $cluetip = $('#cluetip').css({ position: 'absolute' }); $cluetipOuter = $('#cluetip-outer').css({ position: 'relative', zIndex: cluezIndex }); $cluetipInner = $('#cluetip-inner'); $cluetipTitle = $('#cluetip-title'); $cluetipArrows = $('#cluetip-arrows'); $cluetipWait = $('<div id="cluetip-waitimage"></div>').css({ position: 'absolute' }).insertBefore($cluetip).hide();
            }
            var dropShadowSteps = (opts.dropShadow) ? +opts.dropShadowSteps : 0; if (!$dropShadow) {
                $dropShadow = $([]); for (var i = 0; i < dropShadowSteps; i++) { $dropShadow = $dropShadow.add($('<div></div>').css({ zIndex: cluezIndex - 1, opacity: .1, top: 1 + i, left: 1 + i })); }
                $dropShadow.css({ position: 'absolute', backgroundColor: '#000' }).prependTo($cluetip);
            }
            var tipAttribute = $this.attr(opts.attribute), ctClass = opts.cluetipClass; if (!tipAttribute && !opts.splitTitle && !js) { return true; }
            if (opts.local && opts.localPrefix) { tipAttribute = opts.localPrefix + tipAttribute; }
            if (opts.local && opts.hideLocal) { $(tipAttribute + ':first').hide(); }
            var tOffset = parseInt(opts.topOffset, 10), lOffset = parseInt(opts.leftOffset, 10); var tipHeight, wHeight, defHeight = isNaN(parseInt(opts.height, 10)) ? 'auto' : (/\D/g).test(opts.height) ? opts.height : opts.height + 'px'; var sTop, linkTop, posY, tipY, mouseY, baseline; var tipInnerWidth = parseInt(opts.width, 10) || 275, tipWidth = tipInnerWidth + (parseInt($cluetip.css('paddingLeft'), 10) || 0) + (parseInt($cluetip.css('paddingRight'), 10) || 0) + dropShadowSteps, linkWidth = this.offsetWidth, linkLeft, posX, tipX, mouseX, winWidth; var tipParts; var tipTitle = (opts.attribute != 'title') ? $this.attr(opts.titleAttribute) : ''; if (opts.splitTitle) {
                if (tipTitle == undefined) { tipTitle = ''; }
                tipParts = tipTitle.split(opts.splitTitle); tipTitle = tipParts.shift();
            }
            if (opts.escapeTitle) { tipTitle = tipTitle.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'); }
            var localContent; function returnFalse() { return false; }
            var activate = function (event) {
                if (!opts.onActivate($this)) { return false; }
                isActive = true; $cluetip.removeClass().css({ width: tipInnerWidth }); if (tipAttribute == $this.attr('href')) { $this.css('cursor', opts.cursor); }
                if (opts.hoverClass) { $this.addClass(opts.hoverClass); }
                linkTop = posY = $this.offset().top; linkLeft = $this.offset().left; mouseX = event.pageX; mouseY = event.pageY; if (link.tagName.toLowerCase() != 'area') { sTop = $(document).scrollTop(); winWidth = $(window).width(); }
                if (opts.positionBy == 'fixed') { posX = linkWidth + linkLeft + lOffset; $cluetip.css({ left: posX }); } else {
                    posX = (linkWidth > linkLeft && linkLeft > tipWidth) || linkLeft + linkWidth + tipWidth + lOffset > winWidth ? linkLeft - tipWidth - lOffset : linkWidth + linkLeft + lOffset; if (link.tagName.toLowerCase() == 'area' || opts.positionBy == 'mouse' || linkWidth + tipWidth > winWidth) { if (mouseX + 20 + tipWidth > winWidth) { $cluetip.addClass(' cluetip-' + ctClass); posX = (mouseX - tipWidth - lOffset) >= 0 ? mouseX - tipWidth - lOffset - parseInt($cluetip.css('marginLeft'), 10) + parseInt($cluetipInner.css('marginRight'), 10) : mouseX - (tipWidth / 2); } else { posX = mouseX + lOffset; } }
                    var pY = posX < 0 ? event.pageY + tOffset : event.pageY; $cluetip.css({ left: (posX > 0 && opts.positionBy != 'bottomTop') ? posX : (mouseX + (tipWidth / 2) > winWidth) ? winWidth / 2 - tipWidth / 2 : Math.max(mouseX - (tipWidth / 2), 0), zIndex: $this.data('thisInfo').zIndex }); $cluetipArrows.css({ zIndex: $this.data('thisInfo').zIndex + 1 });
                }
                wHeight = $(window).height(); if (js) {
                    if (typeof js == 'function') { js = js.call(link); }
                    $cluetipInner.html(js); cluetipShow(pY);
                }
                else if (tipParts) {
                    var tpl = tipParts.length; $cluetipInner.html(tpl ? tipParts[0] : ''); if (tpl > 1) { for (var i = 1; i < tpl; i++) { $cluetipInner.append('<div class="split-body">' + tipParts[i] + '</div>'); } }
                    cluetipShow(pY);
                }
                else if (!opts.local && tipAttribute.indexOf('#') !== 0) {
                    if (/\.(jpe?g|tiff?|gif|png)$/i.test(tipAttribute)) { $cluetipInner.html('<img src="' + tipAttribute + '" alt="' + tipTitle + '" />'); cluetipShow(pY); } else if (cluetipContents && opts.ajaxCache) { $cluetipInner.html(cluetipContents); cluetipShow(pY); } else {
                        var optionBeforeSend = opts.ajaxSettings.beforeSend, optionError = opts.ajaxSettings.error, optionSuccess = opts.ajaxSettings.success, optionComplete = opts.ajaxSettings.complete; var ajaxSettings = { cache: false, url: tipAttribute, beforeSend: function (xhr) {
                            if (optionBeforeSend) { optionBeforeSend.call(link, xhr, $cluetip, $cluetipInner); }
                            $cluetipOuter.children().empty(); if (opts.waitImage) { $cluetipWait.css({ top: mouseY + 20, left: mouseX + 20, zIndex: $this.data('thisInfo').zIndex - 1 }).show(); } 
                        }, error: function (xhr, textStatus) { if (isActive) { if (optionError) { optionError.call(link, xhr, textStatus, $cluetip, $cluetipInner); } else { $cluetipInner.html('<i>sorry, the contents could not be loaded</i>'); } } }, success: function (data, textStatus) {
                            cluetipContents = opts.ajaxProcess.call(link, data); if (isActive) {
                                if (optionSuccess) { optionSuccess.call(link, data, textStatus, $cluetip, $cluetipInner); }
                                $cluetipInner.html(cluetipContents);
                            } 
                        }, complete: function (xhr, textStatus) {
                            if (optionComplete) { optionComplete.call(link, xhr, textStatus, $cluetip, $cluetipInner); }
                            imgCount = $('#cluetip-inner img').length; if (imgCount && !$.browser.opera) { $('#cluetip-inner img').bind('load error', function () { imgCount--; if (imgCount < 1) { $cluetipWait.hide(); if (isActive) { cluetipShow(pY); } } }); } else { $cluetipWait.hide(); if (isActive) { cluetipShow(pY); } } 
                        } 
                        }; var ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings, ajaxSettings); $.ajax(ajaxMergedSettings);
                    } 
                } else if (opts.local) { var $localContent = $(tipAttribute + (/#\S+$/.test(tipAttribute) ? '' : ':eq(' + index + ')')).clone(true).show(); $cluetipInner.html($localContent); cluetipShow(pY); } 
            }; var cluetipShow = function (bpY) {
                $cluetip.addClass('cluetip-' + ctClass); if (opts.truncate) { var $truncloaded = $cluetipInner.text().slice(0, opts.truncate) + '...'; $cluetipInner.html($truncloaded); }
                function doNothing() { }; tipTitle ? $cluetipTitle.show().html(tipTitle) : (opts.showTitle) ? $cluetipTitle.show().html('&nbsp;') : $cluetipTitle.hide(); if (opts.sticky) { var $closeLink = $('<div id="cluetip-close"><a href="#">' + opts.closeText + '</a></div>'); (opts.closePosition == 'bottom') ? $closeLink.appendTo($cluetipInner) : (opts.closePosition == 'title') ? $closeLink.prependTo($cluetipTitle) : $closeLink.prependTo($cluetipInner); $closeLink.bind('click.cluetip', function () { cluetipClose(); return false; }); if (opts.mouseOutClose) { $cluetip.bind('mouseleave.cluetip', function () { cluetipClose(); }); } else { $cluetip.unbind('mouseleave.cluetip'); } }
                var direction = ''; $cluetipOuter.css({ zIndex: $this.data('thisInfo').zIndex, overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight }); tipHeight = defHeight == 'auto' ? Math.max($cluetip.outerHeight(), $cluetip.height()) : parseInt(defHeight, 10); tipY = posY; baseline = sTop + wHeight; if (opts.positionBy == 'fixed') { tipY = posY - opts.dropShadowSteps + tOffset; } else if ((posX < mouseX && Math.max(posX, 0) + tipWidth > mouseX) || opts.positionBy == 'bottomTop') { if (posY + tipHeight + tOffset > baseline && mouseY - sTop > tipHeight + tOffset) { tipY = mouseY - tipHeight - tOffset; direction = 'top'; } else { tipY = mouseY + tOffset; direction = 'bottom'; } } else if (posY + tipHeight + tOffset > baseline) { tipY = (tipHeight >= wHeight) ? sTop : baseline - tipHeight - tOffset; } else if ($this.css('display') == 'block' || link.tagName.toLowerCase() == 'area' || opts.positionBy == "mouse") { tipY = bpY - tOffset; } else { tipY = posY - opts.dropShadowSteps; }
                if (direction == '') { posX < linkLeft ? direction = 'left' : direction = 'right'; }
                $cluetip.css({ top: tipY + 'px' }).removeClass().addClass('clue-' + direction + '-' + ctClass).addClass(' cluetip-' + ctClass); if (opts.arrows) { var bgY = (posY - tipY - opts.dropShadowSteps); $cluetipArrows.css({ top: (/(left|right)/.test(direction) && posX >= 0 && bgY > 0) ? bgY + 'px' : /(left|right)/.test(direction) ? 0 : '' }).show(); } else { $cluetipArrows.hide(); }
                $dropShadow.hide(); $cluetip.hide()[opts.fx.open](opts.fx.openSpeed || 0); if (opts.dropShadow) { $dropShadow.css({ height: tipHeight, width: tipInnerWidth, zIndex: $this.data('thisInfo').zIndex - 1 }).show(); }
                if ($.fn.bgiframe) { $cluetip.bgiframe(); }
                if (opts.delayedClose > 0) { closeOnDelay = setTimeout(cluetipClose, opts.delayedClose); }
                opts.onShow.call(link, $cluetip, $cluetipInner);
            }; var inactivate = function (event) {
                isActive = false; $cluetipWait.hide(); if (!opts.sticky || (/click|toggle/).test(opts.activation)) { cluetipClose(); clearTimeout(closeOnDelay); }
                if (opts.hoverClass) { $this.removeClass(opts.hoverClass); } 
            }; var cluetipClose = function () {
                $cluetipOuter.parent().hide().removeClass(); opts.onHide.call(link, $cluetip, $cluetipInner); $this.removeClass('cluetip-clicked'); if (tipTitle) { $this.attr(opts.titleAttribute, tipTitle); }
                $this.css('cursor', ''); if (opts.arrows) { $cluetipArrows.css({ top: '' }); } 
            }; $(document).bind('hideCluetip', function (e) { cluetipClose(); }); if ((/click|toggle/).test(opts.activation)) {
                $this.bind('click.cluetip', function (event) {
                    if ($cluetip.is(':hidden') || !$this.is('.cluetip-clicked')) { activate(event); $('.cluetip-clicked').removeClass('cluetip-clicked'); $this.addClass('cluetip-clicked'); } else { inactivate(event); }
                    this.blur(); return false;
                });
            } else if (opts.activation == 'focus') { $this.bind('focus.cluetip', function (event) { activate(event); }); $this.bind('blur.cluetip', function (event) { inactivate(event); }); } else {
                $this[opts.clickThrough ? 'unbind' : 'bind']('click', returnFalse); var mouseTracks = function (evt) { if (opts.tracking == true) { var trackX = posX - evt.pageX; var trackY = tipY ? tipY - evt.pageY : posY - evt.pageY; $this.bind('mousemove.cluetip', function (evt) { $cluetip.css({ left: evt.pageX + trackX, top: evt.pageY + trackY }); }); } }; if ($.fn.hoverIntent && opts.hoverIntent) { $this.hoverIntent({ sensitivity: opts.hoverIntent.sensitivity, interval: opts.hoverIntent.interval, over: function (event) { activate(event); mouseTracks(event); }, timeout: opts.hoverIntent.timeout, out: function (event) { inactivate(event); $this.unbind('mousemove.cluetip'); } }); } else { $this.bind('mouseenter.cluetip', function (event) { activate(event); mouseTracks(event); }).bind('mouseleave.cluetip', function (event) { inactivate(event); $this.unbind('mousemove.cluetip'); }); }
                $this.bind('mouseover.cluetip', function (event) { $this.attr('title', ''); }).bind('mouseleave.cluetip', function (event) { $this.attr('title', $this.data('thisInfo').title); });
            } 
        });
    }; $.fn.cluetip.defaults = { width: 275, height: 'auto', cluezIndex: 97, positionBy: 'auto', topOffset: 15, leftOffset: 15, local: false, localPrefix: null, hideLocal: true, attribute: 'rel', titleAttribute: 'title', splitTitle: '', escapeTitle: false, showTitle: true, cluetipClass: 'default', hoverClass: '', waitImage: true, cursor: 'help', arrows: false, dropShadow: true, dropShadowSteps: 6, sticky: false, mouseOutClose: false, activation: 'hover', clickThrough: false, tracking: false, delayedClose: 0, closePosition: 'top', closeText: 'Close', truncate: 0, fx: { open: 'show', openSpeed: '' }, hoverIntent: { sensitivity: 3, interval: 50, timeout: 0 }, onActivate: function (e) { return true; }, onShow: function (ct, ci) { }, onHide: function (ct, ci) { }, ajaxCache: true, ajaxProcess: function (data) { data = data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm, '').replace(/<(link|meta)[^>]+>/g, ''); return data; }, ajaxSettings: { dataType: 'html' }, debug: false }; var insertionType = 'appendTo', insertionElement = 'body'; $.cluetip.setup = function (options) {
        if (options && options.insertionType && (options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)) { insertionType = options.insertionType; }
        if (options && options.insertionElement) { insertionElement = options.insertionElement; } 
    };
})(jQuery);

/* Sticky Tooltip script (v1.0)
* Created: Nov 25th, 2009. This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/
var stickytooltip = {
    tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips
    fadeinspeed: 200, //duration of fade effect in milliseconds
    rightclickstick: true, //sticky tooltip when user right clicks over the triggering element (apart from pressing "s" key) ?
    stickybordercolors: ["black", "darkred"], //border color of tooltip depending on sticky state
    stickynotice1: ["Press \"s\"", "or right click", "to pin"], //customize tooltip status message
    stickynotice2: "Click outside this box to unpin", //customize tooltip status message

    //***** NO NEED TO EDIT BEYOND HERE

    isdocked: false,

    positiontooltip: function ($, $tooltip, e) {
        var x = e.pageX + this.tooltipoffsets[0], y = e.pageY + this.tooltipoffsets[1]
        var tipw = $tooltip.outerWidth(), tiph = $tooltip.outerHeight(),
		x = (x + tipw > $(document).scrollLeft() + $(window).width()) ? x - tipw - (stickytooltip.tooltipoffsets[0] * 2) : x
        y = (y + tiph > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop() + $(window).height() - tiph - 10 : y
        $tooltip.css({ left: x, top: y })
    },

    showbox: function ($, $tooltip, e) {
        $tooltip.fadeIn(this.fadeinspeed)
        this.positiontooltip($, $tooltip, e)
    },

    hidebox: function ($, $tooltip) {
        if (!this.isdocked) {
            $tooltip.stop(false, true).hide()
            $tooltip.css({ borderColor: 'black' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[0] }).html(this.stickynotice1)
        }
    },

    docktooltip: function ($, $tooltip, e) {
        this.isdocked = true
        $tooltip.css({ borderColor: 'darkred' }).find('.stickystatus:eq(0)').css({ background: this.stickybordercolors[1] }).html(this.stickynotice2)
    },


    init: function (targetselector, tipid) {
        jQuery(document).ready(function ($) {
            var $targets = $(targetselector)
            var $tooltip = $('#' + tipid).appendTo(document.body)
            if ($targets.length == 0)
                return
            var $alltips = $tooltip.find('div.atip')
            if (!stickytooltip.rightclickstick)
                stickytooltip.stickynotice1[1] = ''
            stickytooltip.stickynotice1 = stickytooltip.stickynotice1.join(' ')
            stickytooltip.hidebox($, $tooltip)
            $targets.bind('mouseenter', function (e) {
                $alltips.hide().filter('#' + $(this).attr('data-tooltip')).show()
                stickytooltip.showbox($, $tooltip, e)
            })
            $targets.bind('mouseleave', function (e) {
                stickytooltip.hidebox($, $tooltip)
            })
            $targets.bind('mousemove', function (e) {
                if (!stickytooltip.isdocked) {
                    stickytooltip.positiontooltip($, $tooltip, e)
                }
            })
            $tooltip.bind("mouseenter", function () {
                stickytooltip.hidebox($, $tooltip)
            })
            $tooltip.bind("click", function (e) {
                e.stopPropagation()
            })
            $(this).bind("click", function (e) {
                if (e.button == 0) {
                    stickytooltip.isdocked = false
                    stickytooltip.hidebox($, $tooltip)
                }
            })
            $(this).bind("contextmenu", function (e) {
                if (stickytooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length == 1) { //if oncontextmenu over a target element
                    stickytooltip.docktooltip($, $tooltip, e)
                    return false
                }
            })
            $(this).bind('keypress', function (e) {
                var keyunicode = e.charCode || e.keyCode
                if (keyunicode == 115) { //if "s" key was pressed
                    stickytooltip.docktooltip($, $tooltip, e)
                }
            })
        }) //end dom ready
    }
}

//stickytooltip.init("targetElementSelector", "tooltipcontainer")
stickytooltip.init("*[data-tooltip]", "mystickytooltip")

var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-7489188-1']); _gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.async = true; ga.src = 'http://www.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();

/* The Great Cornholio Countdown, version: 1.00 (October 14th, 2010)
* Copyright (c) 2010 Lecho Buszczynski
* lecho@phatcat.eu
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* Requires: jQuery v?.?
*/
(function ($) {
    $.fn.tgcCountdown = function (options) {
        var settings = { counter: '[D] Days, [H]:[M]:[S]', counter_warning: '<span style="color: #F00;">[D] Days, [H]:[M]:[S]</span>', counter_expired: '<span style="color: #F00;">expired</span>', interval: 1000, warnonminutesleft: 60 };
        $.extend(settings, options);
        var target = $(this);
        var stamp = $(this).html();
        var date_e = false;
        var executer = false;
        var getSecondsDiff = function () {
            var secs = 0;
            var now = new Date();
            secs = date_e.getTime() - now.getTime();
            return (secs / 1000);
        }
        var getFormattedDiff = function () {
            var secs = getSecondsDiff();
            var counter = '';
            var val = '';
            if (secs < 0) {
                counterStop();
                return settings.counter_expired;
            } else if (secs < settings.warnonminutesleft * 60) {
                counter = settings.counter_warning;
            } else {
                counter = settings.counter;
            }
            val = new String(Math.floor(secs / 86400));

            counter = counter.replace('[D]', val);
            secs = secs % 86400;
            val = new String(Math.floor(secs / 3600));
            if (val.length == 1) {
                val = '0' + val;
            }
            counter = counter.replace('[H]', val);
            secs = secs % 3600;
            val = new String(Math.floor(secs / 60));
            if (val.length == 1) {
                val = '0' + val;
            }
            counter = counter.replace('[M]', val);
            secs = secs % 60;
            val = new String(Math.ceil(secs));
            if (val.length == 1) {
                val = '0' + val;
            }
            counter = counter.replace('[S]', val);
            return counter;
        }
        var counterUpdate = function () {
            target.html(getFormattedDiff());
        }
        var counterStart = function () {
            counterUpdate();
            executer = setInterval(function () { counterUpdate() }, settings.interval);
        }
        var counterStop = function () {
            clearInterval(executer);
        }
        if (/^[0-9]{14}$/.test(stamp)) {
            date_e = new Date(stamp.substr(0, 4), (stamp.substr(4, 2) - 1), stamp.substr(6, 2), stamp.substr(8, 2), stamp.substr(10, 2), stamp.substr(12, 2), 0);
            counterStart()
        }
    };
})(jQuery);




