var clipTop = 0;
var clipBottom = 50;
var topper = 0;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;

var clipLeft = 0;
var clipRight = 390;
var clibHeight = 150;

function init() {
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('viewer');
	if (document.layers) {
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = 0;
		x.style.clip.left = clipLeft;
		x.style.clip.right = clipRight;
		x.style.clip.bottom = clipBottom;
	} else if (document.getElementById || document.all) {
		lyrheight = x.obj.offsetWidth;

		var clipstring = 'rect(0px,'+clipRight+'px,'+clibHeight+'px,'+clipLeft+'px)'
		x.style.clip = clipstring;
	}
}


function scrollayer(layername,amt,tim) {
	if (!DHTML) init();
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
	return false;
}

function realscroll() {
	if (!DHTML) return;
	clipLeft += amount;
	clipRight += amount;
	topper -= amount;

	if (clipLeft < 0  || clipRight > lyrheight) {
		clipLeft -= amount;
		clipRight -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all) {

		clipstring = 'rect(0px,'+clipRight+'px,'+clibHeight+'px,'+clipLeft+'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.left = topper + 'px';
	} else if (document.layers)	{
		thelayer.style.clip.left = clipLeft;
		thelayer.style.clip.right = clipRight;
		thelayer.style.left = topper;
	}
	time = setTimeout('realscroll()',theTime);
	return false;
}

function stopScroll() {
	if (time) clearTimeout(time);
	return false;
}

function vis(val) {
	if (!DHTML) return;
	var f = new getObj('example');
	f.style.visibility = val;
}

function getObj(name) {
  if (document.getElementById) {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  } else if (document.all)  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }  else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function displayControls(obj,display) {
	obj.getElementsByTagName("div")[0].style.display = display;
}

function approveMedia(approved) {
	ajaxRequestUrl = "/ajaxEditMediaApprovals.htm";
	myParams = "id=222&approved=true";
	new Ajax.Request(ajaxRequestUrl, {parameters:myParams, onSuccess:successFunc, onFailure:errFunc});
}

var successFunc = function(t) {
	alert("success " + t.responseText);
}

var errFunc = function(t) {
	alert("error");
}


