

if ( /Opera\/9|Chrome\/(1|2|3)|Firefox\/(1|2|3)\.0|iPod|iPhone/.test( navigator.userAgent ) ) {
	var root = document.documentElement;
	root.className += ( root.className ? ' ' : '' ) + 'no-fontface';
}



function addLoadEvent(func)
{
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function init()
{
    var rollovers = new Array("image1", "image2");
    var loader = new Array();
    
    for(i = 0; i < rollovers.length; i++)
    {
        loader[i] = new Image;
        loader[i].src = "http://images.wallaceandgromit.com/" + rollovers[i] + ".gif";
    }
}

// Set up selection destinations for the films dropdown

filmList = new Array("granddayout","wrongtrousers","acloseshave","crackingcontraptions","wererabbit");

function selectfilm() {
	var filmdrop = document.getElementById("filmdrop");
	var selectedFilm = parseInt(filmdrop.options[filmdrop.selectedIndex].value);
	if(selectedFilm == 0){
		selectedFilm = 5;
	}
	document.location.href = "films/" + filmList[selectedFilm - 1] + ".html";
}

function changeFilmBackdrop() {
	var filmdrop = document.getElementById("filmdrop");
	var filmdiv = document.getElementById("films");
	var selectedFilm = parseInt(filmdrop.options[filmdrop.selectedIndex].value);
	if(selectedFilm == 0){
		selectedFilm = 5;
	}
	filmdiv.className = filmList[selectedFilm - 1];
}

function popWp(sc,sz) {
	window.open("/download/wallpapers/index.html?scene=" + sc + "&size=" + sz , "wp" , "width=900,height=760")
}

function popMsn(ch) {
	window.open("/download/msn/index.html?" + ch, "msn" , "width=400,height=395")
}

function tickMsg(){
         
	messageDiv = document.getElementById('ticker');
	messageDiv.style.visibility = "visible";
	messageDiv.innerHTML = "<h2>News: </h2> ";
	inc = 1;
	tickDelay = 150;
	
	setTimeout('tickIncrement();',tickDelay);  

 }
 
 function tickIncrement(){
	if(inc < message.length){
	   partmsg = message.substr(0,inc);
	   messageDiv.innerHTML = "<a href='" + msgLink + "'><h2>News: </h2> " + partmsg + "<img alt='' src='http://images.wallaceandgromit.com/blink.gif' /></a>";
	   inc++;
	
	   setTimeout('tickIncrement();',tickDelay); 
	} else {
	   messageDiv.innerHTML = "<a href='" + msgLink + "'><h2>News: </h2> " + message + "</a>";
	}
 }

/* inspired by http://aktuell.de.selfhtml.org/artikel/javascript/bbcode/  */
function ins(txtSmilie)
{
  aTag = ''; 
  eTag = '';

  var input = document.getElementById("message");
  input.focus();

  /* IE */
  if(typeof document.selection != 'undefined') {
    /* insert text */
    var range = document.selection.createRange();
    var insText = txtSmilie;
    range.text = aTag + insText + eTag;
    /* correct cursor position */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* gecko-based */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* insert text */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = txtSmilie;
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* correct cursor position */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* all others */
  else
  {
    var pos;
    pos = input.value.length;
    var insText = txtSmilie;
    input.value = input.value.substr(0, pos) + aTag + insText + eTag;
  }
}

