var clients,news,gallery;

function Popup(URL, name, w, h, l, t, scrolling) {
	var windowprops = "location=no,scrollbars=" + scrolling + ",menubars=no,toolbars=no,resizable=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
	var refocus = false;
	if (name == 'client_list'){
		clients = window.open(URL,name,windowprops);
		clients.focus();
		refocus = true;
	} else if (name == 'news_archive'){
		news = window.open(URL,name,windowprops);
		news.focus();
		refocus = true;
	} else if (name == 'gallery'){
		gallery = window.open(URL,name,windowprops);
		gallery.focus();
		refocus = true;
	} else {
		netimage = window.open(URL,name,windowprops);
		netimage.focus();
	}
	
	if (refocus){
		if (news != null && !news.closed){
			news.focus();
		}
		if (clients != null && !clients.closed){
			clients.focus();
		}
		if (gallery != null && !gallery.closed){
			gallery.focus();
		}
	}
}

function PopupCenter(URL, name, w, h, scrolling) {
	var windowprops = "location=no,scrollbars=" + scrolling + ",menubars=no,toolbars=no,resizable=no,left=120,top=120,width=" + w + ",height=" + h;
	netimage = window.open(URL,name,windowprops);
	netimage.moveTo(((window.screen.width - w) / 2), ((window.screen.height - h) / 2));
	netimage.focus();
}

function stopError() {
  return true;
}
window.onerror = stopError;

function checkData()
{
correct = true
if (document.logon.username.value == "")
{correct = false; alert("Please enter your username. Having problems? Email support@netimagemedia.com")
return correct}
if (document.logon.password.value == "")
{correct = false; alert("Please enter your password. Having problems? Email support@netimagemedia.com")}
else {checkEmail()}
if (correct == true){}
return correct
}

function checkEmail()
{
var EmailCorrect = false
for (var i = 0; i <= document.logon.username.value.length; i++)
 {
 if (document.logon.username.value.charAt(i) == "@") {EmailCorrect = true}
 }
if (EmailCorrect == false){alert("Your username is invalid. Having problems? Email support@netimagemedia.com");
correct= false}
}