// Javascript functions for Black Dog Studios, A. Treshansky, 2006

var usesDOM;
var textSize;

 function domTest() {
	usesDOM = document.getElementById ? 1 : 0;
}

function updateText() {
//alert('in update text');
	var fontUnit = 'em';
	document.body.style.fontSize=textSize + fontUnit;
//(uses the DOM to change the fontsize property for the whole document)
// for this site we only want to change it in an image enlargement div 
// but that div hasn't appeared yet.  css keeps other text the same.

}

// set text area to maximum length

function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Maximum length is '+ maxlen);
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}

function textResize( change ) {

	var incrementAmt = (0.1-0);
	if ( change=='Zoom In' ) {
    		textSize = textSize + incrementAmt;
	if (textSize > 2.5) textSize = 2.5;
// (maximum)
  	}
  	else {
    		textSize = textSize - incrementAmt;
		if (textSize < 0.5) textSize = 0.5;
		if ( change=='Reset' ) textSize=1;
//minimum size
  	}

//call the updateText function to change the size of text on the screen.
	updateText();
 }


function displayTextResizer() {

// Display options and send request for text resizing
 //   	document.write( "ZOOM IN OR OUT: <br>");
     	document.write( " <input type='button' value='Zoom In' ");
	document.write( " onclick='textResize( value ); return false;'> ");
	document.write( " <input type='button' value='Zoom Out' ");
	document.write( " onclick='textResize( value ); return false;'> ");
	document.write( " <input type='button' value='Reset' ");
	document.write( " onclick='textResize( value ); return false;'> ");
}



function initialise() {
textSize=1;
// DOM testing
	
	domTest();

  	if ( usesDOM ) {


// display text at previously chosen size, or default if none has been chosen

updateText();
	}
}

// Javascript functions for disabling right click on images, from DynamicDrive.com

var clickmessage="Images on this website are copyright.  Please contact us if you wish to use them."

function disableclick(e) {
  if (document.all) {
    if (event.button==2||event.button==3) {
      if (event.srcElement.tagName=="IMG"){
        alert(clickmessage);
        return false;
      }
    }
  }
  else if (document.layers) {
    if (e.which == 3) {
      alert(clickmessage);
      return false;
    }
  }
  else if (document.getElementById){
    if (e.which==3&&e.target.tagName=="IMG"){
      alert(clickmessage)
      return false
    }
  }
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}


function popupWin(popupURL) {

  var myPopup = null;

  myPopup=window.open(popupURL, "newWin", "width=250, height=580, left=0, top=0, toolbar=no,scrollbars=yes,resizable=yes,fullscreen=no");
     // close document for writing -
      // otherwise the hourglass stays when you load it

 //   myPopup.document.close();

    // bring window to front
    myPopup.focus();

}

function popupScreen(popupURL) {

  var myPopup = null;

 if (popupURL.Length != 0) { 

    if ((navigator.platform.indexOf('Mac') != -1) || (navigator.userAgent.indexOf('MSIE') == -1)) { //mac 
      var w = screen.width;
      var h = screen.height;
			
      myPopup=window.open(popupURL, '_blank', 'toolbar=no,scrollbars=yes,resizable=yes,width=' + w + ',height=' + h + ',top=0,left=0, menubar=no');

    }

    else { // COMMENT BY AT: IE GOES HERE
      myPopup=window.open(popupURL, '_blank', 'toolbar=no, scrollbars=yes, resizable=yes, fullscreen=yes');
    }
  }
     // close document for writing -
      // otherwise the hourglass stays when you load it

    myPopup.document.close();

    // bring window to front
    myPopup.focus();
}


