// Name:		Default.js
// Author:	Brad Blanchard
// Date:		12 Jul 2005

function Check( id )
{
	document.getElementById( id ).checked = true;
}

function Show( id )
{
	document.getElementById( id ).style.display = "";
}

function Hide( id )
{
	document.getElementById( id ).style.display = "none";
	//alert( id );
}

/*** Types ***/
var Sections = new Array( "Proofs", "Samples", "Home" );
var Types    = new Array( "Add", "Edit", "Delete" );

var CurrentSection = "Proofs";
var CurrentType    = "Add";

function find( array, data )
{
	for( var i = 0; i < array.length; i++ )
		if( array[i] == data )
			return true;
	return false;
}

function HideAll()
{
	for( var i = 0; i < Sections.length; i++ )
	{
		Hide( Sections[i] + 'Section' );
		if( Sections[i] != 'Home' )
		{
			Hide( 'Edit' + Sections[i] + 'Type' );
			for( var j = 0; j < Types.length; j++ )
				Hide( Types[j] + Sections[i] + 'Section' );
		}
	}
}

function SetActiveSection( Section, Type )
{
	CurrentSection = Section;
	CurrentType    = Type;

	HideAll();
	
	Show( Section + 'Section' );
	Check( Section + 'Radio' );
	
	if( Section != 'Home' )
	{
		Show( 'Edit' + Section + 'Type' )
		
		if( Type )
		{
			Show( Type + Section + 'Section' );
			Check( Type + Section + 'Radio' );
		}
	}
}

/*** Image Viewer ***/

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = screen.width;
defaultHeight = screen.height;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if ( parseInt(navigator.appVersion.charAt(0) ) >=4 )
{
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

var optNN='toolbar=0,scrollbars=auto,status=0,width='+defaultWidth+',height='+defaultHeight+',left=0,top=0';
var optIE='toolbar=0,scrollbars=auto,status=0,width=150,height=100,left=0,top=0';

function ViewImage( imageURL, imageTitle )
{
	var win = window.open( imageURL, '_blank', 'location=no,menubar=no,status=no,toolbar=no' );
}

/*
function ViewImage( imageURL, imageTitle )
{
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	
	with (imgWin.document)
	{
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=40+100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=40+100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);');
		writeln('window.moveTo(screen.width/2-width/2,screen.height/2-height/2);}'); writeln('if (isNN){');
		writeln('width=40+document.images["ImageSample"].width;');
		writeln('height=40+document.images["ImageSample"].height;');
		writeln('window.innerWidth=width;window.innerHeight=height;window.moveTo(screen.width/2-width/2,screen.height/2-height/2);}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		
		if (!AutoClose) writeln('</head><body bgcolor=FFFFFF scroll="auto" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor=FFFFFF scroll="auto" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		
		writeln('<img name="ImageSample" src='+imageURL+' style="position:absolute; top: 20px; left: 20px;"></body></html>');
		close();		
	}
}
*/

/*** End Image Viewer ***/

/*** Cookie Handling Functions ***/

function WriteCookie( Name, Value )
{	
	var date = new Date();
	date.setTime( date.getTime() + ( 3*60*1000 ) ); // 3 Minutes
	var Expires = "; expires=" + date.toGMTString();
	
	document.cookie = Name + "=" + Value + Expires + "; path=/";
}

function ReadCookie( Name )
{
	var NameExt = Name + "=";
	var ca = document.cookie.split( ';' );
	for( var i = 0; i < ca.length; i++ )
	{
		var c = ca[i];
		while( c.charAt(0)==' ' ) c = c.substring( 1, c.length );
		if( c.indexOf(NameExt) == 0 ) return c.substring( NameExt.length, c.length );
	}
	
	return null;
}

function DeleteCookie( Name )
{
	WriteCookie( Name, "", -1 );
}

/*** End Cookie Handling Functions ***/
