
/* Comment Generated by Combres - Resource '~/js/MicrosoftMvcAjax.js' (Mode: Static) */
//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
// MicrosoftMvcAjax.js

Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_AjaxOptions=function(){return {};}
Sys.Mvc.InsertionMode=function(){};Sys.Mvc.InsertionMode.prototype = {replace:0,insertBefore:1,insertAfter:2}
Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode',false);Sys.Mvc.AjaxContext=function(request,updateTarget,loadingElement,insertionMode){this.$3=request;this.$4=updateTarget;this.$1=loadingElement;this.$0=insertionMode;}
Sys.Mvc.AjaxContext.prototype={$0:0,$1:null,$2:null,$3:null,$4:null,get_data:function(){if(this.$2){return this.$2.get_responseData();}else{return null;}},get_insertionMode:function(){return this.$0;},get_loadingElement:function(){return this.$1;},get_object:function(){var $0=this.get_response();return ($0)?$0.get_object():null;},get_response:function(){return this.$2;},set_response:function(value){this.$2=value;return value;},get_request:function(){return this.$3;},get_updateTarget:function(){return this.$4;}}
Sys.Mvc.AsyncHyperlink=function(){}
Sys.Mvc.AsyncHyperlink.handleClick=function(anchor,evt,ajaxOptions){evt.preventDefault();Sys.Mvc.MvcHelpers.$2(anchor.href,'post','',anchor,ajaxOptions);}
Sys.Mvc.MvcHelpers=function(){}
Sys.Mvc.MvcHelpers.$0=function($p0,$p1,$p2){if($p0.disabled){return null;}var $0=$p0.name;if($0){var $1=$p0.tagName.toUpperCase();var $2=encodeURIComponent($0);var $3=$p0;if($1==='INPUT'){var $4=$3.type;if($4==='submit'){return $2+'='+encodeURIComponent($3.value);}else if($4==='image'){return $2+'.x='+$p1+'&'+$2+'.y='+$p2;}}else if(($1==='BUTTON')&&($0.length)&&($3.type==='submit')){return $2+'='+encodeURIComponent($3.value);}}return null;}
Sys.Mvc.MvcHelpers.$1=function($p0){var $0=$p0.elements;var $1=new Sys.StringBuilder();var $2=$0.length;for(var $4=0;$4<$2;$4++){var $5=$0[$4];var $6=$5.name;if(!$6||!$6.length){continue;}var $7=$5.tagName.toUpperCase();if($7==='INPUT'){var $8=$5;var $9=$8.type;if(($9==='text')||($9==='password')||($9==='hidden')||((($9==='checkbox')||($9==='radio'))&&$5.checked)){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($8.value));$1.append('&');}}else if($7==='SELECT'){var $A=$5;var $B=$A.options.length;for(var $C=0;$C<$B;$C++){var $D=$A.options[$C];if($D.selected){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($D.value));$1.append('&');}}}else if($7==='TEXTAREA'){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent(($5.value)));$1.append('&');}}var $3=$p0._additionalInput;if($3){$1.append($3);$1.append('&');}return $1.toString();}
Sys.Mvc.MvcHelpers.$2=function($p0,$p1,$p2,$p3,$p4){if($p4.confirm){if(!confirm($p4.confirm)){return;}}if($p4.url){$p0=$p4.url;}if($p4.httpMethod){$p1=$p4.httpMethod;}if($p2.length>0&&!$p2.endsWith('&')){$p2+='&';}$p2+='X-Requested-With=XMLHttpRequest';var $0=$p1.toUpperCase();var $1=($0==='GET'||$0==='POST');if(!$1){$p2+='&';$p2+='X-HTTP-Method-Override='+$0;}var $2='';if($0==='GET'||$0==='DELETE'){if($p0.indexOf('?')>-1){if(!$p0.endsWith('&')){$p0+='&';}$p0+=$p2;}else{$p0+='?';$p0+=$p2;}}else{$2=$p2;}var $3=new Sys.Net.WebRequest();$3.set_url($p0);if($1){$3.set_httpVerb($p1);}else{$3.set_httpVerb('POST');$3.get_headers()['X-HTTP-Method-Override']=$0;}$3.set_body($2);if($p1.toUpperCase()==='PUT'){$3.get_headers()['Content-Type']='application/x-www-form-urlencoded;';}$3.get_headers()['X-Requested-With']='XMLHttpRequest';var $4=null;if($p4.updateTargetId){$4=$get($p4.updateTargetId);}var $5=null;if($p4.loadingElementId){$5=$get($p4.loadingElementId);}var $6=new Sys.Mvc.AjaxContext($3,$4,$5,$p4.insertionMode);var $7=true;if($p4.onBegin){$7=$p4.onBegin($6)!==false;}if($5){Sys.UI.DomElement.setVisible($6.get_loadingElement(),true);}if($7){$3.add_completed(Function.createDelegate(null,function($p1_0){
Sys.Mvc.MvcHelpers.$3($3,$p4,$6);}));$3.invoke();}}
Sys.Mvc.MvcHelpers.$3=function($p0,$p1,$p2){$p2.set_response($p0.get_executor());if($p1.onComplete&&$p1.onComplete($p2)===false){return;}var $0=$p2.get_response().get_statusCode();if(($0>=200&&$0<300)||$0===304||$0===1223){if($0!==204&&$0!==304&&$0!==1223){var $1=$p2.get_response().getResponseHeader('Content-Type');if(($1)&&($1.indexOf('application/x-javascript')!==-1)){eval($p2.get_data());}else{Sys.Mvc.MvcHelpers.updateDomElement($p2.get_updateTarget(),$p2.get_insertionMode(),$p2.get_data());}}if($p1.onSuccess){$p1.onSuccess($p2);}}else{if($p1.onFailure){$p1.onFailure($p2);}}if($p2.get_loadingElement()){Sys.UI.DomElement.setVisible($p2.get_loadingElement(),false);}}
Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:target.innerHTML=content;break;case 1:if(content&&content.length>0){target.innerHTML=content+target.innerHTML.trimStart();}break;case 2:if(content&&content.length>0){target.innerHTML=target.innerHTML.trimEnd()+content;}break;}}}
Sys.Mvc.AsyncForm=function(){}
Sys.Mvc.AsyncForm.handleClick=function(form,evt){var $0=Sys.Mvc.MvcHelpers.$0(evt.target,evt.offsetX,evt.offsetY);form._additionalInput = $0;}
Sys.Mvc.AsyncForm.handleSubmit=function(form,evt,ajaxOptions){evt.preventDefault();var $0=form.validationCallbacks;if($0){for(var $2=0;$2<$0.length;$2++){var $3=$0[$2];if(!$3()){return;}}}var $1=Sys.Mvc.MvcHelpers.$1(form);Sys.Mvc.MvcHelpers.$2(form.action,form.method||'post',$1,form,ajaxOptions);}
Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext');Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink');Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers');Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm');
// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
// -----------------------------------
;


/* Comment Generated by Combres - Resource '~/js/omniturecustomclick.js' (Mode: Static) */

function OmnitureClick(clickname, ltv, pagename) {
    if (typeof (window['s']) != 'undefined' && typeof (window['s']) != 'string') {
        // Put the click name in an sProp if defined
        var addClickNameProp = typeof (window['CustomClickPropNumber']) != 'undefined';
        if (addClickNameProp) {
            eval('s.prop' + CustomClickPropNumber + ' = clickname;s.eVar' + CustomClickPropNumber + ' = clickname;');
            var ltvToAdd = 'prop' + CustomClickPropNumber + ',eVar' + CustomClickPropNumber;
            if (ltv && ltv.length > 0)
                ltv = ltv + ',' + ltvToAdd;
            else
                ltv = ltvToAdd;
        }

        // linkTrackVars
        if (ltv)
            s.linkTrackVars = ltv;
        else
            s.linkTrackVars = '';

        // click name / page name
        var c;
        if (pagename)
            c = pagename + '.' + clickname;
        else
            c = clickname;

        // call the click
        s.tl(this, 'o', c);
        if (addClickNameProp) { // clear the custom click prop so it is not sent on the automatic exit link tracking
            eval('s.prop' + CustomClickPropNumber + ' = null;s.eVar' + CustomClickPropNumber + ' = null;');
        }
    }
    return true;
}

function OmniturePageView(pagename) {
    s.pageName = pagename;
    s.t();
};


/* Comment Generated by Combres - Resource '~/js/common.js' (Mode: Static) */
/// <reference path="jquery-1.4.1.min.js" />

function breakIFrame() {
    if (self != top) {
        top.location.href = self.location.href;
    }
}

function showseolinks() {
    $("#aseoopen").hide();
    $("#aseoclose").show();
    $("#headerdrophider").show();
    OmnitureClick("HeaderNavExpand");
}

function hideseolinks() {
    $("#aseoopen").show();
    $("#aseoclose").hide();
    $("#headerdrophider").hide();
}

function setBodyHeight() { // expand content to user's available screen height
    //alert("navigator.userAgent = " + navigator.userAgent); // test  
    //alert("document.documentElement.clientHeight = " + document.documentElement.clientHeight); // test
    var minimumHeight = document.documentElement.clientHeight - 236; // subtract header and footer height  

    if (minimumHeight < 554) {
        minimumHeight = "554"; // Firefox, Chrome, Safari
    }
    if (navigator.userAgent.indexOf("MSIE 8") > -1) {
        minimumHeight += 16; // IE 8        
    }
    if (navigator.userAgent.indexOf("MSIE 7") > -1 || navigator.userAgent.indexOf("Opera") > -1) {
        minimumHeight += 15; // IE 7, Opera             
    }
    if (navigator.userAgent.indexOf("MSIE 6") > -1) {
        minimumHeight += 13; // IE 6      
        // IE6 doesn't support minimum height
        document.getElementById("shell").style.height = minimumHeight + "px";
    } else {
        if (typeof interstitialOn != "undefined" && interstitialOn && (navigator.userAgent.indexOf("MSIE") > -1)) {
            //Interstitial with IE7, 8 - don't expand Shell
            document.getElementById("shell").style.minHeight = 900 + "px";
        } else {
            document.getElementById("shell").style.minHeight = minimumHeight + "px";
        }
    }
}

function autofitIframe(id) {
    try {
        var ctrl = parent.document.getElementById(id);
        if (ctrl) {
            if (!window.opera && !document.mimeType && document.all && document.getElementById) {
                ctrl.style.height = this.document.body.offsetHeight + "px";
            }
            else if (document.getElementById) {
                ctrl.style.height = this.document.body.scrollHeight + "px";
            }
        }
    }
    catch (err)
{ }
}

/*
* Search
*/

// Set visibility based on current value of malt result counters
function SetNoResultsVisibility() {
    if (_numMaltsWithResults == 0 && _numMaltsNoResults >= _numMalts) {
        $('#SearchNoResults').show();
    }
}

/*
* YouTube
*/

function PopRankVideo(topicID) {
    var iMyLeft = (window.screen.availWidth / 2) - (348 + 10);
    var iMyHeight = (window.screen.availHeight);
    window.open('/rankyoutube.aspx?topicid=' + topicID, 'ratevideo', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=885,height=' + iMyHeight + ',left=' + iMyLeft + ',top=0');
}

function PopVideoPlayer(URL) {
    var tubeWin = window.open(URL, 'playvideo', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=835,height=620');
    tubeWin.focus();
}

/*
* Error reporting
*/

window.onerror = window_onerror;

function window_onerror(message, file, lineNumber) {
    if (_reportClientErrors) {
        reportError(message, file, lineNumber);
    }
}

function reportException(err) {
    if (_reportClientErrors) {
        //lineNumber & stack avail only in FF
        reportError(err.description, null, err.lineNumber, e.stack);
    }
}

var _numErrors = 0;
function reportError(message, file, lineNumber, trace) {
    try {
        if (++_numErrors > 3)
            return;
        var url = window.location;
        var queryString = '/Error.ashx?bugMessage=' + escape(message)
      + '&bugFile=' + escape(file)
      + '&bugUrl=' + escape(url)
 	  + '&bugLineNumber=' + lineNumber
      + '&trace=' + escape(trace)
      + '&r=' + Math.random();
        var img = new Image();
        img.src = queryString;
        return true;
    } catch (err) {
        //do nothing
    }
}

// Firebug graceful degredation from http://getfirebug.com/firebug/firebugx.js
if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() { }
}


/* Interstitial */

function closeInterstitial() { //Closes ad and screen when close button is clicked
    $('#interstitial-ad-2').remove(); //Removes interstitial from DOM in order to stop audio playback
    $('#interstitial-wrapper').remove();
    $('#interstitial-screen').fadeOut('slow'); //Fades out interstitial background tint
    $('iframe').fadeIn().css('visibility', 'visible'); //Makes all other ads on the page display after interstitial is closed
    $('#ctl00_Header1_SearchBox1_TextBoxSearchTerm_searchbox').focus(); //Returns focus to search box at top of page after interstitial is closed

    return false;
}

$(document).ready(function() {
    if (navigator.userAgent.indexOf("MSIE 6") > -1) {
        //Prevents script from adding 100% height, which isn't functional in IE6
    } else {
        $('#interstitial-screen').css('height', '100%');
    }
});


/* END Interstitial */

/* bread crumb expansion */
function togglebc(speed) {
    $("#titlelink").toggleClass("bcexpanded");
    var bc = $("#expapand_breadcrumb_expanded");
    if (bc.is(":visible")) {
        bc.fadeTo(speed, 0).slideUp(speed);
    } else {
        bc.slideDown(speed).fadeTo(speed, 1);
    }
}

/* read more link */
function toggleDocView(jElement, scrollToElement) {

    jElement.children().toggle();

    if (scrollToElement) {
        try {
            scroll(0, parseInt(jElement.prev(".doctitle").offset().top, 10) - 100);
        } catch (e1) { }
    }
}

/* citation link */
function showCitation(element) {

    var thisDocWrapper = $(element).closest('div.docwrapper');
    if (thisDocWrapper) {
        // Expand doc
        if (thisDocWrapper.find('div#populate_document_textfull.rm_full').is(':hidden')) {
            toggleDocView(thisDocWrapper.children("div.doccontentwrapper"));
        }

        // Scroll to citation for that doc
        scroll(0, parseInt(thisDocWrapper.find("div#TopicCitationDiv").offset().top, 10) - 20);
    }

    pagetoolsflyclose(element);
}


;


/* Comment Generated by Combres - Resource '~/js/FeaturedTopics.js' (Mode: Static) */
/// <reference path="jquery-1.4.1.min.js" />
/******DECLARATIONS***************************/
var textXmlMime = "text/xml";
var responseValueTagName = "string";
var HEAD_HTML, FOOT_HTML;
var req2;        //THE XML REQUEST OBJECT
var itemlist2;   //the list of strings to fill the dropdown
var _clientid;  //the client id to the aspx control
var _hiddenid;  //client id of the hiddenfield for the search term

var timerID = null;
var timerOn = false;
var timecount = 125;   // Change this to the time delay that you desire 
var ob = null;

function fteventcollection(num, topicnum) {
    TabMe(ob, num);
    GetNextTopic(topicnum);
}

function fttimerstart(theob, num, topicnum) {
    ob = theob;
    if (timerOn == false && FT_SELECTED != topicnum) {
        timerID = setTimeout(function() {
            fteventcollection(num, topicnum);
        }, timecount);
        timerOn = true;
    }
}

function fttimerclear() {
    if (timerOn) {
        clearTimeout(timerID);
        timerID = null;
        timerOn = false;
    }
}

/**********string builders**************/

//create req2uest url to WCF service
function createAFRequestUrl2(topicid) {

    return "/Home/FeaturedTopic/" + topicid + ".ashx";
}

//create the dropdown's div client id
function createDivId(clientid) {
    return clientid + "_featuredTopic";
}

//create the SOAP envelope to the ASMX service
function createEnvelope(startswith, count) {
    return '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><GetAutoFillList xmlns="http://tempuri.org/"><prefixText>' + startswith + '</prefixText><count>' + count + '</count></GetAutoFillList></soap12:Body></soap12:Envelope>';
}
/************UI FUNCTIONS******************/

//handle up, down and enter keys
function RegisterClient(clientid) {
    _clientid = clientid;
}

/*************UTILS**********************/
function getElementsByClass(searchClass, tag) {

    var classElements = new Array();
    var els = document.getElementsByTagName(tag);
    var elsLen = els.length;
    for (i = 0, j = 0; i < elsLen; i++) {
        if (searchClass == els[i].className) {
            classElements[j] = els[i];
            j++;
        }
    }

    return classElements;

}

function TabMe(ob, fromleft) {
    if (ob.className != "offbehind")
        return;
    var onbc = getElementsByClass("onbehind", "*");
    for (var idx in onbc) { onbc[idx].className = "offbehind"; }

    var onbcf = getElementsByClass("onbehindfirst", "*");
    for (var idx in onbcf) { onbcf[idx].className = "offbehind"; }

    var onbcl = getElementsByClass("onbehindlast", "*");
    for (var idx in onbcl) { onbcl[idx].className = "offbehind"; }

    var offbc = getElementsByClass("offbehind", "*");
    if (offbc[0] == ob) { ob.className = "onbehindfirst"; }
    else if (offbc[9] == ob) { ob.className = "onbehindlast"; }
    else { ob.className = "onbehind"; }

    var tabbottom = getElementsByClass("bottomzone", "span");
    if (tabbottom.length <= 0) { tabbottom = getElementsByClass("bottomzoneleft", "span"); if (tabbottom.length <= 0) { tabbottom = getElementsByClass("bottomzoneright", "span"); } }
    if (tabbottom.length <= 0) { alert("Something's wrong... Couldn't find the bottomzone"); }
    if (fromleft == 0) { tabbottom[0].className = "bottomzoneleft"; }
    else if (fromleft == 9) { tabbottom[0].className = "bottomzoneright"; }
    else { tabbottom[0].className = "bottomzone"; }
    var leftoffset = fromleft * 94;
    tabbottom[0].style.left = leftoffset + "px";
}

//get the event source (cross browser)
function getEventSource(ev) {
    var res = null;
    if (ev && ev.target)			//Moz
    {
        res = ev.target;
    }

    if (!res && window.event)	//IE
    {
        res = window.event.srcElement;
    }

    return res;
}

//reset variables
function resetAutoFill() {
    tbstr = "";
    req2 = null;
    pos = -1;
}

//create an XMLHTTPRequest (cross browser)
function createrequest2() {
    var ua = navigator.userAgent.toLowerCase();
    if (!window.ActiveXObject)
        req2 = new XMLHttpRequest();
    else if (ua.indexOf('msie 5') == -1)
        req2 = new ActiveXObject("Msxml2.XMLHTTP");
    else
        req2 = new ActiveXObject("Microsoft.XMLHTTP");
}

//create an XMLDocument (cross browser)
function createXmlDoc() {
    var doc;

    try {
        doc = new DOMParser();
    }
    catch (e) {
        doc = new ActiveXObject("Microsoft.XMLDOM");
    }

    if (doc)
        doc.async = false;

    return doc;
}

//get event's keycode (cross browser)
function getKeyCode(e) {
    var key;
    if (window.event)
        key = window.event.keyCode;
    else
        key = e.which;
    return key;
}


//send the akax req2uest to update the list 
//based on the current searchbox value
function GetNextTopic(topicid) {
    //get req2uest
    createrequest2();

    if (!req2)
        return;

    //open the req2uest to the web service
    req2.open("GET", createAFRequestUrl2(topicid));

    //set up onreadystatechange event
    req2.onreadystatechange = handleReqProgress2;

    //send the req2uest
    req2.send(null);

    //hack for async calls in FF without firebug or when firebug's dissabled
    try //breaks in IE 
    {
        if (req2.onreadystatechange == null)
            handleReqProgress2();
    }
    catch (e)
    { }
}

//handle the onreadystatechange event of the xmlhttpreq2uest
function handleReqProgress2() {
    //we only care when it's done
    if (!req2 || req2.readyState != 4)
        return;

    //make sure there's response text
    if (req2.responseText) {
        //get the returned object from the response's json
        //the list is actually a member of the object
        var _list = eval('(' + req2.responseText + ')');
        //make sure there's a list
        if (_list)
            itemlist2 = _list; //assign to itemlist2
        else
            itemlist2 = null;    //or make sure its empty
    }

    //write results or hide the list
    if (itemlist2) {
        writeList2();
    }
}

//write contents of itemlist2 to the dropdown list
function writeList2() {
    if (itemlist2) {
        SetHeroImage(itemlist2.HeroUrl, "Learn more about " + itemlist2.PreferredName);
        SetHeroLink(itemlist2.TopicUrl);
        SetHeroImageCaption(itemlist2.HeroTitle + ". " + itemlist2.HeroSource + " (" + itemlist2.HeroAttribution + ")");
        SetTopicTitle("<a href=\"" + itemlist2.TopicUrl + "\">" + itemlist2.Caption + "</a>");

        var byline = "";
        if (itemlist2.DocPublication)
            byline += itemlist2.DocPublication;
        SetTopicText("<p><strong>" + byline + "&nbsp;</strong></p>" + itemlist2.Text + "  <a class=\"fwb\" href=\"" + itemlist2.TopicUrl + "\">Read more</a>");
        SetRelatedTopicsList(itemlist2.RelatedTopics);

        FT_SELECTED = itemlist2.TopicId;
    }
}

/*-----     setting controls html --------------*/

function SetHeroImage(url, alt) {
    var hi = document.getElementById(FT_IMG_HERO);
    if (!hi)
        return;
    hi.src = url.replace(/&amp;/g, "&");

    hi.alt = alt;
    hi.title = alt;
}

function SetHeroLink(url) {
    var hl = document.getElementById(FT_LINK_HERO);
    if (!hl)
        return;
    hl.href = url;
}

function SetHeroImageCaption(text) {
    var hic = document.getElementById(FT_P_HEROCAPTION);
    if (!hic)
        return;
    hic.innerHTML = text;
}

function SetTopicTitle(title) {
    var ttl = document.getElementById(FT_DIV_TITLE);
    if (!ttl)
        return;
    ttl.innerHTML = title;
}

function SetTopicText(text) {
    var txt = document.getElementById(FT_DIV_TEXT);
    if (!txt)
        return;
    txt.innerHTML = text;
}

function SetRelatedTopicsList(rtlist) {
    var lst = document.getElementById(FT_DIV_RT);
    if (!lst)
        return;
    if (!rtlist) {
        lst.innerHTML = "";
        return;
    }
    var str = "";
    for (var x = 0; (x < rtlist.length) && (x < 5); x++) {
        if (0 == x) {
            str += "<h3>See also:</h3><ul id='featuredtopicsrelatedtopicslist'>";
        }
        str += "<li><a href='";
        str += rtlist[x][1];
        str += "' >";
        str += rtlist[x][0];
        str += "</a></li> ";
    }
    /* The space after the closing </li> tag is vitally important to page layout. Don't remove it.*/
    str = str + "</ul>";
    lst.innerHTML = str;
};


/* Comment Generated by Combres - Resource '~/js/maltmvc.js' (Mode: Static) */
/// <reference path="jquery-1.4.1.min.js" />
var _numMalts = 0;
var _numMaltsWithResults = 0;
var _numMaltsNoResults = 0;

function BuildResults(data, resultElement, templateElementName, waitElement, maltWrapElement) {
    $("#" + waitElement).hide();
    if (data == null || data.Malts == null || data.Malts.length == 0) {
        $("#" + maltWrapElement).hide();
        _numMaltsNoResults++;
    }
    else {
        $("#" + resultElement).setTemplate($("#" + templateElementName).html(), [], {filter_data: false});
        $("#" + resultElement).processTemplate(data);
        FixBold(resultElement);
        _numMaltsWithResults++;
    }

    // When all malts are ready to display show/hide the "no results message"
    if ((_numMaltsWithResults + _numMaltsNoResults) == _numMalts) {
        SetNoResultsVisibility();
    }
}

function GetMalt(maltParameters, resultElement, templateElementName, waitElement, maltWrapElement, numResults) {
    $.post("/SearchMalt.aspx", maltParameters, function(data) {
        BuildResults(data, resultElement, templateElementName, waitElement, maltWrapElement);
    }, "json");
}

function FixBold(resultElement) {
    var $teasers = $(".maltarticlewrap");
    FixBoldInJQ($teasers);

    var $titles = $(".maltlink");
    FixBoldInJQ($titles);

    var $titles = $(".maltbyline");
    FixBoldInJQ($titles);
}

function FixBoldInJQ($jq) {
    if ($jq && $jq.length > 0) {
        for (var i = 0; i < $jq.length; i++) {
            $jq[i].innerHTML = $jq[i].innerHTML.replace(/&lt;strong&gt;/gi, '<strong>').replace(/&lt;\/strong&gt;/gi, '</strong>').replace(/&amp;/gi, '&');
        }
    }
}
;


/* Comment Generated by Combres - Resource '~/js/jquery-jtemplates.js' (Mode: Static) */
/* jTemplates 0.7.8 (http://jtemplates.tpython.com) Copyright (c) 2009 Tomasz Gloc */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('a(37.b&&!37.b.38){(9(b){6 m=9(s,A,f){5.1M=[];5.1u={};5.2p=E;5.1N={};5.1c={};5.f=b.1m({1Z:1f,3a:1O,2q:1f,2r:1f,3b:1O,3c:1O},f);5.1v=(5.f.1v!==F)?(5.f.1v):(13.20);5.Y=(5.f.Y!==F)?(5.f.Y):(13.3d);5.3e(s,A);a(s){5.1w(5.1c[\'21\'],A,5.f)}5.1c=E};m.y.2s=\'0.7.8\';m.R=1O;m.y.3e=9(s,A){6 2t=/\\{#14 *(\\w*?)( .*)*\\}/g;6 22,1x,M;6 1y=E;6 2u=[];2v((22=2t.3N(s))!=E){1y=2t.1y;1x=22[1];M=s.2w(\'{#/14 \'+1x+\'}\',1y);a(M==-1){C j Z(\'15: m "\'+1x+\'" 2x 23 3O.\');}5.1c[1x]=s.2y(1y,M);2u[1x]=13.2z(22[2])}a(1y===E){5.1c[\'21\']=s;c}N(6 i 24 5.1c){a(i!=\'21\'){5.1N[i]=j m()}}N(6 i 24 5.1c){a(i!=\'21\'){5.1N[i].1w(5.1c[i],b.1m({},A||{},5.1N||{}),b.1m({},5.f,2u[i]));5.1c[i]=E}}};m.y.1w=9(s,A,f){a(s==F){5.1M.B(j 1g(\'\',1,5));c}s=s.U(/[\\n\\r]/g,\'\');s=s.U(/\\{\\*.*?\\*\\}/g,\'\');5.2p=b.1m({},5.1N||{},A||{});5.f=j 2A(f);6 p=5.1M;6 1P=s.1h(/\\{#.*?\\}/g);6 16=0,M=0;6 e;6 1i=0;6 25=0;N(6 i=0,l=(1P)?(1P.V):(0);i<l;++i){6 17=1P[i];a(1i){M=s.2w(\'{#/1z}\');a(M==-1){C j Z("15: 3P 1Q 3f 1z.");}a(M>16){p.B(j 1g(s.2y(16,M),1,5))}16=M+11;1i=0;i=b.3Q(\'{#/1z}\',1P);1R}M=s.2w(17,16);a(M>16){p.B(j 1g(s.2y(16,M),1i,5))}6 3R=17.1h(/\\{#([\\w\\/]+).*?\\}/);6 26=I.$1;2B(26){q\'3S\':++25;p.27();q\'a\':e=j 1A(17,p);p.B(e);p=e;D;q\'J\':p.27();D;q\'/a\':2v(25){p=p.28();--25}q\'/N\':q\'/29\':p=p.28();D;q\'29\':e=j 1n(17,p,5);p.B(e);p=e;D;q\'N\':e=2a(17,p,5);p.B(e);p=e;D;q\'1R\':q\'D\':p.B(j 18(26));D;q\'2C\':p.B(j 2D(17,5.2p));D;q\'h\':p.B(j 2E(17));D;q\'2F\':p.B(j 2G(17));D;q\'3T\':p.B(j 1g(\'{\',1,5));D;q\'3U\':p.B(j 1g(\'}\',1,5));D;q\'1z\':1i=1;D;q\'/1z\':a(m.R){C j Z("15: 3V 2H 3f 1z.");}D;2I:a(m.R){C j Z(\'15: 3W 3X: \'+26+\'.\');}}16=M+17.V}a(s.V>16){p.B(j 1g(s.3Y(16),1i,5))}};m.y.K=9(d,h,z,H){++H;6 $T=d,2b,2c;a(5.f.3b){$T=5.1v(d,{2d:(5.f.3a&&H==1),1S:5.f.1Z},5.Y)}a(!5.f.3c){2b=5.1u;2c=h}J{2b=5.1v(5.1u,{2d:(5.f.2q),1S:1f},5.Y);2c=5.1v(h,{2d:(5.f.2q&&H==1),1S:1f},5.Y)}6 $P=b.1m({},2b,2c);6 $Q=(z!=F)?(z):({});$Q.2s=5.2s;6 19=\'\';N(6 i=0,l=5.1M.V;i<l;++i){19+=5.1M[i].K($T,$P,$Q,H)}--H;c 19};m.y.2J=9(1T,1o){5.1u[1T]=1o};13=9(){};13.3d=9(3g){c 3g.U(/&/g,\'&3Z;\').U(/>/g,\'&3h;\').U(/</g,\'&3i;\').U(/"/g,\'&40;\').U(/\'/g,\'&#39;\')};13.20=9(d,1B,Y){a(d==E){c d}2B(d.2K){q 2A:6 o={};N(6 i 24 d){o[i]=13.20(d[i],1B,Y)}a(!1B.1S){a(d.41("2L"))o.2L=d.2L}c o;q 42:6 o=[];N(6 i=0,l=d.V;i<l;++i){o[i]=13.20(d[i],1B,Y)}c o;q 2M:c(1B.2d)?(Y(d)):(d);q 43:a(1B.1S){a(m.R)C j Z("15: 44 45 23 46.");J c F}2I:c d}};13.2z=9(2e){a(2e===E||2e===F){c{}}6 o=2e.47(/[= ]/);a(o[0]===\'\'){o.48()}6 2N={};N(6 i=0,l=o.V;i<l;i+=2){2N[o[i]]=o[i+1]}c 2N};6 1g=9(2O,1i,14){5.2f=2O;5.3j=1i;5.1d=14};1g.y.K=9(d,h,z,H){6 2g=5.2f;a(!5.3j){6 2P=5.1d;6 $T=d;6 $P=h;6 $Q=z;2g=2g.U(/\\{(.*?)\\}/g,9(49,3k){1C{6 1D=10(3k);a(1E 1D==\'9\'){a(2P.f.1Z||!2P.f.2r){c\'\'}J{1D=1D($T,$P,$Q)}}c(1D===F)?(""):(2M(1D))}1F(e){a(m.R){a(e 1G 18)e.1j="4a";C e;}c""}})}c 2g};6 1A=9(L,1H){5.2h=1H;L.1h(/\\{#(?:J)*a (.*?)\\}/);5.3l=I.$1;5.1p=[];5.1q=[];5.1I=5.1p};1A.y.B=9(e){5.1I.B(e)};1A.y.28=9(){c 5.2h};1A.y.27=9(){5.1I=5.1q};1A.y.K=9(d,h,z,H){6 $T=d;6 $P=h;6 $Q=z;6 19=\'\';1C{6 2Q=(10(5.3l))?(5.1p):(5.1q);N(6 i=0,l=2Q.V;i<l;++i){19+=2Q[i].K(d,h,z,H)}}1F(e){a(m.R||(e 1G 18))C e;}c 19};2a=9(L,1H,14){a(L.1h(/\\{#N (\\w+?) *= *(\\S+?) +4b +(\\S+?) *(?:12=(\\S+?))*\\}/)){L=\'{#29 2a.3m 3n \'+I.$1+\' 2H=\'+(I.$2||0)+\' 1Q=\'+(I.$3||-1)+\' 12=\'+(I.$4||1)+\' u=$T}\';c j 1n(L,1H,14)}J{C j Z(\'15: 4c 4d "3o": \'+L);}};2a.3m=9(i){c i};6 1n=9(L,1H,14){5.2h=1H;5.1d=14;L.1h(/\\{#29 (.+?) 3n (\\w+?)( .+)*\\}/);5.3p=I.$1;5.x=I.$2;5.W=I.$3||E;5.W=13.2z(5.W);5.1p=[];5.1q=[];5.1I=5.1p};1n.y.B=9(e){5.1I.B(e)};1n.y.28=9(){c 5.2h};1n.y.27=9(){5.1I=5.1q};1n.y.K=9(d,h,z,H){1C{6 $T=d;6 $P=h;6 $Q=z;6 1r=10(5.3p);6 1U=[];6 1J=1E 1r;a(1J==\'3q\'){6 2R=[];b.1e(1r,9(k,v){1U.B(k);2R.B(v)});1r=2R}6 u=(5.W.u!==F)?(10(5.W.u)):(($T!=E)?($T):({}));6 s=1V(10(5.W.2H)||0),e;6 12=1V(10(5.W.12)||1);a(1J!=\'9\'){e=1r.V}J{a(5.W.1Q===F||5.W.1Q===E){e=1V.4e}J{e=1V(10(5.W.1Q))+((12>0)?(1):(-1))}}6 19=\'\';6 i,l;a(5.W.1W){6 2S=s+1V(10(5.W.1W));e=(2S>e)?(e):(2S)}a((e>s&&12>0)||(e<s&&12<0)){6 1K=0;6 3r=(1J!=\'9\')?(4f.4g((e-s)/12)):F;6 1s,1k;N(;((12>0)?(s<e):(s>e));s+=12,++1K){1s=1U[s];a(1J!=\'9\'){1k=1r[s]}J{1k=1r(s);a(1k===F||1k===E){D}}a((1E 1k==\'9\')&&(5.1d.f.1Z||!5.1d.f.2r)){1R}a((1J==\'3q\')&&(1s 24 2A)){1R}6 3s=u[5.x];u[5.x]=1k;u[5.x+\'$3t\']=s;u[5.x+\'$1K\']=1K;u[5.x+\'$3u\']=(1K==0);u[5.x+\'$3v\']=(s+12>=e);u[5.x+\'$3w\']=3r;u[5.x+\'$1U\']=(1s!==F&&1s.2K==2M)?(5.1d.Y(1s)):(1s);u[5.x+\'$1E\']=1E 1k;N(i=0,l=5.1p.V;i<l;++i){1C{19+=5.1p[i].K(u,h,z,H)}1F(2T){a(2T 1G 18){2B(2T.1j){q\'1R\':i=l;D;q\'D\':i=l;s=e;D;2I:C e;}}J{C e;}}}1l u[5.x+\'$3t\'];1l u[5.x+\'$1K\'];1l u[5.x+\'$3u\'];1l u[5.x+\'$3v\'];1l u[5.x+\'$3w\'];1l u[5.x+\'$1U\'];1l u[5.x+\'$1E\'];1l u[5.x];u[5.x]=3s}}J{N(i=0,l=5.1q.V;i<l;++i){19+=5.1q[i].K($T,h,z,H)}}c 19}1F(e){a(m.R||(e 1G 18))C e;c""}};6 18=9(1j){5.1j=1j};18.y=Z;18.y.K=9(d){C 5;};6 2D=9(L,A){L.1h(/\\{#2C (.*?)(?: 4h=(.*?))?\\}/);5.1d=A[I.$1];a(5.1d==F){a(m.R)C j Z(\'15: 4i 3o 2C: \'+I.$1);}5.3x=I.$2};2D.y.K=9(d,h,z,H){6 $T=d;6 $P=h;1C{c 5.1d.K(10(5.3x),h,z,H)}1F(e){a(m.R||(e 1G 18))C e;}c\'\'};6 2E=9(L){L.1h(/\\{#h 1T=(\\w*?) 1o=(.*?)\\}/);5.x=I.$1;5.2f=I.$2};2E.y.K=9(d,h,z,H){6 $T=d;6 $P=h;6 $Q=z;1C{h[5.x]=10(5.2f)}1F(e){a(m.R||(e 1G 18))C e;h[5.x]=F}c\'\'};6 2G=9(L){L.1h(/\\{#2F 4j=(.*?)\\}/);5.2U=10(I.$1);5.2V=5.2U.V;a(5.2V<=0){C j Z(\'15: 2F 4k 4l 4m\');}5.2W=0;5.2X=-1};2G.y.K=9(d,h,z,H){6 2Y=b.O(z,\'1X\');a(2Y!=5.2X){5.2X=2Y;5.2W=0}6 i=5.2W++%5.2V;c 5.2U[i]};b.1a.1w=9(s,A,f){a(s.2K===m){c b(5).1e(9(){b.O(5,\'2i\',s);b.O(5,\'1X\',0)})}J{c b(5).1e(9(){b.O(5,\'2i\',j m(s,A,f));b.O(5,\'1X\',0)})}};b.1a.4n=9(1L,A,f){6 s=b.2Z({1t:1L,1Y:1f}).3y;c b(5).1w(s,A,f)};b.1a.4o=9(30,A,f){6 s=b(\'#\'+30).2O();a(s==E){s=b(\'#\'+30).3z();s=s.U(/&3i;/g,"<").U(/&3h;/g,">")}s=b.4p(s);s=s.U(/^<\\!\\[4q\\[([\\s\\S]*)\\]\\]>$/3A,\'$1\');s=s.U(/^<\\!--([\\s\\S]*)-->$/3A,\'$1\');c b(5).1w(s,A,f)};b.1a.4r=9(){6 1W=0;b(5).1e(9(){a(b.2j(5)){++1W}});c 1W};b.1a.4s=9(){b(5).3B();c b(5).1e(9(){b.3C(5,\'2i\')})};b.1a.2J=9(1T,1o){c b(5).1e(9(){6 t=b.2j(5);a(t===F){a(m.R)C j Z(\'15: m 2x 23 3D.\');J c}t.2J(1T,1o)})};b.1a.31=9(d,h){c b(5).1e(9(){6 t=b.2j(5);a(t===F){a(m.R)C j Z(\'15: m 2x 23 3D.\');J c}b.O(5,\'1X\',b.O(5,\'1X\')+1);b(5).3z(t.K(d,h,5,0))})};b.1a.4t=9(1L,h,G){6 X=5;G=b.1m({1j:\'4u\',1Y:1O,32:1f},G);b.2Z({1t:1L,1j:G.1j,O:G.O,3E:G.3E,1Y:G.1Y,32:G.32,3F:G.3F,4v:\'4w\',4x:9(d){6 r=b(X).31(d,h);a(G.2k){G.2k(r)}},4y:G.4z,4A:G.4B});c 5};6 2l=9(1t,h,2m,2n,1b,G){5.3G=1t;5.1u=h;5.3H=2m;5.3I=2n;5.1b=1b;5.3J=E;5.33=G||{};6 X=5;b(1b).1e(9(){b.O(5,\'34\',X)});5.35()};2l.y.35=9(){5.3K();a(5.1b.V==0){c}6 X=5;b.4C(5.3G,5.3I,9(d){6 r=b(X.1b).31(d,X.1u);a(X.33.2k){X.33.2k(r)}});5.3J=4D(9(){X.35()},5.3H)};2l.y.3K=9(){5.1b=b.3L(5.1b,9(o){a(b.4E.4F){6 n=o.36;2v(n&&n!=4G){n=n.36}c n!=E}J{c o.36!=E}})};b.1a.4H=9(1t,h,2m,2n,G){c j 2l(1t,h,2m,2n,5,G)};b.1a.3B=9(){c b(5).1e(9(){6 2o=b.O(5,\'34\');a(2o==E){c}6 X=5;2o.1b=b.3L(2o.1b,9(o){c o!=X});b.3C(5,\'34\')})};b.1m({38:9(s,A,f){c j m(s,A,f)},4I:9(1L,A,f){6 s=b.2Z({1t:1L,1Y:1f}).3y;c j m(s,A,f)},2j:9(z){c b.O(z,\'2i\')},4J:9(14,O,3M){c 14.K(O,3M,F,0)},4K:9(1o){m.R=1o}})})(b)}',62,295,'|||||this|var|||function|if|jQuery|return|||settings||param||new|||Template|||node|case||||extData|||_name|prototype|element|includes|push|throw|break|null|undefined|options|deep|RegExp|else|get|oper|se|for|data|||DEBUG_MODE|||replace|length|_option|that|f_escapeString|Error|eval||step|TemplateUtils|template|jTemplates|ss|this_op|JTException|ret|fn|objs|_templates_code|_template|each|false|TextNode|match|literalMode|type|cval|delete|extend|opFOREACH|value|_onTrue|_onFalse|fcount|ckey|url|_param|f_cloneData|setTemplate|tname|lastIndex|literal|opIF|filter|try|__tmp|typeof|catch|instanceof|par|_currentState|mode|iteration|url_|_tree|_templates|true|op|end|continue|noFunc|name|key|Number|count|jTemplateSID|async|disallow_functions|cloneData|MAIN|iter|not|in|elseif_level|op_|switchToElse|getParent|foreach|opFORFactory|_param1|_param2|escapeData|optionText|_value|__t|_parent|jTemplate|getTemplate|on_success|Updater|interval|args|updater|_includes|filter_params|runnable_functions|version|reg|_template_settings|while|indexOf|is|substring|optionToObject|Object|switch|include|Include|UserParam|cycle|Cycle|begin|default|setParam|constructor|toString|String|obj|val|__template|tab|arr|tmp|ex|_values|_length|_index|_lastSessionID|sid|ajax|elementName|processTemplate|cache|_options|jTemplateUpdater|run|parentNode|window|createTemplate||filter_data|clone_data|clone_params|escapeHTML|splitTemplates|of|txt|gt|lt|_literalMode|__1|_cond|funcIterator|as|find|_arg|object|_total|prevValue|index|first|last|total|_root|responseText|html|im|processTemplateStop|removeData|defined|dataFilter|timeout|_url|_interval|_args|timer|detectDeletedNodes|grep|parameter|exec|closed|No|inArray|ppp|elseif|ldelim|rdelim|Missing|unknown|tag|substr|amp|quot|hasOwnProperty|Array|Function|Functions|are|allowed|split|shift|__0|subtemplate|to|Operator|failed|MAX_VALUE|Math|ceil|root|Cannot|values|has|no|elements|setTemplateURL|setTemplateElement|trim|CDATA|hasTemplate|removeTemplate|processTemplateURL|GET|dataType|json|success|error|on_error|complete|on_complete|getJSON|setTimeout|browser|msie|document|processTemplateStart|createTemplateURL|processTemplateToText|jTemplatesDebugMode'.split('|'),0,{}));


/* Comment Generated by Combres - Resource '~/js/jquery.history.js' (Mode: Static) */
/*
 * jQuery history plugin
 * 
 * The MIT License
 * 
 * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
 * Copyright (c) 2010 Takayuki Miwa
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

(function($) {
    var locationWrapper = {
        put: function(hash, win) {
            (win || window).location.hash = this.encoder(hash);
        },
        get: function(win) {
            var hash = ((win || window).location.hash).replace(/^#/, '');
            try {
                return $.browser.mozilla ? hash : decodeURIComponent(hash);
            }
            catch (error) {
                return hash;
            }
        },
        encoder: encodeURIComponent
    };

    var iframeWrapper = {
        id: "__jQuery_history",
        init: function() {
            var html = '<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />';
            $("body").prepend(html);
            return this;
        },
        _document: function() {
            return $("#"+ this.id)[0].contentWindow.document;
        },
        put: function(hash) {
            var doc = this._document();
            doc.open();
            doc.close();
            locationWrapper.put(hash, doc);
        },
        get: function() {
            return locationWrapper.get(this._document());
        }
    };

    function initObjects(options) {
        options = $.extend({
                unescape: false
            }, options || {});

        locationWrapper.encoder = encoder(options.unescape);

        function encoder(unescape_) {
            if(unescape_ === true) {
                return function(hash){ return hash; };
            }
            if(typeof unescape_ == "string" &&
               (unescape_ = partialDecoder(unescape_.split("")))
               || typeof unescape_ == "function") {
                return function(hash) { return unescape_(encodeURIComponent(hash)); };
            }
            return encodeURIComponent;
        }

        function partialDecoder(chars) {
            var re = new RegExp($.map(chars, encodeURIComponent).join("|"), "ig");
            return function(enc) { return enc.replace(re, decodeURIComponent); };
        }
    }

    var implementations = {};

    implementations.base = {
        callback: undefined,
        type: undefined,

        check: function() {},
        load:  function(hash) {},
        init:  function(callback, options) {
            initObjects(options);
            self.callback = callback;
            self._options = options;
            self._init();
        },

        _init: function() {},
        _options: {}
    };

    implementations.timer = {
        _appState: undefined,
        _init: function() {
            var current_hash = locationWrapper.get();
            self._appState = current_hash;
            self.callback(current_hash);
            setInterval(self.check, 100);
        },
        check: function() {
            var current_hash = locationWrapper.get();
            if(current_hash != self._appState) {
                self._appState = current_hash;
                self.callback(current_hash);
            }
        },
        load: function(hash) {
            if(hash != self._appState) {
                locationWrapper.put(hash);
                self._appState = hash;
                self.callback(hash);
            }
        }
    };

    implementations.iframeTimer = {
        _appState: undefined,
        _init: function() {
            var current_hash = locationWrapper.get();
            self._appState = current_hash;
            iframeWrapper.init().put(current_hash);
            self.callback(current_hash);
            setInterval(self.check, 100);
        },
        check: function() {
            var iframe_hash = iframeWrapper.get(),
                location_hash = locationWrapper.get();

            if (location_hash != iframe_hash) {
                if (location_hash == self._appState) {    // user used Back or Forward button
                    self._appState = iframe_hash;
                    locationWrapper.put(iframe_hash);
                    self.callback(iframe_hash); 
                } else {                              // user loaded new bookmark
                    self._appState = location_hash;  
                    iframeWrapper.put(location_hash);
                    self.callback(location_hash);
                }
            }
        },
        load: function(hash) {
            if(hash != self._appState) {
                locationWrapper.put(hash);
                iframeWrapper.put(hash);
                self._appState = hash;
                self.callback(hash);
            }
        }
    };

    implementations.hashchangeEvent = {
        _init: function() {
            self.callback(locationWrapper.get());
            $(window).bind('hashchange', self.check);
        },
        check: function() {
            self.callback(locationWrapper.get());
        },
        load: function(hash) {
            locationWrapper.put(hash);
        }
    };

    var self = $.extend({}, implementations.base);

    if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) {
        self.type = 'iframeTimer';
    } else if("onhashchange" in window) {
        self.type = 'hashchangeEvent';
    } else {
        self.type = 'timer';
    }

    $.extend(self, implementations[self.type]);
    $.history = self;
})(jQuery);

