﻿try{
	//change following variables according to the web site language
	var utcSearchBoxString = "Søk...";
	var utcSearchToolTipString = "Søk";
	var utcShareText = " Del";
	var utcPrintText = "Skrive ut";
	var utcHomeNodeText = "Hjem";
	
	$(document).ready(function(){

			$('#s4-searcharea .ms-sbcell input').attr('value', utcSearchBoxString);
			$('#s4-searcharea .ms-sbcell input').attr('alt', utcSearchToolTipString);
			$('#s4-searcharea .ms-sbcell input').attr('title', utcSearchToolTipString);
			$(this).removeClass('s4-searchbox-QueryPrompt');
			
			$('#s4-searcharea .ms-sbcell input').removeAttr('onfocus').removeAttr('onblur').removeAttr('onkeydown');		
			$('#s4-searcharea a[id$="lnkSearchPageLink"]').removeAttr('onclick');
			
			$('#s4-searcharea .ms-sbcell input').bind('focus',function(){
				if ($(this).val().trim() == utcSearchBoxString) {
					$(this).val("");				
				}
			});
			
            $('#s4-searcharea .ms-sbcell input').bind('blur', function () {
                searchBox = this;

                if ($(this).val() == '') {
                    $(this).val(utcSearchBoxString);    
					
                    $('#SRSB').children().children('input').val('0');
                }
                else {
                    $('#SRSB').children().children('input').val('1');
                }
            });
			
			$('#s4-searcharea .ms-sbcell input').bind('keydown', function (event) {
				PerformSearch(event,this.id,utcSearchBoxString);
			});
			
			$('#s4-searcharea a[id$="lnkSearchPageLink"]').bind('click', function(){
				AssignSearchParams($('#s4-searcharea [id$="txtGlobalSearchBox"]').attr('id'), utcSearchBoxString);
			});
			
			//change the bread crub home node text to sites' language
			if($('.breadcrumbs a').length == 1){
					$('.breadcrumbs:first-child').css('width','39px');
					$('#sphome').html('<a href="/" style="white-space: nowrap;float:left;width:auto;">'+utcHomeNodeText+'</a>&nbsp;&nbsp;&gt;').css({'width':'100%', 'text-align':'right', 'float':'left'});
			}
			else
			{
					$('.breadcrumbs:first-child').css('width','44px');
					$('#sphome').html('<a href="/" style="white-space: nowrap;float:left;width:auto;">'+utcHomeNodeText+'</a>&nbsp;&nbsp;&gt;&nbsp;&nbsp;').css({'width':'100%', 'text-align':'right', 'float':'left'});
			}
			
			//change the print and share text to sites' language
			$('.titlerow-table #actions a').each(function(){
				var _this = $(this);

				switch($(this).text().trim()){
					case 'Share':
						_this.text(utcShareText);
						break;
					case 'Print':
						_this.text(utcPrintText);
						break;
					default:
						break;
				}
			});		
	});
	
	String.prototype.trim = function () {
		return this.replace(/^\s+|\s+$/g, "");
	}	
}
catch(Error){}
