function BookmarkPage()
   {
   title = document.title;
   url = window.location;
   
   	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
		
   }

// Ajax default return
function AjaxCommand_Callback(res)
{
    if (res.value != null && res.value.length >= 2)
    {
        if (res.value[0].length > 0)
        {
            document.getElementById(res.value[0]).innerHTML = res.value[1];
        }
    }

    if (res.value != null && res.value.length >= 4) {
        if (res.value[2].length > 0) {
            var status = res.value[4];
            if (status == "Information") status = "notice";
            else if (status == "Warning") status = "warning";
            else if (status == "Error") status = "error";
            else if (status == "Success") status = "success";
            var message = res.value[2];
            jQuery.noConflict();
            jQuery().toastmessage('showToast', {
                text: message,     // content of the item
                sticky: false,               // should the toast item sticky or not?
                position: 'middle-center',       // top-left, top-center, top-right, middle-left, middle-center, middle-right
                // Position of the toast container holding different toast.
                // Position can be set only once at the very first call,
                // changing the position after the first call does nothing
                type: status,        // notice, warning, error, success
                close: function() { }
            });
        }
    }   
}

// Dropdown Handling

var MDDropDownTimeout = 50;
var MDDropDownCloseTimer = 0;
var MDDropDownMenuItem = 0;

function MDDropDownOpen(id, closeFunction)
{
 MDDropDownCancelCloseTime();

 MDDropDownClose();

 MDDropDownSetDocumentOnClick(closeFunction);

 MDDropDownMenuItem = document.getElementById(id);
 MDDropDownMenuItem.style.display = 'block';

}

function MDDropDownClose()
{
 if(MDDropDownMenuItem) MDDropDownMenuItem.style.display = 'none';
}

function MDDropDownCloseTime()
{
 MDDropDownCancelCloseTime();
 MDDropDownCloseTimer = window.setTimeout(MDDropDownClose, MDDropDownTimeout);
}

function MDDropDownCancelCloseTime()
{
 if(MDDropDownCloseTimer)
 {
  window.clearTimeout(MDDropDownCloseTimer);
  MDDropDownCloseTimer = null;
 }
}

function MDDropDownSetDocumentOnClick(functionName)
{
	document.onclick = functionName;
}

// Clear element
function clearElement(elementName)
{
    // This function is used, because ie7 has a bug with the innerHTML = '' method
    document.getElementById(elementName).innerHTML='';
    document.getElementById(elementName).outerHTML='<div id="' + elementName + '"></div>';
}



/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 * @author Ariel Flesler
 * @version 1.4
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);
