function chkForm()
{	_form = document.contactForm;
	err = '';
	emailRegEx = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

	if( _form.fname.value.length == 0 )
		err += '\n\r       - Please Enter your First Name';

	if( _form.lname.value.length == 0 )
		err += '\n\r       - Please Enter your Last Name';
	
	if( _form.email2.value.search(emailRegEx) != 0 )
		err += '\n\r       - Please supply a proper email address';

	if( err == '')
		_form.submit();
	else
		alert('Please complete all the required fields.\n\rThe following fields were not completed properly.'+err);
}

function swapStage(_img)
{	_div = document.getElementById('centerStage');
	_div.style.backgroundImage = "url('/imgs/works/logos/"+_img+"')";
}

var _lastId = '';

function expandRow(_id)
{	
	/*
	if( _lastId != '' )
	{	Effect.BlindUp(_lastId);
		$(_lastId).parentNode.className = $(_lastId).parentNode.className.replace(' plus','');
	}
	
	if( _lastId != _id )
	{	Effect.BlindDown(_id);
		$(_id).parentNode.className += ' plus';
	}
	
	if( _lastId == _id )
		_lastId = '';
	else
		_lastId = _id;
	*/
	
	if( $(_id).parentNode.className.search(' plus') > 0 )
	{	Effect.BlindUp(_id);
		$(_id).parentNode.className = $(_id).parentNode.className.replace(' plus','');
	}
	else
	{	Effect.BlindDown(_id);
		$(_id).parentNode.className += ' plus';
	}
}
function placeSputnik()
{	if( readCookie('sputniktop') != null ){	
		$('sputnik').style.top = readCookie('sputniktop');
		$('sputnik').style.right = readCookie('sputnikright');
	}
}
function flySputnik()
{	
	theduration = 250.0;
	
	if( readCookie('sputniktop') != null ){
		$('sputnik').style.top = readCookie('sputniktop');
		$('sputnik').style.right = readCookie('sputnikright');
		
		if( $('sputnik').style.right == $('outerShell').clientWidth+'px' ){
			$('sputnik').style.right = '-110px';
			$('sputnik').style.top = '100px';
		}
		
		sputniktop = $('sputnik').style.top;
		theduration = parseInt(sputniktop.substring(0,sputniktop.length-2));
	}
	
	new Effect.Morph('sputnik', {
	  style: 'right: '+$('outerShell').clientWidth+'px; top: 0px;', // CSS Properties
	  duration: theduration // Core Effect properties
	});
	setInterval('saveSputnikPos()',300);
}

function saveSputnikPos()
{	createCookie('sputniktop',$('sputnik').style.top,7);
	createCookie('sputnikright',$('sputnik').style.right,7);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

