/* Put all code that should be run once the page has been loaded in here */

var $ = jQuery;

$(document).ready(function() {
    // Captify images
    $('img.captify').captify({});

    var form_action = $('form#SimpleSearchForm').attr('action');

    if (form_action.indexOf("/lft") != -1) {
        $('form#SimpleSearchForm').attr('action', form_action.replace("/lft", ""));
    } else if (form_action.indexOf("/intranett") != -1) {
        $('form#SimpleSearchForm').attr('action', form_action.replace("/intranett", ""));
    }

    var advanced_form_action = $('form#advancedSearchForm').attr('action');
    if(advanced_form_action != undefined)
    {
	    if (advanced_form_action.indexOf("/lft") != -1) {
	        $('form#advancedSearchForm').attr('action', advanced_form_action.replace("/lft", ""));
	    } else if (advanced_form_action.indexOf("/intranett") != -1) {
	        $('form#advancedSearchForm').attr('action', advanced_form_action.replace("/intranett", ""));
	    }
    }

    $('span.page-number a').each(function () {
      var page_action = $(this).attr('href');
      if (page_action.indexOf("/lft") != -1) {
          $(this).attr('href', page_action.replace("/lft", ""));
      } else if (page_action.indexOf("/intranett") != -1) {
          $(this).attr('href', page_action.replace("/intranett", ""));
      }
    });
});

function openLink(href, target) {
    window.open(href, target);
    return false;
}

