var clipTop = 0;
var clipWidth = 250;
var clipBottom = 495;
var topper = 50;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;
var img = new Array();

function preloadImages() {
	img[0] = new Image;
	img[0].src = "img/b_home_mo.png";
	img[1] = new Image;
	img[1].src = "img/b_creative_mo.png";
	img[2] = new Image;
	img[2].src = "img/b_services_mo.png";
	img[3] = new Image;
	img[3].src = "img/b_clients_mo.png";
	img[4] = new Image;
	img[4].src = "img/b_contacts_mo.png";
	img[5] = new Image;
	img[5].src = "img/b_login_mo.png";
}

function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('works');
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		var clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		x.style.clip = clipstring;
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function vis(val)
{
	if (!DHTML) return;
	var f = new getObj('works');
	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 imageOn(pimg,ext) {
	if (!ext) {
		document.getElementById(pimg).src = "img/" + pimg + "_mo.png";
	} else {
		document.getElementById(pimg).src = "img/" + pimg + "_mo." + ext;
	}
}

function imageOff(pimg,ext) {
	if (!ext) {
		document.getElementById(pimg).src = "img/" + pimg + "_norm.png";
	} else {
		document.getElementById(pimg).src = "img/" + pimg + "_norm." + ext;
	}
}

function openN(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

/***********************
**** MY LIGHT BOXING ****
***********************/
var uploadWindowOpen = false;
var http_request = null;

function openViewerWindow($project) {
	openMask();
	document.getElementById("view_work").style.display="block";
	document.getElementById("upload_page").src="uploader.php?project="+$project;
}
	
function closeViewerWindow() {
	closeMask();
	document.getElementById("view_work").style.display="none";
}
	
function openMask() {
	var s = document.getElementsByTagName("select");
	for(var i=0;i<s.length;i++) {
		s[i].style.display="none";
	}
	document.getElementById("alpha_mask").style.display="block";
}

function closeMask() {
	var s = document.getElementsByTagName("select");
	for(var i=0;i<s.length;i++) {
		s[i].style.display="inline";
	}
	document.getElementById("alpha_mask").style.display="none";
}
