Array.prototype.push = function(value) {this[this.length] = value}

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (k = 0, l = arrObjClass.length; k < l; k++) {
      for (m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

var SIR = {
  class_hook: 'SIR',

  over_convention: '_over',

  ext_re:    '(\.(png|gif|jpe?g))$',
  freeze_re: '(-[ao])' + this.ext_re,

  over_src: function(src) {
    return src.replace(new RegExp(SIR.ext_re), SIR.over_convention + '$1')
  },
  out_src: function(src) {
    return src.replace(new RegExp(SIR.over_convention + SIR.ext_re), '$1')
  },

  over: function(img) {
    if (!img || !img.src) img = this
    img.src = SIR.over_src(img.src)
  },
  out: function(img) {
    if (!img || !img.src) img = this
    img.src = SIR.out_src(img.src)
  },

  over_other: function(container) {
    imgs = this.getElementsByTagName('img')
    for (var j=0; j<imgs.length; j++) {
      if (!imgs[j] || !imgs[j].src) imgs[j] = this
        imgs[j].src = SIR.over_src(imgs[j].src)
    }
  },
  out_other: function(container) {
    imgs = this.getElementsByTagName('img')
    for (var j=0; j<imgs.length; j++) {
      if (!imgs[j] || !imgs[j].src) imgs[j] = this
        imgs[j].src = SIR.out_src(imgs[j].src)
    }
  },

  attach_to_img: function(img) {
    img.onmouseover = SIR.over
    img.onmouseout  = SIR.out
    SIR.preload_rollover(img)
  },

  attach_to_other: function(container) {
    container.onmouseover = SIR.over_other
    container.onmouseout  = SIR.out_other
  },

  preload_rollover: function(img) {
    var pre = new Image()
    pre.src = SIR.over_src(img.src)
  },

  // append init() to window.onload to enable
  init: function() {
    var marked = getElementsByClassName(SIR.class_hook)
    var imgs
    for (var i=0; i<marked.length; i++) {
      if (marked[i].nodeName == 'IMG' && !marked[i].src.match(new RegExp(SIR.freeze_re))) { 
        SIR.attach_to_img(marked[i])
      }
      else {
        SIR.attach_to_other(marked[i])
        imgs = marked[i].getElementsByTagName('img')
        for (var j=0; j<imgs.length; j++) {
          SIR.preload_rollover(imgs[j])
        }
      }

    }
  }

}

function RunHomePage(moviename) {
  document.write('<object\n');
  document.write('classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n');
  document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"\n');
  document.write('width="760"\n');
  document.write('height="226">\n');
  document.write('<param name="movie" value="'+moviename+'" />\n');
  document.write('<param name="quality" value="high" />\n');
  document.write('<param name="wmode" value="transparent">\n');
  document.write('<embed src="'+moviename+'"\n');
  document.write('quality="high"\n');
  document.write('bgcolor="#000"\n');
  document.write('width="760"\n');
  document.write('height="226"\n');
  document.write('type="application/x-shockwave-flash"\n');
  document.write('pluginspage="http://macromedia.com/go/getflashplayer"\n');
  document.write('wmode="transparent"\n');
  document.write('></embed>\n');
  document.write('</object>\n');
}

function RunVideoTip(name) {
	document.write('<object\n');
    document.write('classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n');
    document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"\n');
    document.write('width="550"\n');
    document.write('height="400">\n');
    document.write('<param name="movie" value="/videotips/' + name + '.swf" />\n');
    document.write('<param name="quality" value="high" />\n');
    document.write('<param name="wmode" value="transparent">\n');
    document.write('<embed src="/videotips/'  + name + '.swf"\n');
    document.write('quality="high"\n');
    document.write('bgcolor="#000"\n');
    document.write('width="550"\n');
    document.write('height="400"\n');
    document.write('type="application/x-shockwave-flash"\n');
    document.write('pluginspage="http://macromedia.com/go/getflashplayer"\n');
    document.write('wmode="transparent"\n');
    document.write('></embed>\n');
    document.write('</object>\n');
}


function getViewportSize()
{
 var size = [0, 0];

 if (typeof window.innerWidth != 'undefined')
 {
   size = [
       window.innerWidth,
       window.innerHeight
   ];
 }
 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
 {
   size = [
       document.documentElement.clientWidth,
       document.documentElement.clientHeight
   ];
 }
 else
 {
   size = [
       document.getElementsByTagName('body')[0].clientWidth,
       document.getElementsByTagName('body')[0].clientHeight
   ];
 }

 return size;
}

if (window.XMLHttpRequest) {
  a = 5
} else {
  window.onresize = function()
  {
    var size = getViewportSize();
    var newsize = size[1] - 224;
    document.getElementById('body').style.height = newsize;
  };
}

window.onload = function()
{
    if (window.XMLHttpRequest) {
      a = 5
    } else {
      var size = getViewportSize();
      var newsize = size[1] - 224;
      document.getElementById('body').style.height = newsize;
    }
    SIR.init();
}

