Event.observe(window, "load", InitContentPage);
Event.observe(window, "resize", SetContentScreenObjects);

var xpos = 0;


function InitContentPage()
{
  SetContentScreenObjects(); 
  ShowContentScreen(); 
  
   _contentbaritems = $("contentbar_items");
  
}

function SetContentScreenObjects()
{
	if (document.body) {
		var cpw = parseInt(document.body.clientWidth);
		var cph = parseInt(document.body.clientHeight);
		var ic = $("innercontent");
		var iic = $("innerinnercontent");
		if ((ic) && (iic)) {
		  ic.style.left = "0px";
		  ic.style.top = "1px"; 
		  
		  var icw = cpw - 5;
		  var ich = cph - 1;
		  		  
		  if (icw < 0) { icw = 0; }
		  if (ich < 0) { ich = 0; }
		  
		  ic.style.width = icw + "px";
		  ic.style.height = ich + "px";	
		  	
		  iic.style.width = icw + "px";
		  iic.style.height = ich + "px";		  
		}
  }
}

function ShowContentScreen()
{
  var ic = $("innercontent");
	if (ic) {
	  Effect.SlideDown(ic);
	}  	
	
	var cb = $("contentbar");
	if (cb) {
	  Effect.SlideDown(cb);
	}
}

function OverArrow(obj)
{
  var imagenormal = $("image_" + obj.id);
  var imagehot = $("imagehot_" + obj.id);
  if ( (imagenormal) && (imagehot) ) {
    Element.hide(imagenormal);
    Element.show(imagehot);
  }   	
}

function OutArrow(obj)
{
  var imagenormal = $("image_" + obj.id);
  var imagehot = $("imagehot_" + obj.id);
  if ( (imagenormal) && (imagehot) ) {
    Element.hide(imagehot);
    Element.show(imagenormal);
  } 	
}

function LeftClick()
{
  if (_contentbaritems) {
	  step = 190;
	  xpos = xpos + step;
		if (xpos > 0) {
		  xpos = 0;	
		}
	  new Effect.Move(_contentbaritems, { x:xpos , y:0, mode: 'absolute', duration:0.5, transition: Effect.Transitions.spring});
	}
}

function RightClick()
{  
  if (_contentbaritems) {
  	step = 190;   
  	var tdcol = _contentbaritems.getElementsByTagName("TD");
    minleft = 0 - ((tdcol.length - 3) * step); 
	  xpos = xpos - step;
	  if (xpos < minleft) {
	    xpos = minleft;	
	  } 
	new Effect.Move(_contentbaritems, { x:xpos , y:0, mode: 'absolute', duration:0.5, transition: Effect.Transitions.spring});
	}
}

function LeftLargeClick()
{
  if (_contentbaritems) {
	  step = 548;
	  xpos = xpos + step;
		if (xpos > 0) {
		  xpos = 0;	
		}
	  new Effect.Move(_contentbaritems, { x:xpos , y:0, mode: 'absolute', duration:0.5, transition: Effect.Transitions.spring});
	}
}

function RightLargeClick()
{  
  if (_contentbaritems) {
    step = 548;
    var tdcol = _contentbaritems.getElementsByTagName("TD");
    minleft = 0 - ((tdcol.length - 1) * step); 
    xpos = xpos - step;	
	  if (xpos < minleft) {
	    xpos = minleft;	
	  } 
	new Effect.Move(_contentbaritems, { x:xpos , y:0, mode: 'absolute', duration:0.5, transition: Effect.Transitions.spring});
	}
}
