var curr_page;
var soundstatus;
var splishstatus;
var queryString=location.search.substring(1,location.search.length);

function getParameter(queryString, parameterName ){
  parameterName = parameterName + "=";
  if ( queryString.length > 0 ){
    begin = queryString.indexOf( parameterName);
    if ( begin != -1 ){
      begin += parameterName.length;
      end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ){
        end = queryString.length
      }
      return unescape ( queryString.substring ( begin, end ) );
    }
    return "null";
  }
}
function getVals(){
  var queryString=location.search.substring(1,location.search.length);
  document.cookie = "cookieName=nickflashparams"+"; domain=.nickelodeon.com.au";
  if (queryString == "" || queryString.indexOf("bid") != -1 || queryString.indexOf("qid") != -1 || queryString.indexOf("id") != -1 || queryString.indexOf("place") != -1 || queryString.indexOf("arqid") != -1 ||queryString.indexOf("question") != -1 || queryString.indexOf("rand") != -1 || queryString.indexOf("x") != -1 || queryString.indexOf("qs") != -1){
    curr_page = getCookie("curr_page");
    soundstatus = getCookie("soundstatus");
    splishstatus = getCookie("splishstatus");
  } else {
    curr_page = getParameter(queryString, "curr_page");
    soundstatus = getParameter(queryString, "sound");
    splishstatus = getParameter(queryString, "splash");
  }
  if(curr_page == null){
    curr_page = 0;
    soundstatus = 1;
    splishstatus = 1;
  }
  if (soundstatus == null || soundstatus == 'null'){ soundstatus = 0; }
  if (splishstatus == null || splishstatus == 'null'){ splishstatus = 0; }
  document.cookie = "curr_page=" + curr_page +"; domain=.nickelodeon.com.au";
  document.cookie = "soundstatus=" + soundstatus+"; domain=.nickelodeon.com.au";
  document.cookie = "splishstatus=" + splishstatus+"; domain=.nickelodeon.com.au";
}
function getCookie (name){
  var dcookie = document.cookie;
  var cname = name + "=";
  var clen = dcookie.length;
  var cbegin = 0;
  while (cbegin < clen){
    var vbegin = cbegin + cname.length;
    if (dcookie.substring(cbegin, vbegin) == cname){
      var vend = dcookie.indexOf (";", vbegin);
      if (vend == -1) vend = clen;
      return unescape(dcookie.substring(vbegin, vend));
    }
    cbegin = dcookie.indexOf(" ", cbegin) + 1;
    if (cbegin == 0) break;
  }
  return null;
}
function embedFlash(){
  getVals();
  if (mac && browser_type == "Microsoft Internet Explorer" && soundstatus == 0){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_off.swf?curr_page=";
    newContent += curr_page + "&sound=0";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
  }
  else if (mac && browser_type == "Microsoft Internet Explorer" && soundstatus == 1){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_on.swf?curr_page=";
    newContent += curr_page + "&sound=1";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
  }
  else if (mac && browser_type == "Netscape" && soundstatus == 0){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_off.swf?curr_page=";
    newContent += curr_page + "&sound=0";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
    document.close();
  }
  else if (mac && browser_type == "Netscape" && soundstatus == 1){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_on.swf?curr_page=";
    newContent += curr_page + "&sound=1";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
    document.close();
  }
  else if(win && browser_type == "Netscape" && (browser_version >= 4) && soundstatus == 0){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_off.swf?curr_page=";
    newContent += curr_page + "&sound=0";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
    document.close();
  }
  else if(win && browser_type == "Netscape" && (browser_version >= 4) && soundstatus == 1){
    newContent = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>";
    newContent += "<embed src='/main_flash/top_nav_on.swf?curr_page=";
    newContent += curr_page + "&sound=1";
    newContent += "&splash=";
    newContent += splishstatus;
    newContent += "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>";
    newContent += "</embed>";
    newContent += "</object>";
    document.write(newContent);
    document.close();
  }
  else if (win && browser_type == "Microsoft Internet Explorer" && soundstatus == 0){
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>");
    document.write("<param name=movie value='/main_flash/top_nav_off.swf?curr_page=" + curr_page + "&sound=0&splash=" + splishstatus + "'>");
    document.write("<param name=quality value=high>");
    document.write("<param name=wmode value=opaque>");
    document.write("<embed src='/main_flash/top_nav_off.swf?curr_page=" + curr_page + "&sound=0&splash=" + splishstatus + "quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>");
    document.write("</embed>");
    document.write("</object>");
  }
  else if(win && browser_type == "Microsoft Internet Explorer" && soundstatus == 1){
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='613' height='118'>");
    document.write("<param name=movie value='/main_flash/top_nav_on.swf?curr_page=" + curr_page + "&sound=1&splash=" + splishstatus + "'>");
    document.write("<param name=quality value=high>");
    document.write("<param name=wmode value=opaque>");
    document.write("<embed src='/main_flash/top_nav_on.swf?curr_page=" + curr_page + "&sound=1&splash=" + splishstatus + "quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='613' height='118'>");
    document.write("</embed>");
    document.write("</object>");
  }
}
function pop(){
  popup = window.open ("/message.php",'popup','toolbar=0,location=0,directories=0,scrollbars=0,status=0,menubar=0,resizable=0,width=350,height=175');
  popup.focus();
}