﻿var scrollX, scrollY;


$(document).ready(function () {

    var iHeight = $(document).height();
    var iWidth = $(document).width();


    if ($('.pgTable').length != 0) {
        if ($('.pgTable') != null) {
            $('.pgTable').height(iHeight - 150);
        }
    }



    if ($('.pgDebug').length != 0) {
        if ($('.pgDebug') != null) {
            var iNavMHeight = 0;

            if ($('.pgMain').length != 0) {
                iNavMHeight = $('.pgMain').height();

            }
            $('.pgDebug').css('top', iNavMHeight - 200);
        }
    }

    var iMetaHeight = 0;
    var iDYMHeight = 0;

    var bDYM = false;
    var bMeta = false;
    var iTop = 50;
    var iSpacer = 10;
    var iSearchTop = iTop;
    var iMidHeight = 0;
    var iSearchContent = 0;

    // Position Search for DYM, MetaSearch, Listings
    if ($("#divDYMText").length != 0) {
        bDYM = true;
        iDYMHeight = $('.Search_600_DidYouMean').height();
    }

    if ($("#tblMeta").length != 0) {
        bMeta = true;
        iMetaHeight = $('.MetaSearch_600_100_BrowsePaths').height();
    }


    if ($("#tblSearchSEOContent").length != 0) {
        iSearchContent = $('.SearchSEOContent').height();
    }


    if ($("#divListings").length != 0) {
        // DYM Only
        if (bDYM && !bMeta) {
            $('.Search_600_DidYouMean').css('top', iTop);
            iSearchTop = iTop + iDYMHeight + iSpacer;
        }

        // Meta Only
        if (!bDYM && bMeta) {
            $('.MetaSearch_600_100_BrowsePaths').css('top', 50);
            iSearchTop = iTop + iMetaHeight + iSpacer;

        }

        // DYM and Meta
        if (bDYM && bMeta) {

            $('.Search_600_DidYouMean').css('top', iTop);
            $('.MetaSearch_600_100_BrowsePaths').css('top', iTop + iSpacer + iDYMHeight);


            iSearchTop = iTop + iDYMHeight + iSpacer; iMetaHeight + iSpacer;
        }

        if ($('.Search_600_Unlimited_ListingResults').length != 0)
            $('.Search_600_Unlimited_ListingResults').css('top', iSearchTop + iSearchContent);

    }

    iHeight = $(document).height() + 20 + iMetaHeight + iSearchContent;
    if ($('.pgFooterBottom').length != 0) {
        if ($('.pgFooterBottom') != null) {
            $('.pgFooterBottom').css('top', iHeight - 150);
            $('.pgFooterBottom').css('width', iWidth);
        }
    }

    //    if ($('.pgFooter').length != 0) {
    //        if ($('.pgFooter') != null) {
    //            $('.pgFooter').css('top', iHeight - 150);

    //        }
    //    }

    var browserName = navigator.appName;
    var footertop = 160;
    if (browserName == "Firefox") {
        footertop = 180;
    }

    if ($('.footerBottom').length != 0) {
        if ($('.footerBottom') != null) {
            $('.footerBottom').css('top', iHeight - footertop);
        }
    }



    if ($('.tblHeader').length != 0) {
        if ($('.tblHeader') != null) {
            $('.tblHeader').css('width', iWidth);
        }
    }



    if ($('.pgDebug').length != 0) {
        if ($('.pgDebug') != null) {
            var iNHeight = $(document).height();

            $('.pgDebug').css('top', iNHeight - 170);
        }
    }

    if ($('.pgMain').length != 0) {
        if ($('.pgMain') != null) {
            $('.pgMain').css('visibility', 'visible');
        }
    }

    if ($('.pgNavFooter').length != 0) {
        if ($('.pgNavFooter') != null) {
            $('.pgNavFooter').css('top', iHeight - 500);

        }
    }

    sstchur_SmartScroller_Scroll;

});

function openLearnMore(obj, programid) {

    if ($get('lsmoreinfo_' + programid) != null) {
        obj.target = $get('lsmoreinfo_' + programid).target;
        obj.href = $get('lsmoreinfo_' + programid).href;
    }

}

function urlParam(name) {

    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (!results) { return 0; }
    return results[1] || 0;
}

function GetUSMapXML() {
    var stringresult = "";
    jQuery.ajax({
        url: '/ajax/getusmapxml',
        data: { parentId: 8052, contextPathPartTwo: "||0" },
        success: function (result) {
            stringresult = result;
        },
        async: false
    });
    return stringresult;
}

function GetWorldMapXML() {
    var stringresult = "";
    jQuery.ajax({
        url: '/ajax/getworldmapxml',
        data: { parentId: 8048, contextPathPartTwo: "||0" },
        success: function (result) {
            stringresult = result;
        },
        async: false
    });
    return stringresult;
}


$(document).ready(function () {
    if ($('.slideshow').cycle != undefined) {
        $('.slideshow').cycle({
            fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
            speed: 'fast',
            timeout: 0,
            next: '#next2',
            prev: '#prev2'
        });
    }
});

$(document).ready(function () {

    $(".tempLogin").click(function (n) {
        alert("You are viewing the beta version of the new GradSchools.com. The Registation and login functions have been disabled. Please visit the www.gradschools.com main site to login or register.");
        return false;
    });

});


function textCounter(maxlimit) {
    var field = document.getElementById('message');
    var countfield = document.getElementById('remLen');
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
    else
        countfield.innerHTML = maxlimit - field.value.length;
}

//$(function () {

//    var $sidebar = $("#sidebar"),
//        $window = $(window),
//        offset = $sidebar.offset(),
//        topPadding = 15;

//    $window.scroll(function () {
//        var currentScrollTop = $window.scrollTop();
//        var currentOffSetTop = offset.top;
//        if (currentScrollTop > currentOffSetTop) {
//            $sidebar.stop().animate({
//                marginTop: -currentOffSetTop
//            });
//        } else {
//            $sidebar.stop().animate({
//                marginTop: 0
//            });
//        }
//    });

//});

$(document).ready(function () {

    $(".nvParentLink").click(function (n) {
        if (this.href.indexOf('?toggle=') > 0) {
            window.location.href = this.href.substr(0, this.href.indexOf('?toggle=')) + "?toggle=" + this.id;
        }
        else
            window.location.href = this.href + "?toggle=" + this.id;
        return false;
    });

});

$(document).ready(function () {
    var comment = '';

    $(".saveShortListComments").click(function (n) {

        if ($get('txtComment_' + this.id) != null)
            comment = $get('txtComment_' + this.id).value;
        jQuery.ajax({
            url: '/ajax/saveshortlistcomments',
            data: { s: this.id, c: comment },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);
            },
            async: false
        });
        // window.location.href = this.value;
        return false;
    });

});


$(document).ready(function () {
    $("#removeShortList").click(function (n) {

        var programids = '';
        for (var i = 0; i < document.all.length; i++) {
            var e = document.all[i];
            if (e.type == 'checkbox' && e.id.indexOf('chkShortList_') == 0) {
                if (e.checked) {
                    programids = programids + e.id.substring(e.id.indexOf('_') + 1) + ',';
                }
            }
        }

        if (programids != '') {

            jQuery.ajax({
                url: '/ajax/removeshortlist',
                data: { s: programids },
                success: function (result) {
                    if (result.isOk == false)
                        alert(result.message);
                },
                async: false
            });
            window.location.reload();
            return false;
        }
    });
});

$(document).ready(function () {
    $(".nvChildChk").click(function (n) {
        alert("Checkbox selected " + this.id + "  Value:" + this.value);

        jQuery.ajax({
            url: '/ajax/setcheckboxvalue',
            data: { s: this.id, c: this.checked },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);
            },
            async: false
        });

        window.location.href = this.value;

        return false;
    });
});


$(document).ready(function () {
    $("a.nvFooter").click(function (n) {
        // alert("FooterLink selected " + this.id);
        jQuery.ajax({
            url: '/ajax/settogglestate',
            data: { s: this.id },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);

            },
            async: false
        });
        window.location.href = this.href;
        return false;
    });
});


$(document).ready(function () {
    $(".nvRemoveChildChk").click(function (n) {
        //alert(" remove check box selected " + this.id);

        if (document.all) {
            if (!document.documentElement.scrollLeft)
                scrollX = document.body.scrollLeft;
            else
                scrollX = document.documentElement.scrollLeft;

            if (!document.documentElement.scrollTop)
                scrollY = document.body.scrollTop;
            else
                scrollY = document.documentElement.scrollTop;
        }
        else {
            scrollX = window.pageXOffset;
            scrollY = window.pageYOffset;
        }


        jQuery.ajax({
            url: '/ajax/setcheckboxremovevalue',
            data: { s: this.id, c: this.checked, iXPos: scrollX, iYPos: scrollY },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);
            },
            async: false
        });
        //alert(this.value);
        window.location.href = this.value;
        return true;
    });
});


$(document).ready(function () {
    $("a.cssMenua").click(function (n) {
        jQuery.ajax({
            url: '/ajax/setpopupvalue',
            data: { s: this.href, c: this.checked },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);
            },
            async: false
        });
        window.location.href = this.href;
        return false;
    });
});

$(document).ready(function () {
    $("li.pureCssMenu a").click(function (n) {
        // alert("Popup selected " + this.href);
        jQuery.ajax({
            url: '/search/clearsearchtext?' + Date(),
            data: { s: this.href },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);
            },
            async: false
        });
        if (this.href != '') {
            window.location.href = this.href;
        }
        return false;
    });
});


function ProcessNewsLetterRequest() {
    var d1 = document.getElementById('txtNewsLetter');
    var d = document.getElementById('divSignUp');
    var s = d1.value;
    if (s != '') {
        jQuery.ajax({
            url: '/ajax/processnewsletterrequest',
            data: { sEmail: s },
            success: function (result) {
                if (result.isOk == false)
                    alert(result.message);

                if (result == 'Login')
                    window.location.href = '/my-gradschools/login';
                else
                    d.innerHTML = result;

            },
            async: false
        });
    }
}


function GetViewPrograms(aggregateKey, institutionSalesInterimId, searchText, aggregateRecordCount) {
    //    var iHeight = $(document).height();

    //    var divListing = document.getElementById('divListings');
    //    var height = dl.offsetHeight;

    //    var divAggregateKey = document.getElementById('div_' + aggregateKey);

    //    if (divAggregateKey != null)
    //        divAggregateKey.style.display = "none";

    //    var sID = "div_" + aggregateKey + "_all";
    var divAggregateKeyAll = document.getElementById('div_' + aggregateKey + "_all");
    divAggregateKeyAll.style.display = "block";

    jQuery.ajax({
        url: '/ajax/setviewprograms',
        data: { s: aggregateKey, sRecFilter: institutionSalesInterimId, sTerm: searchText, sRecCount: aggregateRecordCount },
        success: function (result) {
            if (result.isOk == false) {
                alert(result.message);
            }
            divAggregateKeyAll.innerHTML = result;
        },
        async: false
    });


    //    var iHeight = $(document).height();
    //    var iMetaHeight = 0;
    //    var iDYMHeight = 0;
    //    var iMidHeight = 0;
    //    var iHdrHeight = 0;
    //    var iListHdrHeight = 0;

    //    var pgMainTable = document.getElementById('pgMainTable');
    //    //    if (pgMainTable != null) {
    //    //        pgMainTable.style.pixelHeight = pgMainTable.clientHeight + (dl.offsetHeight - height);
    //    //    }
    //    // 
    //    var iHeight1 = $(document).height();

    //    if ($('.MetaSearch_600_100_BrowsePaths').length != 0) {
    //        iMetaHeight = $('.MetaSearch_600_100_BrowsePaths').height() + 80;
    //    }

    //    if ($('.Search_600_DidYouMean').length != 0) {
    //        iDYMHeight = $('.Search_600_DidYouMean').height();
    //    }

    //    if ($('.AdSection_Midway_Row').length != 0) {
    //        iMidHeight = 30;
    //    }

    //    if ($('.pgHeader').length != 0) {
    //        iHdrHeight = 30;
    //    }

    //    if ($('.pgListingsHeader').length != 0) {
    //        iListHdrHeight = 30;
    //    }

    //    var footerht = 0;

    //    if (document.getElementById('pgPagerDiv') != null) {
    //        //alert($('.factorMaster').height());

    //        footerht = document.getElementById('pgPagerDiv').offsetTop + iMetaHeight + iDYMHeight + iMidHeight + iListHdrHeight + iHdrHeight + 175;
    //        //        if (footerht < 1750) {
    //        //            footerht = $(document).height() + 200;


    //        if (footerht < document.getElementById('pgNavFooter').offsetTop + 400) {
    //            footerht = document.getElementById('pgNavFooter').offsetTop + 400;

    //        }
    //    }

    //    if ($('.pgFooterBottom') != null) {
    //        $('.pgFooterBottom').css('top', footerht);
    //    }

    //    var browserName = navigator.appName;
    //    var footertop = 10;
    //    if (browserName == "Firefox") {
    //        footertop = 30;
    //    }

    //    if ($('#pgFooter') != null) {
    //        $('#pgFooter').css('top', footerht - footertop);
    //    }
}



function CollapseViewPrograms(a, c) {

    var dl1 = document.getElementById('divListings');
    var iHeight = dl1.offsetHeight;

    var d1 = document.getElementById('div_' + a);
    if (d1 != null)
        d1.style.display = "block";

    var d = document.getElementById('div_' + a + "_all");
    d.style.display = "none";


    var iMetaHeight = 0;
    var iDYMHeight = 0;
    var iMidHeight = 0;
    var iHdrHeight = 0;

    if ($('.MetaSearch_600_100_BrowsePaths').length != 0) {
        iMetaHeight = $('.MetaSearch_600_100_BrowsePaths').height();
    }

    if ($('.Search_600_DidYouMean').length != 0) {
        iDYMHeight = $('.Search_600_DidYouMean').height();
    }

    if ($('.AdSection_Midway_Row').length != 0) {
        iMidHeight = 30;
    }

    if ($('.pgHeader').length != 0) {
        iHdrHeight = 30;
    }


    var iHeight1 = $(document).height();
    var pgMainTable = document.getElementById('pgMainTable');

    if (pgMainTable != null) {
        pgMainTable.style.pixelHeight = (pgMainTable.clientHeight - (iHeight - dl1.offsetHeight));
    }

    var footerht = 0;
    var pgfooterht = 0;
    if (document.getElementById('pgPagerDiv') != null) {
        //  alert($('.factorMaster').height());
        footerht = document.getElementById('pgPagerDiv').offsetTop + iMetaHeight + iDYMHeight + iMidHeight + +175;

        pgfooterht = 0;
        //        if (footerht < 1750) {
        //            footerht = $(document).height() + 200;
        //            alert(footerht);
        //        }

        if (footerht < document.getElementById('pgNavFooter').offsetTop + 400) {
            footerht = document.getElementById('pgNavFooter').offsetTop + 400;

        }
    }

    if ($('.pgFooterBottom') != null) {
        $('.pgFooterBottom').css('top', footerht);
    }

    var browserName = navigator.appName;
    var footertop = 10;
    if (browserName == "Firefox") {
        footertop = 30;
    }

    if ($('#pgFooter') != null) {
        $('#pgFooter').css('top', footerht - footertop);
    }

    if (window.location.href.indexOf('#') > 0)
        window.location.href = window.location.href.split('#')[0] + '#' + a;
    else
        window.location.href = window.location.href + '#' + a;
    return false;
}

$(document).ready(function () {
    $(".nvZipInput").keypress(function (e) {
        //alert(e);
        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {

            return false;
        }
    });
});

//toggle drop down menu in breadcrumb trail
$(document).ready(function () {

    $("#dropDownArrow").click(function () {

        if ($('.hiddenMenu').is(':visible')) {
            $('.hiddenMenu').hide();
        }
        else {
            //get position of the arrow and place the menu at the same position.  This has to be dynamic because you can have 1 item in your bread crumb trail or many and the position
            //of the drop down arrow is variable.  I love jQuery for making this so simple. 
            var position = $('#dropDownArrow').offset();
            $('ul.hiddenMenu').css('position', 'absolute');
            $('ul.hiddenMenu').css('left', position.left);
            $('ul.hiddenMenu').css('top', position.top + 20);
            $('.hiddenMenu').show();
        }
    });

});


//toggle drop down menu in breadcrumb trail
$(document).ready(function () {

    $("#dropDownArrowNav").click(function () {

        if ($('.hiddenMenu').is(':visible')) {
            $('.hiddenMenu').hide();
        }
        else {
            //get position of the arrow and place the menu at the same position.  This has to be dynamic because you can have 1 item in your bread crumb trail or many and the position
            //of the drop down arrow is variable.  I love jQuery for making this so simple. 
            var position = $('#dropDownArrowNav').offset();
            $('ul.hiddenMenu').css('position', 'absolute');
            $('ul.hiddenMenu').css('left', position.left);
            $('ul.hiddenMenu').css('top', position.top + 20);
            $('.hiddenMenu').show();
        }
    });

});


//$(".moreDegrees").each(function () {
//    $(this).click(function () {
//        alert('got here');
//                $(this).parent().find(".resultDegreeMenu").slideToggle("fast");
//                $(this).text($(this).text() == "Read More about GradSchools.com" ? "Hide more content" : "Read More about GradSchools.com");
//        event.preventDefault();
//    });
//});

$(document).ready(function () {
    $('.moreDegrees').each(function () {
        $(this).mouseover(function () {
            if ($('.resultDegreeMenu').is(':visible')) {
                $('.resultDegreeMenu').slideToggle('fast');
            }
            else {
                var position = $('#moredegreelink').offset();
                //alert(position.left);
                $('.resultDegreeMenu').css('position', 'absolute');
                $('.resultDegreeMenu').css('left', position.left + 50);
                $('.resultDegreeMenu').css('top', position.top - 10);
                $('.resultDegreeMenu').slideToggle('fast');
            }
        });
    });
});



$(document).ready(function () {
    $("#EdDyGSForm").keypress(function (e) {

        if (e.which == 13) {
            var sText = document.getElementById("txtSearchTerms").value;
            var objHiddenText = document.getElementById("txtHiddenSearchTerms");
            objHiddenText.value = sText;
            sText = sText.replace(/[^a-zA-Z0-9]/g, '-');    // replace all non-letters and numbers with dash
            sText = sText.replace(/-/, ' ');
            sText = sText.replace(/\s+$/, '');
            sText = sText.replace(/-$/, '');  // trim any trailing dash

            jQuery.ajax({
                url: '/search/setsearchtext',
                data: { sActualText: objHiddenText.value, sParsedText: sText },
                success: function (result) {
                    if (result.isOk == false)
                        alert(result.message);
                },
                async: false
            });

            var sInterface;
            if ($.cookie("searchUrl") != null) {
                sInterface = $.cookie("searchUrl");
            }
            else {
                sInterface = document.getElementById("cboSearch").value;
            }

            if (sText != '') {

                var oForm = document.getElementById("EdDyGSForm");

                oForm.method = "post";

                if (sInterface == 'Programs') {
                    var sUrl = escape("/search-programs/term-" + sText);
                    document.getElementById("EdDyGSForm").action = "/search-programs/term-" + sText;
                }

                if (sInterface == 'Schools') {
                    document.getElementById("EdDyGSForm").action = "/search-schools/term-" + sText;
                }
                if (sInterface == 'Resources') {
                    document.getElementById("EdDyGSForm").action = "/search-resources/term-" + sText;
                }
                document.getElementById("EdDyGSForm").submit();

            }
            return false;
        }

    });
});



//$(document).ready(function () {

//    $(".search-submit").click(function (e) {
//        if ($(".search-input").val() != null && $('#cboSearch :selected').text() != null) {
//            var sText = $(".search-input").val();
//            //            var objHiddenText = document.getElementById("txtHiddenSearchTerms");
//            //            objHiddenText.value = sText;
//            sText = sText.replace(/[^a-zA-Z0-9]/g, '-');
//            sText = sText.replace(/-/, ' ');
//            sText = sText.replace(/\s+$/, '');

//            jQuery.ajax({
//                url: '/search/setsearchtext',
//                data: { sActualText: sText, sParsedText: sText },
//                success: function (result) {
//                    if (result.isOk == false)
//                        alert(result.message);
//                },
//                async: false
//            });

//            var sInterface = $('#cboSearch :selected').text();
//            if (sText != '') {
//                if (sInterface == 'Programs')
//                    document.getElementById("EdDyGSForm").action = "/search-programs/term-" + sText;

//                if (sInterface == 'Schools')
//                    document.getElementById("EdDyGSForm").action = "/search-schools/term-" + sText;

//                if (sInterface == 'Resources')
//                    document.getElementById("EdDyGSForm").action = "/search-resources/term-" + sText;

//                document.getElementById("EdDyGSForm").submit();
//                return false;
//            }
//        }
//    });
//});





function GetInstitutions(a) {

    var d = document.getElementById('typeInstitutionDiv');
    var height = $('.typeInstitutionDiv').height();
    //d.innerHTML = '';
    $('.typeInstitutionDiv').height(0);
    $('#typeInstitutionDiv').height(0);

    jQuery.ajax({
        url: '/ajax/getinstitutions',
        data: { s: a },
        success: function (result) {
            if (result.isOk == false)
                alert(result.message);
            d.innerHTML = result.toString();
        },
        async: false
    });

    //    if ($(document).height() > d.offsetHeight)
    //        height = $(document).height();
    //    else
    //        height = d.offsetHeight;


    var footerht = $('.typeInstitutionDiv').height() + 200;

    if (footerht < 1700) {
        footerht = 1700;
    }

    if ($('.pgFooterBottom') != null) {
        $('.pgFooterBottom').css('top', footerht);
    }

    var browserName = navigator.appName;
    var footertop = 10;
    if (browserName == "Firefox") {
        footertop = 30;
    }

    if ($('#pgFooter') != null) {
        $('#pgFooter').css('top', footerht - footertop);
    }



}



function MenuClick(a) {
    EdDyGSForm.action = "/programs/Program?id=" + a;
    EdDyGSForm.submit();
}


$(document).ready(function () {
    $("#resetpasswordsubmit").click(function (n) {


        var newpassword = $("#newpassword").val();
        var confirmpassword = $("#confirmpassword").val();

        if (newpassword == "") {
            $('#errormessage').html("Please enter new password ");
            return false;
        }
        else if (confirmpassword == "") {
            $('#errormessage').html("Please enter confirm password");
            return false;
        }
        else {
            if (newpassword == confirmpassword) {
                if (IsStrongPassword()) {

                    var username = $("#username").val();
                    jQuery.ajax({
                        url: '/ajax/resetpassword',
                        data: { username: username, newpassword: newpassword },
                        success: function (result) {

                            if (result == 'true') {

                                $('#errormessage').html("Password changed sucessfully");
                            }
                            else {

                                $('#errormessage').html("Oops error occured, please try again");

                            }
                        },
                        async: false
                    });

                    return false;

                }
                else {
                    $('#errormessage').html("Password should be strong");
                    return false;
                }
            }
            else {
                $('#errormessage').html("Both Passwords should match");
                return false;
            }
        }

    });

});


function IsStrongPassword() {



    var myString = $("#newpassword").val();

    var Stringlen = myString.length;
    var ValidateDigits = /[^0-9]/g;
    var ValidateChar = /[^a-zA-Z]/g;

    var digitString = myString.replace(ValidateDigits, "");
    var charString = myString.replace(ValidateChar, "");

    if (Stringlen < 6) {

        $('#errormessage').html("Passwords must be at least 6 characters");
        $("#newpassword").val('');
        $("#confirmpassword").val('');
        $("#newpassword").focus();
        return false;
    }
    else if (digitString < 1) {

        $('#errormessage').html("Passwords must include at least 1 numeric characters");
        $("#newpassword").val('');
        $("#confirmpassword").val('');
        $("#newpassword").focus();
        return false;
    }
    else if (charString < 1) {

        $('#errormessage').html("Passwords must include at least 1 alpha characters");
        $("#newpassword").val('');
        $("#confirmpassword").val('');
        $("#newpassword").focus();
        return false;
    }
    else return true;
}
//  dataType: "json",
$(document).ready(function () {
    $("#contactussubmit").click(function (n) {


        var contactusdata = {

            firstname: $("#firstname").val(),
            lastname: $("#lastname").val(),
            email: $("#email").val(),
            usertype: $("#usertype").val(),
            usertypetext: $("#usertype option:selected").text(),
            school: $("#school").val(),
            message: $("#message").val()
        };

        jQuery.ajax({
            url: '/ajax/contactusvalidate',
            data: contactusdata,

            success: function (result) {
                if (result.indexOf('Gradschools', 0) > -1) {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'completed');
                } else {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'error');
                }

            },
            async: false
        });
        return false;
    });
});




$(document).ready(function () {
    $("#sitefeedbacksubmit").click(function (n) {


        var sitefeedbackdata = {

            feedbacktype: $("#feedbacktype").val(),
            feedbacktypetext: $("#feedbacktype option:selected").text(),
            feedback: $("#message").val(),
            firstname: $("#firstname").val(),
            lastname: $("#lastname").val(),
            email: $("#emailaddress").val(),
            school: $("#school").val(),
            usertype: $("#usertype").val(),
            usertypetext: $("#usertype option:selected").text(),
            phonenumber: $("#daytimephonenumber").val()
        };

        jQuery.ajax({
            url: '/ajax/sitefeedbackvalidate',
            data: sitefeedbackdata,
            success: function (result) {

                if (result.indexOf('Appreciate', 0) > -1) {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'completed');
                } else {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'error');
                }
            },
            async: false

        });
        return false;
    });
});

$(document).ready(function () {
    $("#advertisewithussubmit").click(function (n) {
        var advertisewithusdata = {
            first_name: $("#first_name").val().trim(),
            last_name: $("#last_name").val().trim(),
            email: $("#email").val().trim(),
            institution: $("#company").val().trim(),
            department: $("#00N70000001t5rh").val().trim(),
            phone: $("#phone").val().trim(),
            address: $("#address").val().trim(),
            city: $("#city").val().trim(),
            state: $("#state").val().trim(),
            zip: $("#zip").val().trim(),
            description: $("#description").val().trim()
        };
        jQuery.ajax({
            url: '/ajax/advertisewithusvalidate',
            data: advertisewithusdata,
            success: function (result) {
                if (result != '') {
                    $('#errormessage').html(result.toString());
                }
                else {
                    var oForm = document.getElementById("EdDyGSForm1");
                    oForm.method = "post";
                    document.getElementById("EdDyGSForm1").action = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
                    document.getElementById("EdDyGSForm1").submit();
                }
            },
            async: false

        });
        return false;
    });
});

$(document).ready(function () {
    $("#feedback").val('');
    $("#message").val('');
});


$(document).ready(function () {
    $("#usertype").change(function () {
        var value = $("#usertype").val();
        if (value == 2 || value == 4) {
            $("#trSchool").show();
            $("#IamAn").show();
            $("#IamA").hide();
        }
        else {
            $("#trSchool").hide();
            $("#school").val("");
            $("#IamAn").hide();
            $("#IamA").show();
        }
    });
});

//Slide up ad JQuery
jQuery(function ($) {

    function setCookie(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    }

    function getCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    function deleteCookie(name) {
        setCookie(name, "", -1);
    }

    //find page path so we only show this ad on the home page
    var pathname = window.location.pathname;
    if (pathname == '/') {

        //set session cookie so that we only show the ad once per session
        var cookieC;
        //set reference to container
        var container = $("#SlideUpContainer");
        var HomeBannerAd = $("#HomeBannerAd");
        var BannerClose = $("#BannerClose");
        HomeBannerAd.hide();
        BannerClose.hide();

        cookieC = getCookie('sliderAdShown');
        if (cookieC == null) {
        //show ad container on page load if cookie doesn't exist
        container.slideDown(1500, 'linear', function () { HomeBannerAd.fadeIn(300); BannerClose.fadeIn(300) });
        setCookie('sliderAdShown', 'yes');
        _gaq.push(['_trackEvent', 'Ad view', 'float', '', '', true]);
        }

        // Bind the link to close the slider ad
        $("#closeAdvert").bind('click', function () {
            // Toggle the slide based on its current
            // visibility.
            if (container.is(":visible")) {
                // Hide - slide up.
                HomeBannerAd.fadeOut(100);
                BannerClose.fadeOut(100);
                container.slideUp(500, 'linear');
                _gaq.push(['_trackEvent', 'Ad Close', 'float', '', '', true]);
            } else {
                // Show - slide down.
                container.slideDown(1500, 'linear', function () { HomeBannerAd.fadeIn(300); BannerClose.fadeIn(300) });
            }
        });
    }
});

//

$(document).ready(function () {
    $("#emailsend").click(function (n) {
        $('#emailerror').html("");
        var email = $("#emailtext").val();
        $("#emailerror").css("display", "none");


        jQuery.ajax({
            url: '/ajax/getexistinguser',
            data: { userEmail: email },
            success: function (result) {

                switch (result) {
                    case "Email cannot be empty<br />":
                        $('#emailerror').html(result.toString());
                        $('#emailerror').attr('style', '');
                        $('#emailerror').attr('class', 'error');
                        break;
                    case "Please enter valid email<br />":
                        $('#emailerror').html(result.toString());
                        $('#emailerror').attr('style', '');
                        $('#emailerror').attr('class', 'error');
                        break;
                    default:
                        $('#emailerror').html(result.toString());
                        $('#emailerror').attr('style', '');
                        $('#emailerror').attr('class', 'results');
                        break;
                }
            },
            async: false
        });

        return false;
    });

    $("#emailCancel").click(function (n) {
        $('#dgtest').dialog('close');
    });
});


$(document).ready(function () {
    $("#forgotpwdmodal").click(function (n) {


        $("#emailtext").val("");
        $('#emailerror').html("");
        $("#emailerror").css("display", "none");
        $("#dgtest").dialog({
            bgiframe: true, autoOpen: false, modal: true, draggable: false, width: 400, height: 260, dialogClass: "dgtest"
        });

        $('#dgtest').dialog('open');

        return false;
    });
});

$(document).ready(function () {
    $("#password").keypress(function (e) {

        if (e.which == 13) {

            var username = $("#username").val();
            var password = $("#password").val();
            var check = $('#remember').attr('checked') ? 1 : 0;
            var status = false;
            jQuery.ajax({
                url: '/ajax/validateuser',
                data: { username: username, password: password, remember: check },
                type: "GET",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {

                    if (result[0] == 'true') {
                        $('#errormessage').html("");
                        window.location.href = result[1];
                    }
                    else {
                        $('#errormessage').html("Please enter a valid email address and password.");
                        //$("#username").val("");
                        $("#password").val("");
                        status = false;
                    }
                },
                async: false
            });
        }
        return status;
    });
});


$(document).ready(function () {
    $("#imageGo").click(function (n) {

        var username = $("#username").val();
        var password = $("#password").val();
        var check = $('#remember').attr('checked') ? 1 : 0;
        var status = false;
        jQuery.ajax({
            url: '/ajax/validateuser',
            data: { username: username, password: password, remember: check },
            type: "GET",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                if (result[0] == 'true') {
                    window.location.href = result[1];
                }
                else {
                    $('#validationMessage').html("Please enter a valid email address and password.");
                    $("#password").val("");
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'error');
                    status = false;
                }
            },
            async: false
        });

        return status;
    });
});

//$(document).ready(function() {
//    $("#Inquirycancel").click(function(n) {


//    });
//});

function InquiryRegcancelClick(a) {

    window.location.href = a;
    return false;
}

function InquiryCancelClick(a) {

    window.location.href = a;
    return false;
}

$(document).ready(function () {
    $("#inquirysubmit").click(function (n) {
        //   $('#loadimg').show();
        $('#registrationerror').attr('style', 'display:none;');
        var retstatus = false;
        if (!$(".form-holder input[type*='text'].required, .form-holder input[type*='password'].required, .form-holder textarea.required").hasClass('error-field')) {
            var inquirydata = {
                firstname: $("#firstname").val(),
                lastname: $("#lastname").val(),
                email: $("#email").val(),
                phone: $("#phone").val(),
                address1: $("#address1").val(),
                address2: $("#address2").val(),
                city: $("#city").val(),
                state: $("#state").val(),
                statetext: $("#state option:selected").text(),
                zip: $("#zip").val(),
                country: $("#country").val(),
                countrytext: $("#country option:selected").text(),
                usertypetext: $("#usertype option:selected").text(),
                fieldofstudy: $("#fieldofstudy").val(),
                fieldofstudytext: $("#fieldofstudy option:selected").text(),
                subject: $("#subject").val(),
                subjecttext: $("#subject option:selected").text(),
                expectedstartseasontext: $("#expectedstartseasontext option:selected").text(),
                expectedstartseasonvalue: $("#expectedstartseasontext").val(),
                expectedstartyeartext: $("#expectedstartyeartext option:selected").text(),
                expectedstartyearvalue: $("#expectedstartyeartext option:selected").val(),
                contactpreference: GetContactPreference(),
                message: $("#message").val(),
                inquirymailcopy: $("#enquirymail").attr('checked') ? true : false,
                newsletter: $("#newsletter").attr('checked') ? true : false,
                programid: $("#programid").html(),
                institutionname: $("#institutionname").html(),
                schoolname: $("#schoolname").html(),
                programname: $("#programname").html(),
                admasterdetailid: $("#admasterdetailid").html(),
                programcontactemail: $("#programcontactemail").html()
            };
            jQuery.ajax({
                url: '/ajax/contactprogramvalidate',
                data: inquirydata,
                success: function (result) {

                    //   $('#loadimg').hide();

                    if (result[0] != "") {
                        $('#registrationerror').html(result[0].toString());
                        $('#registrationerror').attr('style', '');
                        $('#registrationerror').attr('class', 'error');
                    } else if (result[0] == "" && result[1] != "true" && result[2] == "true") {
                        retstatus = true;
                        if ($("#admasterdetailid").html() == 0) {
                            if ($("#campaignID").html() != "0") {
                                _gaq.push(['_trackEvent', 'Ad submit form', 'suspended', $("#campaignID").html()]);
                            } else {
                                _gaq.push(['_trackEvent', 'Ad submit form', 'free', $("#campaignID").html()]);
                            }
                        } else {
                            _gaq.push(['_trackEvent', 'Ad submit form', 'cpc', $("#campaignID").html()]);
                        }
                        $('form').submit();
                    }
                    else if (result[1] == "true" && result[2] == "true") {
                        if ($("#admasterdetailid").html() == "0") {
                            window.open("http://gradschools.elearners.com/", "_blank", "toolbar=yes, location=yes, directories=yes,status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600");
                        }
                        $('#registrationerror').attr('style', '');
                        $('#registrationerror').attr('class', 'completed');
                        $('#registrationerror').html('<p>Your Inquiry has been submitted.</p><br/><p><a href="' + window.document.referrer + '">Return to Listings</a></p>');
                        if ($("#admasterdetailid").html() == 0) {
                            if ($("#campaignID").html() != '') {
                                _gaq.push(['_trackEvent', 'Ad submit form', 'suspended', $("#campaignID").html()]);
                            } else {
                                _gaq.push(['_trackEvent', 'Ad submit form', 'free', $("#campaignID").html()]);
                            }
                        } else {
                            _gaq.push(['_trackEvent', 'Ad submit form', 'cpc', $("#campaignID").html()]);
                        }

                    }

                    var target = $('#registrationerror');
                    var target_offset = target.offset();
                    var target_top = target_offset.top - 20;
                    $('html, body').animate({ scrollTop: target_top }, 500);


                },
                async: false

            });
        }
        return retstatus;
    });
});
$(document).ready(function () {


    var title = document.URL.toString();

    if (title.indexOf("contactprogram") > 0) {

        jQuery.ajax({

            type: "GET",
            contentType: "application/json; charset=utf-8",
            url: '/ajax/contactprogrampopulate',
            data: "{}",
            dataType: "json",
            success: function (result) {

                if (result.length > 0) {

                    BindData(result);
                }
            },
            async: false

        });
    }
    return false;

});

function BindData(result) {

    if (result[2] != null) {
        var loginSection = $('#loginsection');
        var inquirySection = $('#inquirysection');
        loginSection.attr('style', 'display:none;');
        inquirySection.attr('class', 'inquirysection-centered');
        BindContactProgramData(result[2], result[0], result[1]);
    } else {
        var selectedState = null;
        var selectedCountry = null;
        BindStatesData(result[0], selectedState);
        BindCountriesData(result[1], selectedCountry);
    }
    BindYear();

}

function BindStatesData(states, selectedState) {

    var states = states;
    var options = "";
    for (p in states) {
        if (states[p] == selectedState) {
            options += "<option selected='selected' value='" + (p) + "'>" + states[p] + "</option>";
        } else {
            options += "<option value='" + (p) + "'>" + states[p] + "</option>";
        }
    }
    $("#state").html(options);
}
function BindCountriesData(countries, selectedCountry) {

    var countries = countries;
    var options = "";
    for (p in countries) {
        if ((p) == selectedCountry) {
            options += "<option selected='selected' value='" + (p) + "'>" + countries[p] + "</option>";
        } else {
            options += "<option value='" + (p) + "'>" + countries[p] + "</option>";
        }
    }
    $("#country").html(options);


}
function BindYear() {
    var maxY = 4;
    var year = (new Date).getFullYear() + maxY;
    var options = '';
    var y = 1;
    options = '<option value="0"></option>';
    for (var i = maxY; i >= 0; i--) {
        var yr = year.toString();
        options += "<option value='" + y + "'>" + yr + "</option>";
        year--;
        y++;
    }
    $("#expectedstartyeartext").html(options);
    //$("#expectedstartyeartext").append(options);
}
function Bindfieldofstudy(fieldofstudy) {

    var fieldofstudy = fieldofstudy[0];

    var options = "<option value='0'>All</option>";
    for (p in fieldofstudy) {
        options += "<option value='" + p + "'>" + fieldofstudy[p] + "</option>";
    }
    $("#fieldofstudy").html(options);
}
function BindSubjects(subjects) {

    var subjects = subjects[0];
    var options = "<option value='0'>Select Subject</option>";
    for (p in subjects) {
        options += "<option value='" + p + "'>" + subjects[p] + "</option>";
    }
    $("#subject").html(options);
}
function BindContactProgramData(contactProgramData, states, countries) {

    $("#firstname").val(contactProgramData.FirstName);
    $("#lastname").val(contactProgramData.LastName);
    $("#email").val(contactProgramData.Email);
    $("#phone").val(contactProgramData.Phone);
    $("#address1").val(contactProgramData.Address1);
    $("#address2").val(contactProgramData.Address2);
    $("#city").val(contactProgramData.City);
    $("#zip").val(contactProgramData.Zip);
    var selectedState = contactProgramData.State;
    var selectedCountry = contactProgramData.Country;
    BindStatesData(states, selectedState);
    BindCountriesData(countries, selectedCountry);
}
function GetContactPreference() {

    var contactpreference = '';
    if ($("#contactemail").attr('checked'))
        contactpreference = "12,";
    if ($("#contactphone").attr('checked'))
        contactpreference += "10,";
    if ($("#contactmail").attr('checked'))
        contactpreference += "11";



    return contactpreference.toString();

}


$(document).ready(function () {


    var title = document.URL.toString();

    if (title.indexOf("inquirysubmission") > 0) {

        jQuery.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            url: '/ajax/getfeildofstudy',
            // data: "{}",
            dataType: "json",
            success: function (result) {

                if (result.length > 0) {

                    // $("#fieldofstudy").html("");
                    // $("#subject").html("");
                    Bindfieldofstudy(result);
                }
            },
            async: false

        });
    }
    return false;

});



$(document).ready(function () {
    $("#fieldofstudy").change(
function () {

    BindSubjects(LoadSubjects($("#fieldofstudy").val()));

});
});

function LoadSubjects(feildofstudy) {

    var stringresult = "";
    var feildofstudy = feildofstudy;
    jQuery.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        data: { feildofstudy: feildofstudy },
        dataType: "json",
        url: '/ajax/getsubject',

        success: function (result) {

            stringresult = result;
        },
        async: false

    });
    return stringresult;

}
$(document).ready(function () {
    $("#saveandregister").click(function (n) {
        var inquirysubmissiondata = {
            fieldofstudy: $("#fieldofstudy").val(),
            fieldofstudytext: $("#fieldofstudy option:selected").text(),
            subject: $("#subject").val(),
            subjecttext: $("#subject option:selected").text(),
            password: $("#password").val(),
            reenterpassword: $("#reenterpassword").val(),
            contactpreference: InquirySubmissionContactPreference(),
            privacypolicy: $("#privacypolicy").attr('checked') ? true : false
        };

        jQuery.ajax({
            url: '/ajax/inquirysubmissionvalidate',
            data: inquirysubmissiondata,
            success: function (result) {
                var sValues = result.split('*', 2);
                if (sValues.length > 1) {
                    if (sValues[1] == '1') {
                        $('#submissionerror').attr('style', '');
                        $('#submissionerror').attr('class', 'error');
                        $('#submissionerror').html(sValues[0]);
                    } else {
                        if (InquirySubmissionContactPreference() == 0) {
                            $('#submissionerror').attr('style', '');
                            $('#submissionerror').attr('class', 'completed');
                            $('#submissionerror').html('<p>Thank you, your inquiry has been sent and your profile has been stored.</p><br/><p><a href="#" OnClick="javascript:history.go(-2)">Return to Listings</a></p>');
                        } else {
                            window.location.href = sValues[0];
                        }
                    }
                } else {
                    $('#submissionerror').attr('style', '');
                    $('#submissionerror').attr('class', 'error');
                    $('#submissionerror').html(result.toString());
                }
                var target = $('#submissionerror');
                var target_offset = target.offset();
                var target_top = target_offset.top - 20;
                $('html, body').animate({ scrollTop: target_top }, 500);
            },
            async: false

        });
        return false;
    });
});
function InquirySubmissionContactPreference() {

    var contactpreference = '';
    if ($("#only").attr('checked'))
        contactpreference = "0";
    if ($("#anyservice").attr('checked'))
        contactpreference = "1";


    return contactpreference.toString();

}


$(document).ready(function () {
    $("#inquirylogin").click(function (n) {
        var username = $("#username").val();
        var password = $("#password").val();
        var check = $('#remember').attr('checked') ? 1 : 0;
        var status = false;
        jQuery.ajax({
            url: '/ajax/contactprogramvalidateuser',
            data: { username: username, password: password, remember: check },
            success: function (result) {

                if (result != "") {

                    var d1 = document.getElementById('loginsection');
                    d1.style.display = "none";
                    BindContactProgramData(result);

                }
                else {

                    $('#loginerror').html("Please enter a valid email address and password.");

                    status = false;
                }

            },
            async: false
        });

        return status;
    });
});

$(document).ready(function () {
    $("#articleemail").click(function (n) {

        $("#emailthispage").dialog({
            bgiframe: true, autoOpen: false, modal: true, draggable: false, width: 430, height: 500
        });

        $('#errormessage').html('');
        $("#toemail").val('');
        $("#message").val('');
        $('input[id=sendmecopy]').attr('checked', false);
        jQuery.ajax({
            url: '/ajax/getemailaddress',
            data: "{}",
            success: function (result) {
                $("#fromemail").val(result);
            },
            async: false

        });

        // $('#sendmecopy').attr('checked') ? 1 : 0;

        $('#emailthispage').dialog('open');

        return false;
    });
});

//$(document).ready(function () {
//    $("#print").click(function (n) {
//        $("#printPopup").dialog({
//            bgiframe: true, autoOpen: false, modal: true, draggable: false, width: 740, height: 600
//        });


//        $('#printPopup').dialog('open');
//        // var rt = document.getElementById('print').innerHTML.replace(/href/gi, "rel");
//        var html = $('.pgArticleDetail_750_PlaceHolder').html();
//        // $('#IF1').contents().find('#printarea').html(html);
//        // Print the DIV.
//        //  $(".pgArticleDetail_750_PlaceHolder").print();

//        $('#printarea').html(html);


//        return false;
//    });
//});


//$(document).ready(function () {
//    $("#printProgramDetails").click(function (n) {
//        $("#printProgramDetailsPopup").dialog({
//            autoOpen: false, modal: true, width: 724, height: 600
//        });

//        $('#printprogramdetailsarea').attr("class", "printRegion");
//        $('#printprogramdetailsarea').load("../../ProgramPrintView/");
//        $('#printProgramDetailsPopup').dialog('open');
//        return false;
//    });
//});

function PrintManager() {
    this.RenderPrintPreviewAjax = function (modalButtonId, updatableRegionId, printButtonId, dialogRegionId, printableViewUrl) {
        $(modalButtonId).click(function () {
            $(dialogRegionId).dialog({
                autoOpen: false, modal: true, width: 724, height: 650
            });
            $(updatableRegionId).attr("class", "printRegion");
            $(updatableRegionId).load(printableViewUrl);
            $(dialogRegionId).dialog('open');
            return false;
        });
    };
    this.RenderPrintPreview = function (modalButtonId, updatableRegionId, printButtonId, dialogRegionId, printableRegionId) {
        $(modalButtonId).click(function () {
            $(dialogRegionId).dialog({
                autoOpen: false, modal: true, width: 724, height: 650
            });
            $(updatableRegionId).attr("class", "printRegion");
            var printableRegion = $(printableRegionId).html();
            $(updatableRegionId).html(printableRegion);
            $(printButtonId).click(function () {
                $(".printRegion").print();
                return false;
            });
            $(dialogRegionId).dialog('open');

            return false;
        });
    };
};

//$(document).ready(function () {
//    $("#imgPrint").click(function (n) {
//        $(".printRegion").print();
//        return false;
//    });
//});

$(document).ready(function () {
    $("#emailthispagecancel").click(function (n) {

        $('#emailthispage').dialog('close');

        return false;
    });
});

$(document).ready(function () {
    $("#emailthispagesubmit").click(function (n) {
        var emailthispagedata = {
            FromEmail: $("#fromemail").val(),
            ToEmail: $("#toemail").val(),
            Message: $("#message").val(),
            SendCopy: $('#sendmecopy').attr('checked') ? true : false,
            PageURL: document.URL.toString()
        };
        jQuery.ajax({
            url: '/ajax/emailthispagevaildate',
            data: emailthispagedata,
            success: function (result) {
                if (result.indexOf('sucessfully', 0) > -1) {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'completed');
                } else {
                    $('#validationMessage').html(result.toString());
                    $('#validationMessage').attr('style', '');
                    $('#validationMessage').attr('class', 'error');
                }
            },
            async: false

        });
        return false;
    });
});

//facebook Management
function FaceBookManager() {
    this.RenderLikeButtonFBML = function (likedUrl, layout) {
        var fbml = '<div id="fb-root"></div><fb:like href="' + likedUrl + '" send="false" width="40" show_faces="true" layout="' + layout + '" font="">&#160;</fb:like>';
        document.write(fbml);
        return false;
    };
    this.RenderLikeButtonIframe = function (likedUrl) {
        document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + likedUrl + '&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=like&amp;font=segoe+ui&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; height:20px; width:100px;"></iframe>');
        return false;
    };
}

//menus

function ArticleMenu() {
    this.initialize = function () {


        $("#content-menu .menu-plus, #content-menu .menu-plus-child").click(function (event) {

            event.preventDefault();

            var checkElement = $(this).next("ul");
            $(checkElement).slideToggle(400);
            $(this).parent().toggleClass("current_click_state");

            if ($(this).hasClass("menu-plus-child")) {
                $(this).parent().toggleClass("current_child_category");
            }

        });

        $("#content-menu .menu-plus, #content-menu .menu-plus-child").each(function () {
            var checkElement = $(this).next("ul");
            $(checkElement).slideUp(400);
            $(this).parent().toggleClass("current_click_state");
            if ($(this).hasClass("menu-plus-child")) {
                $(this).parent().toggleClass("current_child_category");
            }
        });
    };
    this.ExpandSelectedCategory = function () {
        var selectedLink = $('#183');
        //  $(selectedLink).each(function () {
        //   $(selectedLink).parent().each(function () {
        var opened = selectedLink.parent().parent().parent().parent();
        opened.slideDown(400);
        opened.toggleClass("current_click_state");


        if (opened.hasClass("menu-plus-child")) {
            opened.toggleClass("current_child_category");
        }

        //IE does not like spans with absolute position
        if ($.browser.msie == true) {
            if (opened.find("li span").is(":visible")) {
                opened.find("li span").hide();
            }
            else {
                opened.find("li span").fadeIn(1000);
            }
        }
        opened.slideDown(400);
        //});
        //});
    };
}

// Print

// Create a jquery plugin that prints the given element.
jQuery.fn.print = function () {
    // NOTE: We are trimming the jQuery collection down to the
    // first element in the collection.
    if (this.size() > 1) {
        this.eq(0).print();
        return;
    } else if (!this.size()) {
        return;
    }

    // ASSERT: At this point, we know that the current jQuery
    // collection (as defined by THIS), contains only one
    // printable element.

    // Create a random name for the print frame.
    var strFrameName = ("printer-" + (new Date()).getTime());

    // Create an iFrame with the new name.
    var jFrame = $("<iframe name='" + strFrameName + "'>");

    // Hide the frame (sort of) and attach to the body.
    jFrame
		.css("width", "1px")
		.css("height", "1px")
		.css("position", "absolute")
		.css("left", "-9999px")
		.appendTo($("body:first"))
	;

    // Get a FRAMES reference to the new frame.
    var objFrame = window.frames[strFrameName];

    // Get a reference to the DOM in the new frame.
    var objDoc = objFrame.document;

    // Grab all the style tags and copy to the new
    // document so that we capture look and feel of
    // the current document.

    // Create a temp document DIV to hold the style tags.
    // This is the only way I could find to get the style
    // tags into IE.
    var jStyleDiv = $("<div>").append(
		$("style").clone()
		);

    // Write the HTML for the document. In this, we will
    // write out the HTML of the current element.
    objDoc.open();
    objDoc.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    objDoc.write("<html>");
    objDoc.write("<body>");
    objDoc.write("<head>");
    objDoc.write("<title>");
    objDoc.write(document.title);
    objDoc.write("</title>");
    objDoc.write(jStyleDiv.html());
    objDoc.write("</head>");
    objDoc.write(this.html());
    objDoc.write("</body>");
    objDoc.write("</html>");
    objDoc.close();

    // Print the document.
    objFrame.focus();
    objFrame.print();

    // Have the frame remove itself in about a minute so that
    // we don't build up too many of these frames.
    setTimeout(
		function () {
		    jFrame.remove();
		},
		(60 * 1000)
		);
};

function ShowAllProgramLocations(a) {
    var dLink = document.getElementById("view_programlocations_link_" + a);
    var dAll = document.getElementById("view_programlocations_all_" + a);

    dLink.style.display = "none";
    dAll.style.display = "block";
    return true;
}

function HideAllProgramLocations(a) {
    var dLink = document.getElementById("view_programlocations_link_" + a);
    var dAll = document.getElementById("view_programlocations_all_" + a);

    dLink.style.display = "block";
    dAll.style.display = "none";
    return true;
}



function sstchur_SmartScroller_GetCoords() {

    if (document.all) {
        if (!document.documentElement.scrollLeft)
            scrollX = document.body.scrollLeft;
        else
            scrollX = document.documentElement.scrollLeft;

        if (!document.documentElement.scrollTop)
            scrollY = document.body.scrollTop;
        else
            scrollY = document.documentElement.scrollTop;
    }
    else {
        scrollX = window.pageXOffset;
        scrollY = window.pageYOffset;
    }
    //alert('x=' + scrollX + ', y=' + scrollY);

    jQuery.ajax({
        url: '/ajax/setwindowposition',
        data: { x: scrollX, y: scrollY },
        success: function (result) {
            if (result.isOk == false)
                alert(result.message);


        },
        async: false
    });

}

function sstchur_SmartScroller_Scroll() {
    var x = 1;

    jQuery.ajax({
        url: '/ajax/getwindowposition?' + Date(),
        success: function (result) {
            if (result.isOk == false)
                alert(result.message);

            var sValues = result.split(',', 2);
            scrollX = sValues[0];
            scrollY = sValues[1];

        },
        async: false
    });

    window.scrollTo(scrollX, scrollY);
}

//window.onload = sstchur_SmartScroller_Scroll;
//window.onscroll = sstchur_SmartScroller_GetCoords;
//window.onkeypress = sstchur_SmartScroller_GetCoords;
//window.onclick = sstchur_SmartScroller_GetCoords;


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            if (oldonload) {
                oldonload();
            }
            func();
        };
    }
}

addLoadEvent(sstchur_SmartScroller_Scroll);


//new skin jQuery

$(document).ready(function () {

    //Gives your the app Root
    var appRoot = $("#app-root").val() + "/";

    //Email Sign Up Scripts

    //Set Global Search Vars
    var emailText = "Email Address";
    var emailErrorText = "Incorrect Email";

    //Change Text
    $(".email-input").bind({
        focus: function () {
            $(this).parent().parent().addClass("focused");
            if ($(this).val() == emailText || $(this).val() == emailErrorText) {
                $(this).val("");
            }
        },
        blur: function () {
            $(this).parent().parent().removeClass("focused");
            if ($(this).val() == "") {
                $(this).val(emailText);
            }
        }
    });

    //    //Home Read More
    //    $(".read-more-link").click(function (event) {
    //        $(this).parent().find(".hide").slideToggle("fast");
    //        $(this).text($(this).text() == "Read More about GradSchools.com" ? "Hide more content" : "Read More about GradSchools.com");
    //        event.preventDefault();
    //    });

    //Home Read More in Carousel (This allows read more functionality in carousel)
    $(".read-more-link").click(function (event) {
        $(this).parent().find(".hide").toggle();
        $(this).parents(".viewport").css("height", $(this).parents(".carousel-item").height());



        $(this).text($(this).text() == "Read more" ? "Read less" : "Read more");

        $(".carousel-pager-holder").toggle();
        event.preventDefault();
    });

    //Added 8/31/2011 for Homepage carousel updates and browse SEO concerns

    //Activate Carousel on Homepage
    $('#home-page-carousel').tinycarousel({ pager: true });


    $(".email-input").keypress(function () {
        $(this).removeClass("error");
    });

    //Validate email
    $(".email-submit").click(function (event) {
        var emailInput = $(this).prev().val();

        if (emailInput != emailText || emailInput != emailErrorText) {
            event.preventDefault();
            jQuery.ajax({
                url: '/ajax/processnewsletterrequest',
                data: { sEmail: emailInput },
                success: function (result) {
                    if (result == 'Please enter valid email<br />') {
                        $('#email-sign-up-form-validation-message').html(result.toString());
                        $('#email-sign-up-form-validation-message').attr('style', '');
                        $('#email-sign-up-form-validation-message').attr('class', 'error');
                        //$(this).prev().val(emailErrorText).addClass("error");
                    } else {
                        $('.email-sign-up-form').attr('style', 'display:none;');
                        $('#email-sign-up-form-validation-message').html(result.toString());
                        $('#email-sign-up-form-validation-message').attr('style', '');
                        $('#email-sign-up-form-validation-message').attr('class', 'completed');
                    }
                },
                async: false
            });
        }
    });

    //Simple Tabs
    $(".js-tabs a").click(function (event) {
        $(this).parent().parent().find("li").removeClass("selected");
        $(this).parent().addClass("selected");
        var currentTab = $(this).attr("href");
        var HiddenTabs = $(this).parent().parent().attr("id");
        $("." + HiddenTabs).hide();
        $(currentTab).fadeIn(500);
        event.preventDefault();
    });

    //Search Scripts

    //Set Global Search Vars
    var searchText = "Search GradSchools.com";
    var searchErrorText = "Please Use Another Query";
    var searchTextCleaned = "Search-GradSchools-com";
    var searchErrorTextCleaned = "Please-Use-Another-Query";

    var hostname = window.location.hostname;

    if (hostname == 'localhost') {
        hostname = 'http://' + hostname + ':2275/';
    }
    else {
        hostname = 'http://' + hostname + '/';
    }

    //Change Text
    $(".search-input").bind({
        focus: function () {
            $(this).parent().parent().addClass("focused");
            if ($(this).val() == searchText || $(this).val() == searchErrorText) {
                $(this).val("");
            }
        },
        blur: function () {
            $(this).parent().parent().removeClass("focused");
            if ($(this).val() == "") {
                $(this).val(searchText);
            }
        }
    });

    $(".search-input").keypress(function () {
        if ($(this).val().length <= 0) {
            $(this).parent().parent().removeClass("focused");
            $(this).parent().parent().removeClass("error");
        }
        else {
            $(this).parent().parent().addClass("focused");
            $(this).parent().parent().removeClass("error");
        }
    });

    //Validate Search
    $(".search-submit").click(function (event) {
        var searchInput = $.trim($(this).prev().val()); //trim the searchInput first so that the blank spaces don't get set to dashes.  
        //Before if you put in 3 spaces you'd get 2 dashes and it would throw off the check below if (searchInput == "")
        searchInput = searchInput.replace(/[^a-zA-Z0-9]/g, '-');    // replace all non-letters and numbers with dash
        //searchInput = searchInput.replace(/-/, ' ');
        searchInput = searchInput.replace(/\s+$/, '');
        //searchInput = searchInput.replace('\-{2,}', '-');  // change multiple consecutive dashes to single dash   TODO not working
        searchInput = searchInput.replace(/-$/, '');    // trim any trailing dash
        event.preventDefault();

        if (searchInput == searchText || searchInput == searchErrorText || searchInput == searchTextCleaned || searchInput == searchErrorTextCleaned || searchInput == "") {
            $(this).prev().val(searchErrorText);
            $(this).parent().parent().addClass("SearchError");
            //alert($(this).parent().parent().attr("class"));
        }
        else {

            formAction = "";
            var cboSearch = $("#cboSearch :selected").val();
            switch (cboSearch) {
                case "Programs":
                    formAction = "search-programs/term-";
                    break;
                case "Schools":
                    formAction = "search-schools/term-";
                    break;
                case "Resources":
                    formAction = "search-resources/term-";
                    break;
            }

            location.href = hostname + formAction + searchInput.replace("&", "").toLowerCase();
        }

    });

    //Search Action Change with Drop-Down
    $(".search-type").val("programs");
    $(".search-type").focus(function () {
        $(this).css("background", "#fff");
    });
    $(".search-type").blur(function () {
        $(this).css("background", "transparent");
    });


    $(".search-type").change(function () {
        formAction = "";
        var cboSearch = $("#cboSearch :selected").val();

        switch (cboSearch) {
            case "Programs":
                formAction = "search-programs/term-";
                break;
            case "Schools":
                formAction = "search-schools/term-";
                break;
            case "Resources":
                formAction = "search-resources/term-";
                break;
        }

        $(this).parent("form").attr("action", hostname + formAction);
    });

    //Form Field Validation

    //Focus Blur Text Fields
    $(".form-holder .text-field").focus(function () {
        $(this).addClass("focused");
    });
    $(".form-holder .text-field").blur(function () {
        $(this).removeClass("focused");
    });

    //Validation Message
    //form validation needs to centralized and have common element ids. There should be a new user story created to address this.
    //$(".form-holder input[type*='text'].required").not("input[type*='checkbox'], input[type*='radio']").parent().parent().addClass("required-parent");
    $(".form-holder select.required").parent().parent().addClass("required-select");
    $(".form-holder input[type*='checkbox'].required").parent().parent().addClass("required-checkbox");
    $(".form-holder .required-list").parent().parent().parent().addClass("required-list-parent");

    var errorTop = '<div class="validation-message validation-error-container clearfix"><span class="validation-error"><table class="error-message-hover"><tr class="row-1"><td class="cell-1-1"></td><td class="cell-1-2"></td><td class="cell-1-3"></td><td class="cell-1-4" rowspan="3"></td></tr><tr class="row-2"><td class="cell-2-1"></td><td class="cell-2-2">';
    var errorBottom = '</td><td class="cell-2-3"></td></tr><tr class="row-3"><td class="cell-3-1"></td><td class="cell-3-2"></td><td class="cell-3-3"></td></tr></table></span></div>';
    $(".form-holder input[type*='text'].required, .form-holder input[type*='password'].required, .form-holder textarea.required").blur(function () {
        $(this).parent().find(".validation-message").remove();
        if ($(this).val() == "") {
            var text = $(this).attr("data-required");
            $(this).before(errorTop + text + errorBottom).addClass("error-field");
        }
        else {
            $(this).before('<span class="validation-message validation-confirm"></span>').removeClass("error-field");
        }
    });
    $(".form-holder input[type*='text'].email").blur(function () {
        if (!validEmail($(this).val())) {
            $(this).addClass("error-field");
            //form validation needs to centralized and have common element ids. There should be a new user story created to address this. This is temporary fix please don't yell at me :).
            if ($('#registrationerror').length > 0) {
                $('#registrationerror').attr('style', '');
                $('#registrationerror').attr('class', 'error');
                $('#registrationerror').html('Please enter a valid email.');
            }
        } else {
            if ($('#registrationerror').length > 0) {
                $('#registrationerror').attr('style', 'display:none;');
            }
          
        }
    });
    function validEmail(email) {
        var re = "^[a-zA-Z0-9_\\+-]+(\\.[a-zA-Z0-9_\\+-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.([a-zA-Z]{2,4})$";
        return email.match(re);
    }
    $(".form-holder select.required").change(function () {
        $(this).parent().find(".validation-message").remove();
        if ($(this).val() == "") {
            var text = $(this).attr("data-required");
            $(this).before(errorTop + text + errorBottom).addClass("error-select"); ;
        }
        else {
            $(this).before('<span class="validation-message validation-confirm"></span>').removeClass("error-select");
        }
    });


    function ActivateLink() {
        $(".alpha-wrapper a").removeClass("selected");
        //Look through all letters in the GS List
        var returnVal = false;
        $(".alpha-wrapper a").filter(function () {
            //Take the current URL
            var currentURL = window.location.toString();

            // this line only does this for Graduate Schools List and ignores this behavior on the Subject List
            if (currentURL[currentURL.length - 2] == "/") {
                //return true if the bit after the last slash is the current page name
                returnVal = $(this).attr("href")[$(this).attr("href").length - 1].toLowerCase() == currentURL[currentURL.length - 1].toLowerCase();
            }
            return returnVal;
            //when the filter function is done, you're left with the links that match.
        }).addClass("selected");

        //Afterwards, look back through the links. If none of them were marked,
        //mark your default one.
        if ($(".alpha-wrapper a").hasClass("selected") == false) {
            $("#A").addClass("selected");
        }
    }

    ActivateLink();

    //Activate Jquery Suckerfish for Drop Down Menus
    $('ul.sf-menu').superfish();
    $('ul.program-selected').superfish();

    //Adding this to change width of first Drop Down Menu
    $('ul.sf-menu ul:first').addClass("first-menu-child");

    //Add Class to FIRST menu where children go below the page. Just add the count and another ||
    $("ul.sf-menu ul:first > li").each(function (i) {
        if (i == 7 || i == 9 || i == 10 || i == 11 || i == 12 || i == 13) {
            $(this).addClass("menu-bottom");
        }
    });

    //International Graduate Programs Drop down logic.
    $(document).ready(function () {
        //first load of page choose the first item
        if ($('#viewSchools').attr('href') == 'none' && $.cookie('selectedSchool') == '') {
            $.cookie('selectedSchool', '../programs/afghanistan');
            $('#viewSchools').attr('href', $.cookie('selectedSchool'));
        };

        //if cookie exists use that (this will allow an href value if someone clicks "View schools" and then uses the back button.
        if ($('#viewSchools').attr('href') == 'none' && $.cookie('selectedSchool') != '') {
            $('#viewSchools').attr('href', $.cookie('selectedSchool'));
            $('#int-country-select').val($.cookie('selectedSchool'));
        };

        //any change to the drop down will result in the selected value being set for the cookie and href.
        $('#int-country-select').change(function () {
            $.cookie('selectedSchool', $('#int-country-select').val());
            $('#viewSchools').attr('href', $.cookie('selectedSchool'));
        });

    });

    $(document).ready(function () {
        var searchUrl;
        // alert('searchUrlBefore=' + $.cookie("searchUrl"));
        if ($.cookie("searchUrl") == null) {
            searchUrl = "programs";
            $.cookie("searchUrl", searchUrl);
        }
        else if ($.cookie("searchUrl") === $("#cboSearch").val()) {
            $("#cboSearch").val($("#cboSearch").val());

        }
        else {
            $("#cboSearch").val($.cookie("searchUrl"));
        }

        // alert('searchUrlAfter=' + $.cookie("searchUrl"));

        $("#cboSearch").change(function () {
            $.cookie("searchUrl", null);
            $.cookie("searchUrl", $("#cboSearch").val());
            $(".search-input").val(searchText);
        });

    });



    //activate Auto Complete
    var acOptions = {
        minChars: 3,
        delay: 100,
        dataType: 'json', // this parameter is currently unused
        extraParams: {
            format: 'json' // pass the required context to the Zend Controller
        },
        parse: function (data) {
            var parsed = [];

            for (var i = 0; i < data.length; i++) {
                parsed[parsed.length] = {
                    data: data[i],
                    value: data[i].ResultName,
                    result: data[i].ResultName
                };
            }
            return parsed;
        },
        formatItem: function (item) {
            return item.ResultName;
        }
    };

    $(".search-input")
        .autocomplete(hostname + 'search/autocomplete', acOptions)
        .result(function (event, item) {
            location.href = item.NavPath;
        });


    //Scroll To Search Box
    $(".search-footer-holder .search-input").focus(function (event) {
        event.preventDefault();
        var targetOffset = $(this).parent().parent().offset();
        var targetTop = targetOffset.top;
        $('html, body').animate({ scrollTop: targetTop }, 2000);
    });

    //Show Hide Similar Programs
    var moreText = "View More Programs";
    var lessText = "Hide More Programs";
    $(".view-more-trigger a").click(function (event) {
        var currentParent = $(this).parent().parent().parent().parent().parent().parent();
        currentParent.parent().addClass("active");
        currentParent.find(".more-matching").first().slideToggle(500);
        // $(this).parent().parent().parent().parent().parent().parent().siblings().find(".view-less-trigger").hide();
        currentParent.find(".view-less-trigger").toggle();
        currentParent.toggleClass("active");
        currentParent.find(".more-matching:visible").not(currentParent.find(".more-matching")).first().hide().parent(".active").removeClass("active");
        $(this).not($(this)).text(lessText);
        var currentText = $(this).text();
        $(this).text(currentText == moreText ? lessText : moreText);
        $(".program-holder-parent-inner, .program-holder-child").hoverIntent({
            over: showHidden,
            timeout: 100,
            out: hideHidden
        });
        event.preventDefault();
    });

    $(".view-less-trigger a").click(function (event) {
        var currentParent = $(this).parent().parent().parent().parent().parent().parent();
        currentParent.find(".more-matching").slideUp(500);
        currentParent.find(".more-matching").parent(".active").removeClass("active");
        $(this).parent().hide();
        $(".view-more-trigger a").text(moreText);
        event.preventDefault();
    });

    $(".program-holder-parent-inner, .program-holder-child").hoverIntent({
        over: showHidden,
        timeout: 100,
        out: hideHidden
    });

    function showHidden() {

        var programVideoCheckParameters = {};
        programVideoCheckParameters.mediaType = "video";
        programVideoCheckParameters.id = $(this).find(".video-photo-icons").attr('id');
        var parent = $(this);
        $.getJSON('/ajax/doesprogramhavemedia', programVideoCheckParameters,
            function (response) {
                if (response.HasMedia) {
                    var videoIcon = parent.find("#video");
                    videoIcon.removeClass("hide");
                }
            }
        );
        var programPhotosCheckParameters = {};
        programPhotosCheckParameters.mediaType = "photo";
        programPhotosCheckParameters.id = $(this).find(".video-photo-icons").attr('id');
        $.getJSON('/ajax/doesprogramhavemedia', programPhotosCheckParameters,
            function (response) {
                if (response.HasMedia) {
                    var photoIcon = parent.find("#photo");
                    photoIcon.removeClass("hide");
                }
            }
        );
        $(this).find(".hoverIntent").fadeIn(100).css("display", "inline-block");
        $(this).parent().not(".active").addClass("active-hover");
        $("#hiddenPlaceholder").hide();
    }

    function hideHidden() {
        $(this).find(".hoverIntent").fadeOut(100);
        $(this).parent().removeClass("active-hover");
        $("#hiddenPlaceholder").show();
    }


    //Read more for 1-2 Dim pages
    $(".page-summary-read-more").click(function () {
        $("#page-summary-hidden").slideToggle(200);
        $(this).toggleClass("page-summary-read-more-active");
        $(this).find("a").text($(this).find("a").text() == "Read More" ? "Hide More" : "Read More");
    });
    $(".page-summary-read-more a").click(function (event) {
        event.preventDefault();
    });

    //Smooth Scrolling

    $(".scroll").click(function (event) {
        event.preventDefault();
        var full_url = this.href;
        var parts = full_url.split("#");
        var trgt = parts[1];
        var target = $("#" + trgt);
        var target_offset = target.offset();
        var target_top = target_offset.top;
        $('html, body').animate({ scrollTop: target_top }, 500);
    });


    //location Selection

    //    $(".select-location li").each(function () {
    //        // $(this).find("a").before('<input type="checkbox" value="' + $(this).text() + '" />');
    //    });

    //    $(".multi-select").click(function () {

    //        //alert($(this).attr("id") + "-button");
    //        if ($("body").find("#" + $(this).attr("id") + "-lightbox").size() == 0) {
    //            $(".page-holder").after('<div class="lightbox multi-select-lightbox" id="' + $(this).attr("id") + "-lightbox" + '"><div class="lighbox-inner clearfix">' + $(this).find(".multi-select-hidden").html() + '<div class="button-holder"><button class="cancel">Cancel</button><button class="update" id="' + $(this).attr("id") + "-button" + '">Update</button></div></div></div>');
    //        }
    //        else {
    //            $("#" + $(this).attr("id") + "-lightbox").show();
    //        }

    //        $(".multi-select-lightbox").css("left", $(window).width() / 2 - ($(".multi-select-lightbox").width() / 2)).css("top", $(window).height() / 2 - ($(".multi-select-lightbox").height() / 2));

    //        $(".overlay").fadeTo(0, 0.70);

    //        if ($.browser.msie == true) {
    //            $(".sf-menu").css("visibility", "hidden");
    //        }

    //        $(this).find(".multi-select-lightbox").show();

    //    });

    //Hides Overlay and lightbox
    $(".multi-select-lightbox .cancel, .overlay").live("click", function () {
        $(".overlay").fadeOut(500);
        $(".multi-select-lightbox").remove();
        if ($.browser.msie == true) {
            $(".sf-menu").css("visibility", "visible");
        }
    });

    $(".multi-select-lightbox a").live("click", function (event) {
        if ($(this).prev('input').is(':checked')) {
            $(this).prev('input').attr('checked', false);
        }
        else {
            $(this).prev('input').attr('checked', true);
        }

        event.preventDefault();
    });

    //Puts multi select value in data-original-text attribute
    $(".multi-select h6").each(function () {
        $(this).attr("data-original-text", $(this).text());
    });



    //Home Page Location Search
    //    $("#zip-code").keyup(function () {
    //        $(this).val($(this).val().replace(/[^0-9\.]+/g, ""));
    //    });

    //    $(".home-search-button").click(function () {
    //        var HomeUrl = "";
    //        $(".home-location-select h6").each(function () {
    //            if ($(this).hasClass("has-form-values")) {
    //                HomeUrl += $(this).text().replace(/, /g, "/").replace(/ /g, "-").toLowerCase() + '/';
    //            }
    //        });

    //        if ($("#zip-code").val() != "") {
    //            HomeUrl = HomeUrl + "zip-" + $("#zip-code").val() + "-radius-" + $("#zip-radius").val();
    //        }

    //        location.href = "search-programs/" + HomeUrl;

    //    });

    //    //Inner page Zip Code Search
    //    $(".inner #zip-button").click(function (event) {
    //        if ($("#zip-code").val() != "") {
    //            location.href = "search-programs/" + "zip-" + $("#zip-code").val() + "-radius-" + $("#zip-radius").val();
    //        }
    //        else {
    //            alert("Please Enter a Zip Code");
    //            event.preventDefault();
    //        }

    //    });
    //search by Location Menu
    function SearchByLocationMenu() {

        var currentLightBoxElement;
        this.SetCurrentLightBoxElement = function (lightBoxElement) {
            this.currentLightBoxElement = lightBoxElement;
        }

        this.SetZipCodeControls = function (container, textInput, buttonInput, selectInput) {
            var parent = this;



            buttonInput.click(function (event) {
                event.preventDefault();
                if (textInput.val() != "") {

                    parent.redirectToZipSearchResultsPage(textInput.val(), selectInput.val());
                }
                else {
                    $('#zipvalidationmessage').html("<p>Please Enter a Zip Code</P>");
                    $('#zipvalidationmessage').attr('style', '');
                    $('#zipvalidationmessage').attr('class', 'form error');


                }

            });


        }

        var currentCountrySelectButton;
        this.SetCurrentCountrySelectButton = function (selectButton) {
            var parent = this;
            if (selectButton.length > 0) {
                this.currentCountrySelectButton = selectButton;
                this.enableCurrentCountrySelectButton();
                if (this.compareCookieAgainstUrl(this.currentCountrySelectButton.attr("id"))) {
                    var currentCountrySelectCookieValue = $.cookie(this.currentCountrySelectButton.attr("id"));
                    currentCountrySelectCookieValueArray = currentCountrySelectCookieValue.split(';');
                    if (currentCountrySelectCookieValue != null) {
                        if (currentCountrySelectCookieValue.toLowerCase().indexOf('united-states') > -1 && currentCountrySelectCookieValueArray.length == 1) {
                            this.disableCurrentCountrySelectButton();
                        }
                        else {
                            if (currentCountrySelectCookieValue.toLowerCase().indexOf('united-states') == -1) {
                                this.disableCurrentStateSelectButton();
                                this.disableCurrentCitySelectButton();
                            }
                        }
                        this.renderSelectedLocations(this.currentCountrySelectButton, "#selected-countries", currentCountrySelectCookieValueArray);
                    } else {
                        this.renderSelectedLocations(this.currentCountrySelectButton, "#selected-countries", location.pathname.split("/"));
                    }
                }
                else {
                    this.deleteSearchStateCookie(this.currentCountrySelectButton.attr("id"));
                }
            }
        }
        this.disableCurrentCountrySelectButton = function () {
            var parent = this;
            if (this.currentCountrySelectButton != null) {
                if (this.currentCountrySelectButton.length > 0) {
                    this.currentCountrySelectButton.unbind();
                    this.currentCountrySelectButton.fadeTo('slow', 0.5);
                    this.currentCountrySelectButton.attr('style', 'cursor:default;');
                }
            }
        }
        this.enableCurrentCountrySelectButton = function () {
            var parent = this;
            if (this.currentCountrySelectButton != null) {
                if (this.currentCountrySelectButton.length > 0) {
                    this.currentCountrySelectButton.click(function () { parent.renderLightBox($(this)); });
                    this.currentCountrySelectButton.fadeTo('slow', 1);
                    this.currentCountrySelectButton.attr('style', '');
                }
            }
        }
        var currentStateSelectButton;
        this.SetCurrentStateSelectButton = function (selectButton) {
            var parent = this;
            if (selectButton.length > 0) {
                this.currentStateSelectButton = selectButton;
                if (this.currentStateSelectButton != null) {
                    this.enableCurrentStateSelectButton();
                    var currentStateSelectCookieValue = $.cookie(this.currentStateSelectButton.attr("id"));
                    if (currentStateSelectCookieValue != null) {
                        currentStateSelectCookieValue = currentStateSelectCookieValue.split(';');
                        this.renderSelectedLocations(this.currentStateSelectButton, "#selected-states", currentStateSelectCookieValue);
                    } else {
                        this.renderSelectedLocations(this.currentStateSelectButton, "#selected-states", location.pathname.split("/"));
                    }
                }
            }
        }
        this.disableCurrentStateSelectButton = function () {
            var parent = this;
            if (this.currentStateSelectButton != null) {
                if (this.currentStateSelectButton.length > 0) {
                    this.currentStateSelectButton.unbind();
                    this.currentStateSelectButton.fadeTo('slow', 0.5);
                    this.currentStateSelectButton.attr('style', 'cursor:default;');
                }
            }
        }
        this.enableCurrentStateSelectButton = function () {
            var parent = this;
            if (this.currentStateSelectButton != null) {
                if (this.currentStateSelectButton.length > 0) {
                    this.currentStateSelectButton.click(function () { parent.renderLightBox($(this)); });
                    this.currentStateSelectButton.fadeTo('slow', 1);
                    this.currentStateSelectButton.attr('style', '');
                }
            }
        }
        var currentCitySelectButton;
        this.SetCurrentCitySelectButton = function (selectButton) {
            var parent = this;
            if (selectButton.length > 0) {
                this.currentCitySelectButton = selectButton;
                this.enableCurrentCitySelectButton();
                var currentCitySelectCookieValue = $.cookie(this.currentCitySelectButton.attr("id"));
                if (currentCitySelectCookieValue != null) {
                    currentCitySelectCookieValue = currentCitySelectCookieValue.split(';');
                    this.renderSelectedLocations(this.currentCitySelectButton, "#selected-cities", currentCitySelectCookieValue);
                } else {
                    this.renderSelectedLocations(this.currentCitySelectButton, "#selected-cities", location.pathname.split("/"));
                }
            }
        }

        this.disableCurrentCitySelectButton = function () {
            var parent = this;
            if (this.currentCitySelectButton != null) {
                if (this.currentCitySelectButton.length > 0) {
                    this.currentCitySelectButton.unbind();
                    this.currentCitySelectButton.fadeTo('slow', 0.5);
                    this.currentCitySelectButton.attr('style', 'cursor:default;');
                }
            }
        }
        this.enableCurrentCitySelectButton = function () {
            var parent = this;
            if (this.currentCitySelectButton != null) {
                if (this.currentCitySelectButton.length > 0) {
                    this.currentCitySelectButton.click(function () { parent.renderLightBox($(this)); });
                    this.currentCitySelectButton.fadeTo('slow', 1);
                    this.currentCitySelectButton.attr('style', '');
                }
            }
        }
        this.renderSelectedLocations = function (senderObj, region, selectedLocationsArray) {
            var parent = this;
            $(region).find("a").each(function (index) {
                $(this).click(function (index) {
                    parent.removeLocation(senderObj, $(this).attr("alt"));
                });
            });
        }

        this.renderLightBox = function (senderObj) {

            var parent = this;
            if ($("body").find("#" + senderObj.attr("id") + "-lightbox").size() == 0) {
                $(".page-holder").after('<div class="lightbox multi-select-lightbox" id="' +
                senderObj.attr("id") + "-lightbox" + '"><div class="lighbox-inner clearfix">' +
                senderObj.find(".multi-select-hidden").html() +
                '<div class="button-holder"><button class="cancel">Cancel</button><button class="update" id="' +
                senderObj.attr("id") + "-button" + '">Update</button></div></div></div>');
            }
            else {
                $("#" + senderObj.attr("id") + "-lightbox").show();
            }

            $(".multi-select-lightbox").css("left", $(window).width() / 2 - ($(".multi-select-lightbox").width() / 2)).css("top", $(window).height() / 2 - ($(".multi-select-lightbox").height() / 2));

            $(".overlay").fadeTo(0, 0.70);

            if ($.browser.msie == true) {
                $(".sf-menu").css("visibility", "hidden");
            }

            //Multi Select
            $(".multi-select-lightbox .update").click(function () {
                var lightBoxId = "#" + $(this).attr("id").replace("button", "lightbox");
                var checkBoxes = $(lightBoxId + " input:checked");
                parent.deleteSearchStateCookie(senderObj.attr("id"));
                if (parent.currentStateSelectButton != null) {
                    if ($(this).attr("id").indexOf(parent.currentStateSelectButton.attr("id")) > -1 || $(this).attr("id").indexOf(parent.currentCitySelectButton.attr("id")) > -1) {
                        parent.saveSearchStateCookie(senderObj.attr("id"), parent.buildSearchDisplayString(checkBoxes));
                        if (parent.currentCountrySelectButton != null) {
                            var currentCountrySelectCookieValue = $.cookie(parent.currentCountrySelectButton.attr("id"));

                            if (currentCountrySelectCookieValue == null) {

                                parent.saveSearchStateCookie(parent.currentCountrySelectButton.attr("id"), "united-states");
                            }
                        }
                        parent.redirectToSearchResultsPage(parent.buildSearchUrlString(checkBoxes), "united-states");
                    } else {
                        parent.saveSearchStateCookie(senderObj.attr("id"), parent.buildSearchDisplayString(checkBoxes));
                        parent.redirectToSearchResultsPage(parent.buildSearchUrlString(checkBoxes), "");
                    }
                } else {
                    parent.saveSearchStateCookie(senderObj.attr("id"), parent.buildSearchDisplayString(checkBoxes));
                    parent.redirectToSearchResultsPage(parent.buildSearchUrlString(checkBoxes), "");
                }
            });

            senderObj.find(".multi-select-lightbox").show();
        }



        this.removeLocation = function (senderObj, locationString) {
            formatedlocationString = this.formatLocationForUrl(locationString);
            var currentLocation = location.href;
            if (this.currentCountrySelectButton != null) {
                if (senderObj.attr("id") == this.currentCountrySelectButton.attr("id")) {

                    var updatedCountryCookieValue = $.cookie(this.currentCountrySelectButton.attr("id"));
                    if (updatedCountryCookieValue != null) {
                        var updatedCountryCookieValueArray = updatedCountryCookieValue.split(";");
                        if (updatedCountryCookieValueArray.length > 1) {

                            if (updatedCountryCookieValueArray[0] == locationString) {
                                updatedCountryCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(locationString.toLowerCase() + ",", "");
                                this.saveSearchStateCookie(senderObj.attr("id"), updatedCountryCookieValue);
                            }
                            else {
                                updatedCountryCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(";" + locationString.toLowerCase(), "");
                                this.saveSearchStateCookie(senderObj.attr("id"), updatedCountryCookieValue);
                            }
                        } else {
                            this.deleteSearchStateCookie(senderObj.attr("id"));
                        }
                        currentLocation = currentLocation.toLowerCase().replace("/" + formatedlocationString.toLowerCase(), "");
                    }

                    if (this.currentStateSelectButton != null) {
                        var updatedStateCookieValue = $.cookie(this.currentStateSelectButton.attr("id"));
                        if (updatedStateCookieValue != null) {
                            updatedStateCookieValueArray = updatedStateCookieValue.split(";");
                            for (i = 0; i < updatedStateCookieValueArray.length; i++) {
                                formatedLocation = this.formatLocationForUrl(updatedStateCookieValueArray[i]);
                                if (currentLocation.indexOf(this.formatLocationForUrl(updatedStateCookieValueArray[i]) + "/") > -1) {
                                    currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedStateCookieValueArray[i]) + "/", "");
                                }
                                else {
                                    currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedStateCookieValueArray[i]), "");
                                }
                            }
                            this.deleteSearchStateCookie(this.currentStateSelectButton.attr("id"));
                        }
                    }
                    if (this.currentCitySelectButton != null) {
                        var updatedCityCookieValue = $.cookie(this.currentCitySelectButton.attr("id"));
                        if (updatedCityCookieValue != null) {
                            var updatedCityCookieValueArray = updatedCityCookieValue.split(";");
                            for (i = 0; i < updatedCityCookieValueArray.length; i++) {
                                var value = this.formatLocationForUrl(updatedCityCookieValueArray[i]);
                                if (currentLocation.indexOf(value + "/") > -1) {
                                    currentLocation = currentLocation.replace(value + "/", "");
                                }
                                else {
                                    currentLocation = currentLocation.replace(value, "");
                                }
                            }
                            this.deleteSearchStateCookie(this.currentCitySelectButton.attr("id"));
                        }
                    }
                    var testVal = currentLocation.substring(currentLocation.length - 1, currentLocation.length);
                    if (testVal == "/") {
                        currentLocation = currentLocation.substring(0, currentLocation.length - 1);
                    }
                    location.replace(currentLocation);
                } else {
                    var updatedCookieValue = $.cookie(senderObj.attr("id"));
                    var updatedCookieValueArray = updatedCookieValue.split(";");

                    if (updatedCookieValueArray.length > 1) {

                        if (updatedCookieValueArray[0] == locationString) {
                            updatedCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(locationString.toLowerCase() + ",", "");
                            this.saveSearchStateCookie(senderObj.attr("id"), updatedCookieValue);
                        }
                        else {
                            updatedCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(";" + locationString.toLowerCase(), "");
                            this.saveSearchStateCookie(senderObj.attr("id"), updatedCookieValue);
                        }
                    } else {
                        this.deleteSearchStateCookie(senderObj.attr("id"));
                    }
                    currentLocation = currentLocation.toLowerCase().replace("/" + formatedlocationString.toLowerCase(), "");
                    var testVal = currentLocation.substring(currentLocation.length - 1, currentLocation.length);
                    if (testVal == "/") {
                        currentLocation = currentLocation.substring(0, currentLocation.length - 1);
                    }
                    location.replace(currentLocation);
                }
            } else {
                var updatedCookieValue = $.cookie(senderObj.attr("id"));
                var updatedCookieValueArray = updatedCookieValue.split(";");

                if (updatedCookieValueArray.length > 1) {

                    if (updatedCookieValueArray[0] == locationString) {
                        updatedCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(locationString.toLowerCase() + ",", "");
                        this.saveSearchStateCookie(senderObj.attr("id"), updatedCookieValue);
                    }
                    else {
                        updatedCookieValue = $.cookie(senderObj.attr("id")).toLowerCase().replace(";" + locationString.toLowerCase(), "");
                        this.saveSearchStateCookie(senderObj.attr("id"), updatedCookieValue);
                    }
                } else {
                    this.deleteSearchStateCookie(senderObj.attr("id"));
                }
                currentLocation = currentLocation.toLowerCase().replace("/" + formatedlocationString.toLowerCase(), "");
                var testVal = currentLocation.substring(currentLocation.length - 1, currentLocation.length);
                if (testVal == "/") {
                    currentLocation = currentLocation.substring(0, currentLocation.length - 1);
                }
                location.replace(currentLocation);
            }

        }

        this.formatLocationForUrl = function (locationString) {
            locationString = locationString.replace(".", " ");
            locationString = locationString.replace(", ", " ");
            locationString = locationString.replace(",", "");
            locationString = locationString.replace(new RegExp(" ", 'g'), "-");
            return locationString.toLowerCase();
        }

        this.buildSearchUrlString = function (inputs) {
            var urlString = "";
            var loopLength = inputs.size();
            inputs.each(function (index) {
                if (location.pathname.indexOf($(this).val().toLowerCase()) == -1) {
                    urlString += $(this).val();
                    if (index < loopLength - 1) {
                        if (loopLength > 1) {
                            urlString += "/";
                        }
                    }
                }
            });
            return urlString;
        }

        this.buildSearchDisplayString = function (inputs) {
            var searchString = "";
            var loopLength = inputs.size();
            inputs.each(function (index) {

                searchString += $(this).attr("value");
                if (index < loopLength - 1) {
                    if (loopLength > 1) {
                        searchString += ";";
                    }
                }

            });
            return searchString;
        }
        this.redirectToZipSearchResultsPage = function (zipcode, radius) {
            var path = location.pathname;
            if (path.indexOf('/zip-') != -1) {
                path = path.substr(0, path.indexOf('/zip-'));
            }
            if (path == "/") {
                path = '/search-programs';
            }
            if (path.indexOf('/programs') != -1) {
                path = path.replace('programs', 'search-programs');
            }

            if (location.hostname == 'localhost') {
                location.replace('http://' + location.host + this.removeAllLocationsFromPath(path) + '/' + "zip-" + zipcode + "-radius-" + radius);
            }
            else {
                location.replace('http://' + location.hostname + this.removeAllLocationsFromPath(path) + '/' + "zip-" + zipcode + "-radius-" + radius);
            }
        }
        this.redirectToSearchResultsPage = function (searchUrlString, country) {
            var urlString = "";
            var path = location.pathname;
            if (path.indexOf('/zip-') != -1) {
                path = path.substr(0, path.indexOf('/zip-'));
            }
            if (path.indexOf('program-types/') != -1) {
                path = path.substr(0, path.indexOf('program-types/'));
            }
            if (searchUrlString != "") {

                if (path.indexOf('/programs') > -1 || path.indexOf('/search-programs') > -1) {
                    if (country != "") {
                        if (path.indexOf(country) > -1) {
                            path = path.replace(new RegExp(country + "/", 'g'), "");
                        }
                        path = path + "/" + country;
                    }
                    if (searchUrlString.split("/").length > 1 && path.split("/").length > 1) {

                        if (path.indexOf('/programs') != -1) {
                            path = path.replace('programs', 'search-programs');
                        }
                        urlString = path + "/" + searchUrlString;

                    } else {

                        if (path.indexOf('/search-programs') != -1) {
                            if (path.split("/").length == 1) {
                                path = path.replace('search-programs', 'programs');
                            }
                        }
                        urlString = path + "/" + searchUrlString;
                    }
                }
                else {
                    if (path == "/") {
                        if (country != "") {
                            if (path.indexOf(country) > -1) {
                                path = path.replace(new RegExp(country + "/", 'g'), "");
                            }
                            path = path + country + "/";
                        }
                        if (searchUrlString.split("/").length > 1) {
                            urlString = "/search-programs" + path + searchUrlString;
                        } else {
                            urlString = "/programs" + path + searchUrlString;
                        }
                    } else {
                        path = path.substr(1, path.length);
                        urlString = "/" + path + "/" + searchUrlString;
                    }
                }
                if (location.hostname == 'localhost') {
                    location.replace('http://' + location.host + urlString);
                }
                else {
                    location.replace('http://' + location.hostname + urlString);
                }
            } else {
                if (location.hostname == 'localhost') {
                    location.replace('http://' + location.host + path);
                }
                else {
                    location.replace('http://' + location.hostname + path);
                }
            }
        }

        this.compareCookieAgainstUrl = function (cookieName) {
            var doesUrlHaveCookieValues = false;
            var cookieToCompareValue = $.cookie(cookieName);
            if (cookieToCompareValue != null) {
                var cookieToCompareValueArray = cookieToCompareValue.split(";");
                for (i = 0; i < cookieToCompareValueArray.length; i++) {
                    if (location.pathname.indexOf(cookieToCompareValueArray[i].toLowerCase()) > -1) {
                        doesUrlHaveCookieValues = true;
                        break;
                    }
                }
            }
            return doesUrlHaveCookieValues;
        }

        this.removeAllLocationsFromPath = function (path) {
            var currentLocation = path;
            var cleanedPath = "";
            if (this.currentCountrySelectButton != null) {
                var updatedCountryCookieValue = $.cookie(this.currentCountrySelectButton.attr("id"));
                if (updatedCountryCookieValue != null) {
                    updatedCountryCookieValueArray = updatedCountryCookieValue.split(";");
                    for (i = 0; i < updatedCountryCookieValueArray.length; i++) {
                        formatedLocation = this.formatLocationForUrl(updatedCountryCookieValueArray[i]);
                        if (currentLocation.indexOf(this.formatLocationForUrl(updatedCountryCookieValueArray[i]) + "/") > -1) {
                            currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedCountryCookieValueArray[i]) + "/", "");
                        }
                        else {
                            currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedCountryCookieValueArray[i]), "");
                        }
                    }
                }
            }
            if (this.currentStateSelectButton != null) {
                var updatedStateCookieValue = $.cookie(this.currentStateSelectButton.attr("id"));
                if (updatedStateCookieValue != null) {
                    updatedStateCookieValueArray = updatedStateCookieValue.split(";");
                    for (i = 0; i < updatedStateCookieValueArray.length; i++) {
                        formatedLocation = this.formatLocationForUrl(updatedStateCookieValueArray[i]);
                        if (currentLocation.indexOf(this.formatLocationForUrl(updatedStateCookieValueArray[i]) + "/") > -1) {
                            currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedStateCookieValueArray[i]) + "/", "");
                        }
                        else {
                            currentLocation = currentLocation.replace(this.formatLocationForUrl(updatedStateCookieValueArray[i]), "");
                        }
                    }
                }
            }
            if (this.currentCitySelectButton != null) {
                var updatedCityCookieValue = $.cookie(this.currentCitySelectButton.attr("id"));
                if (updatedCityCookieValue != null) {
                    var updatedCityCookieValueArray = updatedCityCookieValue.split(";");
                    for (i = 0; i < updatedCityCookieValueArray.length; i++) {
                        var value = this.formatLocationForUrl(updatedCityCookieValueArray[i]);
                        if (currentLocation.indexOf(value + "/") > -1) {
                            currentLocation = currentLocation.replace(value + "/", "");
                        }
                        else {
                            currentLocation = currentLocation.replace(value, "");
                        }
                    }
                }
            }
            var testVal = currentLocation.substring(currentLocation.length - 1, currentLocation.length);
            if (testVal == "/") {
                currentLocation = currentLocation.substring(0, currentLocation.length - 1);
            }
            return currentLocation;

        }

        this.deleteSearchStateCookie = function (element) {
            $.cookie(element, null, { path: '/' });
        }

        this.saveSearchStateCookie = function (element, statevalue) {
            $.cookie(element, statevalue, { path: '/' });
        }
    }
    var leftNavSearchMenu = new SearchByLocationMenu();

    leftNavSearchMenu.SetZipCodeControls($('#zip-field-holder'), $('#txt_8053'), $('#zip-button'), $('#zip-radius'));

    leftNavSearchMenu.SetCurrentStateSelectButton($('#multi-state-select'));

    leftNavSearchMenu.SetCurrentCitySelectButton($('#multi-select-city'));

    leftNavSearchMenu.SetCurrentCountrySelectButton($('#multi-select-country'));


});

//Jquery Plugins




//Hover Intent Plugin
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);

//jQuery Autocomplete plugin 1.1
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;
} (';(3($){$.2e.1u({19:3(b,d){5 c=W b=="1B";d=$.1u({},$.M.1T,{Y:c?b:P,y:c?P:b,1J:c?$.M.1T.1J:10,X:d&&!d.1D?10:48},d);d.1y=d.1y||3(a){6 a};d.1v=d.1v||d.1R;6 A.I(3(){1M $.M(A,d)})},L:3(a){6 A.11("L",a)},1k:3(a){6 A.14("1k",[a])},2b:3(){6 A.14("2b")},28:3(a){6 A.14("28",[a])},24:3(){6 A.14("24")}});$.M=3(o,r){5 t={2Y:38,2S:40,2N:46,2I:9,2E:13,2B:27,2x:3I,2v:33,2p:34,2n:8};5 u=$(o).3r("19","3o").Q(r.2Q);5 p;5 m="";5 n=$.M.3c(r);5 s=0;5 k;5 h={1F:C};5 l=$.M.32(r,o,1Z,h);5 j;$.1Y.2X&&$(o.2U).11("45.19",3(){4(j){j=C;6 C}});u.11(($.1Y.2X?"43":"42")+".19",3(a){s=1;k=a.2M;3V(a.2M){O t.2Y:a.1d();4(l.N()){l.30()}w{12(0,D)}R;O t.2S:a.1d();4(l.N()){l.2D()}w{12(0,D)}R;O t.2v:a.1d();4(l.N()){l.2C()}w{12(0,D)}R;O t.2p:a.1d();4(l.N()){l.2A()}w{12(0,D)}R;O r.17&&$.1c(r.S)==","&&t.2x:O t.2I:O t.2E:4(1Z()){a.1d();j=D;6 C}R;O t.2B:l.Z();R;3J:1P(p);p=1O(12,r.1J);R}}).2t(3(){s++}).3E(3(){s=0;4(!h.1F){2r()}}).2q(3(){4(s++>1&&!l.N()){12(0,D)}}).11("1k",3(){5 c=(1r.7>1)?1r[1]:P;3 1N(q,a){5 b;4(a&&a.7){16(5 i=0;i<a.7;i++){4(a[i].L.J()==q.J()){b=a[i];R}}}4(W c=="3")c(b);w u.14("L",b&&[b.y,b.F])}$.I(15(u.K()),3(i,a){21(a,1N,1N)})}).11("2b",3(){n.1o()}).11("28",3(){$.1u(r,1r[1]);4("y"2h 1r[1])n.1e()}).11("24",3(){l.1p();u.1p();$(o.2U).1p(".19")});3 1Z(){5 e=l.2g();4(!e)6 C;5 v=e.L;m=v;4(r.17){5 b=15(u.K());4(b.7>1){5 f=r.S.7;5 c=$(o).18().1I;5 d,1H=0;$.I(b,3(i,a){1H+=a.7;4(c<=1H){d=i;6 C}1H+=f});b[d]=v;v=b.3f(r.S)}v+=r.S}u.K(v);1l();u.14("L",[e.y,e.F]);6 D}3 12(b,c){4(k==t.2N){l.Z();6}5 a=u.K();4(!c&&a==m)6;m=a;a=1m(a);4(a.7>=r.29){u.Q(r.26);4(!r.1s)a=a.J();21(a,3a,1l)}w{1q();l.Z()}};3 15(b){4(!b)6[""];4(!r.17)6[$.1c(b)];6 $.4h(b.23(r.S),3(a){6 $.1c(b).7?$.1c(a):P})}3 1m(a){4(!r.17)6 a;5 c=15(a);4(c.7==1)6 c[0];5 b=$(o).18().1I;4(b==a.7){c=15(a)}w{c=15(a.22(a.37(b),""))}6 c[c.7-1]}3 1G(q,a){4(r.1G&&(1m(u.K()).J()==q.J())&&k!=t.2n){u.K(u.K()+a.37(1m(m).7));$(o).18(m.7,m.7+a.7)}};3 2r(){1P(p);p=1O(1l,4g)};3 1l(){5 c=l.N();l.Z();1P(p);1q();4(r.36){u.1k(3(a){4(!a){4(r.17){5 b=15(u.K()).1n(0,-1);u.K(b.3f(r.S)+(b.7?r.S:""))}w{u.K("");u.14("L",P)}}})}};3 3a(q,a){4(a&&a.7&&s){1q();l.35(a,q);1G(q,a[0].F);l.20()}w{1l()}};3 21(f,d,g){4(!r.1s)f=f.J();5 e=n.31(f);4(e&&e.7){d(f,e)}w 4((W r.Y=="1B")&&(r.Y.7>0)){5 c={4f:+1M 4e()};$.I(r.2Z,3(a,b){c[a]=W b=="3"?b():b});$.4d({4c:"4b",4a:"19"+o.49,2V:r.2V,Y:r.Y,y:$.1u({q:1m(f),47:r.X},c),44:3(a){5 b=r.1A&&r.1A(a)||1A(a);n.1i(f,b);d(f,b)}})}w{l.2T();g(f)}};3 1A(c){5 d=[];5 b=c.23("\\n");16(5 i=0;i<b.7;i++){5 a=$.1c(b[i]);4(a){a=a.23("|");d[d.7]={y:a,F:a[0],L:r.1z&&r.1z(a,a[0])||a[0]}}}6 d};3 1q(){u.1h(r.26)}};$.M.1T={2Q:"41",2P:"3Z",26:"3Y",29:1,1J:3W,1s:C,1f:D,1w:C,1g:10,X:3U,36:C,2Z:{},1X:D,1R:3(a){6 a[0]},1v:P,1G:C,E:0,17:C,S:", ",1y:3(b,a){6 b.22(1M 3T("(?![^&;]+;)(?!<[^<>]*)("+a.22(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2K,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2K"),"<2J>$1</2J>")},1D:D,1E:3S};$.M.3c=3(g){5 h={};5 j=0;3 1f(s,a){4(!g.1s)s=s.J();5 i=s.2H(a);4(g.1w=="3R"){i=s.J().1k("\\\\b"+a.J())}4(i==-1)6 C;6 i==0||g.1w};3 1i(q,a){4(j>g.1g){1o()}4(!h[q]){j++}h[q]=a}3 1e(){4(!g.y)6 C;5 f={},2G=0;4(!g.Y)g.1g=1;f[""]=[];16(5 i=0,2F=g.y.7;i<2F;i++){5 c=g.y[i];c=(W c=="1B")?[c]:c;5 d=g.1v(c,i+1,g.y.7);4(d===C)1V;5 e=d.3Q(0).J();4(!f[e])f[e]=[];5 b={F:d,y:c,L:g.1z&&g.1z(c)||d};f[e].1U(b);4(2G++<g.X){f[""].1U(b)}};$.I(f,3(i,a){g.1g++;1i(i,a)})}1O(1e,25);3 1o(){h={};j=0}6{1o:1o,1i:1i,1e:1e,31:3(q){4(!g.1g||!j)6 P;4(!g.Y&&g.1w){5 a=[];16(5 k 2h h){4(k.7>0){5 c=h[k];$.I(c,3(i,x){4(1f(x.F,q)){a.1U(x)}})}}6 a}w 4(h[q]){6 h[q]}w 4(g.1f){16(5 i=q.7-1;i>=g.29;i--){5 c=h[q.3O(0,i)];4(c){5 a=[];$.I(c,3(i,x){4(1f(x.F,q)){a[a.7]=x}});6 a}}}6 P}}};$.M.32=3(e,g,f,k){5 h={H:"3N"};5 j,z=-1,y,1t="",1S=D,G,B;3 2y(){4(!1S)6;G=$("<3M/>").Z().Q(e.2P).T("3L","3K").1Q(1K.2w);B=$("<3H/>").1Q(G).3G(3(a){4(U(a).2u&&U(a).2u.3F()==\'2s\'){z=$("1L",B).1h(h.H).3D(U(a));$(U(a)).Q(h.H)}}).2q(3(a){$(U(a)).Q(h.H);f();g.2t();6 C}).3C(3(){k.1F=D}).3B(3(){k.1F=C});4(e.E>0)G.T("E",e.E);1S=C}3 U(a){5 b=a.U;3A(b&&b.3z!="2s")b=b.3y;4(!b)6[];6 b}3 V(b){j.1n(z,z+1).1h(h.H);2o(b);5 a=j.1n(z,z+1).Q(h.H);4(e.1D){5 c=0;j.1n(0,z).I(3(){c+=A.1a});4((c+a[0].1a-B.1b())>B[0].3x){B.1b(c+a[0].1a-B.3w())}w 4(c<B.1b()){B.1b(c)}}};3 2o(a){z+=a;4(z<0){z=j.1j()-1}w 4(z>=j.1j()){z=0}}3 2m(a){6 e.X&&e.X<a?e.X:a}3 2l(){B.2z();5 b=2m(y.7);16(5 i=0;i<b;i++){4(!y[i])1V;5 a=e.1R(y[i].y,i+1,b,y[i].F,1t);4(a===C)1V;5 c=$("<1L/>").3v(e.1y(a,1t)).Q(i%2==0?"3u":"3P").1Q(B)[0];$.y(c,"2k",y[i])}j=B.3t("1L");4(e.1X){j.1n(0,1).Q(h.H);z=0}4($.2e.2W)B.2W()}6{35:3(d,q){2y();y=d;1t=q;2l()},2D:3(){V(1)},30:3(){V(-1)},2C:3(){4(z!=0&&z-8<0){V(-z)}w{V(-8)}},2A:3(){4(z!=j.1j()-1&&z+8>j.1j()){V(j.1j()-1-z)}w{V(8)}},Z:3(){G&&G.Z();j&&j.1h(h.H);z=-1},N:3(){6 G&&G.3s(":N")},3q:3(){6 A.N()&&(j.2j("."+h.H)[0]||e.1X&&j[0])},20:3(){5 a=$(g).3p();G.T({E:W e.E=="1B"||e.E>0?e.E:$(g).E(),2i:a.2i+g.1a,1W:a.1W}).20();4(e.1D){B.1b(0);B.T({2L:e.1E,3n:\'3X\'});4($.1Y.3m&&W 1K.2w.3l.2L==="1x"){5 c=0;j.I(3(){c+=A.1a});5 b=c>e.1E;B.T(\'3k\',b?e.1E:c);4(!b){j.E(B.E()-2R(j.T("2O-1W"))-2R(j.T("2O-3j")))}}}},2g:3(){5 a=j&&j.2j("."+h.H).1h(h.H);6 a&&a.7&&$.y(a[0],"2k")},2T:3(){B&&B.2z()},1p:3(){G&&G.3i()}}};$.2e.18=3(b,f){4(b!==1x){6 A.I(3(){4(A.2d){5 a=A.2d();4(f===1x||b==f){a.4n("2c",b);a.3h()}w{a.4m(D);a.4l("2c",b);a.4k("2c",f);a.3h()}}w 4(A.3g){A.3g(b,f)}w 4(A.1C){A.1C=b;A.3e=f}})}5 c=A[0];4(c.2d){5 e=1K.18.4j(),3d=c.F,2a="<->",2f=e.3b.7;e.3b=2a;5 d=c.F.2H(2a);c.F=3d;A.18(d,d+2f);6{1I:d,39:d+2f}}w 4(c.1C!==1x){6{1I:c.1C,39:c.3e}}}})(4i);', 62, 272, '|||function|if|var|return|length|||||||||||||||||||||||||else||data|active|this|list|false|true|width|value|element|ACTIVE|each|toLowerCase|val|result|Autocompleter|visible|case|null|addClass|break|multipleSeparator|css|target|moveSelect|typeof|max|url|hide||bind|onChange||trigger|trimWords|for|multiple|selection|autocomplete|offsetHeight|scrollTop|trim|preventDefault|populate|matchSubset|cacheLength|removeClass|add|size|search|hideResultsNow|lastWord|slice|flush|unbind|stopLoading|arguments|matchCase|term|extend|formatMatch|matchContains|undefined|highlight|formatResult|parse|string|selectionStart|scroll|scrollHeight|mouseDownOnSelect|autoFill|progress|start|delay|document|li|new|findValueCallback|setTimeout|clearTimeout|appendTo|formatItem|needsInit|defaults|push|continue|left|selectFirst|browser|selectCurrent|show|request|replace|split|unautocomplete||loadingClass||setOptions|minChars|teststring|flushCache|character|createTextRange|fn|textLength|selected|in|top|filter|ac_data|fillList|limitNumberOfItems|BACKSPACE|movePosition|PAGEDOWN|click|hideResults|LI|focus|nodeName|PAGEUP|body|COMMA|init|empty|pageDown|ESC|pageUp|next|RETURN|ol|nullData|indexOf|TAB|strong|gi|maxHeight|keyCode|DEL|padding|resultsClass|inputClass|parseInt|DOWN|emptyList|form|dataType|bgiframe|opera|UP|extraParams|prev|load|Select|||display|mustMatch|substring||end|receiveData|text|Cache|orig|selectionEnd|join|setSelectionRange|select|remove|right|height|style|msie|overflow|off|offset|current|attr|is|find|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|mouseover|ul|188|default|absolute|position|div|ac_over|substr|ac_odd|charAt|word|180|RegExp|100|switch|400|auto|ac_loading|ac_results||ac_input|keydown|keypress|success|submit||limit|150|name|port|abort|mode|ajax|Date|timestamp|200|map|jQuery|createRange|moveEnd|moveStart|collapse|move'.split('|'), 0, {}));

//Super Sucker Fish Plugin
(function ($) {
    $.fn.superfish = function (op) {

        var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
			over = function () {
			    var $$ = $(this), menu = getMenu($$);
			    clearTimeout(menu.sfTimer);
			    $$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function () {
			    var $$ = $(this), menu = getMenu($$), o = sf.op;
			    clearTimeout(menu.sfTimer);
			    menu.sfTimer = setTimeout(function () {
			        o.retainPath = ($.inArray($$[0], o.$path) > -1);
			        $$.hideSuperfishUl();
			        if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
			    }, o.delay);
			},
			getMenu = function ($menu) {
			    var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
			    sf.op = sf.o[menu.serial];
			    return menu;
			},
			addArrow = function ($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

        return this.each(function () {
            var s = this.serial = sf.o.length;
            var o = $.extend({}, sf.defaults, op);
            o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function () {
                $(this).addClass([o.hoverClass, c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
            });
            sf.o[s] = sf.op = o;

            $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function () {
                if (o.autoArrows) addArrow($('>a:first-child', this));
            })
			.not('.' + c.bcClass)
				.hideSuperfishUl();

            var $a = $('a', this);
            $a.each(function (i) {
                var $li = $a.eq(i).parents('li');
                $a.eq(i).focus(function () { over.call($li); }).blur(function () { out.call($li); });
            });
            o.onInit.call(this);

        }).each(function () {
            var menuClasses = [c.menuClass];
            if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
            $(this).addClass(menuClasses.join(' '));
        });
    };

    var sf = $.fn.superfish;
    sf.o = [];
    sf.op = {};
    sf.IE7fix = function () {
        var o = sf.op;
        if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
            this.toggleClass(sf.c.shadowClass + '-off');
    };
    sf.c = {
        bcClass: 'sf-breadcrumb',
        menuClass: 'sf-js-enabled',
        anchorClass: 'sf-with-ul',
        arrowClass: 'sf-sub-indicator',
        shadowClass: 'sf-shadow'
    };
    sf.defaults = {
        hoverClass: 'sfHover',
        pathClass: 'overideThisToUse',
        pathLevels: 1,
        delay: 800,
        animation: { height: 'show' },
        speed: 'fast',
        autoArrows: true,
        dropShadows: true,
        disableHI: false, 	// true disables hoverIntent detection
        onInit: function () { }, // callback functions
        onBeforeShow: function () { },
        onShow: function () { },
        onHide: function () { }
    };
    $.fn.extend({
        hideSuperfishUl: function () {
            var o = sf.op,
				not = (o.retainPath === true) ? o.$path : '';
            o.retainPath = false;
            var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility', 'hidden');
            o.onHide.call($ul);
            return this;
        },
        showSuperfishUl: function () {
            var o = sf.op,
				sh = sf.c.shadowClass + '-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility', 'visible');

            sf.IE7fix.call($ul);
            o.onBeforeShow.call($ul);
            $ul.animate(o.animation, o.speed, function () {
                sf.IE7fix.call($ul);
                o.onShow.call($ul);

            });
            return this;
        }
    });

})(jQuery);


(function ($) {
    $.tiny = $.tiny || {};

    $.tiny.carousel = {
        options: {
            start: 1, // where should the carousel start?
            display: 1, // how many blocks do you want to move at 1 time?
            axis: 'x', // vertical or horizontal scroller? ( x || y ).
            controls: true, // show left and right navigation buttons.
            pager: false, // is there a page number navigation present?
            interval: false, // move to another block on intervals.
            intervaltime: 3000, // interval time in milliseconds.
            rewind: false, // If interval is true and rewind is true it will play in reverse if the last slide is reached.
            animation: true, // false is instant, true is animate.
            duration: 1000, // how fast must the animation move in ms?
            callback: null // function that executes after every move.
        }
    };

    $.fn.tinycarousel = function (options) {
        var options = $.extend({}, $.tiny.carousel.options, options);
        this.each(function () { $(this).data('tcl', new Carousel($(this), options)); });
        return this;
    };
    $.fn.tinycarousel_start = function () { $(this).data('tcl').start(); };
    $.fn.tinycarousel_stop = function () { $(this).data('tcl').stop(); };
    $.fn.tinycarousel_move = function (iNum) { $(this).data('tcl').move(iNum - 1, true); };

    function Carousel(root, options) {
        var oSelf = this;
        var oViewport = $('.viewport:first', root);
        var oContent = $('.overview:first', root);
        var oPages = oContent.children();
        var oBtnNext = $('.next:first', root);
        var oBtnPrev = $('.prev:first', root);
        var oPager = $('.pager:first', root);
        var iPageSize, iSteps, iCurrent, oTimer, bPause, bForward = true, bAxis = options.axis == 'x';

        function initialize() {
            iPageSize = bAxis ? $(oPages[0]).outerWidth(true) : $(oPages[0]).outerHeight(true);
            var iLeftover = Math.ceil(((bAxis ? oViewport.outerWidth() : oViewport.outerHeight()) / (iPageSize * options.display)) - 1);
            iSteps = Math.max(1, Math.ceil(oPages.length / options.display));
            iCurrent = Math.min(iSteps, Math.max(1, options.start)) - 2;
            oContent.css(bAxis ? 'width' : 'height', (iPageSize * oPages.length));
            oSelf.move(1);
            setEvents();
            return oSelf;
        };
        function setEvents() {
            if (options.controls && oBtnPrev.length > 0 && oBtnNext.length > 0) {
                oBtnPrev.click(function () { oSelf.move(-1); return false; });
                oBtnNext.click(function () { oSelf.move(1); return false; });
            }
            if (options.interval) { root.hover(oSelf.stop, oSelf.start); }
            if (options.pager && oPager.length > 0) { $('a', oPager).click(setPager); }
        };
        function setButtons() {
            if (options.controls) {
                oBtnPrev.toggleClass('disable', !(iCurrent > 0));
                oBtnNext.toggleClass('disable', !(iCurrent + 1 < iSteps));
            }
            if (options.pager) {
                var oNumbers = $('.pagenum', oPager);
                oNumbers.removeClass('active');
                $(oNumbers[iCurrent]).addClass('active');
            }
        };
        function setPager(oEvent) {
            if ($(this).hasClass('pagenum')) { oSelf.move(parseInt(this.rel), true); }
            return false;
        };
        function setTimer() {
            if (options.interval && !bPause) {
                clearTimeout(oTimer);
                oTimer = setTimeout(function () {
                    iCurrent = iCurrent + 1 == iSteps ? -1 : iCurrent;
                    bForward = iCurrent + 1 == iSteps ? false : iCurrent == 0 ? true : bForward;
                    oSelf.move(bForward ? 1 : -1);
                }, options.intervaltime);
            }
        };
        this.stop = function () { clearTimeout(oTimer); bPause = true; };
        this.start = function () { bPause = false; setTimer(); };
        this.move = function (iDirection, bPublic) {
            iCurrent = bPublic ? iDirection : iCurrent += iDirection;
            if (iCurrent > -1 && iCurrent < iSteps) {
                var oPosition = {};
                oPosition[bAxis ? 'left' : 'top'] = -(iCurrent * (iPageSize * options.display));
                oContent.animate(oPosition, {
                    queue: false,
                    duration: options.animation ? options.duration : 0,
                    complete: function () {
                        if (typeof options.callback == 'function')
                            options.callback.call(this, oPages[iCurrent], iCurrent);
                    }
                });
                setButtons();
                setTimer();
            }
        };
        return initialize();
    };
})(jQuery);

//end new skin


//Web trends
// WebTrends SmartSource Data Collector Tag
// Version: 8.6.2     
// Tag Builder Version: 3.0
// Created: 5/17/2010 11:02:22 AM

function WebTrends() {
    var that = this;
    // begin: user modifiable
    this.dcsid = "dcs5w0txb10000wocrvqy1nqm_6n1p";
    this.domain = "sdc.gradschools.com";
    this.timezone = -5;
    this.fpcdom = ".beta.gradschools.com";
    this.enabled = true;
    this.i18n = false;
    this.fpc = "WT_FPC";
    this.paidsearchparams = "gclid";
    // end: user modifiable
    this.DCS = {};
    this.WT = {};
    this.DCSext = {};
    this.images = [];
    this.index = 0;
    this.exre = (function () { return (window.RegExp ? new RegExp("dcs(uri)|(ref)|(aut)|(met)|(sta)|(sip)|(pro)|(byt)|(dat)|(p3p)|(cfg)|(redirect)|(cip)", "i") : ""); })();
    this.re = (function () { return (window.RegExp ? (that.i18n ? { "%25": /\%/g} : { "%09": /\t/g, "%20": / /g, "%23": /\#/g, "%26": /\&/g, "%2B": /\+/g, "%3F": /\?/g, "%5C": /\\/g, "%22": /\"/g, "%7F": /\x7F/g, "%A0": /\xA0/g }) : ""); })();
}
WebTrends.prototype.dcsGetId = function () {
    if (this.enabled && (document.cookie.indexOf(this.fpc + "=") == -1) && (document.cookie.indexOf("WTLOPTOUT=") == -1)) {
        document.write("<scr" + "ipt type='text/javascript' src='" + "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + this.domain + "/" + this.dcsid + "/wtid.js" + "'><\/scr" + "ipt>");
    }
}
WebTrends.prototype.dcsGetCookie = function (name) {
    var cookies = document.cookie.split("; ");
    var cmatch = [];
    var idx = 0;
    var i = 0;
    var namelen = name.length;
    var clen = cookies.length;
    for (i = 0; i < clen; i++) {
        var c = cookies[i];
        if ((c.substring(0, namelen + 1)) == (name + "=")) {
            cmatch[idx++] = c;
        }
    }
    var cmatchCount = cmatch.length;
    if (cmatchCount > 0) {
        idx = 0;
        if ((cmatchCount > 1) && (name == this.fpc)) {
            var dLatest = new Date(0);
            for (i = 0; i < cmatchCount; i++) {
                var lv = parseInt(this.dcsGetCrumb(cmatch[i], "lv"));
                var dLst = new Date(lv);
                if (dLst > dLatest) {
                    dLatest.setTime(dLst.getTime());
                    idx = i;
                }
            }
        }
        return unescape(cmatch[idx].substring(namelen + 1));
    }
    else {
        return null;
    }
}
WebTrends.prototype.dcsGetCrumb = function (cval, crumb, sep) {
    var aCookie = cval.split(sep || ":");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}
WebTrends.prototype.dcsGetIdCrumb = function (cval, crumb) {
    var id = cval.substring(0, cval.indexOf(":lv="));
    var aCrumb = id.split("=");
    for (var i = 0; i < aCrumb.length; i++) {
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}
WebTrends.prototype.dcsIsFpcSet = function (name, id, lv, ss) {
    var c = this.dcsGetCookie(name);
    if (c) {
        return ((id == this.dcsGetIdCrumb(c, "id")) && (lv == this.dcsGetCrumb(c, "lv")) && (ss == this.dcsGetCrumb(c, "ss"))) ? 0 : 3;
    }
    return 2;
}
WebTrends.prototype.dcsFPC = function () {
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var WT = this.WT;
    var name = this.fpc;
    var dCur = new Date();
    var adj = (dCur.getTimezoneOffset() * 60000) + (this.timezone * 3600000);
    dCur.setTime(dCur.getTime() + adj);
    var dExp = new Date(dCur.getTime() + 315360000000);
    var dSes = new Date(dCur.getTime());
    WT.co_f = WT.vtid = WT.vtvs = WT.vt_f = WT.vt_f_a = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
    if (document.cookie.indexOf(name + "=") == -1) {
        if ((typeof (gWtId) != "undefined") && (gWtId != "")) {
            WT.co_f = gWtId;
        }
        else if ((typeof (gTempWtId) != "undefined") && (gTempWtId != "")) {
            WT.co_f = gTempWtId;
            WT.vt_f = "1";
        }
        else {
            WT.co_f = "2";
            var curt = dCur.getTime().toString();
            for (var i = 2; i <= (32 - curt.length); i++) {
                WT.co_f += Math.floor(Math.random() * 16.0).toString(16);
            }
            WT.co_f += curt;
            WT.vt_f = "1";
        }
        if (typeof (gWtAccountRollup) == "undefined") {
            WT.vt_f_a = "1";
        }
        WT.vt_f_s = WT.vt_f_d = "1";
        WT.vt_f_tlh = WT.vt_f_tlv = "0";
    }
    else {
        var c = this.dcsGetCookie(name);
        var id = this.dcsGetIdCrumb(c, "id");
        var lv = parseInt(this.dcsGetCrumb(c, "lv"));
        var ss = parseInt(this.dcsGetCrumb(c, "ss"));
        if ((id == null) || (id == "null") || isNaN(lv) || isNaN(ss)) {
            return;
        }
        WT.co_f = id;
        var dLst = new Date(lv);
        WT.vt_f_tlh = Math.floor((dLst.getTime() - adj) / 1000);
        dSes.setTime(ss);
        if ((dCur.getTime() > (dLst.getTime() + 1800000)) || (dCur.getTime() > (dSes.getTime() + 28800000))) {
            WT.vt_f_tlv = Math.floor((dSes.getTime() - adj) / 1000);
            dSes.setTime(dCur.getTime());
            WT.vt_f_s = "1";
        }
        if ((dCur.getDay() != dLst.getDay()) || (dCur.getMonth() != dLst.getMonth()) || (dCur.getYear() != dLst.getYear())) {
            WT.vt_f_d = "1";
        }
    }
    WT.co_f = escape(WT.co_f);
    WT.vtid = (typeof (this.vtid) == "undefined") ? WT.co_f : (this.vtid || "");
    WT.vtvs = (dSes.getTime() - adj).toString();
    var expiry = "; expires=" + dExp.toGMTString();
    var cur = dCur.getTime().toString();
    var ses = dSes.getTime().toString();
    document.cookie = name + "=" + "id=" + WT.co_f + ":lv=" + cur + ":ss=" + ses + expiry + "; path=/" + (((this.fpcdom != "")) ? ("; domain=" + this.fpcdom) : (""));
    var rc = this.dcsIsFpcSet(name, WT.co_f, cur, ses);
    if (rc != 0) {
        WT.co_f = WT.vtvs = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
        if (typeof (this.vtid) == "undefined") {
            WT.vtid = "";
        }
        WT.vt_f = WT.vt_f_a = rc;
    }
}
WebTrends.prototype.dcsMultiTrack = function () {
    var args = dcsMultiTrack.arguments ? dcsMultiTrack.arguments : arguments;
    if (args.length % 2 == 0) {
        this.dcsSetProps(args);
        var dCurrent = new Date();
        this.DCS.dcsdat = dCurrent.getTime();
        this.dcsFPC();
        this.dcsTag();
    }
}
WebTrends.prototype.dcsCleanUp = function () {
    this.DCS = {};
    this.WT = {};
    this.DCSext = {};
    if (arguments.length % 2 == 0) {
        this.dcsSetProps(arguments);
    }
}
WebTrends.prototype.dcsSetProps = function (args) {
    for (var i = 0; i < args.length; i += 2) {
        if (args[i].indexOf('WT.') == 0) {
            this.WT[args[i].substring(3)] = args[i + 1];
        }
        else if (args[i].indexOf('DCS.') == 0) {
            this.DCS[args[i].substring(4)] = args[i + 1];
        }
        else if (args[i].indexOf('DCSext.') == 0) {
            this.DCSext[args[i].substring(7)] = args[i + 1];
        }
    }
}
WebTrends.prototype.dcsAdv = function () {
    this.dcsFPC();
}
WebTrends.prototype.dcsVar = function () {
    var dCurrent = new Date();
    var WT = this.WT;
    var DCS = this.DCS;
    WT.tz = parseInt(dCurrent.getTimezoneOffset() / 60 * -1) || "0";
    WT.bh = dCurrent.getHours() || "0";
    WT.ul = navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
    if (typeof (screen) == "object") {
        WT.cd = navigator.appName == "Netscape" ? screen.pixelDepth : screen.colorDepth;
        WT.sr = screen.width + "x" + screen.height;
    }
    if (typeof (navigator.javaEnabled()) == "boolean") {
        WT.jo = navigator.javaEnabled() ? "Yes" : "No";
    }
    if (document.title) {
        if (window.RegExp) {
            var tire = new RegExp("^" + window.location.protocol + "//" + window.location.hostname + "\\s-\\s");
            WT.ti = document.title.replace(tire, "");
        }
        else {
            WT.ti = document.title;
        }
    }
    WT.js = "Yes";
    WT.jv = (function () {
        var agt = navigator.userAgent.toLowerCase();
        var major = parseInt(navigator.appVersion);
        var mac = (agt.indexOf("mac") != -1);
        var ff = (agt.indexOf("firefox") != -1);
        var ff0 = (agt.indexOf("firefox/0.") != -1);
        var ff10 = (agt.indexOf("firefox/1.0") != -1);
        var ff15 = (agt.indexOf("firefox/1.5") != -1);
        var ff20 = (agt.indexOf("firefox/2.0") != -1);
        var ff3up = (ff && !ff0 && !ff10 & !ff15 & !ff20);
        var nn = (!ff && (agt.indexOf("mozilla") != -1) && (agt.indexOf("compatible") == -1));
        var nn4 = (nn && (major == 4));
        var nn6up = (nn && (major >= 5));
        var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
        var ie4 = (ie && (major == 4) && (agt.indexOf("msie 4") != -1));
        var ie5up = (ie && !ie4);
        var op = (agt.indexOf("opera") != -1);
        var op5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
        var op6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
        var op7up = (op && !op5 && !op6);
        var jv = "1.1";
        if (ff3up) {
            jv = "1.8";
        }
        else if (ff20) {
            jv = "1.7";
        }
        else if (ff15) {
            jv = "1.6";
        }
        else if (ff0 || ff10 || nn6up || op7up) {
            jv = "1.5";
        }
        else if ((mac && ie5up) || op6) {
            jv = "1.4";
        }
        else if (ie5up || nn4 || op5) {
            jv = "1.3";
        }
        else if (ie4) {
            jv = "1.2";
        }
        return jv;
    })();
    WT.ct = "unknown";
    if (document.body && document.body.addBehavior) {
        try {
            document.body.addBehavior("#default#clientCaps");
            WT.ct = document.body.connectionType || "unknown";
            document.body.addBehavior("#default#homePage");
            WT.hp = document.body.isHomePage(location.href) ? "1" : "0";
        }
        catch (e) {
        }
    }
    if (document.all) {
        WT.bs = document.body ? document.body.offsetWidth + "x" + document.body.offsetHeight : "unknown";
    }
    else {
        WT.bs = window.innerWidth + "x" + window.innerHeight;
    }
    WT.fv = (function () {
        var i, flash;
        if (window.ActiveXObject) {
            for (i = 10; i > 0; i--) {
                try {
                    flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                    return i + ".0";
                }
                catch (e) {
                }
            }
        }
        else if (navigator.plugins && navigator.plugins.length) {
            for (i = 0; i < navigator.plugins.length; i++) {
                if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1) {
                    return navigator.plugins[i].description.split(" ")[2];
                }
            }
        }
        return "Not enabled";
    })();
    WT.slv = (function () {
        var slv = "Not enabled";
        try {
            if (navigator.userAgent.indexOf('MSIE') != -1) {
                var sli = new ActiveXObject('AgControl.AgControl');
                if (sli) {
                    slv = "Unknown";
                }
            }
            else if (navigator.plugins["Silverlight Plug-In"]) {
                slv = "Unknown";
            }
        }
        catch (e) {
        }
        if (slv != "Not enabled") {
            var i, j, v;
            if ((typeof (Silverlight) == "object") && (typeof (Silverlight.isInstalled) == "function")) {
                for (i = 3; i > 0; i--) {
                    for (j = 9; j >= 0; j--) {
                        v = i + "." + j;
                        if (Silverlight.isInstalled(v)) {
                            slv = v;
                            break;
                        }
                    }
                    if (slv == v) {
                        break;
                    }
                }
            }
        }
        return slv;
    })();
    if (this.i18n) {
        if (typeof (document.defaultCharset) == "string") {
            WT.le = document.defaultCharset;
        }
        else if (typeof (document.characterSet) == "string") {
            WT.le = document.characterSet;
        }
        else {
            WT.le = "unknown";
        }
    }
    WT.tv = "8.6.2";
    //	WT.sp="@@SPLITVALUE@@";
    WT.dl = "0";
    WT.ssl = (window.location.protocol.indexOf('https:') == 0) ? "1" : "0";
    DCS.dcsdat = dCurrent.getTime();
    DCS.dcssip = window.location.hostname;
    DCS.dcsuri = window.location.pathname;
    WT.es = DCS.dcssip + DCS.dcsuri;
    if (window.location.search) {
        DCS.dcsqry = window.location.search;
    }
    if (DCS.dcsqry) {
        var dcsqry = DCS.dcsqry.toLowerCase();
        var params = this.paidsearchparams.length ? this.paidsearchparams.toLowerCase().split(",") : [];
        for (var i = 0; i < params.length; i++) {
            if (dcsqry.indexOf(params[i] + "=") != -1) {
                WT.srch = "1";
                break;
            }
        }
    }
    if ((window.document.referrer != "") && (window.document.referrer != "-")) {
        if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
            DCS.dcsref = window.document.referrer;
        }
    }
}
WebTrends.prototype.dcsEscape = function (S, REL) {
    if (REL != "") {
        S = S.toString();
        for (var R in REL) {
            if (REL[R] instanceof RegExp) {
                S = S.replace(REL[R], R);
            }
        }
        return S;
    }
    else {
        return escape(S);
    }
}
WebTrends.prototype.dcsA = function (N, V) {
    if (this.i18n && (this.exre != "") && !this.exre.test(N)) {
        if (N == "dcsqry") {
            var newV = "";
            var params = V.substring(1).split("&");
            for (var i = 0; i < params.length; i++) {
                var pair = params[i];
                var pos = pair.indexOf("=");
                if (pos != -1) {
                    var key = pair.substring(0, pos);
                    var val = pair.substring(pos + 1);
                    if (i != 0) {
                        newV += "&";
                    }
                    newV += key + "=" + this.dcsEncode(val);
                }
            }
            V = V.substring(0, 1) + newV;
        }
        else {
            V = this.dcsEncode(V);
        }
    }
    return "&" + N + "=" + this.dcsEscape(V, this.re);
}
WebTrends.prototype.dcsEncode = function (S) {
    return (typeof (encodeURIComponent) == "function") ? encodeURIComponent(S) : escape(S);
}
WebTrends.prototype.dcsCreateImage = function (dcsSrc) {
    if (document.images) {
        this.images[this.index] = new Image();
        this.images[this.index].src = dcsSrc;
        this.index++;
    }
    else {
        document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="' + dcsSrc + '">');
    }
}
WebTrends.prototype.dcsMeta = function () {
    var elems;
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("meta");
    }
    if (typeof (elems) != "undefined") {
        var length = elems.length;
        for (var i = 0; i < length; i++) {
            var name = elems.item(i).name;
            var content = elems.item(i).content;
            var equiv = elems.item(i).httpEquiv;
            if (name.length > 0) {
                if (name.toUpperCase().indexOf("WT.") == 0) {
                    this.WT[name.substring(3)] = content;
                }
                else if (name.toUpperCase().indexOf("DCSEXT.") == 0) {
                    this.DCSext[name.substring(7)] = content;
                }
                else if (name.toUpperCase().indexOf("DCS.") == 0) {
                    this.DCS[name.substring(4)] = content;
                }
            }
        }
    }
}
WebTrends.prototype.dcsTag = function () {
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var WT = this.WT;
    var DCS = this.DCS;
    var DCSext = this.DCSext;
    var i18n = this.i18n;
    var P = "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + this.domain + (this.dcsid == "" ? '' : '/' + this.dcsid) + "/dcs.gif?";
    if (i18n) {
        WT.dep = "";
    }
    for (var N in DCS) {
        if (DCS[N] && (typeof DCS[N] != "function")) {
            P += this.dcsA(N, DCS[N]);
        }
    }
    var keys = ["co_f", "vtid", "vtvs", "vt_f_tlv"];
    for (var i = 0; i < keys.length; i++) {
        var key = keys[i];
        if (WT[key]) {
            P += this.dcsA("WT." + key, WT[key]);
            delete WT[key];
        }
    }
    for (N in WT) {
        if (WT[N] && (typeof WT[N] != "function")) {
            P += this.dcsA("WT." + N, WT[N]);
        }
    }
    for (N in DCSext) {
        if (DCSext[N] && (typeof DCSext[N] != "function")) {
            if (i18n) {
                WT.dep = (WT.dep.length == 0) ? N : (WT.dep + ";" + N);
            }
            P += this.dcsA(N, DCSext[N]);
        }
    }
    if (i18n && (WT.dep.length > 0)) {
        P += this.dcsA("WT.dep", WT.dep);
    }
    if (P.length > 2048 && navigator.userAgent.indexOf('MSIE') >= 0) {
        P = P.substring(0, 2040) + "&WT.tu=1";
    }
    this.dcsCreateImage(P);
    this.WT.ad = "";
}
WebTrends.prototype.dcsDebug = function () {
    var t = this;
    var i = t.images[0].src;
    var q = i.indexOf("?");
    var r = i.substring(0, q).split("/");
    var m = "<b>Protocol</b><br><code>" + r[0] + "<br></code>";
    m += "<b>Domain</b><br><code>" + r[2] + "<br></code>";
    m += "<b>Path</b><br><code>/" + r[3] + "/" + r[4] + "<br></code>";
    m += "<b>Query Params</b><code>" + i.substring(q + 1).replace(/\&/g, "<br>") + "</code>";
    m += "<br><b>Cookies</b><br><code>" + document.cookie.replace(/\;/g, "<br>") + "</code>";
    if (t.w && !t.w.closed) {
        t.w.close();
    }
    t.w = window.open("", "dcsDebug", "width=500,height=650,scrollbars=yes,resizable=yes");
    t.w.document.write(m);
    t.w.focus();
}
WebTrends.prototype.dcsCollect = function () {
    if (this.enabled) {
        this.dcsVar();
        this.dcsMeta();
        this.dcsAdv();
        this.dcsTag();
    }
}

function dcsMultiTrack() {
    if (typeof (_tag) != "undefined") {
        return (_tag.dcsMultiTrack());
    }
}

function dcsDebug() {
    if (typeof (_tag) != "undefined") {
        return (_tag.dcsDebug());
    }
}

Function.prototype.wtbind = function (obj) {
    var method = this;
    var temp = function () {
        return method.apply(obj, arguments);
    };
    return temp;
}
//End web trends

//Fusion Maps
/**
* FusionMaps: Flash Player detection and Map embedding.
 
* Version: 1.3 (2st April, 2007) - Added setting up Transparent/opaque mode, added fix for % scaled dimensions
* Version: 1.2 (1st November, 2007) - FORM fix for IE 
* Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE
*
* Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if (typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
if (typeof infosoftglobal.FusionMapsUtil == "undefined") infosoftglobal.FusionMapsUtil = new Object();
infosoftglobal.FusionMaps = function (swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect) {
    if (!document.getElementById) { return; }

    //Flag to see whether data has been set initially
    this.initialDataSet = false;

    //Create container objects
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();

    //Set attributes for the SWF
    if (swf) { this.setAttribute('swf', swf); }
    if (id) { this.setAttribute('id', id); }

    w = w.toString().replace(/\%/, "%25");
    if (w) { this.setAttribute('width', w); }
    h = h.toString().replace(/\%/, "%25");
    if (h) { this.setAttribute('height', h); }

    //Set background color
    if (c) { this.addParam('bgcolor', c); }

    //Set Quality	
    this.addParam('quality', 'high');

    //Add scripting access parameter
    this.addParam('allowScriptAccess', 'always');

    //Pass width and height to be appended as mapWidth and mapHeight
    this.addVariable('mapWidth', w);
    this.addVariable('mapHeight', h);

    //Whether in debug mode
    debugMode = debugMode ? debugMode : 0;
    this.addVariable('debugMode', debugMode);
    //Pass DOM ID to Map
    this.addVariable('DOMId', id);
    //Whether to registed with JavaScript
    registerWithJS = registerWithJS ? registerWithJS : 0;
    this.addVariable('registerWithJS', registerWithJS);

    //Scale Mode of Map
    scaleMode = scaleMode ? scaleMode : 'noScale';
    this.addVariable('scaleMode', scaleMode);

    //Application Message Language
    lang = lang ? lang : 'EN';
    this.addVariable('lang', lang);

    //Whether to auto detect and re-direct to Flash Player installation
    this.detectFlashVersion = detectFlashVersion ? detectFlashVersion : 1;
    this.autoInstallRedirect = autoInstallRedirect ? autoInstallRedirect : 1;

    //Ger Flash Player version 
    this.installedVer = infosoftglobal.FusionMapsUtil.getPlayerVersion();

    if (!window.opera && document.all && this.installedVer.major > 7) {
        // Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
        infosoftglobal.FusionMaps.doPrepUnload = true;
    }
}

infosoftglobal.FusionMaps.prototype = {
    setAttribute: function (name, value) {
        this.attributes[name] = value;
    },
    getAttribute: function (name) {
        return this.attributes[name];
    },
    addParam: function (name, value) {
        this.params[name] = value;
    },
    getParams: function () {
        return this.params;
    },
    addVariable: function (name, value) {
        this.variables[name] = value;
    },
    getVariable: function (name) {
        return this.variables[name];
    },
    getVariables: function () {
        return this.variables;
    },
    getVariablePairs: function () {
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for (key in variables) {
            variablePairs.push(key + "=" + variables[key]);
        }
        return variablePairs;
    },
    getSWFHTML: function () {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
            // netscape plugin architecture			
            swfNode = '<embed type="application/x-shockwave-flash" src="' + this.getAttribute('swf') + '" width="' + this.getAttribute('width') + '" height="' + this.getAttribute('height') + '"  ';
            swfNode += ' id="' + this.getAttribute('id') + '" name="' + this.getAttribute('id') + '" ';
            var params = this.getParams();
            for (var key in params) { swfNode += [key] + '="' + params[key] + '" '; }
            var pairs = this.getVariablePairs().join("&");
            if (pairs.length > 0) { swfNode += 'flashvars="' + pairs + '"'; }
            swfNode += '/>';
        } else { // PC IE			
            swfNode = '<object id="' + this.getAttribute('id') + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getAttribute('width') + '" height="' + this.getAttribute('height') + '">';
            swfNode += '<param name="movie" value="' + this.getAttribute('swf') + '" />';
            var params = this.getParams();
            for (var key in params) {
                swfNode += '<param name="' + key + '" value="' + params[key] + '" />';
            }
            var pairs = this.getVariablePairs().join("&");
            if (pairs.length > 0) { swfNode += '<param name="flashvars" value="' + pairs + '" />'; }
            swfNode += "</object>";
        }
        return swfNode;
    },
    setDataURL: function (strDataURL) {
        //This method sets the data URL for the Map.
        //If being set initially
        if (this.initialDataSet == false) {
            this.addVariable('dataURL', strDataURL);
            //Update flag
            this.initialDataSet = true;
        } else {
            //Else, we update the Map data using External Interface
            //Get reference to map object
            var mapObj = infosoftglobal.FusionMapsUtil.getMapObject(this.getAttribute('id'));
            mapObj.setDataURL(strDataURL);
        }
    },
    setDataXML: function (strDataXML) {
        //If being set initially
        if (this.initialDataSet == false) {
            //This method sets the data XML for the map INITIALLY.
            this.addVariable('dataXML', strDataXML);
            //Update flag
            this.initialDataSet = true;
        } else {
            //Else, we update the map data using External Interface
            //Get reference to map object
            var mapObj = infosoftglobal.FusionMapsUtil.getMapObject(this.getAttribute('id'));
            mapObj.setDataXML(strDataXML);
        }
    },
    setTransparent: function (isTransparent) {
        //Sets map to transparent mode when isTransparent is true (default)
        //When no parameter is passed, we assume transparent to be true.
        if (typeof isTransparent == "undefined") {
            isTransparent = true;
        }
        //Set the property
        if (isTransparent)
            this.addParam('WMode', 'transparent');
        else
            this.addParam('WMode', 'Opaque');
    },

    render: function (elementId) {
        //First check for installed version of Flash Player - we need a minimum of 8
        if ((this.detectFlashVersion == 1) && (this.installedVer.major < 8)) {
            if (this.autoInstallRedirect == 1) {
                //If we can auto redirect to install the player?
                var installationConfirm = window.confirm("You need Adobe Flash Player 8 (or above) to view the maps. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");
                if (installationConfirm) {
                    window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
                } else {
                    return false;
                }
            } else {
                //Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).
                //So, expect the developers to provide a course of way to their end users.
                //window.alert("You need Adobe Flash Player 8 (or above) to view the maps. It is a free and lightweight installation from Adobe.com. ");
                return false;
            }
        } else {
            //Render the map
            var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();

            //Added <FORM> compatibility
            //Check if it's added in Mozilla embed array or if already exits 
            if (!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
                window[this.getAttribute('id')] = document.getElementById(this.getAttribute('id'));
            //or else document.forms[formName/formIndex][chartId]		
            return true;
        }
    }
}

/* ---- detection functions ---- */
infosoftglobal.FusionMapsUtil.getPlayerVersion = function () {
    var PlayerVersion = new infosoftglobal.PlayerVersion([0, 0, 0]);
    if (navigator.plugins && navigator.mimeTypes.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if (x && x.description) {
            PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    } else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
        //If Windows CE
        var axo = 1;
        var counter = 3;
        while (axo) {
            try {
                counter++;
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + counter);
                PlayerVersion = new infosoftglobal.PlayerVersion([counter, 0, 0]);
            } catch (e) {
                axo = null;
            }
        }
    } else {
        // Win IE (non mobile)
        // Do minor version lookup in IE, but avoid Flash Player 6 crashing issues
        try {
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        } catch (e) {
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new infosoftglobal.PlayerVersion([6, 0, 21]);
                axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
            } catch (e) {

                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch (e) { }
        }
        if (axo != null) {
            PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
infosoftglobal.PlayerVersion = function (arrVersion) {
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//
/* Fix for video streaming bug */
infosoftglobal.FusionMapsUtil.cleanupSWFs = function () {
    var objects = document.getElementsByTagName("OBJECT");
    for (var i = objects.length - 1; i >= 0; i--) {
        objects[i].style.display = 'none';
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = function () { };
            }
        }
    }
}
// Fixes bug in fp9
if (infosoftglobal.FusionMaps.doPrepUnload) {
    if (!infosoftglobal.unloadSet) {
        infosoftglobal.FusionMapsUtil.prepUnload = function () {
            __flash_unloadHandler = function () { };
            __flash_savedUnloadHandler = function () { };
            window.attachEvent("onunload", infosoftglobal.FusionMapsUtil.cleanupSWFs);
        }
        window.attachEvent("onbeforeunload", infosoftglobal.FusionMapsUtil.prepUnload);
        infosoftglobal.unloadSet = true;
    }
}
/* Add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function (id) { return document.all[id]; } }
/* Add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function (item) { this[this.length] = item; return this.length; } }

/* Function to return Flash Object from ID */
infosoftglobal.FusionMapsUtil.getMapObject = function (id) {
    var mapRef = null;
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds[id])
            mapRef = document.embeds[id];
        else
            mapRef = window.document[id];
    }
    else {
        mapRef = window[id];
    }
    if (!mapRef)
        mapRef = document.getElementById(id);

    return mapRef;
}
/* Aliases for easy usage */
var getMapFromId = infosoftglobal.FusionMapsUtil.getMapObject;
var FusionMaps = infosoftglobal.FusionMaps;
//end fusion maps
