// Declare Client Variables
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
             && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
             && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4up = (is_ie && (is_major >= 4));
    
var is_win = ((agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1));
var is_mac = (agt.indexOf("mac")!=-1);

// Determine Client Type - Advanced (adv) or Standard (std)
if (is_nav6up || is_ie4up)
{
	var client = 'adv';
}
else
{
	var client = 'std';
}

// Declare Screen Width & Height
var SW = screen.availWidth;
var SH = screen.availHeight;


// Calculate Horizontal Centrepoint
function xcPCalc(SW,SH)
{
	if (SW / SH > 2) { xcP = (SW/4); }
	else { xcP = SW/2; }
	return xcP;
}


// Declare Horizontal Centrepoint
var xcP = xcPCalc(SW,SH);

// Declare Vertical Centrepoint
var ycP = SH/2;


// Check Horizontal Centrepoint
function xCheck(xOff)
{
	if ((screen) && (client == 'adv')) { var x = xcP+xOff; }
	else { var x = 400+xOff; }
	return x;
}


// Check Horizontal Centrepoint
function yCheck(yOff)
{
	if ((screen) && (client == 'adv')) { var y = ycP+yOff; }
	else { var y = 300+yOff; }
	return y;
}


function redirect(trgt){
alert(trgt)
	window.location = trgt;
}

function spawn(w, h, trgt, scrolling, name,x,y)
{

    xOff = ((w+10)/2)*-1;
	yOff = ((h+29)/2)*-1;
	
	if (name == "") name = 'ff';
	// Declare Window Co-ordinates
	if (x == null) {
		var x = xCheck(xOff);
		var y = yCheck(yOff);
	}
	//alert("x: "+x+"\ny: "+y+"\nxOff: "+xOff+"\nyOff: "+yOff+"\nh: "+h+"\nw: "+w);

	// Launch Window
	eval("pop = window.open(trgt,name,'width='+w+',height='+h+',left='+x+',top='+y+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no')");
	
	if (pop == null || pop == false)
	{
		alert("Cannot open a pop-up window.\n\nThis site runs in a pop-up window but one cannot be opened.\n\nThis may be becuase you are using some software (such as Norton Internet Security) that disables pop-up windows.\n\nIf you wish to see this site please disable this software.");
	}
	
	pop.focus();
}

function spawnFull(w, h, trgt)
{
	xOff = ((w+10)/2)*-1;
	yOff = ((h+29)/2)*-1;
	
	// Declare Window Co-ordinates
	var x = xCheck(xOff);
	var y = yCheck(yOff);
	
	//alert("x: "+x+"\ny: "+y+"\nxOff: "+xOff+"\nyOff: "+yOff+"\nh: "+h+"\nw: "+w);

	// Launch Window
	eval("pop = window.open(trgt,'fffull','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes,dependent=no')");
	
	if (pop == null || pop == false)
	{
		alert("Cannot open a pop-up window.\n\nThis site runs in a pop-up window but one cannot be opened.\n\nThis may be becuase you are using some software (such as Norton Internet Security) that disables pop-up windows.\n\nIf you wish to see this site please disable this software.");
	}
	
	pop.focus();
}

function spawnDiploma(url)
{
	spawn(850, 670, url, 0,"diploma");
}
function spawnidcard(url)
{
	spawn(400, 400, url, 0,"id");
}
function spawnWallpaper(url)
{
	spawn(800, 600, url, 1);
}

function spawnGames(url)
{
	spawn(770, 525, url, 1, 0, 0);
}


function spawnPrivacy()
{
	spawn(390, 485, '../terms/privacy.html', 1);
}

function spawnTsandc()
{
	spawn(390, 485, '../terms/tsandc.html', 1);
}

function spawnTsandcHome()
{
	spawn(390, 485, '../terms/tsandc.html', 1);
}

function spawntvPopUp()
{
	spawn(600, 450, 'tvPopUp.html', 1);
}


function spawnCompTsandc(loc)
{
	spawn(390, 485, ""+loc+".html", 1);
}

function spawnClip(loc)
{
	spawn(598, 400, "../"+loc+".html", 0);
}

function spawnClipHome(loc, w, h)
{
	spawn(598, 400, ""+loc+".html", 0);
}

function spawnClipLarge(loc, w, h)
{
	spawn(598, 465, "../"+loc+".html", 0);
}

function spawnCinemaSearch(f)
{
	movietitle = f.movietitle.value;
	postcode = f.postcode.value;
	
	if (movietitle == "")
	{
		alert("Please select a movie title.")
		f.movietitle.focus();
		return;
	}
	if (postcode == "")
	{
		alert("Please enter a postcode.")
		f.postcode.focus();
		return;
	}
	if (!postcode.match(/^\s*[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]{0,1}\s*[0-9]{1}[a-zA-Z]{2}\s*$/))
	{
		alert("You have entered an invalid postcode.\n\nPlease check and try again.");
		f.postcode.focus();
		return;
	}
	spawn(588, 400, "http://www.firstmovies.com/filmfactory/?postcode="+postcode+"&movietitle="+movietitle, 1);
	//spawn(588, 400, "http://my/betawax/ast/fir00134/htdocs/filmfactory/?postcode="+postcode+"&movietitle="+movietitle, 1);
}



