/*
//
//============================================================
//                >> jsImagePlayer 1.0 <<
//            for Netscape3.0+, September 1996
//============================================================
//                  by (c)BASTaRT 1996
//             Praha, Czech Republic, Europe
//
// feel free to copy and use as long as the credits are given
//          by having this header in the code
//
//          contact: xholecko@sgi.felk.cvut.cz
//          http://sgi.felk.cvut.cz/~xholecko
//
//============================================================
// Thanx to Karel & Martin for beta testing and suggestions!
//============================================================
//
// Some changes to the appearence made by Kelly Dean at CSU/CIRA.  Jan 1997
//
// 2003-02-18 Changes made to the standard js loop A.Versteegen
//
// 20/11/2006 Changes made to simplify. D.Rakena
//
//============================================================

first_image = 1;           //first image number
last_image =8;          //last image number

   //!!! the size is very important - if incorrect, browser tries to
   //!!! resize the images and slows down significantly
animation_height  = 300;              //height of the images in the animation
//**************************************************************************
//**************************************************************************



//=== THE CODE STARTS HERE ===
//=== global variables ====
normal_delay = 4000;	//4 seconds
delay = normal_delay;  //delay between frames in 1/100 seconds
current_image = first_image;     //number of the current image
timeID = null;
status = 0;            // 0-stopped, 1-playing
size_valid = 0;

//===> makes sure the first image number is not bigger than the last image number
if (first_image > last_image)
{
   var help = last_image;
   last_image = first_image;
   first_image = help;
};

// Preload animation images - Images 6-9 are copyrighted
theImages = new Array();
 theImages[1] = new Image()
 theImages[1].src = "images/landing/back28.jpg"
 theImages[2] = new Image()
 theImages[2].src = "images/landing/Black_3A.jpg"
 theImages[3] = new Image()
 theImages[3].src = "images/landing/ffd_vert_neg.jpg"
 theImages[4] = new Image()
 theImages[4].src = "images/landing/ffd_vert_neg.jpg"
 theImages[5] = new Image()
 theImages[5].src = "images/landing/ffdd-019.jpg"
 theImages[6] = new Image()
 theImages[6].src = "images/landing/ffdd-030cB.jpg"
 theImages[7] = new Image()
 theImages[7].src = "images/landing/White_2.jpg"
 theImages[8] = new Image()
 theImages[8].src = "images/landing/ffds_stairs_lights.jpg"
;
fadeimages[0]=["images/landing/Black_3A.jpg", "", ""] 
fadeimages[1]=["images/landing/back28.jpg", "", ""] 
fadeimages[2]=["images/landing/ffd_vert_neg.jpg", "", ""] 
fadeimages[3]=["images/landing/ffdd_tbmb.jpg", "", ""] 
fadeimages[4]=["images/landing/ffdd-019.jpg", "", ""] 
fadeimages[5]=["images/landing/ffdd-030cB.jpg", "", ""] 
fadeimages[6]=["images/landing/White_2.jpg", "", ""] 
fadeimages[7]=["images/landing/ffdd-007-8.jpg", "", ""] 
fadeimages[8]=["images/landing/ffds_stairs_lights.jpg", "", ""] 

//===> displays image
function animate_fwd()
{
   current_image++;
   if(current_image > last_image)
   {
         current_image = first_image; //LOOP
   };
   document.animation.src = theImages[current_image].src;
   timeID = setTimeout("animate_fwd()", delay);
}

//===> stop the animation
function stop()
{
   clearTimeout(timeID);

   status = 0;
}

//===> "play forward"
function fwd()
{
   stop();
   status = 1;
   animate_fwd();
}

//===> jumps to a given image number
function go2image(number)
{
   stop();
   if (number > last_image) number = first_image;
   if (number < first_image) number = last_image;
   current_image = number;
   document.animation.src = theImages[current_image].src;
}


//===> sets everything once the whole page and the images are loaded (onLoad handler in <body>)
function launch()
{

   stop();
   current_image = first_image;
   document.animation.src = theImages[current_image].src;

   fwd();
}

//===> writes the interface into the code where you want it
function animation()
{
   document.write(" <P CLASS=\"center\"><IMG NAME=\"animation\" SRC=\"../\"images/logo.gif\" ALT=\"[JavaScript Image Player]\">");
   document.write(" <DIV CLASS=\"center\" > ");
   document.write(" <FORM Method=GO Name=\"control_form\"> ");
   document.write("    <INPUT  CLASS=\"gray\" TYPE=\"button\" Value=\" < \" onClick=\"go2image(--current_image)\"> ");
   document.write("    <INPUT  CLASS=\"gray\" TYPE=\"button\" Value=\" Stop \" onClick=\"stop()\"> ");
   document.write("    <INPUT  CLASS=\"gray\" TYPE=\"button\" Value=\" Play \" onClick=\"fwd()\"> ");
   document.write("    <INPUT  CLASS=\"gray\" TYPE=\"button\" Value=\" > \" onClick=\"go2image(++current_image)\"> ");
   document.write(" <\/FORM> <\/DIV> <\BR/><\BR/>");
   document.write(" <\/P> ");
}

function openPopupWindow(url, name, width, height, returnWindow)
{
	var horizontalOffset, verticalOffset, offsetAmount, windowToReturn, closethiswindow;

	offsetAmount = 0;

	if(width == -1)
	{
		if ((screen.Height >= 0) && (screen.Width >= 0)) {
     			 width = screen.Width - 10;
 		 }
  		else if ((screen.availHeight >= 0) && (screen.availWidth >= 0)) {
      		 width = screen.availWidth - 10;
  		}
	}

	if(height == -1)
	{
		if ((screen.Height >= 0) && (screen.Width >= 0)) {
     			 height = screen.Height - 75;
   		 }
  		else if ((screen.availHeight >= 0) && (screen.availWidth >= 0)) {
      			 height = screen.availHeight - 45;
   		 }
	}

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		horizontalOffset = window.screenLeft + offsetAmount;
		verticalOffset = window.screenTop + offsetAmount;
	}
	else
	{
		horizontalOffset = window.screenX + offsetAmount;
		verticalOffset = window.screenY + offsetAmount;
	}

	if(horizontalOffset + width > screen.availWidth || verticalOffset + height > screen.availHeight)
	{
		horizontalOffset = 0;
		verticalOffset = 0;
	}

	windowToReturn = window.open(url, name, "toolbar=0,location=0,directories=0,status=yes,menubar=no,scrollbars=1,resizable=yes,screenX="
		+ horizontalOffset + ",screenY=" + verticalOffset + ",left=" + horizontalOffset + ",top=" + verticalOffset + ",width=" + width + ",height=" + height);

}
*/
function valid(type){
	var address;

	address = document.f1.email.value;

	if(address != ''){
		var emailCheck = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$");
		var result = emailCheck.test(address);
		if(!result){
			alert("Please input a valid email address");
			return false;
		}
		else{
			document.f1.type.value = type;
			return true;
		}
	}
	else{
		alert("Please input a valid email address");
		return false;
	}
}

