var CLIENT_WIDTH  = -1; // Window Width
var CLIENT_HEIGHT = -1; // Window Height
var openwin_handle = 0; // window handler

function getSeed() 
{
	today=new Date();
	seed = (today.getTime()*84363) % 8630;
	return (seed/(934320))*1000;
}

function rand() 
{
    return Math.floor(getSeed()*203183);
}

function browserLocation(newloc)
{
	parent.window.location= newloc;
}

function isNumber(a) 
{
    return typeof a == 'number' && isFinite(a);
}

function SetClientVariables()
{
	if(document.all)
	{
		CLIENT_HEIGHT = document.body.clientHeight;
		CLIENT_WIDTH = document.body.clientWidth;
	}
	else
	{
		CLIENT_WIDTH = window.innerWidth;
		CLIENT_HEIGHT = window.innerHeight;
	}
}

function OpenCustomWin(loc,width,height)
{
	SetClientVariables();
	
	if(width >= CLIENT_WIDTH)
		width = CLIENT_WIDTH-40;
//	if(height >= CLIENT_HEIGHT)
//		height = CLIENT_HEIGHT-40;

	Nleft = ((CLIENT_WIDTH-width)/2);
	Ntop = 20;//((CLIENT_HEIGHT-height)/2);
	
	if(document.all)
		width += 10;
	var options = "WIDTH=" + width + ",HEIGHT=" + height + ",TOP=" + Ntop + ",LEFT=" + Nleft + ",SCROLLBARS=NO,TOOLBAR=NO,MENUBAR=NO,RESIZABLE=NO,STATUS=NO,DIRECTORIES=NO";
	openwin_handle = window.open(loc, "NONAME",options);
}

function OpenCustomScrollWin(loc,width,height)
{
	SetClientVariables();
	
	if(width >= CLIENT_WIDTH)
		width = CLIENT_WIDTH-40;
	if(height >= CLIENT_HEIGHT)
		height = CLIENT_HEIGHT-40;

	Nleft = ((CLIENT_WIDTH-width)/2);
	Ntop = 20;//((CLIENT_HEIGHT-height)/2);
	
	if(document.all)
		width += 10;
	var options = "WIDTH=" + width + ",HEIGHT=" + height + ",TOP=" + Ntop + ",LEFT=" + Nleft + ",TOOLBAR=NO,MENUBAR=NO,RESIZABLE=NO,STATUS=NO,DIRECTORIES=NO,SCROLLBARS=YES";
	openwin_handle = window.open(loc, "NONAME",options);
}

function CheckValidEmail(email)
{
	if(email.length<5)
		return false;
	if(email.indexOf('@')<=0)
		return false;
	if(email.indexOf('.')<=0)
		return false;
	// could check that there is something between the @ and the . and after that, there are at least 2 after the last .
	// but hey...this is my last day and I'm not goign to push things too much!
	return true;
}
