var myScroll;

var windowHeight = window.innerHeight;
var howMuch = (windowHeight - 514)/2 - 30;
//alert (howMuch);
//
if( typeof( window.innerWidth ) == "number" ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in "standards compliant mode"
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

window.addEvent('domready', function() {
	$("theCredits").setStyle('opacity',0);	
	$("theCredits").addEvent('click', hideCredits);
	document.getElementById('all').style.marginTop = howMuch;
	$("all").setStyle('marginTop',howMuch);	
});

window.addEvent('resize', function() {
	windowHeight = window.innerHeight;
	howMuch = (windowHeight - 514)/2 - 50;
	document.getElementById('all').style.marginTop = howMuch;
	$("all").setStyle('marginTop',howMuch);	
});


var stopped;
function showCredits () {
	stopped = false;
	//$("creditsWindow").tween('margin-top', -800);
	myScroll = new Fx.Tween($('creditsWindow'), {
		property: 'margin-top',
		duration: 30000, 
		transition: 'linear',
		link: 'cancel'
	});
	
	$("creditsWindow").addEvent('mouseover', function() {
											if (!stopped) {
												myScroll.pause();												
											}
										}
	);
	$("creditsWindow").addEvent('mouseout', function() {
											if (!stopped) {
												myScroll.resume();
											}
										}
	);
	
	//myScroll.chainComplete(showCredits());
	
	/*$('creditsWindow').set('tween',{
		duration: 30000,
		link: 'chain'
	});*/
	
	var size = $("all").getSize();
	//alert (size.y);
	myScroll.start(size.y+150,-800);	
	$("theCredits").setStyle('z-index', 100);
	$("theCredits").tween('opacity', 0.7);
}


function hideCredits () {
	stopped = true;
	myScroll.cancel();	
	$("theCredits").tween('opacity', 0);
}


function openForm () {
	var width =  700;
	var height =  400;
	newWindow = window.open('theForm.php', 'PELEG_form', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',left=0, top=0');
}

function openPress (wO) {	
	var width =  800;
	var height =  600;
	newWindow = window.open('images/press/pressPage.php?q='+wO+'', 'PELEG_press', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left=0, top=0');
}

function openPressVid (wO) {
	var width =  565;
	var height =  424;
	newWindow = window.open('images/press/pressVid.php?q='+wO+'', 'PELEG_pressvid', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left=0, top=0');
}

function openProductVid (wO) {
	var width =  565;
	var height =  424;
	newWindow = window.open('images/portfolio/prodVid.php?q='+wO+'', 'PELEG_prodvid', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left=0, top=0');
}