function popUp(URL,WIDTH,HEIGHT)
{
	day = new Date();
	id = day.getTime();
	eval( "page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",left = 0,top = 120');");
	//return true ;
} ;

function PublicPopUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval( "page" + id + " = window.open('http://' + URL, '" + id + "');");
	//return true ;
} ;

function Redirect(URL)
{
	window.location=URL;
	//return true ;
} ;

function Switch( imageid , name )
{ 
	document.getElementById( imageid ).setAttribute( 'src' , name ) ;
	//return true ;
} ;

function SwitchNavTitle( whichNav , num )
{
	var navId = '' ;
	var str = '' ;
	switch( whichNav )
	{
		case 1 :
			navId = 'hLeftNavDisp' ;
			switch( num )
			{
				case 1 :
					str += 'Bio' ;
					break ;
				case 2 :
					str += 'Contact' ;
					break ;
				case 3 :
					str += 'News' ;
					break ;
				default :
					break ;
			}
			break ;
		case 2 :
			navId = 'hRightNavDisp' ;
			switch( num )
			{
				case 1 :
					str += 'Fashion' ;
					break ;
				case 2 :
					str += 'Fine Art' ;
					break ;
				case 3 :
					str += 'Photojournalism' ;
					break ;
				case 4 :
					str += 'Portraits' ;
					break ;
				case 5 :
					str += 'Nudes' ;
					break ;
				case 6 :
					str += 'Archive' ;
					break ;
				case 7 :
					str += 'Editorial' ;
					break ;
				case 8 :
					str += 'Glamour' ;
					break ;
				case 9 :
					str += 'Maternity' ;
					break ;

				default :
					break ;
			}
			break ;
		default :
			navId = 'hLeftNavDisp' ;
			break ;
	}
	document.getElementById( navId ).innerHTML = str ;
} ;

/* Below is AJAX stuff */

var request = false ;
	
function clearInnerCell()
{
	document.getElementById( 'innerCell' ).innerHTML = ' ' ;
} ;

function createRequest()
{
	try
	{
		request = new XMLHttpRequest() ;
	}
	catch( msTwo )
	{
		try
		{
			request = new ActiveXObject( 'Msxml2.XMLHTTP' ) ;
		}
		catch( msOne )
		{
			try
			{
				request = new ActiveXObject( 'Microsoft.XMLHTTP' ) ;
			}
			catch( failure )
			{
				request = false ;
			}
		}
	}
	if( !request )
	{
		alert( 'Could not start up proper page navigation' ) ;
	}
} ;
	
function UpdateCenter( url , cellId )
{	
	createRequest() ;
	request.open( 'GET' , url , true ) ;
	request.onreadystatechange = function(){ updateInnerCell( cellId ) ; }  ;
	request.send( null ) ;	
} ;
function updateInnerCell( cellId )
{
	if( request.readyState == 4 )
	{
		if( request.status == 200 )
		{	
			document.getElementById( cellId ).innerHTML = request.responseText ;
		}
	}
	
	else
	{
		document.getElementById( cellId ).innerHTML = "<div class='text'><h2>Please wait</h2></div>" ;
	}
} ;

/* Below is AJAX and form POST */

/* The following function will always prepare post variables into utf-8 , so it is necessary to convert on the server */
function buildPOST( theFormName )
{
	theForm = document.getElementById( theFormName ) ;
	// theForm = document.forms[theFormName];
	var qs = ''
	for( e = 0 ; e < theForm.elements.length ; e++ )
	{
		if( theForm.elements[e].name != '' )
		{
			var name = theForm.elements[e].name ;
			qs += ( qs =='' ) ? '' : '&'
			qs += name + '=' + encodeURIComponent( theForm.elements[e].value ) ;
		}
	}
	qs += "\n" ;
	return qs ;
} 

function send_post( theFormName , url )
{
	var xmlMessage = buildPOST( theFormName ) ;
	request.open( "POST" , url , false )
	request.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
	request.send( xmlMessage )
}

function display_response() {
    var optionDiv = document.getElementById("innerCell");
    optionDiv.innerHTML = request.responseText;
} 

function contactSubmit()
	{
		var contactName = document.getElementById( 'contact_name' ).value ;
		var contactText = document.getElementById( 'contact_textarea' ).innerHTML ;
		alert  ( contactText ) ;
		createRequest() ;
		request.open( 'POST' , 'contact.php' , true ) ;
		request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		request.onreadystatechange = updateInnerCell() ;
		request.send( "ajax=yes&contact_name=" + contactName + "&contact_textarea=" + contactText ) ;
	} ;
