function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (value) {
    var name = value + "=";
    var len  = name.length;
    var lenCookie = document.cookie.length;
    var i = 0;
    while (i < lenCookie) {
        var j = i + len;
        if (document.cookie.substring(i, j) == name)
            return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0)
            break;
    }
    return null;
}

function GetMyCookie (cookie_name, default_value) {
  var sPage = GetCookie(cookie_name);
  return (sPage ? sPage : default_value);
}

function SetMyCookie (cookie_name, value) {
  var expires = new Date ();
  expires.setTime(expires.getTime() + (366 * 24 * 3600 * 1000));
  document.cookie = cookie_name + "=" + value + "; expires=" + expires.toGMTString();
}

function SearchIMDbBy(searchtype, value) {
  value = "http://us.imdb.com/find?s=" + searchtype + "&q=" + value;
  window.open(value).focus();
}

function SearchIMDb (value) {
  SearchIMDbBy('tt', value)
}

function Thumb (aUPC, aBack, aIdx, aX, aY, aF) {
  document.write('<a href='+aUPC+'.php?backurl='+aBack+'&dvdidx='+aIdx+'&dvdx='+aX+'&dvdy='+aY+'&fontx='+aF+'><img src=pics/'+aUPC+'f.jpg width=177 height=252 border=0></a>');
}

function WriteDvM (txtD, txtM) {
  if (navigator.userAgent.indexOf("iPhone") > 0) {
    document.write(txtM);
  } else {
    document.write(txtD);
  }
}