﻿// jquery dependant - Tested on 1.3.2

// ***************************************************************
//  Global search 
// ***************************************************************
$.fn.DmSetupSearch = function() 
{ 
    //var FirstRun = true;    
    $(this).val("Search");
    
    $(this).click(function()
    {
        /*
        if(FirstRun)
        {
            $(this).val("");
            FirstRun = false;
        }
        */       
        
        if($(this).value = "Search")
        {
            $(this).val("");
        }
    });
    $("#zoomSearchButton").click(function() { $(this).initSearch(); });
}

jQuery.fn.initSearch = function(options) {
    myoptions = jQuery.extend({

},
	options);
// ?zoom_sort=0&zoom_query=my+search&zoom_per_page=10&zoom_and=1

// get the search field value
$.theValue = $("#txtSearch").val();
// do some validation so the default value isn't accepted
if ($.theValue == "Search site..." || $.theValue == "") {
    $(this).attr("href", "#");
}

else {
    // modify the value to prepare it with the query string, replace spaces with + signs
    $.stringValue = $.theValue.replace(" ", "+");
    $.theUrl = "/Search.aspx?zoom_query=" + $.stringValue;
    // build the query string
    $(this).attr("href", $.theUrl);
    CountingSearch();
}
return $.theUrl;
}

var passHeight;
// This function is used by the zoom search html template that is called from the iFrame
fixHeight = function(newHeight) {
    //$("iframe[name=documentLibrary]").css("height", newHeight);
    $("iframe[name=zoomSearchFrame]").height(newHeight);
};

function fixSiteMap() {

    // add class since not all browsers support CSS selectors
    $("#primaryNav > li:last").addClass("last");
    //$("#primaryNav li li li:first-child").addClass("firstLv3");
    //$("#primaryNav li li li:last-child").addClass("lastLv3").removeClass("firstLv3");

    $("#primaryNav > li:last").css("background-image", "url('/DesktopModules/CodingStaff.MenuBox/Skins/SlickMap/images/L1-right.png')");
    $("#primaryNav li li li:first-child").css("background-image", "url('/DesktopModules/CodingStaff.MenuBox/Skins/SlickMap/images/L3-li-top.png')");
    $("#primaryNav li li li:last-child").css("background-image", "url('/DesktopModules/CodingStaff.MenuBox/Skins/SlickMap/images/L3-bottom.png')");
}

$(document).ready(function() {
    $('.newslinkpop').popupWindow({
        height: 650,
        width: 620,
        centerBrowser: 1
    }).each(function() {
        var strhtml = $(this).html().toString();
        strhtml = (strhtml.indexOf("The Vitec Group PLC - ") > -1 ? strhtml.substr(22) : strhtml);
        $(this).html(strhtml);
    });


    // fix due to press release published on 3rd March 2011
    var url = document.location.href;
    if (url == "http://www.vitecgroup.com/tabid/236/ctl/EmailTracking/mid/760/Default.aspx") window.location = "/Investors/Presentations.aspx";
});

// Telerik editor contros
if (typeof Telerik === 'undefined') {
    // ignore
}
else {
    
    Telerik.Web.UI.Editor.CommandList["EmailTemplate"] = function(commandName, editor, args) {
        //alert("Just testing please ignore!");
        editor.pasteHtml('<style type="text/css">html,body,h1,h2,h3,h4,h5, h6, p, ol, ul, li, div, span, table, td{ font-family:Arial, Helvetica, sans-serif;}h1{ font-size:16px;}h2{ font-size:14px;} h3, h4, h5, h6{ font-size:13px;}body,p,li,span, table, td{ font-size:12px;}</style><strong>You are receiving this email because you subscribed to receive news alerts from The Vitec Group plc.  To change or to stop receiving these alerts please visit <a href="http://www.vitecgroup.com/Investors/Alerts.aspx">http://www.vitecgroup.com/Investors/Alerts.aspx</a>. If you have not logged into the new website previously please read the instructions on the page in order to retrieve your username and password.</strong><br /><br />PasteTitle<br /><br />PasteArticle<br /><br /><a href="http://vitecgroup.com/NewsCentre/Pressreleases.aspx">http://vitecgroup.com/NewsCentre/Pressreleases.aspx</a>')};
}
