﻿$(document).ready(function () {
    var TitleString = "";
    if ($('.ResourceName').length > 0) {
        TitleString += $('.ResourceName').text() + ' - ';


    }
  
    if ($('#MainContentDiv h2:first').text() != "") {
        document.title = $('#MainContentDiv h2:first').text();
        SelectMasterpageTab($('#MainContentDiv h2:first').text());
    }
    else {
        document.title = TitleString + $('h2:first').text() + ' - technologytradingpost.com';
    }

    // alert(TitleString);
    $('html').click(function () {
        //Hide the menus if visible
        //$('#AdminOptionsUl, #UserOptionsUl').hide();
        $('.dropdownmenu1Ul').fadeOut('fast');
        //$('#UserOptionsUl').hide();
    });

    $('.dropdownmenu1Ul').click(function (event) {
        event.stopPropagation();
    });


});

function TruncateString(str, len) {
    if (str.length >= len) {
        return str.substring(0, len) + "...";
    }
    else {
        return str;
    }
}

jQuery.fn.center = function () {
    this.css("position", "absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", ((1000 - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

function ShowDropDownMenu(ObjectName) {

    $('.dropdownmenu1Ul').each(function (index) {
        $(this).fadeOut('fast');
    });
    $("#" + ObjectName).toggle();
    if ("undefined" != typeof (event)) event.returnValue = false;
    return false;
}

function ResetFilter(ele) {
    $('#' + ele).val('');
    $('#' + ele).trigger('keyup');
    document.getElementById(ele).focus();
}

function ShowDropDownMenu(ObjectName) {

    $('.dropdownmenu1Ul').each(function (index) {
        $(this).fadeOut('fast');
    });
    $("#" + ObjectName).toggle();
    if ("undefined" != typeof (event)) event.returnValue = false;
    return false;
}

function HighlightKeyword2(element, keyword) {
    if (keyword.length > 0) {
        //$.each(keywordArray, function (index, value) {
        $(element).highlight(value);
        //});
    }
}

function HighlightKeyword(element, keyword) {

    $(element).removeClass('highlight');
    $(element).removeClass('highlight1');
    if (keyword.length > 0) {

        var keywordArray = keyword.trim().split(' ');
        $.each(keywordArray, function (index, value) {
            $(element).highlight(value);
        });


    }
}

function HideAllDialogs() {
    $('.modalPopup').each(function () {
        //$(this).hide();
        $(this).fadeOut('fast');
    });
}

function ShowDialog(id) {
    $(id).center();
    HideAllDialogs();
    $(id).show();
}



$(function () {
    var config = {
        //toolbar: 'Basic',
        //toolbar: [['Source','Bold', 'Italic'], ['UIColor'],['PasteWord']]
        toolbar: [['Source', 'Bold', 'Italic', '-', 'OrderedList', 'UnorderedList', '-', 'Link', 'Unlink', '-'], ['PasteWord']],
        skin: 'chris',
        enterMode: CKEDITOR.ENTER_BR, shiftEnterMode: CKEDITOR.ENTER_P
    };

    $('.ckeditor').ckeditor(config);
});
