﻿// JScript File
// JScript File
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printThis(){

	if (pr){ 	// NS4, IE5
		window.print();
	}else if (da && !mac){
	    // IE4 (Windows)
		vbPrintPage();
	}else{ 	// other browsers
		alert("Sorry, your browser doesn't support this feature.\n\n Please try using the Print button on the browser toolbar.");
	}
}

if (da && !pr && !mac) with (document){
	
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	
	writeln('Sub window_onunload');
	writeln('  On Error Resume Next');
	writeln('  Set WB = nothing');
	writeln('End Sub');
	
	writeln('Sub vbPrintPage');
	writeln('  OLECMDID_PRINT = 6');
	writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
	writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	writeln('  On Error Resume Next');
	writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	writeln('End Sub');

	writeln('<' + '/SCRIPT>');
}


function DoSearch(e)
{

    var characterCode; //literal character code will be stored in this variable

    if(e && e.which){ //if which property of event object is supported (NN4)
        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)
        //get the input and click it
        var inputs = document.getElementById("topBarForm").getElementsByTagName("input");
        
        if (inputs[0] != null)
        {
            // change form action
            document.forms['frmHeaderSearch'].action = "/en-gb/search?q=" + inputs[0].value;
            
            var inputs = document.getElementById("topBarForm").getElementsByTagName("input");
            inputs[1].click();
            
        }
            
        return false;
    }
    return true;
}

function ChangeAction(strAction, strForm)
{
    var actionElement = document.getElementById('action');
    if (actionElement != null)
    {
        actionElement.value = strAction;
        document.forms[strForm].submit();
    }    
}

    
    
