function validate(field,isRequired,validationType) {
	if (!validationType) {
		$(field.id+'_check').src='/images/'+(field.value?'check':(field.value || isRequired?'cross':'spacer'))+'.png';
	} else if (validationType=='email') {
		$(field.id+'_check').src='/images/'+(validate_email(field.value)?'check':(field.value || isRequired?'cross':'spacer'))+'.png';
	}
}

function validate_email(email) {
	var reg=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(email);				
}

function scrollAndScreen() {
	var scrollX,scrollY,width,height;
	if (self.pageYOffset) {
		scrollX=self.pageXOffset;
		scrollY=self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		scrollX=document.documentElement.scrollLeft;
		scrollY=document.documentElement.scrollTop;
	} else if (document.body) {
		scrollX=document.body.scrollLeft;
		scrollY=document.body.scrollTop;
	}
	if (self.innerHeight) {
		width=self.innerWidth;
		height=self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		width=document.documentElement.clientWidth;
		height=document.documentElement.clientHeight;
	} else if (document.body) {
		width=document.body.clientWidth;
		height=document.body.clientHeight;
	}
	return new Array(scrollX,scrollY,width,height);
}

function load_url(src,width,height) {
	setup_overlay(width,height);
	$('image').hide();
	$('url').show();
	$('url').style.width=width+'px';
	$('url').style.height=height+'px';
	window.url.location.href=src;
}

function setup_overlay(width,height) {
	vars=scrollAndScreen();
	var adjwidth=parseInt(width>(vars[2]-75)?vars[2]-75:width);
	var adjheight=parseInt(height>(vars[3]-75)?vars[3]-75:height);
	$('overlay').style.height=(document.body.scrollHeight>vars[3]?document.body.scrollHeight:vars[3])+'px';
	$('overlay').show();
	$('outer_div').style.width=adjwidth+'px';
	$('outer_div').style.height=(adjheight+25)+'px';
	$('outer_div').style.left=vars[0]+(vars[2]-adjwidth)/2+'px';
	$('outer_div').style.top=vars[1]+(vars[3]-(adjheight+25))/2+'px';
	$('outer_div').style.display='';
	$('inner_div').style.overflowX=(adjwidth<width?'scroll':'hidden');
	$('inner_div').style.overflowY=(adjheight<height?'scroll':'hidden');
	$('inner_div').style.width=adjwidth+'px';
	$('inner_div').style.height=adjheight+'px';
}

function close_overlay() {
	$('overlay').hide();
	$('outer_div').hide();
	$('url').hide();
	$('image').show();
	$('image').src='/images/spinner.gif';
}
