// JavaScript Document
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++) x.src=x.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];}
}




/* general variables */

var fadeTargetId = 'slogan'; /* change this to the ID of the fadeable object */
var	fadeTarget;
var preInitTimer;
var currentImage =  1;

function flipSlogan()
{
	if(currentImage == 1)
	{
		currentImage = 2;
	}
	else
	{
		currentImage = 1;
	}
	
document["slogan_img"].src='images/content/slogan_'+currentImage+'.gif';
}
	if(document.getElementById(fadeTargetId))
	{
		preInit();
		/* initialise fader by hiding image object first */
		addEvent (window,'load',fadeInit)

	}

/* functions */

function preInit() {
	/* an inspired kludge that - in most cases - manages to initially hide the image
	   before even onload is triggered (at which point it's normally too late, and a nasty flash
	   occurs with non-cached images) */
	   

		if ((document.getElementById)&&(fadeTarget=document.getElementById(fadeTargetId))) {
			fadeTarget.style.visibility = "hidden";
			if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer); /* thanks to Steve Clay http://mrclay.org/ for this small Opera fix */
		} else {
			preInitTimer = setTimeout("preInit()",2);
		}

}

function fadeInit() {
	if (document.getElementById) {
		/* get a handle on the fadeable object, to make code later more manageable */
		preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
		/* set the initial opacity in a (hopefully) cross browser way
		   notice that because of the way the image is in front, and not obfuscated
		   by another object we need to "fade out", i don't need a fallback mechanism
		   to show/hide the covering object...the image is just there, full stop */
		if (fadeTarget.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			fadeTarget.style.MozOpacity = 0;
		} else if (fadeTarget.style.opacity!=null) {
			/* CSS3 compatible */
			fadeTarget.style.opacity = 0;
		} else if (fadeTarget.style.filter!=null) {
			/* IE's proprietary filter */
			fadeTarget.style.filter = "alpha(opacity=0)";
		}
		/* make the object visible again */
		fadeTarget.style.visibility = 'visible';
		window.setTimeout("fadeIn(0)", 1000);
	}
}

function fadeIn(opacity) {
	if (fadeTarget) {
		if (opacity <= 100) {
			if (fadeTarget.style.MozOpacity!=null) {
				/* Mozilla's pre-CSS3 proprietary rule */
				fadeTarget.style.MozOpacity = (opacity/100)-.001;
				/* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */
			} else if (fadeTarget.style.opacity!=null) {
				/* CSS3 compatible */
				fadeTarget.style.opacity = (opacity/100)-.001;
			} else if (fadeTarget.style.filter!=null) {
				/* IE's proprietary filter */
				fadeTarget.style.filter = "alpha(opacity="+opacity+")";
				/* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */ 
			}
			opacity += 10;
			window.setTimeout("fadeIn("+opacity+")", 30);
		}
		else
		{
			window.setTimeout("fadeOut("+opacity+")", 2000);	
					
		}
	}
}


function fadeOut(opacity) {
	if (fadeTarget) {
		if (opacity >= 0) {
			if (fadeTarget.style.MozOpacity!=null) {
				/* Mozilla's pre-CSS3 proprietary rule */
				fadeTarget.style.MozOpacity = (opacity/100)+.001;
				/* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */
			} else if (fadeTarget.style.opacity!=null) {
				/* CSS3 compatible */
				fadeTarget.style.opacity = (opacity/100)+.001;
			} else if (fadeTarget.style.filter!=null) {
				/* IE's proprietary filter */
				fadeTarget.style.filter = "alpha(opacity="+opacity+")";
				/* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */ 
			}
			opacity -= 10;
			window.setTimeout("fadeOut("+opacity+")", 30);
		}
		else
		{
			flipSlogan();
			window.setTimeout("fadeIn("+opacity+")", 200);		
						
		}		
	}
}

/* 3rd party helper functions */

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture) 
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
} 

var maxPics = 36;
var picsPerPage = 12;
var maxPage = 2;
var initPic = 1;
var currentPage = 0;
var currentPic = initPic;
var picPath = 'images/content/photos/';
var picName = 'belcor';
var thumbName = '_thumb';
var picExt = '.jpg';

function initPics()
{
	
}

function nextPicPage()
{
	currentPage +=1;
	if(currentPage > maxPage)
	{
		currentPage = 0;	
	}
		
	loadThumbs();
}

function loadThumbs()
{
	var i=0;
	
	for(i=1; i<picsPerPage+1; i++)
	{
		var selectPicId = (i + (currentPage * picsPerPage));
		var picSRC = picPath+picName+selectPicId+thumbName+picExt;	
		var thumbnailName = "pic"+i;

		document.getElementById(thumbnailName).src=picSRC;		
	}	
	displayPic(1);
}

function prevPicPage()
{
	if(currentPage == 0)
	{
		currentPage = maxPage;	
	}	

	currentPage -=1;
	loadThumbs();
}

function displayPic(name)
{
	name = name *1; 
	var selectPicId = (name + (currentPage * picsPerPage));
	var picSRC = picPath+picName+selectPicId+picExt;
	document["main_pic"].src=picSRC;
}

