function BrowserCheck() {
	var b = navigator.appName;
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.v = parseInt(this.version);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0);
	this.ie5 = (this.version.indexOf('MSIE 5')>0);
	this.min = (this.ns||this.ie);
	this.pc = (this.version.indexOf('Win')>0);
	this.mac = (this.version.indexOf('PPC')>0);
	this.ns408=(parseFloat(this.version)==4.08);
}

var is = new BrowserCheck();

if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
	widthCheck = window.innerWidth;
	heightCheck = window.innerHeight;
	window.onResize = resizeFix;
}

function hide ( name ) {
	if (W3C) {
		document.getElementById(name).style.display = "none";
	} else if (NS4) {
		document.layers[name].visibility = "none";
	} else {
		document.all[name].style.display = "none";
	}
}

function popWindow(page,windowName) {
	var paraString;
	var wt;
	var ht;
	var urlVal;
	// Bug fix: we are now blanking the windowName variable
	windowName == "";

	// This is specific to Soul Calibur III
	if (page === 'about')
			{
				urlVal = 'about.html';
				widthVal = 500;
				heightVal = 440;
			} else if (page === 'trailer')
			{
				urlVal = 'includes/trailer.php?trailer.html';
				widthVal = 500;
				heightVal = 440;
			} else if (page === 'screenshots')
			{
				urlVal = 'screenshots.html?photo=1';
				widthVal = 580;
				heightVal = 580;
			} else if (page === 'wallpaper')
			{
				urlVal = 'wallpapers.html';
				widthVal = 500;
				heightVal = 500;
			} else if (page === 'wallpapers')
			{
				urlVal = 'wallpapers.html';
				widthVal = 500;
				heightVal = 500;
			} else if (page === 'register')
			{
				urlVal = '';
				widthVal = 500;
				heightVal = 440;
			} else if (page === 'signup')
			{
				urlVal = 'includes/registration.php?registration.php';
				widthVal = 500;
				heightVal = 440;
			} else if (page === 'site')
			{
				urlVal = 'site/index.html';
				widthVal = 1024;
				heightVal = 768;

			} else if (page === 'E3_wmv')
			{
				urlVal = '../includes/trailer.php?E3_wmv.html';
				widthVal = 320;
				heightVal = 300;
			} else if (page === 'E3_mov')
			{
				urlVal = '../includes/trailer.php?E3_mov.html';
				widthVal = 320;
				heightVal = 300;
			} else if (page === 'Full_wmv')
			{
				urlVal = '../includes/trailer.php?Full_wmv.html';
				widthVal = 320;
				heightVal = 300;
			} else if (page === 'Full_mov')
			{
				urlVal = '../includes/trailer.php?Full_mov.html';
				widthVal = 320;
				heightVal = 300;
			} else if (page === 'Short_wmv')
			{
				urlVal = '../includes/trailer.php?Short_wmv.html';
				widthVal = 320;
				heightVal = 300;
			} else if (page === 'Short_mov')
			{
				urlVal = '../includes/trailer.php?Short_mov.html';
				widthVal = 320;
				heightVal = 300;
			}		
	wt = widthVal;
	ht = heightVal;
	windowName = page;

	
	var winl = (screen.width - wt) / 2;
	var wint = (screen.height - ht) / 2;
	if (is.pc){wint = wint - 25};

	paraString = "width=" + wt + ",height=" + ht + ",top=" + wint + ",left=" + winl;

	paraString = paraString + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";

	if(is.ie && is.pc) {
		if(typeof(poppedWindow) == "object") {
			poppedWindow.close();
			if(is.ie4) {
				poppedWindow = window.open(urlVal,windowName,paraString);
			}
		}
	}
	poppedWindow = window.open(urlVal,windowName,paraString);
	poppedWindow.focus();
}

function launchLegal() {
	popWindow('legal.html','legal',655,160);
}
function launchSite() {
	popWindow('main.html','finesthour_site',780,540);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function rollOver(imgname)
	{
		document.images[imgname].src = "images/" + imgname + "-on.jpg";
	}
function rollOut(imgname)
	{
		document.images[imgname].src = "images/" + imgname + "-off.jpg";
	}
	
if (document.images) {
//trailer_on = newImage("images/trailerComing.jpg");
entersite_on = newImage("images/entersiteon.jpg");
entersite_off = newImage("images/entersiteoff.jpg");
trailer_on = newImage("images/trailerOn.jpg");
trailer_off = newImage("images/trailerOff.jpg");
getupdates_on = newImage("images/getupdatesOn.jpg");
getupdates_off = newImage("images/getupdatesOff.jpg");

wmsmall_on = newImage("images/wmsmallon.jpg");
wmsmall_off = newImage("images/wmsmalloff.jpg");
wmmedium_on = newImage("images/wmmediumon.jpg");
wmmedium_off = newImage("images/wmmediumoff.jpg");
wmlarge_on = newImage("images/wmlargeon.jpg");
wmlarge_off = newImage("images/wmlargeoff.jpg");
qtsmall_on = newImage("images/qtsmallon.jpg");
qtsmall_off = newImage("images/qtsmalloff.jpg");
qtmedium_on = newImage("images/qtmediumon.jpg");
qtmedium_off = newImage("images/qtmediumoff.jpg");
qtlarge_on = newImage("images/qtlargeon.jpg");
qtlarge_off = newImage("images/qtlargeoff.jpg");

previous_on = newImage("images/previouson.jpg");
previous_off = newImage("images/previousoff.jpg");
next_on = newImage("images/nexton.jpg");
next_off = newImage("images/nextoff.jpg");
close_on = newImage("images/closeon.jpg");
close_off = newImage("images/closeoff.jpg");

image1_800x600_on = newImage("images/800x600on.jpg");
image1_800x600_off = newImage("images/800x600off.jpg");
image1_1024x768_on = newImage("images/1024x768on.jpg");
image1_1024x768_off = newImage("images/1024x768off.jpg");
image1_1280x1024_on = newImage("images/1280x1024on.jpg");
image1_1280x1024_off = newImage("images/1280x1024off.jpg");
image2_800x600_on = newImage("images/800x600on.jpg");
image2_800x600_off = newImage("images/800x600off.jpg");
image2_1024x768_on = newImage("images/1024x768on.jpg");
image2_1024x768_off = newImage("images/1024x768off.jpg");
image2_1280x1024_on = newImage("images/1280x1024on.jpg");
image2_1280x1024_off = newImage("images/1280x1024off.jpg");

}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function beyondtheSeaSplash_DoFSCommand(command, args) {
	var beyondtheSeaSplashObj = isInternetExplorer ? document.all.beyondtheSeaSplash : document.beyondtheSeaSplash;
	//
	// Place your code here.
	//
}

function hide ( name ) {
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;        
	if (W3C) {
		document.getElementById(name).style.display = "none";
	} else if (NS4) {
		document.layers[name].visibility = "none";
	} else {
		document.all[name].style.display = "none";
	}
}
function show (name ) {
	var ele;                //points to the popup element

	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;

	if ( W3C ) {
		ele = document.getElementById(name);
	} else if ( NS4 ) {
		ele = document.layers[name];
	} else {        // meant for IE4
		ele = window.opener.document.all[name];
	}

	if ( NS4 ) {
		ele.visibility.display = "block";
	} else {  // IE4 & W3C
		ele.style.display = "block";
	}
}

function showvideo(){ 
 hide('videooff');
 show('videoon');
}

function hidevideo(){ 
 hide('videoon');
 show('videooff');
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub beyondtheSeaSplash_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call beyondtheSeaSplash_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function buttonDisable() {
   var a;
}


function pcm_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=pcm_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function ValidateForm()
{
	
	if (pcm_findObj("namefirst").value == "") {
		alert("You must enter a first name.");
		pcm_findObj("namefirst").focus();
		return false;
	}
	if (pcm_findObj("namelast").value == "") {
		alert("You must enter a last name.");
		pcm_findObj("namelast").focus();
		return false;
	}

	if (pcm_findObj("state").value == "") {
		alert("You must enter a state");
		pcm_findObj("state").focus();
		return false;
	}
	var at = pcm_findObj("email").value.indexOf("@");
	var dot = pcm_findObj("email").value.lastIndexOf(".");
	if (at < 1 || dot <= at) {
		alert("Your email appears to be incorrect.");
		pcm_findObj("email").focus();
		return false;
	}
	if (pcm_findObj("city").value == "") {
		alert("You must enter your city.");
		pcm_findObj("city").focus();
		return false;
	}  
	if (pcm_findObj("month").value == "") {
		alert("You must enter your date of birth.");
		pcm_findObj("month").focus();
		return false;
	}  	if (pcm_findObj("day").value == "") {
		alert("You must enter your date of birth.");
		pcm_findObj("day").focus();
		return false;
	}  	if (pcm_findObj("year").value == "") {
		alert("You must enter your date of birth.");
		pcm_findObj("year").focus();
		return false;
	}     
   if ( !checkAge() )   
   {
      window.location.href = 'sorry.html';      
      return false;   
   }	
   
   return true;
}	


function checkCookie()
{
   var allcookies = document.cookie;


   var pos = allcookies.indexOf("regtried");


   if (pos != -1)
   {
      return true; // The cookie exists
   }

   
   return false; // The cookie does not exist
}


function initPage()
{
   if(checkCookie() ) // Cookie exists...
   {
      window.location = 'sorry.html';
   }
}

function checkAge(){
	
	var min_age = 16;
	var fail_page = "sorry.html";
	
	var form = document.forms[0];
	var month = (parseInt(form.month.options[form.month.selectedIndex].value)-1);
	var day = parseInt(form.day.options[form.day.selectedIndex].value);
	var year = parseInt(form.year.options[form.year.selectedIndex].value);
	
	var user = new Date((year+min_age), month, day);
	var today = new Date();
	
	if(today.getTime() - user.getTime() < 0){
	return false;
	}
	else {
	return true;
	}
}

function translateQueryString() {
	var sQS	= unescape(location.search).substr(1);
	var oQS	= {};
	if (sQS.length) {
		var aQS_items	= sQS.split('&'), nQS_items = aQS_items.length, nQS_itemsIdx, aQS_keyValue, nQS_keyValue, nQS_keyValueIdx;
		for (nQS_itemsIdx = 0; nQS_itemsIdx < nQS_items; nQS_itemsIdx++) {
			aQS_keyValue	= aQS_items[nQS_itemsIdx].split('='), nQS_keyValue = aQS_keyValue.length;
			for (nQS_keyValueIdx = 0; nQS_keyValueIdx < nQS_keyValue; nQS_keyValueIdx++) oQS[aQS_keyValue[0]] = aQS_keyValue[1];
		}
	}
	return oQS;
}
var QueryString	= translateQueryString();

  var photo 
  photo = (QueryString['photo']*1);

	var picNum;

		 if (photo != "undefined") { 
			picNum = photo;
			} else {
			picNum = 1;
			}

   var maxVal = 8;
   var picArray = new Array('1','2','3','4','5','6','7','8')


   function picNav(navVal) {

	pNum = navVal

    picNum = pNum;
    document.gallery.mytext.value = picArray[picNum-1];
    document.images[2].src = 'images/downloads/screenshots/SS_int' + picNum + '.jpg';
    document.images[6].src = 'images/screenthumbs' + picNum + '.jpg';

   }
 function popPicWindow(urlVal,windowName,widthVal,heightVal) {
	var paraString;
	var wt;
	var ht;
	// Bug fix: we are now blanking the windowName variable
	windowName == "";
	wt = widthVal;
	ht = heightVal;

	var winl = (screen.width - 640) / 2;
	var wint = (screen.height - 480) / 2;
	if (is.pc){wint = wint - 25};

	paraString = "width=" + 640 + ",height=" + 480 + ",top=" + wint + ",left=" + winl;

	paraString = paraString + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1";

	if(is.ie && is.pc) {
		if(typeof(poppedWindow) == "object") {
			poppedWindow.close();
			if(is.ie4) {
				poppedWindow = window.open('',windowName,paraString);
poppedWindow.document.write('<html><head><title>Soul Calibur III</title></head><body bgcolor="#000000" leftmargin="0px" rightmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px"><a href="#" onClick="top.close();"><img src="images/desktop_pop_header.jpg" width="800" height="98"><br><img src=' + urlVal + ' width="' + widthVal + '" height="' + heightVal + '" border="0"></a></body></html>')
			}
		}
	}
	poppedWindow = window.open('',windowName,paraString);
poppedWindow.document.write('<html><head><title>Soul Calibur III</title></head><body bgcolor="#000000" leftmargin="0px" rightmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px"><a href="#" onClick="top.close();"><img src="images/desktop_pop_header.jpg" width="800" height="98" border="0"><br><img src=' + urlVal + ' width="' + widthVal + '" height="' + heightVal + '" border="0"></a></body></html>')
	poppedWindow.focus();
}
