var isIE, isDOM;

// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant (well, sort of...)
isDOM = (document.getElementById ? true : false);
	
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
  		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.MM_pgW=innerWidth; 
    		document.MM_pgH=innerHeight; 
    		onresize=MM_reloadPage; 
    	}
  }
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();  
}

MM_reloadPage(true);

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_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_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 getAbsX() { 

	if (isIE) 
	{
		element = document.all.favicon;
	} else {
		element = document.getElementById("favicon");
	}
	return (element.x) ? element.x : getAbsPos(element,"Left"); 
}

function getAbsPos(element,which) {
	iPos = 0;
	while (element != null) {
 		iPos += element["offset" + which];
 		element = element.offsetParent;
	}
	return iPos;
}

function setLayerX()
{

	if (isIE) 
	{
		myelement = document.all.thisDiv1_Div;
	} else {
		myelement = document.getElementById("thisDiv1_Div");
	}	

	myelement.style.left = getAbsX();	
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  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; }
}

function shutterfr (divname, wwwroot) {
	if (top.document.getElementById(divname + '_Div').style.display == '') {
		top.document.getElementById(divname + '_Div').style.display = 'none';
		var path = wwwroot + 'global/img/fav_shutter_closed.png';
		top.document.images['Shutter'].src = path;
	} else {
		top.document.getElementById(divname + '_Div').style.display = '';
		var path = wwwroot + 'global/img/fav_shutter_opened.png';
		top.document.images['Shutter'].src = path;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function shutterDiv (divname) {
	if (top.document.getElementById(divname + '_DivS').style.display == 'none') {
		
		top.document.getElementById(divname + '_DivS').style.display = '';
		//top.document.images[divname + '_Img'].src = 'img/yes.gif';
	} else {
		top.document.getElementById(divname + '_DivS').style.display = 'none';
		//top.document.images[divname + '_Img'].src = 'img/no.gif';
	}
}

//SCROLLER

imgPlaces=5 // number of images visible
imgWidth=190 // width of the images
imgHeight=200 // height of the images
imgSpacer=0 // space between the images
rdmImg=0 // 0 = no  1 = yes  show images at random
dir=0 //  scroll direction 0 = left, 1 = right


border=0 // container border width
bordertype="none" // container border type
bordercolor="" // container border colour
borderbackground="" // container background colour

cssPositioning=0 // use CSS to position the display 0 = no  1 = yes
cssLeft=400 // used if cssPositioning is selected
cssTop=100 // used if cssPositioning is selected

newWindow=0 // 0 = Open a new window for links 0 = no  1 = yes

// ********** End User Defining Area **********

if(rdmImg==1){ // generate random images list

tempArray=new Array()
for(i=0;i<data.length;i++){ // create an array identical to data array
tempArray[i]=data[i]
}

rdmArray=new Array() // random images array
for(p=0;p<data.length;p++){ // create an array of randomly selected images
rndnum=Math.floor(Math.random()*(tempArray.length)) // select a random image from tempArray
rdmArray[p]=tempArray[rndnum] // put selected image in rdmArray
tempArray.splice(rndnum,1) // remove selected image from tempArray
}

}

step=1
nextPic=0
speed=18
timer=""
initPos=new Array()
nowDivPos=new Array()
moz=document.getElementById&&!document.all

function createThumbShow(){

if(cssPositioning==0){
document.write("<div id=\"container\" style=\"position:relative; width:0px;height:0px; border:"+border+"px "+bordertype+" "+bordercolor+";background:"+borderbackground+"\">")
}
else{
document.write("<div id=\"container\" style=\"position:absolute; left:"+cssLeft+"px; top:"+cssTop+"px; width:0px;height:0px; border:"+border+" "+bordertype+" "+bordercolor+";background:"+borderbackground+"\">")
}

document.write("<div id=\"display_area\" style=\"position:absolute; left:0; top:0; width:0px; height:0px; clip:rect(0,0,0,0)\" onmouseover=\"stopMe()\" onmouseout=\"animate()\">")

for(i=0;i<imgPlaces+1;i++){ // create image holders
document.write("<div id=\"div_"+[i]+"\" style=\"position:absolute\">")
document.write("<a id=\"loc_"+[i]+"\" href=\"\" onclick=\"newWin(this.location);return false\">")
document.write("<img src=\"\" id=\"pic_"+[i]+"\" width=\""+imgWidth+"\" height=\""+imgHeight+"\" alt=\"Multiple Image SlideShow\" border=\"0\">")
document.write("</a>")
document.write("</div>")
}
document.write("</div>")
document.write("</div>")
} 
function initThumbShow(){
containerBorder=parseInt(document.getElementById("container").style.borderWidth)*2
containerWidth=(imgPlaces*imgWidth)+((imgPlaces-1)*imgSpacer)
document.getElementById("container").style.width=containerWidth+(!moz?containerBorder:"")
document.getElementById("container").style.height=imgHeight+(!moz?containerBorder:"")

displayArea=document.getElementById("display_area")
displayArea.style.width=containerWidth
displayArea.style.clip=(!moz?"rect(0,"+containerWidth+","+imgHeight+",0)":"rect(0,"+containerWidth+","+imgHeight+",0)")

imgPos= -document.getElementById("pic_0").width-border

for(i=0;i<imgPlaces+1;i++){

if(dir==0){imgPos+=(document.getElementById("pic_0").width)+imgSpacer} // if left

initPos[i]=imgPos
if(dir==0){document.getElementById("div_"+[i]).style.left=initPos[i]} // if left

if(dir==1){ // if right
document.getElementById("div_"+[(imgPlaces-i)]).style.left=initPos[i]
imgPos+=(document.getElementById("pic_0").width)+imgSpacer
}

if(nextPic==data.length){
nextPic=0
}

if(rdmImg==1){
document.getElementById("pic_"+[i]).src=rdmArray[nextPic][0]
document.getElementById("pic_"+[i]).alt=rdmArray[nextPic][1]
document.getElementById("loc_"+[i]).location=rdmArray[nextPic][2]
}
else{
document.getElementById("pic_"+[i]).src=data[nextPic][0]
document.getElementById("pic_"+[i]).alt=data[nextPic][1]
document.getElementById("loc_"+[i]).location=data[nextPic][2]
}
nextPic++
}

animate()
}

timer=""
function animate(){
clearTimeout(timer)
for(i=0;i<imgPlaces+1;i++){
nowDivPos[i]=parseInt(document.getElementById("div_"+i).style.left)

if(dir==0){nowDivPos[i]-=step}
if(dir==1){nowDivPos[i]+=step}

if(dir==0&&nowDivPos[i]<= -(document.getElementById("pic_0").width+imgSpacer) || dir==1&&nowDivPos[i]>containerWidth){ 
if(dir==0){document.getElementById("div_"+[i]).style.left=containerWidth+imgSpacer}
if(dir==1){document.getElementById("div_"+[i]).style.left= -document.getElementById("pic_0").width-(imgSpacer*2)}

if(nextPic>data.length-1){
nextPic=0
}

if(rdmImg==1){
document.getElementById("pic_"+[i]).src=rdmArray[nextPic][0]
document.getElementById("pic_"+[i]).alt=rdmArray[nextPic][1]
document.getElementById("loc_"+[i]).location=rdmArray[nextPic][2]
}
else{
document.getElementById("pic_"+[i]).src=data[nextPic][0]
document.getElementById("pic_"+[i]).alt=data[nextPic][1]
document.getElementById("loc_"+[i]).location=data[nextPic][2]
}

nextPic++

}
else{
document.getElementById("div_"+[i]).style.left=nowDivPos[i]
}

}
timer=setTimeout("animate()",speed)

}

function stopMe(){
clearTimeout(timer)
}

function newWin(loc){
if(loc==""){return}
if(newWindow==0){
location=loc
}
else{
//window.open(loc)
window.open(loc,'','left=130,top=270,width=200,height=200') // use for specific size and positioned window
}
}
