var menuArray = new Array("news", "videos", "promo", "media", "contest", "pics", "community", "merch", "faq", "links", "staff");
var pairs=unescape(location.search.substring(1).replace(/\+/g," ")).split('&');
var pair = pairs[0].split('=');
this[pair[0]]=pair[1];
var mod = pair[1];
var i,menu,showtime,tempdrop;


if(document.layers) {
  origWidth = innerWidth;
  origHeight = innerHeight;
  function reDo() {
    if (innerWidth != origWidth || innerHeight != origHeight) location.reload();
  };
  onResize = reDo;
}

function wrapper(elementino) {
  if (document.getElementById) return eval('document.getElementById("' + elementino +'")');
  else if (document.all) return eval('document.all["' + elementino + '"]');
  else if (document.layers) return eval('document.layers["' + elementino + '"]');
  else return eval('document.' + elementino);
};

function boxon(daImage) {
  hideAll();
  clearInterval(showtime);
  if (document.images)
    if (typeof(menuArray[daImage]) == 'string') eval('document.' + menuArray[daImage]).src = 'images/boxon.gif';
    else if ((typeof(menuArray[daImage]) == 'object') && menuArray[daImage] && menuArray[daImage].src) menuArray[daImage].src = 'images/boxon.gif';
  tempdrop = wrapper(menuArray[daImage] + 'drop');
  if (tempdrop)
    if (document.layers) {
      tempdrop.top = 90;
      tempdrop.left = ((window.innerWidth - 761) / 2) - 12;
      tempdrop.visibility = "show";
    } else tempdrop.style.visibility = "visible";
};

function boxoff() {
  showtime=setInterval('resetAll();', 1000);
};

function hideAll() {
  if (document.images) {
    for (i=0; i<menuArray.length; i++) {
      if (typeof(menuArray[i]) == 'string') eval('document.' + menuArray[i]).src = 'images/box.gif';
      else if ((typeof(menuArray[i]) == 'object') && menuArray[i] && menuArray[i].src) menuArray[i].src = 'images/box.gif';
      tempdrop = wrapper(menuArray[i] + 'drop');
      if(tempdrop)
        if(document.layers) tempdrop.visibility = "hide";
        else tempdrop.style.visibility = "hidden";
    }
  }
};

function resetAll() {
  hideAll();
  if (document.images && eval('document.' + mod) && eval('document.' + mod).src) eval('document.' + mod).src = 'images/boxon.gif';
  else document.news.src = 'images/boxon.gif';
};

function noSpam(args) {
	location.href='mailto:'+decodeBase64(args);
}

/* FOLLOWING FUNCTIONS WAS USED FOR BASE64 DECODING */
// ------------------------------------------------ //
var END_OF_INPUT = -1;
var base64Chars = new Array(
    'A','B','C','D','E','F','G','H',
    'I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X',
    'Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n',
    'o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3',
    '4','5','6','7','8','9','+','/'
);

var reverseBase64Chars = new Array();
for (var i=0; i < base64Chars.length; i++){
    reverseBase64Chars[base64Chars[i]] = i;
}

var base64Str;
var base64Count;
function setBase64Str(str){
    base64Str = str;
    base64Count = 0;
}
function readBase64(){    
    if (!base64Str) return END_OF_INPUT;
    if (base64Count >= base64Str.length) return END_OF_INPUT;
    var c = base64Str.charCodeAt(base64Count) & 0xff;
    base64Count++;
    return c;
}
function readReverseBase64(){   
    if (!base64Str) return END_OF_INPUT;
    while (true){      
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}
function ntos(n){
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}
function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}

var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex(n){
    var result = ''
    var start = true;
    for (var i=32; i>0;){
        i-=4;
        var digit = (n>>i) & 0xf;
        if (!start || digit != 0){
            start = false;
            result += digitArray[digit];
        }
    }
    return (result==''?'0':result);
}

function pad(str, len, pad){
    var result = str;
    for (var i=str.length; i<len; i++){
        result = pad + result;
    }
    return result;
}

function encodeHex(str){
    var result = "";
    for (var i=0; i<str.length; i++){
        result += pad(toHex(str.charCodeAt(i)&0xff),2,'0');
    }
    return result;
}

function decodeHex(str){
    str = str.replace(new RegExp("s/[^0-9a-zA-Z]//g"));
    var result = "";
    var nextchar = "";
    for (var i=0; i<str.length; i++){
        nextchar += str.charAt(i);
        if (nextchar.length == 2){
            result += ntos(eval('0x'+nextchar));
            nextchar = "";
        }
    }
    return result;
    
}
/* ------------------------------------------------ */
