function emailok(str) {
 return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}


function submitit()
{
 document.form1.submit (); 
}

function closebox(topy,thanks)
{
var tm=3;
if(thanks)
{

if(!emailok(document.form1.email.value)){ alert("Please fill in your email address"); document.form1.email.value=""; return false; }
if((document.form1.fname.value).length < 2) { alert("Please fill in your first name");  return false; }
document.getElementById("signupbox").style.backgroundPosition="400px";
document.getElementById("signupform").style.visibility="hidden";
thanks=0;
   setTimeout("submitit(); ", 3000);
    setCookie("signup","true",1000);
   return false;
}
else
{
topy=topy-4;
document.getElementById("signupbox").style.top = topy + "px";
if( topy > -400)
{
   setTimeout("closebox(" + topy + "," + thanks +")", tm);
   return;
}   
   setCookie("signup","true",1);
}   
/*document.getElementById("signupbox").style.visibility = "hidden";
document.getElementById("signupbox").style.top = "-400px"; */
}
function movesignupbox(topy,left,endtop,interval)
{
topy= topy+4; 
if (topy > endtop) topy=endtop;
document.getElementById("signupbox").style.top = topy + "px";
document.getElementById("signupbox").style.left = left + "px";
if(topy< endtop)
   setTimeout("movesignupbox(" + topy + ", " + left + ", " + endtop + ", " + interval + ")", interval);
}
function indexfunction()
{
chimes();
<?php if(!isset($_REQUEST['testing'])) { ?>
if(!getCookie("signup")) 
<?php } ?>
{
movesignupbox(-400, (myWidth-400)/2,10,10);
document.getElementById("signupbox").style.visibility = "visible";
}
}

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function getCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}				
	

function setCookie( name, value, expires ) 
{
// set time, it's in milliseconds
var today = new Date();
var path = "/";
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) 

}



/***************************************/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
var ie5  = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);
 //code to find out user's screen dimensions and center
 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var myCenter=Math.floor(myWidth/2);


//*****************************
//fades a div in or out
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//*****************************
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
function setOpacity(id, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
      var obj = document.getElementById(id);
 switch(BrowserDetect.browser)
{
   case "Safari":    obj.style.opacity = opacity/100;
   case "Konqueror": obj.style.KHTMLOpacity = opacity/100; break;
   case "Explorer":   obj.style.filter = "alpha(opacity:"+opacity+")"; break;
   case  "Firefox":   obj.style.opacity = opacity/100; break;
   case "Mozilla":   obj.style.MozOpacity = opacity/100; break;
   default:    obj.style.opacity = opacity/100; obj.style.filter = "alpha(opacity:"+opacity+")"; 
} 

}
var step4Timeout;
function step4(id, opac, flagno) {
      if(freeze) {setflag(flagno,0); return; }
     if((flag=getflag(flagno)) != 3)
	{		

	step4Timeout = setTimeout("step4('" + id + "'," + opac + "," +   flagno + ")",1000); 
	return;
	}

    if(opac < 100){

        opac+=1;
        setOpacity( id, opac)
       step4Timeout= setTimeout("step4('" + id + "'," + opac + "," + flagno +")", 50);
    }else 
	{
		
		setflag(flagno,0);
	}
}
var step3Timeout;
function step3(pExistingImageID, pImageURL,maxw, flagno){
      if(freeze) {setflag(flagno,0); return; }
    if((flag=getflag(flagno)) !=2)
	{
	step3Timeout= setTimeout("step3('" +  pExistingImageID + "','" + pImageURL + "'," + maxw + "," + flagno + ")",1000); 
	return;
	}
;
    
	var img = document.createElement('img');	
	
	var wratio=1.0;
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
		if (this.width > maxw)wratio=maxw/this.width;

        document.getElementById(pExistingImageID).width=Math.floor(this.width*wratio);
        document.getElementById(pExistingImageID).height=Math.floor(this.height*wratio);
    }
    img.src = pImageURL;
    setflag(flagno,3);

	return false;
}
var step2Timeout;
function step2(id, opac2, flagno) {
      if(freeze) {setflag(flagno,0); return;}
      if(opac2 > 0){
        opac2-=1;
      setOpacity( id, opac2)

        step2Timeout=setTimeout("step2('" + id + "'," + opac2 +","+ flagno + ")", 50);
    }
	else
	{
		setflag(flagno,2);	
	}
}

var step1aTimeout, step1bTimeout, step1cTimeout;
function fadeinpicture(id, millisec,pExistingImageID, pImageURL,maxw, flagno) 
{
      if(freeze) {setflag(flagno,0); return; }
    if((flag=getflag(flagno))!=0)
	{
	step1aTimeout=setTimeout("fadeinpicture('" + id + "'," + millisec + ",'" + pExistingImageID + "','" + pImageURL + "'," + maxw + "," + flagno+ ")",1000); 
	return;
	}

   setflag(flagno,1);
   step2(id,100, flagno)
   step1bTimeout=setTimeout("step3('"  + pExistingImageID + "','" + pImageURL + "'," + maxw + "," + flagno +")",millisec+102);
   step1cTimeout=setTimeout("step4('" + id + "'," + 0 + "," +  flagno + ")",millisec*2+10);
}

var fileno=1;

var freeze=0;
function setfileno(num)
{
	freeze=1;
fileno=fileno+num-4;
if(fileno >= fileListLength) fileno= fileno - fileListLength;
if(fileno<0) fileno=fileno+fileListLength;
/*clearTimeout(timeoutID);
clearTimeout(step1aTimeout);
clearTimeout(step1bTimeout);
clearTimeout(step1cTimeout);
clearTimeout(step2Timeout);
clearTimeout(step3Timeout);
clearTimeout(step4Timeout); */
getImageMaxHalt("img1",fileList[fileno],800);
putThumbs();
 setOpacity( "img1", 100)
}

function putThumbs()
{
	  var thumbno=fileno-3;
	 if(thumbno<0) thumbno = thumbno + fileListLength;	 
	 getImageMax("thumb1", fileList[thumbno],80);

 
	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 getImageMax("thumb2", fileList[thumbno],80);


	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 getImageMax("thumb3", fileList[thumbno],80);


	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 getImageMax("thumb4", fileList[thumbno],80);

		  
	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 getImageMax("thumb5", fileList[thumbno],80)


	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 	 getImageMax("thumb6", fileList[thumbno],80)

			  
	 thumbno++; if (thumbno>=fileListLength) thumbno=0;
	 	 	 getImageMax("thumb7", fileList[thumbno],80)

}

var timeoutID;

function gallery()
{	
/*    if(!freeze)
	{*/
		getImageMax("img1", fileList[fileno],800, 1) ;
		putThumbs();
		if(++fileno >= fileListLength) fileno=0;
		 
/*		timeoutID=setTimeout('gallery() ',10000);
	}
	 else if(freeze==1)
	 {
		freeze=2;   
		timeoutID=setTimeout('gallery() ',10000);
	 }
	 else {
		   freeze=0;
		   timeoutID=setTimeout('gallery() ',10000);
	} */
}



function setflag(flagno,what)
{
    switch(flagno)
    {
      case 1: flag1=what; break;
      case 2: flag2=what; break;
      case 3: flag3=what; break;
    }
}
function getflag(flagno)
{
   switch(flagno)
    {
      case 1: flag=flag1; break;
      case 2: flag=flag2; break;
      case 3: flag=flag3; break;
    }
   return(flag);
}

//*****************************
//changes content of a div 
function writeit(text,id)
{
   var x
	if (document.getElementById)
	{
		x = document.getElementById(id);
		if(!x)return;
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		if(!x)return;
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		if(!x)return;
		x.document.open();
		x.document.write(text);
		x.document.close();
	}
}

function getImage(pExistingImageID, pImageURL){
    var img = document.createElement('img');	
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
        document.getElementById(pExistingImageID).width=this.width;
        document.getElementById(pExistingImageID).height=this.height;
    }
    img.src = pImageURL;
	return false;
}
function getImageMax(pExistingImageID, pImageURL,maxw){
    var img = document.createElement('img');	
	var wratio=1;
	//writeit('<img src="images/anbudmisclotus.gif" alt="Loading..." width="120" height="126" />',"loading");
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
		if (this.width > maxw)wratio=maxw/this.width;

        document.getElementById(pExistingImageID).width=Math.floor(this.width*wratio);
        document.getElementById(pExistingImageID).height=Math.floor(this.height*wratio);
    }
    img.src = pImageURL;
//	writeit("","loading");
	return false;
}


function getImageMaxHalt(pExistingImageID, pImageURL,maxw){
    var img = document.createElement('img');	
	var wratio=1;
	//writeit('<img src="images/anbudmisclotus.gif" alt="Loading..." width="120" height="126" />',"loading");
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
		if (this.width > maxw)wratio=maxw/this.width;

        document.getElementById(pExistingImageID).width=Math.floor(this.width*wratio);
        document.getElementById(pExistingImageID).height=Math.floor(this.height*wratio);
    }
    img.src = pImageURL;
setOpacity( "img1", 100);
	return false;
}


var flag1=0, flag2=0, flag3=0;
var minopac=1;


maxw=800;


//Trish wanted this out
function chimes()
{
	//	var html='<EMBED SRC="chimes.mp3" WIDTH=10 HEIGHT=10 AUTOSTART="true">';  //initiate sound
	//	  writeit(html,"sound");  
}
//*****************************
//function that takes care of tasks on loading page
function inithomepage()
{	

   changeOpac(0,"canvas"); //disappear the main body
	document.getElementById("canvas").style.visibility = "visible";
	chimes();
	opacity('canvas', 0, 100, 3000); //fade in main area after the header is there
}

stepx=2; stepy=3; lag=20;

function clippingpic(width,height)
{
if(width>=199 && height >=299)
{
document.getElementById("imga").width=document.getElementById("imgb").width;
document.getElementById("imga").height=document.getElementById("imgb").height;
document.getElementById("imga").src=document.getElementById("imgb").src;
document.getElementById("imgb").style.clip="rect(0px,0px,0px,0px)";
width=0; height=0;
return;
} 
width+=stepx;
height+=stepy;
var top=Math.floor((300-height)/2) ; if(top<0) top=0;
var right=Math.floor(199-(200-width)/2); if(right>199) right=199;
var bottom=Math.floor(299-(300-height)/2 ) ; if(bottom>299) bottom=299;
var left=Math.floor((200-width)/2 ); if(left<0) left=0;
document.getElementById('divb').style.clip ='rect('  + top + 'px,'  + right + 'px,' + bottom + 'px,' +  left + 'px)';
setTimeout("clippingpic(" + width + "," + height + ")",lag);
}

function moveLeft()
{
	
}
function moveRight()
{
	
}
/*****************************/