var num_slider_images = 0;
var current_fade_photo = 0;
function init() {
	var h1Array = document.getElementsByTagName('h1');
	for (var i = 0; i < h1Array.length; i++) { 	
		var bg_image = 'url("/images/title_text/' + document.getElementById(h1Array[i].id).innerHTML + '.png")';
		document.getElementById(h1Array[i].id).style.backgroundImage = bg_image;
	}	
	var i = 1;
	while(document.getElementById('picture' + i)) {		
		//document.getElementById('picture' + i).style.display = 'none';
		var new_pos = parseInt(num_slider_images*180) + parseInt(num_slider_images*45);
		document.getElementById('picture' + i).style.left = new_pos + 'px';		
		if(i <= 3) {
			setTimeout("new Effect.Appear('picture" + i + "')", (i*250));			
		}
		num_slider_images++;
		i++;
	}
	if(document.getElementById('pictures_loading')) {
		new Effect.Fade('pictures_loading');
	}
	if(document.getElementById('pictures_next')) {
		if(num_slider_images > 3) {
			new Effect.Fade('pictures_next');
		}
	}
	clearEmailBox();
}
function toggleSubcats(el) {
	if(document.getElementById(el).style.display == 'none') {
		new Effect.BlindDown(el);
		new Effect.Appear(el);
	} else {
		new Effect.BlindUp(el);
		new Effect.Fade(el);
	}
}
function slidePictures(increment) {	
	if(increment == 1) {
		var gap = 225;
	} else {
		var gap = -225;
	}
	var current_left = document.getElementById('pictures_rail').style.left;
	current_left = current_left.replace(/px/, '');	
	if(current_left == '') {
		current_left = 0;
	} else {	
		current_left = parseInt(parseInt(current_left) + parseInt(45*increment));
	}	
	var new_left = parseInt(parseInt(current_left) + parseInt(gap));	
	var num_steps = 10;
	var current_step = 1;
	var step = 20*increment;	
	var current_left_image = document.getElementById('left_picture').value;
	var current_right_image = document.getElementById('right_picture').value;	
	var proceed = 1;	
	if(increment == 1) {
		if(current_left_image == 1) {
			proceed = 0;
			new Effect.Fade('pictures_next');
		} else {			
			if (navigator.userAgent.indexOf("MSIE")!=-1) {
				document.getElementById('picture' + current_right_image).style.display = 'none';
			} else {
				new Effect.Fade('picture' + current_right_image, 50);
			}
			document.getElementById('right_picture').value = parseInt(parseInt(current_right_image) - parseInt(1));
			document.getElementById('left_picture').value = parseInt(parseInt(current_left_image) - parseInt(1));
			setTimeout("new Effect.Appear('picture" + document.getElementById('left_picture').value + "', 250);", 50);
			if(document.getElementById('left_picture').value == 1) {
				new Effect.Fade('pictures_next');
			}
		}
	} else if(increment == -1) {
		if(current_right_image == num_slider_images) {
			proceed = 0;
		} else {
			if (navigator.userAgent.indexOf("MSIE")!=-1) {
				document.getElementById('picture' + current_left_image).style.display = 'none';
			} else {
				new Effect.Fade('picture' + current_left_image, 50);
			}
			document.getElementById('right_picture').value = parseInt(parseInt(current_right_image) + parseInt(1));
			document.getElementById('left_picture').value = parseInt(parseInt(current_left_image) + parseInt(1));
			setTimeout("new Effect.Appear('picture" + document.getElementById('right_picture').value + "', 250);", 50);
			if(document.getElementById('right_picture').value == num_slider_images) {
				new Effect.Fade('pictures_prev');
			}
		}
	}  
	if( proceed == 1 ) {
		if(document.getElementById('pictures_prev').style.display == 'none') {
			new Effect.Appear('pictures_prev', 50);
		}
		if(document.getElementById('pictures_next').style.display == 'none') {
			new Effect.Appear('pictures_next', 50);
		}		
		while(current_step < num_steps) {
			current_left = parseInt(parseInt(current_left) + parseInt(step));
			if(increment == 1 && current_left > new_left) {
				current_left = new_left;
				current_step = num_steps;
			} else if(increment == -1 && current_left < new_left) {
				current_left = new_left;
				current_step = num_steps;
			}
			setTimeout("document.getElementById('pictures_rail').style.left = '" + current_left + "px';", (current_step*50));					
			current_step++;
		}		
	}
}
function clearEmailBox() {
	if(document.getElementById('login_form_name')) {
		var default_value = 'Username';
		if(document.getElementById('login_form_name').value == '') {
			document.getElementById('login_form_name').value = default_value;
		} else if(document.getElementById('login_form_name').value == default_value) {
			document.getElementById('login_form_name').value = '';
		}
	}
}
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=400,screenX=150,screenY=150,top=150,left=150')
}
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
function previewFilm(url, alt_text, img) {
	document.getElementById('thumb_link').href = url;
	document.getElementById('thumb_img').alt = alt_text;
	document.getElementById('thumb_img').src = '/images/new/' + img;
}
function startPhotoFade() {
	new Effect.Fade('slideshow' + current_fade_photo);
	current_fade_photo = current_fade_photo + 1;
	if(!document.getElementById('slideshow' + current_fade_photo)) {
		current_fade_photo = 0;
	}
	setTimeout("new Effect.Appear('slideshow" + current_fade_photo + "');", 2000);
	setTimeout("startPhotoFade()", 7000);
}