function SubmitSearch(searchWords,langcode,language)
{
if (searchWords.length != 0)
    {
        //location.href = "/Search.aspx?cx=012247359196088331808%3Aopbgschux9e&cof=FORID%3A11&ie=ISO-8859-1&q=" + encodeURI(searchWords) + "&sa=S%F8g";
        jQuery(location).attr('href',"/Search.aspx?cx=012247359196088331808%3A"+langcode+"&cof=FORID%3A11&ie=UTF-8&q=" + encodeURI(searchWords) + "&sa=S%F8g&lr=lang_" + language);
        return false;
    }
}

function checkEnter(e, caller) //e is event object passed from function invocation
{
    var characterCode //literal character code will be stored in this variable

    if (e && e.which || e.which == 0) { //if which property of event object is supported (NN4)
        e = e
        characterCode = e.which //character code is contained in NN4's which property
    }
    else {
        e = event
        characterCode = e.keyCode //character code is contained in IE's keyCode property
    }

    if (characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
    {
        document.getElementById(caller).click();
        return false
    }
    else {
        return true
    }
}

// Google code for tracking outbound links
function recordOutboundLink(link, category, action) {
  try {
    var myTracker=_gat._getTrackerByName();
    _gaq.push(['myTracker._trackEvent', ' + category + ', ' + action + ']);
    setTimeout('document.location = "' + link.href + '"', 100)
  }catch(err){}
}

// Functions for fancyList

//show target image in fancylist
function showFancylist(target) {
// Set path to target image
var DOMobject = "#content .fancylist ul li img."+target;

		//stop all animation
    jQuery(DOMobject).stop(true, true);

    // if target image is invisible, show it
    if (jQuery(DOMobject+":visible").size() == 0) {
    	// hide all other images in list
        resetFancylist();
        // show target image with opacity animation
		jQuery(DOMobject).fadeIn(defaultSpeed);
	}
}

// Hide all images in fancyList
function resetFancylist(speed) {
	// if we did not receive a specific speed, use default (set in onload.js)
	if (speed == null)
		speed = defaultSpeed;

    //hide all images in fancylist
    jQuery("#content .fancylist ul li img").fadeOut(speed);
}

// display tooltips on a horiazontal line of a's with img's in them (for GIRI frontpage, february 2012)
function mouseovervideoscontainerdivtooltips()
{
	var widthOfRightmostVideo = jQuery('.mouseovervideoscontainerdiv .video:last-child').width();
	var vinduesbredde = jQuery('.mouseovervideoscontainerdiv .video:last-child').position().left+widthOfRightmostVideo;
	
	jQuery('.mouseovervideoscontainerdiv a').hover( 
		function () { 
			// remove tooltips from any previous hover
			jQuery('.mouseovervideoscontainerdiv').find("#tooltip").remove();
			jQuery('.mouseovervideoscontainerdiv').find("#tooltiparrow").remove();
			// (re)add tooltip
			var spaceBetweenImageAndTooltip = 3;
			var videoimageTag = jQuery(this).find("img");
			jQuery('.mouseovervideoscontainerdiv').append('<img id="tooltiparrow" src="/images/ITUInternet/uparrow.gif" style="display:none; position:absolute;"/>');
			var tooltiparrowTag = jQuery('#tooltiparrow');
			var anchorLeft = parseInt(jQuery(this).position().left);				
			var imgLeft = parseInt(videoimageTag.position().left);				
			var imgHeight = parseInt(videoimageTag.height());
			var imgWidth = parseInt(videoimageTag.width());
			var imgMiddlePosition = imgLeft+(imgWidth/2);		
			var tooltiparrowHeight = parseInt(tooltiparrowTag.height());
			var tooltipTop = imgHeight+spaceBetweenImageAndTooltip;	
			jQuery('.mouseovervideoscontainerdiv').append('<div id="tooltip" style="display:none; background-color:black; color:white; padding: 7px; margin:0px; position:absolute; top:'+tooltipTop+'px; font-family: Verdana; font-size: 14px; line-height:14px; z-index:2;">' + jQuery(this).find("img").attr('alt') + '</div>');				
			var tooltipTag = jQuery('#tooltip');
			var tooltipPaddingHorizontal = parseInt(tooltipTag.css("padding-left"))+parseInt(tooltipTag.css("padding-right"));
			tooltipTag.fadeIn();
			tooltiparrowTag.fadeIn();				
			var tooltipWidth = parseInt(tooltipTag.width())+tooltipPaddingHorizontal;	
			var tooltipLeft = (vinduesbredde-tooltipWidth)*(anchorLeft/(vinduesbredde-widthOfRightmostVideo));								
			// tooltipLeft may be NaN, so in that case set it to 0
			if(isNaN(tooltipLeft)){tooltipLeft=0;}
			tooltipTag.css("left",tooltipLeft);0
			var tooltipArrowWidth = parseInt(tooltiparrowTag.width());				
			tooltiparrowTag.css("top", imgHeight-tooltiparrowHeight+spaceBetweenImageAndTooltip);
			tooltiparrowTag.css("left", imgMiddlePosition-tooltipArrowWidth/2);

			// adjust position of tooltip if it is too far away from the tooltiparrow
			var tooltipRight = tooltipLeft+tooltipWidth;
			var tooltiparrowLeft = parseInt(tooltiparrowTag.position().left);
			var tooltiparrowRight = tooltiparrowLeft+tooltipArrowWidth;				
			if(tooltiparrowLeft<tooltipLeft | tooltiparrowRight>tooltipRight)
			{										
				tooltipTag.css("left", imgMiddlePosition-tooltipWidth/2  );
				//alert('tooltipLeft:'+tooltipLeft+' tooltipRight:'+tooltipRight+' arrowleft:'+tooltiparrowLeft+' arrowRight:'+tooltiparrowRight);
			}
			if(tooltipLeft<0){tooltipTag.css("left","0");}
		},  
		function () { 			
			jQuery('.mouseovervideoscontainerdiv').find("#tooltip").fadeOut(); 
			jQuery('.mouseovervideoscontainerdiv').find("#tooltiparrow").fadeOut(); 		
		} 
	);
}	

