$(document).ready(function(){

// your code here

var myblock = $("table#newstable");
var newsoffset = myblock.offset();
var newsurl = $("input#getnewsurl").attr("value");

var cell_21_html = "<marquee id=\"MENU\" direction=\"up\" scrollAmount=\"1\" scrolldelay=\"0\" style=\"padding:0px 3px 0px 3px;border-width:3px;border-color:SlateGray;border-style:ridge;background-color:#c4e1d4; \"></marquee>";
var cell_22_html = "<div id=\"midelement\"><table id=\"tblnewsbar\" style=\"height:180px;border-margin:0px 0px 0px 0px;border-collapse: separate; border-spacing: 0;*border-collapse: expression(\"separate\", cellSpacing = \"0px\");\"><tr><td id=\"upfastestbutton\">^</td></tr><tr><td id=\"upfasterbutton\" class=\"midbuttons\">&middot;</td></tr><tr><td id=\"upfastbutton\" class=\"midbuttons\">&middot;</td></tr><tr><td id=\"stopbutton\" class=\"midbuttons\">X</td></tr><tr><td id=\"downfastbutton\" class=\"midbuttons\">&middot;</td></tr><tr><td id=\"downfasterbutton\" class=\"midbuttons\">&middot;</td></tr><tr><td id=\"downfastestbutton\">v</td></tr></table></div>";

$("div#newnews").css({'border-width':'3px','border-color':'SlateGray','border-style':'ridge','padding':'3px','color':'DarkGreen','background-color':'#c4e1d4'});
$.get(newsurl, {latestnews: "true"}, function(newnewsdata){$('div#newnews').html(newnewsdata);});

// if the block is toward the left side of the page, invert the marquee and the sidebar

if (newsoffset.left<100){

// the newsview cell now becomes the newsbar cell, and viceversa
  $("td#newsview").css({'position':'relative','vertical-align':'middle'});
  if ($.browser.msie)$("td#newsview").css({'width':'8%'});
  $("td#newsview").html(cell_22_html);
  $("td#newsbar").html(cell_21_html);
}

// if it's not near the left hand side of the window, build it normally

else {
  $("td#newsview").html(cell_21_html);
  if ($.browser.msie)$("td#newsview").css({'width':'92%'});
  $("td#newsbar").css({'position':'relative','vertical-align':'middle'});
  $("td#newsbar").html(cell_22_html);
}

  $("div#midelement").css({"vertical-align":"middle"});
  if ($.browser.msie) {$("div#midelement").css({"position":"absolute","top":"50%"});$("table#tblnewsbar").css({"position":"relative","top":"-50%"});}

  $.get(newsurl, function(mydata){$('marquee#MENU').html(mydata);});


$("td#upfastestbutton").css({"cursor":"pointer", "background-color":"#c4e1d4", "color":"DarkSlateGray", "text-align":"center", "border-color":"LightCyan", "border-style":"groove", "border-width":"2px 2px 0px 2px"});
$("td.midbuttons").css({"cursor":"pointer", "background-color":"#c4e1d4", "color":"DarkSlateGray", "text-align":"center", "border-color":"LightCyan", "border-style":"groove", "border-width":"0px 2px 0px 2px"});
$("td#downfastestbutton").css({"cursor":"pointer", "background-color":"#c4e1d4", "color":"DarkSlateGray", "text-align":"center", "border-color":"LightCyan", "border-style":"groove", "border-width":"0px 2px 2px 2px"});
$("td#upfastestbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("marquee#MENU").attr({
       direction: "down", scrollAmount: 10});
  }
)
$("td#upfasterbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("marquee#MENU").attr({
       direction: "down", scrollAmount: 4});
  }
)
$("td#upfastbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("marquee#MENU").attr({
       direction: "down", scrollAmount: 1});
  }
)
$("td#stopbutton").hover(
   function(){
     $("marquee#MENU").trigger("stop");
  }
)
$("td#downfastbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("#MENU").attr({
       direction: "up", scrollAmount: 1});
  }
)
$("td#downfasterbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("#MENU").attr({
       direction: "up", scrollAmount: 4});
  }
)
$("td#downfastestbutton").hover(
   function(){
     $("marquee#MENU").trigger("start");
     $("#MENU").attr({
       direction: "up", scrollAmount: 10});
  }
)

$("marquee#MENU > a").hover(function(){$(this).css({color:"red"});}, function(){$(this).css({color:"DarkBlue"});});

// your code ends here

 });