<!--

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) xx.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;

  // if (!obj) {alert("no object declared");return null;}
  // if (!obj) {alert("no object declared");return null;}
  for (i=0; i<(args.length-2); i+=3) {
  	if ((obj=MM_findObj(args[i]))!=null) {
  		v=args[i+2];
    		if (obj.style) {
    			obj=obj.style;
    			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
    			obj.visibility=v;
    		}
    		else {
    			alert("cannot find style for object " + obj.name);return null;
    		}
    	}
    	else {
    		alert("cannot find object " + obj.name);return null;
    	}
   }
}

// return y position, minus
function getLayerX($objname) {
	$x = event.clientX;
	//$objW = MM_findObj($objname).width;
	//$x = document.body.clientWidth - $objW - 10;
	return $x;
}

// return y position, minus
function getLayerY($objname) {
	//$y = event.clientY;
	$objH = MM_findObj($objname).height;
	$y = (event.clientY - $objH);
	return $y;
}


// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/

function code_henry(){
  coded = "OII@1N6EI2151IdmI7VOOI29.n86"
  key = "d2Asl6H9nGYhFSEfIouMkP7aW3ijXUR0O4tr1TCmLycvQ8NBbZeVKx5pgzJDwq"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write('<a href="mailto:'+link+'">e-mail</a>')
}

function code_nonine() {
  coded = "OII@1N6EI2151IdmI7VOOI29.n86"
  key = "d2Asl6H9nGYhFSEfIouMkP7aW3ijXUR0O4tr1TCmLycvQ8NBbZeVKx5pgzJDwq"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write('<a href="mailto:'+link+'">e-mail</a>')
}

function code_letusknow(){
  coded = "OII@1N6EI2151IdmI7VOOI29.n86"
  key = "d2Asl6H9nGYhFSEfIouMkP7aW3ijXUR0O4tr1TCmLycvQ8NBbZeVKx5pgzJDwq"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write('<a href="mailto:'+link+'">e-mail</a>')
}

function code_noninemailonly(){
  coded = "OII@1N6EI2151IdmI7VOOI29.n86"
  key = "d2Asl6H9nGYhFSEfIouMkP7aW3ijXUR0O4tr1TCmLycvQ8NBbZeVKx5pgzJDwq"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write('<a href="mailto:'+link+'">e-mail</a>')
}

function code_nousdire(){
  coded = "OII@1N6EI2151IdmI7VOOI29.n86"
  key = "d2Asl6H9nGYhFSEfIouMkP7aW3ijXUR0O4tr1TCmLycvQ8NBbZeVKx5pgzJDwq"
  shift=coded.length
  link=""
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i)
      link += (ltr)
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
      link += (key.charAt(ltr))
    }
  }
  document.write('<a href="mailto:'+link+'">e-mail</a>')
}

//STANDARD FUNCTIONS

//checks if value is a date
function isDate( str ){
	if(str==""){
		return false;
	}
	var m_strDate = FormatDate(str);
	if(m_strDate==""){
		return false;
	}
	else {
		var m_arrDate = m_strDate.split("/");
		var m_DAY = m_arrDate[0];
		var m_MONTH = m_arrDate[1];
		var m_YEAR = m_arrDate[2];
		if(m_YEAR.length > 4){
			return false;
		}
		else {
			m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
			var testDate=new Date(m_strDate);
			if(testDate.getMonth()+1==m_MONTH){
				return true;
			}
			else{
				return false;
			}
		}
	}
}

//checks if field is empty
function isEmpty( str ){
    strRE = new RegExp( );
    strRE.compile( '^[\s ]*$', 'gi' );
    return strRE.test( str.value );
}

//checks if email is valid
function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}


//checks content is only letters
function isLetters( str ) {
	var myregexp = new RegExp("[^a-zA-Z]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only numbers
function isNumbers( str ) {
	if (str.match(/[^0-9]/)) {
		return true;
	}
	return false;
}

//checks content is only numbers
function isPhoneNumber( str ) {
	if (str.match(/[^0-9+() ]/)) {
		return true;
	}
	return false;
}


//checks content is only numbers and lowercase letters
function isNumbersAndLcLetters( str ) {
	var myregexp = new RegExp("[^a-z0-9]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks is a price of numbers and dot
function isPriceWithDot( str ) {
    if (str.match(/[^0-9]+[.]+[^0-9]/)) {
		return true;
	}
	return false;
}

//checks if box is ticked
function notChecked( box ){
    if( box.checked ){
        return false;
    }
    else{
        return true;
    }
}

//SPECIFIC FUNCTIONS

function checkArtistPicker( form ){
    if( isEmpty( form.artist ) ){
        alert( 'please choose an artist...' );
        form.artist.focus();
        return false;
    }
}

function checkItemPicker( form ){
    if( isEmpty( form.item ) ){
        alert( 'please choose an item...' );
        form.item.focus();
        return false;
    }
}

function checkMediaPicker( form ){
    if( isEmpty( form.media ) ){
        alert( 'please choose a medium...' );
        form.media.focus();
        return false;
    }
}

function checkPricePicker( form ){
    if( isEmpty( form.price ) ){
        alert( 'please choose a price range...' );
        form.price.focus();
        return false;
    }
}

// fields
// artistcode  artist1  artist2  artistfull  artistvisible  artistwebsite  artistgender  artistinfo_en  artistinfo_fr  artistsuffix
// rules :
// artistcode, artistfull must contain strings
// either artist1 or artist2 must contain a string
function checkUpdateArtist( form ){
    if ( isEmpty( form.artistcode ) ) {
        alert( 'please enter a unique artistcode \n\n (ideally as the artists full name\n  in lowercase, with no spaces or special characters)' );
        form.artistcode.focus();
        return false;
    }
    if ( isEmpty( form.artistfull ) ){
        alert( 'please enter the artist\'s full name as (name1) - space - (name2)' );
        form.artistfull.focus();
        return false;
    }
    if (( isEmpty( form.artist1 )) && ( isEmpty( form.artist1 ))) {
        alert( 'please enter either a first name or second name (name1 AND name2 cannot be blank)' );
        if ( isEmpty( form.artist1 ) ){form.artist1.focus();}
        if ( isEmpty( form.artist2 ) ){form.artist2.focus();}
        return false;
    }
    if( isEmpty( form.artistgender ) ){
        alert( 'please specify whether the artist is male or female...' );
        form.artistgender.focus();
        return false;
    }
}

//check file is selected
//check extension is jpg
function checkUploadJPG( form ){
    if( isEmpty( form.userjpgfile ) ){
        alert( 'please choose the file to upload (' + form.userjpgfile.value + ')');
        form.userjpgfile.focus();
        return false;
    }
    var str = form.userjpgfile.value;
	var pos = str.lastIndexOf(".jpg");
	if (pos == -1) {
		alert( 'sorry, but the file extension should be .jpg');
		return false;
	}
}

function checkAddArtist( form ){
    if (( isEmpty( form.artist1 )) && ( isEmpty( form.artist2 ))) {
        alert( 'please enter either a first name or surname (they can\'t both  be blank)' );
        return false;
    }
    if( isEmpty( form.artistgender ) ){
        alert( 'please specify whether the artist is male or female...' );
        form.artistgender.focus();
        return false;
    }
}

function checkUpdateAutolink( form ){
    if( isEmpty( form.lookfor ) ){
        alert( 'please enter a phrase to look for (without hashes)' );
        form.lookfor.focus();
        return false;
    }
    if( isEmpty( form.replacewith ) ){
        alert( 'please enter a phrase to replace with (as html)' );
        form.replacewith.focus();
        return false;
    }
}

function updateItemStatus( form ){
    if( isEmpty( form.value ) ){
        alert( 'please choose an image' );
        form.value.focus();
        return false;
    }
    if( isEmpty( form.newvalue ) ){
        alert( 'please choose the new status' );
        form.newvalue.focus();
        return false;
    }
}

function updateItemPrice( form ){
    if( isEmpty( form.value ) ){
        alert( 'please choose an image' );
        form.value.focus();
        return false;
    }
    if( isEmpty( form.newvalue ) ){
        alert( 'please enter the price in pounds and pence (0.00)' );
        form.newvalue.focus();
        return false;
    }
    if (form.newvalue.value == 0 ) {
        alert('cannot enter a zero price');
        return false;
    }
    if (form.newvalue.value.length < 4) {
        alert('please enter the price in pounds and pence (0.00) - i.e. at least 4 characters' );
        return false;
    }
    if( isPriceWithDot( form.newvalue ) ){
        alert( 'please enter the price in pounds and pence (0.00)' );
        form.newvalue.focus();
        return false;
    }
    alert( 'price is ' + form.newvalue );
}

function updateItemVisibility( form ){
    if( isEmpty( form.value ) ){
        alert( 'please choose an image' );
        form.value.focus();
        return false;
    }
    if( isEmpty( form.newvalue ) ){
        alert( 'please choose VISIBLE to display the item on the website, or HIDDEN to hide it' );
        form.newvalue.focus();
        return false;
    }
}

function checkUpdateItem( form ){
}

function checkUpdateEvent( form ){
}

function checkUpdatePage( form ){
}

function checkUpdateRambling( form ){
}

function no9_statbar() {
	//	window.status = "Number nine the gallery";
}

function checkLogIn( form ){
    if( isEmpty( form.user_em ) ){
        alert('please enter your email address..' );
        form.user_em.focus();
        return false;
    }
    if( notValidEmail( form.user_em ) ){
        alert('please enter your email address..' );
        form.user_em.focus();
        return false;
    }
    if( isEmpty( form.key ) ){
        alert('please enter your password..' );
        form.key.focus();
        return false;
    }
}

function checkSendMessageEN( form ){
    if( notValidEmail( form.sender ) ){
        alert('Please enter your email address, so we can reply to you.' );
        form.sender.focus();
        return false;
    }
    if( isEmpty( form.message ) ){
    	alert('Please enter your message.');
        form.message.focus();
        return false;
    }
}

function checkSendMessageFR( form ){
    if( notValidEmail( form.sender ) ){
        alert('(fr)Please enter your email address, so we can reply to you.' );
        form.sender.focus();
        return false;
    }
    if( isEmpty( form.message ) ){
    	alert('(fr)Please enter your message.');
        form.message.focus();
        return false;
    }
}


function submitClientId( form ){
    if( isEmpty( form.client_id ) ){
        alert('please choose a client..' );
        return false;
    }
    if( form.client_id.value == 0 ){
        alert('please choose a client..' );
        return false;
    }
}

function submitContactId( form ){
    if( isEmpty( form.contact_id ) ){
        alert('please choose a contact..' );
        return false;
    }
    if( form.client_id.value == 0 ){
        alert('please choose a contact..' );
        return false;
    }
}

function submitNewContact( form ){
	// if not empty and contact_email is valid
	if( isEmpty( form.contact_email ) ){}
	else {
		if( notValidEmail( form.contact_email ) ){
			alert('Please enter a valid email address..' );
			form.contact_email.focus();
			return false;
		}
	}

	if( isEmpty( form.contact_name ) ){
		alert('Please enter the first name.' );
		form.contact_name.focus();
		return false;
	}

	if( isEmpty( form.contact_surname ) ){
		alert('Please enter the surname.' );
		form.contact_surname.focus();
		return false;
	}

	if( isEmpty( form.contact_full_name ) ){
		alert('Please enter the full_name.' );
		form.contact_full_name.focus();
		return false;
	}

	var phonemsg = '\nfor example:\n +33 (0)1 23456789 for a French number\n +44 (0)123 456789 for a UK number\n\n..allowed characters are : +0123456789() and spaces\n\nnote: if you do not have any phone numbers for this entry\nyou can enter ten zeros 0000000000 in the home number field.\nThe field will then appear highlighted in red to remind you to update it later';

	// one of these 3 must be completed
	if( form.contact_hometel.value.length < 10 ){
		if( form.contact_worktel.value.length < 10 ){
			if( form.contact_mobtel.value.length < 10 ){
				alert('Please enter at least one phone number' + phonemsg );
				form.contact_hometel.focus();
				return false;
			}
			else {
			    if( isPhoneNumber( form.contact_mobtel.value ) ){
				alert('Please enter the mobile number' + phonemsg );
				form.contact_mobtel.focus();
				return false;
			    }
			}
		}
		else {
		    if( isPhoneNumber( form.contact_worktel.value ) ){
			alert('Please enter the work number' + phonemsg );
			form.contact_worktel.focus();
			return false;
		    }
		}
	}
	else {
	    if( isPhoneNumber( form.contact_hometel.value ) ){
		alert('Please enter the home number' + phonemsg );
		form.contact_hometel.focus();
		return false;
	    }
	}

	// contact_address1 length > 0
	if( isEmpty( form.contact_address1 ) ){
		alert('Please complete the first line of the address (at least the first two lines must be completed).' );
		form.contact_address1.focus();
		return false;
	}

	if( isEmpty( form.contact_address2 ) ){
		alert('Please complete the second line of the address (at least the first two lines must be completed).' );
		form.contact_address2.focus();
		return false;
	}

	// contact_postcode length > 0
	if( isEmpty( form.contact_postcode ) ){
		alert('Please enter the postcode.' );
		form.contact_postcode.focus();
		return false;
	}

	// contact_country length = 2
	if( isEmpty( form.contact_country ) ){
		alert('Please select the country of residence.' );
		form.contact_country.focus();
		return false;
	}
	return true;
}
//-->