/*************************************************************************
Functions
1  fnMail(sDomain, bProtocol, sName)
2  whichBrowser()
3  checkthis(site)
4  add2Fav()
5  loadVideo(clip, width, align, loop)
6  playVideo(newVideo)
7  stopVideo(newVideo)
8  VideoInsert(ID, Player7video, Player6video, UIMODE, WIDTH, HEIGHT, BASEURL)
9  Modified for opening video on popup window
   VideoInsert(ID, Player7video, Player6video, Player6mode, UIMODE, WIDTH, HEIGHT, BASEURL){
10 scaleMe()
11 popMe( path,w,h,i,title)
12 jumpto(Item,FormName)
13 onTop()
14 Minimize()
15 Maximize() 
16 doRain()
17 handleResponse(im1,im2)
18 buildQueryString(Form)
19 callToServer(qstr)
20 loadIframe(iframeName, url)
21 popUP(mypage, myname, w, h, scroll, titlebar)
22 AddRows(table)
23 checkEnter(myFORM,e)
24 opacity(id, opacStart, opacEnd, millisec) 
25 changeOpac(opacity, id)
26 blendimage(divid, imageid, imagefile, millisec)
27 currentOpac(id, opacEnd, millisec)
**************************************************************************/
var AVAILABLE_SCREEN_WIDTH =  screen.availWidth;
var AVAILABLE_SCREEN_HEIGHT =  screen.availHeight;
var fromIndexHTM = 0;
var curpath="";
var i=1;
var oCount = 0;
var x=0;
var y=0;
var pic;
var butt;
var Pic = null;
var PicArray = new Array();
var TicArray = new Array();
var picArray = new Array();
var Image1 = null;
var table2 = null;
var col1 = null;
var trans;         //used by popMe function
var uL=-1;          //used with addMoreFile function on Menu page
var fn = "";
var fv = "init";         
var ofileName = "";
var UpoF = "";
var UpF = "";
var firstTime = 1;   //used by menu.php
var ratio = 0;
var pFn = "";
var UpFn = "";
var ImLoad=0;     //used in dcvg.org galleryTimed.php
var LogoOn=1;
var i=1;
var curpath="";
var oldMozilla=0;
var frameObject = new Object();
var dec;
var foxi=0;
var maxi=0;

//To Get out from frames
function outOfFrames(){
   if (top.location!= self.location) top.location = this.location;
}



//var Player_1=new Object();
function fnMail(sDomain, bProtocol, sName)
  {
    var r = (bProtocol) ? "lto" : '';
    var s = sName + "@" + sDomain;
    if (bProtocol) r = "mai"+r+':';
    return r+s;
  }
	
//Browser detection  usage:  if(browser=="IE" && version > 5)  dosomething;
//Operating system detection  useage:  if(OS=="Mac" && version > 9)  dosomething;	
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari'))  browser = "Safari";
else if (checkIt('omniweb')) browser = "OmniWeb";
else if (checkIt('opera'))   browser = "Opera";
else if (checkIt('webtv'))   browser = "WebTV";
else if (checkIt('icab'))    browser = "iCab";
else if (checkIt('msie'))    browser = "IE";
else if (checkIt('firefox')) browser = "Firefox";
else if (!checkIt('compatible'))
{
	if(navigator.appName == "Netscape") browser = "NS";
	else browser = "unknown";
	version = detect.charAt(8);
}
else browser = "unknown";
if (!version) version = detect.charAt(place + thestring.length);
if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac";
	else if (checkIt('win')) OS = "Windows";
	else OS = "unknown";
}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//End of Browser detection/////////////////////////////////////////////////////
	
	
//Does not allow right mouse click////////////////////////////////////////////	
var message = "Right click is disabled.\n\n"; 
function click(e) {
  if (browser=="IE") {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
//It does not work in these browsers well
//  if (browser=="NS" || browser=="Opera") {
//    if (e.which == 3) {
//      alert(message);
//      return false;
//    }
//  }
}//End of function
//if (browser=="NS") {
//  document.captureEvents(Event.MOUSEDOWN);
//}
//document.onmousedown=click;  //enable this line to have it to work
//////////////////////////////////////////////////////////////////////////////
		
	
	
	function whichBrowser()
	{		
		
		var ms = navigator.appVersion.indexOf("MSIE")
		var macness = navigator.appVersion.indexOf("Macintosh")
		ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)
		
		if(ie4) { 
                            ns6 = false; 
                            return 1; 
                        }
                if(!ie4)
		   {
			if((navigator.appName == "Netscape") &&
				(parseInt(navigator.appVersion.substring(0, 1)) >= 5))
			{
				ns6=true;
                                return 0;  
				
			}
			else if((navigator.appName == "Netscape") &&
				(parseInt(navigator.appVersion.substring(0, 1)) == 4))
			{
				other=true;
                                return 0; 
			}
			
		   }
                                 
	}
//****************************************************************************************************************************************************************
function checkthis(site)
{
    if (oInputBox.checked == true && site=="www")
    {
      window.target="WORKING";   
    }
    else window.target="_blank";
}
//****************************************************************************************************************************************************************
//Does NOT work in IE7
function add2Fav(){
  //if ((navigator.appVersion.indexOf("MSIE") > 0)
  //&& (parseInt(navigator.appVersion) >= 4)) 
	if(browser=="IE" && version > 5) 
	{
	  var sText = "<U><SPAN STYLE='cursor:pointer;' ";
    sText += " onclick='window.external.AddFavorite(location.href, document.title);'>Add this page to your favorites</SPAN></U>";
 		document.write(sText);
  }
}
//****************************************************************************************************************************************************************
function loadIframe( rsiframe, im1, im2, im3, im4) {
  //alert("1In loadIframe im1= " + im1);
	url = im1;
		if(im1=="galleryTableAVI.php") document.getElementById('RSIFrame').style.height='65%';
	  else document.getElementById('RSIFrame').style.height='95%';
	
	if(im1=="Google") url =  "http://www.google.com.au/search?hl=en&" + im2 + "&" + im3 + "&" + im4 + "param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	else url += "?" + "param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	//if(im1=="Google") url = "http://www.google.com.au/search?hl=en" + im2 + "&" + im3 + "&" + im4 + "param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	//else url += "?" + "param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	//url += "?" + im2 + "&" + im3 + "&" + im4 + "param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	//url += "? param2="+im2 + "&param3=" + im3 + "&param4=" + im4;
	//alert("2In loadIframe url= " + url);
	
	
	if ( window.parent.frames[rsiframe]) {
			 //alert("within if url = " + url);
			 window.parent.frames[rsiframe].location.replace(url);
			
			 
			 //alert("IE - "+url);
			 return true;
			}   
  else if ( document.frames[rsiframe]) {
       document.frames[rsiframe].location.href = url;
			 //alert("NS - "+url);
			 return true;
			}       
	else return false;
}
//****************************************************************************************************************************************************************
// These functions are used for RPC (Remote Procedure Call) or
// RS(Remote Scripting) communication
// Client.htm appends an iframe using callToServer(qstr) function and
// sends data to Server.php
// Server.php processes data and calls function handleResponse(im1,im2) in Client.htm
function handleResponse(im1, im2, im3, im4) {
 //alert("im1= " + im1 + " im2= " + im2 +" im3= " + im3 + " im4= " + im4);
	loadIframe('RSIFrame', im1, im2, im3, im4);	
	//loadIframe('RSIFrame', "param1="+im1, "param2="+im2, "param3="+im3, "param4="+im4);	
	LogoOn=0;
	//newTXT=document.getElementById('Dp').childNodes[1].nodeValue="";
}
//****************************************************************************************************************************************************************
function buildQueryString(Form) {
  theForm = document.forms[Form];
  var qs = ''
  for (e=0;e<theForm.elements.length;e++) {
    if (theForm.elements[e].name!='') {
      qs+=(qs=='')?'?':'&'
      qs+=theForm.elements[e].name+'='+escape(theForm.elements[e].value)
      }
    }
  return qs
}
//****************************************************************************************************************************************************************
var IFrameObj=null; // our IFrame object
var anim=null;
function callToServer(param1,param2,param3,param4, d2) {
   
	if (!document.createElement) {return true};
	param4 += document.getElementById(d2).clientWidth;
	var IFrameDoc=null;
  //Tif(d2 == "Td2") => calling from index.php or indexNoslides.php
	//if(d2 == "div_1" || d2 == "div_2" ) => calling from slideshow.php
	if(d2 == "Td2") var URL = 'php/server.php?' + param1 + '&' + param2 +'&' + param3 +'&' + param4;
  if(d2 == "div_1" || d2 == "div_2" ) var URL = 'server.php?' + param1 + '&' + param2 +'&' + param3 +'&' + param4;
 //alert("param1  "+param1 + "  param2  "+param2 +"  param3  "+param3 +"  param4  "+param4 );
  
 
 //alert("URL= " + URL);
if (!IFrameObj && document.createElement) {
   try {
			var tempIFrame=document.createElement('iframe');
      tempIFrame.id='RSIFrame';
			tempIFrame.name='RSIFrame';
			//tempIFrame.width=document.getElementById("Td2").width-20;
      //tempIFrame.height=document.getElementById("Td2").height-20;
			tempIFrame.style.width="95%";
			//tempIFrame.style.height="50%";
			tempIFrame.frameBorder='0'; //for IE
			tempIFrame.marginWidth='0';
			tempIFrame.marginHeight='0';
			tempIFrame.hspace='0';
			tempIFrame.vspace='0';
			tempIFrame.scrolling='auto';
			IFrameObj = document.getElementById(d2).appendChild(tempIFrame);
			//IFrameObj.height="200px";
			//IFrameObj.style.visibility="hidden";
			//IFrameObj.style.overflowX = "scroll";
			//IFrameObj.style.overflowY = "scroll";
			
			//window.parent.document.getElementById("BANNERTABLE").style.visibility="hidden"; 
			//window.parent.document.getElementById("FOOTERTABLE").style.visibility="hidden"; 
			 
			 if (document.frames) {
	      // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
				
				}
    } 
		catch(exception) 
		{
          // This is for IE5 PC, which does not allow dynamic creation
          // and manipulation of an iframe object. Instead, we'll fake
          // it up by creating our own objects.
          iframeHTML='\<iframe id="RSIFrame" style="';
          iframeHTML+='border:0;';
          iframeHTML+='width:808;';
          iframeHTML+='height:418px;';
          iframeHTML+='"><\/iframe>';
          document.body.innerHTML+=iframeHTML;
          IFrameObj = new Object();
          IFrameObj.document = new Object();
          IFrameObj.document.location = new Object();
          IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
          IFrameObj.document.location.replace = function(location) {this.iframe.src = location; }
    return false;
  }//catch
}//if (!IFrameObj && document.createElement)
  
	
          window.parent.frames['RSIFrame'].location.replace(URL);
 
	
  return false;
}
//****************************************************************************************************************************************************************
function AddRows(table)
{
var row,col1,col2,txt1,txt2; 
txt1=document.createTextNode("this is new text 1"); 
txt2=document.createTextNode("this is new text 2"); 
row=document.createElement("TR"); 
col1=document.createElement("TD"); 
col2=document.createElement("TD"); 
col1.appendChild(txt1); 
col2.appendChild(txt2); 
row.appendChild(col1); 
row.appendChild(col2); 
table.firstChild.appendChild(row) 
}

//**********************************************                  C   H   E   C   K     E   N   T   E   R               ******************************************

function checkEnter(myFORM,e){ //e is event object passed from function invocation
  var characterCode //literal character code will be stored in this variable
  if(e && e.which){ //if which property of event object is supported (NN4)
    e = e
    characterCode = e.which //character code is contained in NN4's which property
  }
  else{
    e = event
    characterCode = e.keyCode //character code is contained in IE's keyCode property
  }
  if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
    myFORM.submit() //submit the form
    return false 
  }
  else{
    return true 
  }
}

//**********************************************                  C   H   E   C   K     K  e  y  P  r  e  s  s           *****************************************


//now create the event handler function to process the event
function checkEscapeKey(e) {
  if( !e ) {
    if( window.event ) {
      e = window.event;
    } else {
      return;
    }
  }
  if( typeof( e.keyCode ) == 'number'  ) {
    cc = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
    e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
    cc = e.charCode;
  } else {
    return;
  }
		return cc;
}


	
//**********************************************************************     S  L  I  D  E     S  H  O  W      ***************************************************
/*
<img id="img_1" src="images/slideshow/1_Sample_115.jpg" style="visibility:hidden;" />

<script type="text/javascript">
  var slideshowCache = new Array();
	slideshowCache[0] = "http://aitkenandassociates.com.au/images/blank.gif";
	slideshowCache[1] = "images/slideshow/1_Sample_115.jpg";
  slideshowCache[2] = "images/slideshow/2_Sample_116.jpg";

 var textCache = new Array();
  textCache[0] = "CAD 3D Drafting";
  textCache[1] = "CAD 2D Drafting";
  textCache[2] = "";

var ratio = document.getElementById("img_1").width / document.getElementById("img_1").height;
var oLeft = 300;
var oTop = 200;
var imageWidth = 800;
var imageHeight = imageWidth / ratio;	
		
		document.getElementById("img_1").style.display = "none";
	
   slideshow(slideshowCache,oLeft,oTop,imageWidth,imageHeight,textCache);
   //randomIMAGES(slideshowCache,imageWidth,imageHeight,textCache);

</script>


*/
 
var txtContainer = null;
var oldTXT = "";
function slideshow(imageArray,x,y,imageWidth,imageHeight,textArray,doAfterSlideshow1,doAfterSlideshow2){
				 
				 var image = null;
				 var pauseSlideShow = new Array();
				 var pauseSlideRemove = new Array();
				 maxi = imageArray.length;

    for (i=0; i < maxi; i++){	
		     var image = null;
				 var cc = imageArray[i].substring(imageArray[i].lastIndexOf(".")+1);	
		  if( cc == "gif" || cc == "jpg" || cc == "png" || cc == "bmp" || cc == "tif" || 
					cc == "GIF" || cc == "JPG" || cc == "PNG" || cc == "BMP" || cc == "TIF" ||	
					cc == "ico" || cc == "ICO" || cc == "wmf" || cc == "WMF" ){
					image = loadIMG(i,maxi,imageArray[i],imageWidth, imageHeight, 0,0,'center');
	     }//if 
   }//for

	 //alert(document.getElementById("img-"+(maxi-1)).id);
                
		for (i=0; i <= maxi; i++) { 
						 pauseSlideShow[i] = setTimeout("PicArray["+i+"]=showIMG("+i+","+maxi+","+x+","+y+",'"+textArray[i]+"')", i * 2000);
						 pauseSlideRemove[i] = setTimeout("removeIMG(PicArray["+i+"])", (i * 2000) + 2000);
		}//for

	 			 pausePICShow = setTimeout(doAfterSlideshow1, ((maxi-1) * 2000) + 2000);
	 			 pausePICFade = setTimeout(doAfterSlideshow2, (maxi * 2000) + 2000);


				 //Text Container
          var objContainer = document.createElement("SPAN");
          txtContainer = document.body.appendChild(objContainer);
          txtContainer.id = "SlideShowText";
					txtContainer.innerHTML = "";
					txtContainer.style.width = 300;
					txtContainer.style.position = (browser=="IE")?"relative":"absolute";
					txtContainer.style.left = x;
					txtContainer.style.top = y + image.height;
					txtContainer.style.align = "left";
				  oldTXT = txtContainer.innerHTML;


					 if(window.addEventListener){ // Mozilla, Netscape, Firefox
							//document.addEventListener("keypress",  checkEscapeKey, false);    
							document.addEventListener("keypress", function(event){  if(typeof( event.keyCode ) == 'number' &&  event.keyCode != 27) { for (i=Slidecounter-1; i < maxi; i++) {  clearTimeout(pauseSlideShow[i]); }        for (i=Slidecounter-1; i < maxi; i++) { clearTimeout(pauseSlideRemove[i]);  }     for (i=Slidecounter-2; i < maxi; i++) {   try{ removeRandomIMG(slideCache[i]); removeAnimatedIMG(p); } catch(x){}     }      window.parent.document.getElementById("SlideShowText").innerHTML = "";     clearTimeout(pausePICShow);  eval(doAfterSlideshow2);   } }, false);    
            } 
						else { // IE
							document.body.attachEvent("onkeypress",  function(event){  if(typeof( event.keyCode ) == 'number' ) {  for (i=Slidecounter-1; i < maxi; i++) {  clearTimeout(pauseSlideShow[i]); }        for (i=Slidecounter-1; i < maxi; i++) { clearTimeout(pauseSlideRemove[i]);  }      for (i=Slidecounter-2; i < maxi; i++) {     try{ removeRandomIMG(slideCache[i]); removeAnimatedIMG(p); } catch(x){ }   }      window.parent.document.getElementById("SlideShowText").innerHTML = "";    clearTimeout(pausePICShow);  /*clearTimeout(pausePICFade);*/  eval(doAfterSlideshow2);  } } );    
						}
}


var slideCache = new Array(); 
function imageLoaded()
{
	return true;
}

function loadIMG(ImageCounter, _maxi, clip, clipWidth, clipHeight, hspace, vspace, align) {
 
     maxi=_maxi;
     var newIMG = document.createElement("IMG");
     newIMG.src = clip;
		 
  try{
		 newIMG.width = clipWidth;
     newIMG.height =  clipHeight;
     newIMG.hspace=hspace; newIMG.vspace=vspace; 
     newIMG.align= align; 
     newIMG.onload=imageLoaded();
		 var img = slideCache[ImageCounter-1] = newIMG;
		 //slideCache[ImageCounter-1].style.visibility = "hidden";
		 return img;

		 //var img = document.body.appendChild(slideCache[ImageCounter-1]);
		 //img.id = "img-"+ImageCounter;
     //return img;
  }
  catch(x){
    newIMG.width = clipWidth;
    newIMG.height =  clipHeight;
    newIMG.hspace=hspace; newIMG.vspace=vspace; 
    newIMG.align= align; 
		var img = slideCache[ImageCounter-1] = newIMG;
		//slideCache[ImageCounter-1].style.visibility = "hidden";
		return img;

		//var img = document.body.appendChild(slideCache[ImageCounter-1]);
		//img.id = "img-"+ImageCounter;
		//return img;
		 
   }
}


function showIMG(picNO,picALL,x,y,txt) {

		Slidecounter++;		

 		var newImage;
		var oldImage;
    var soundFile = whichBrowser() ? "http://aitkenandassociates.com.au/sound/TICKTWO.WAV" : "http://aitkenandassociates.com.au/sound/TICKTWO.WAV"
    
  try{ 
			window.parent.document.getElementById("SlideShowText").style.left = x ;
			window.parent.document.getElementById("SlideShowText").style.top =  y + slideCache[picNO-1].height;
			newTXT = window.parent.document.getElementById("SlideShowText").innerHTML = "<p id='p_1'  style='color:#6FB795; font-family:Arial Black, verdana, sans-serif; font-size:16px' >"+txt+"</p>";
			//txtContainer.style.left = x ;
			//txtContainer.style.top =  y + slideCache[picNO-1].height;
			//newTXT = txtContainer.innerHTML = "<p id='p_1'  style='color:#0000ff; font-family:Arial Black, verdana, sans-serif; font-size:26px' >"+txt+"</p>"; 
		
	if(picNO < picALL - 1){
//newImage
		slideCache[picNO].style.top = y  + "px";
    slideCache[picNO].style.left =  x + "px";
		ratio=slideCache[picNO].width / slideCache[picNO].height;
    slideCache[picNO].id = "Pic" + (picNO - 1);
    //slideCache[picNO].style.visibility="visible";
    slideCache[picNO].width=slideCache[picNO].width;
    slideCache[picNO].height=slideCache[picNO].height;
    slideCache[picNO].hspace=0; 
    slideCache[picNO].vspace=0;
    slideCache[picNO].style.position = "absolute";
    slideCache[picNO].style.zIndex = 0;
		//newImage=slideCache[picNO];
	  newImage=document.body.appendChild(slideCache[picNO]);
//oldImage
		//slideCache[picNO-1].width *= 1.1;
		//slideCache[picNO-1].height *= 1.1;
		slideCache[picNO-1].style.top = y  + "px";
    slideCache[picNO-1].style.left =  x + "px";
		ratio=slideCache[picNO-1].width / slideCache[picNO-1].height;
    slideCache[picNO-1].id = "Pic" + (picNO - 1);
    //slideCache[picNO-1].style.visibility="visible";
    slideCache[picNO-1].width=slideCache[picNO-1].width;
    slideCache[picNO-1].height=slideCache[picNO-1].height;
    slideCache[picNO-1].hspace=0; 
    slideCache[picNO-1].vspace=0;
    slideCache[picNO-1].style.position = "absolute";
    slideCache[picNO-1].style.zIndex = 0;
		//oldImage=slideCache[picNO-1];
	  oldImage=document.body.appendChild(slideCache[picNO-1]);
   fadeout.speed = (browser=="IE")?50:50;  fadeout.finalOpacity = 0;  fadeout.currentOpacity =  (browser=="IE")?100:1;     fadeout.init( oldImage );
	 
	}
else if(picNO == picALL - 1) document.body.removeChild(slideCache[picNO-1]);
  }
  catch(e) {}

	return oldImage;

}//function showIMG

function removeIMG(img){
	if(img) document.body.removeChild(img);
}
				
//****************************   S  L  I  D  E  S  H  O  W          R  A  N  D  O  M     I  M  A  G  E  S       **************************************************
/*
<img id="img_1" src="images/slideshow/1_Sample_115.jpg" style="visibility:hidden;" />

<script type="text/javascript">
  var slideshowCache = new Array();
	slideshowCache[0] = "http://aitkenandassociates.com.au/images/blank.gif";
	slideshowCache[1] = "images/slideshow/1_Sample_115.jpg";
  slideshowCache[2] = "images/slideshow/2_Sample_116.jpg";

 var textCache = new Array();
  textCache[0] = "CAD 3D Drafting";
  textCache[1] = "CAD 2D Drafting";
  textCache[2] = "";

var ratio = document.getElementById("img_1").width / document.getElementById("img_1").height;
var oLeft = 300;
var oTop = 200;
var imageWidth = 800;
var imageHeight = imageWidth / ratio;	
		
		document.getElementById("img_1").style.display = "none";
	
   //slideshow(slideshowCache,oLeft,oTop,imageWidth,imageHeight,textCache);
   randomIMAGES(slideshowCache,imageWidth,imageHeight,textCache);

</script>


*/

var Slidecounter = 0;

function randomIMAGES(imageArray,imageWidth,imageHeight,textArray,doAfterSlideshow1,doAfterSlideshow2, isAnimated){
				 var image = null;
				 var pauseSlideShow1 = new Array();
				 var pauseSlideShow2 = new Array();
				 var pauseSlideRemove1 = new Array();
				 var pauseSlideRemove2 = new Array();
				 maxi = imageArray.length;
				 maxi = imageArray.length;
				 
    for (i=0; i < maxi; i++){	
		     var cc = imageArray[i].substring(imageArray[i].lastIndexOf(".")+1);	
		  if( cc == "gif" || cc == "jpg" || cc == "png" || cc == "bmp" || cc == "tif" || 
					cc == "GIF" || cc == "JPG" || cc == "PNG" || cc == "BMP" || cc == "TIF" ||	
					cc == "ico" || cc == "ICO" || cc == "wmf" || cc == "WMF" ){
					image = loadRandomIMG(i,maxi,imageArray[i],imageWidth, imageHeight, 0,0,'center');
	        //pauseShow=setTimeout("showRandomIMG("+i+","+maxi+",'"+textArray[i]+"')", i * 3000);
			 }//if 
 	 }//for

		//alert(document.getElementById("img-"+(maxi-1)).id);

    for (i=0; i < maxi; i++){
				  
        
					if(isAnimated) {
												 pauseSlideShow1[i] = setTimeout("PicArray["+i+"]=animatedRandomIMG("+i+","+maxi+",'"+textArray[i]+"')", i * 5000);
												 pauseSlideShow2[i] = setTimeout("TicArray["+i+"]=animatedRandomIMG("+i+","+maxi+",'"+textArray[i]+"')", i * 5000);
												 pauseSlideRemove1[i] = setTimeout("removeAnimatedIMG(PicArray["+i+"])", (i * 5000) + 5000);
												 
												 
												 pauseSlideRemove2[i] = setTimeout("removeAnimatedIMG(TicArray["+i+"])", (i * 5000) + 5000);

												 }
					else  { 			 pauseSlideShow1[i] = setTimeout("PicArray["+i+"]=showRandomIMG("+i+","+maxi+",'"+textArray[i]+"')", i * 2000);
												 pauseSlideRemove1[i] = setTimeout("removeRandomIMG(PicArray["+i+"])", (i * 2000) + 2000);
												 }
						
 	 }//for
	 
	 
	 			 pausePICShow = setTimeout(doAfterSlideshow1, ((maxi-1) * 2000) + 2000);
	 			 pausePICFade = setTimeout(doAfterSlideshow2, (maxi * 2000) + 2000);

				 //Text Container
          var objContainer = document.createElement("SPAN");
          txtContainer = document.body.appendChild(objContainer);
          txtContainer.id = "SlideShowText";
					txtContainer.innerHTML = "";
					txtContainer.style.width = 300;
					txtContainer.style.position = (browser=="IE")?"relative":"absolute";
					txtContainer.style.left = 0;
					txtContainer.style.top = 0;
					txtContainer.style.align = "left";
				  oldTXT = txtContainer.innerHTML; 
         


					 if(window.addEventListener){ // Mozilla, Netscape, Firefox
							//document.addEventListener("keypress",  checkEscapeKey, false);    
							document.addEventListener("keypress", function(event){  if(typeof( event.keyCode ) == 'number' &&  event.keyCode != 27) { for (i=Slidecounter-1; i < maxi; i++) {  clearTimeout(pauseSlideShow1[i]);  clearTimeout(pauseSlideShow2[i]);  }        for (i=Slidecounter-1; i < maxi; i++) { clearTimeout(pauseSlideRemove1[i]); clearTimeout(pauseSlideRemove2[i]); }     for (i=Slidecounter-2; i < maxi; i++) {   try{ removeRandomIMG(slideCache[i]); removeAnimatedIMG(p); } catch(x){}     }      window.parent.document.getElementById("SlideShowText").innerHTML = "";     clearTimeout(pausePICShow); /* clearTimeout(pausePICFade);    eval(doAfterSlideshow1); */ eval(doAfterSlideshow2);   } }, false);    
            } 
						else { // IE
							document.body.attachEvent("onkeypress",  function(event){  if(typeof( event.keyCode ) == 'number' ) {  for (i=Slidecounter-1; i < maxi; i++) {  clearTimeout(pauseSlideShow1[i]);  clearTimeout(pauseSlideShow2[i]);}        for (i=Slidecounter-1; i < maxi; i++) { clearTimeout(pauseSlideRemove1[i]); clearTimeout(pauseSlideRemove2[i]); }      for (i=Slidecounter-2; i < maxi; i++) {     try{ removeRandomIMG(slideCache[i]); removeAnimatedIMG(p); } catch(x){ }   }      window.parent.document.getElementById("SlideShowText").innerHTML = "";    clearTimeout(pausePICShow);  clearTimeout(pausePICFade);    /*eval(doAfterSlideshow1); eval(doAfterSlideshow2); */  eval(doAfterSlideshow2);  } } );    
						}
}


function loadRandomIMG(ImageCounter, _maxi, clip, clipWidth, clipHeight, hspace, vspace, align) {
 
     maxi=_maxi;
     var newIMG = document.createElement("IMG");
     newIMG.src = clip;
		 
  try{
		 newIMG.width = clipWidth;
     newIMG.height =  clipHeight;
     newIMG.hspace=hspace; newIMG.vspace=vspace; 
     newIMG.align= align; 
     newIMG.onload=imageLoaded();
		 slideCache[ImageCounter-1] = newIMG;
		 slideCache[ImageCounter-1].style.visibility = "hidden";
		 var img = document.body.appendChild(slideCache[ImageCounter-1]);
		 img.id = "img-"+ImageCounter;
     return img;
  }
  catch(x){
    newIMG.width = clipWidth;
    newIMG.height =  clipHeight;
    newIMG.hspace=hspace; newIMG.vspace=vspace; 
    newIMG.align= align; 
		slideCache[ImageCounter-1] = newIMG;
		slideCache[ImageCounter-1].style.visibility = "hidden";
		var img = document.body.appendChild(slideCache[ImageCounter-1]);
		img.id = "img-"+ImageCounter;
		return img;
		 
   }
}


function showRandomIMG(picNO,picALL,txt) {

		Slidecounter++;			 

 		var newImage;
		var oldImage;
		var randomX = Math.random( );  
		var randomY = Math.random( ); 
    //var soundFile = whichBrowser() ? "../sound/TICKTWO.WAV" : "sound/TICKTWO.WAV"
    var soundFile = whichBrowser() ? "http://aitkenandassociates.com.au/sound/TICKTWO.WAV" : "http://aitkenandassociates.com.au/sound/TICKTWO.WAV"
    
  try{ 
      var upperboundX = document.body.clientWidth - 200;
      var lowerboundX = 150;
      var upperboundY = document.body.clientHeight - 20;
      var lowerboundY = 100;
			var x = Math.floor(((upperboundX - lowerboundX - slideCache[picNO-1].width) * randomX) + 120);
			var y = Math.floor(((upperboundY - lowerboundY - slideCache[picNO-1].height) * randomY) + 100);
		  
			window.parent.document.getElementById("SlideShowText").style.left = x ;
			window.parent.document.getElementById("SlideShowText").style.top =  y + slideCache[picNO-1].height;
			newTXT = window.parent.document.getElementById("SlideShowText").innerHTML = "<p id='p_1'  style='color:#0000ff; font-family:Arial Black, verdana, sans-serif; font-size:26px' >"+txt+"</p>";
			//txtContainer.style.left = x ;
			//txtContainer.style.top =  y + slideCache[picNO-1].height;
			//newTXT = txtContainer.innerHTML = "<p id='p_1'  style='color:#0000ff; font-family:Arial Black, verdana, sans-serif; font-size:26px' >"+txt+"</p>"; 
		
	if(picNO < picALL - 1){
//newImage
		slideCache[picNO].style.top = y  + "px";
    slideCache[picNO].style.left =  x + "px";
		ratio=slideCache[picNO].width / slideCache[picNO].height;
    slideCache[picNO].id = "Pic" + (picNO - 1);
    slideCache[picNO].style.visibility="visible";
    slideCache[picNO].width=slideCache[picNO].width;
    slideCache[picNO].height=slideCache[picNO].height;
    slideCache[picNO].hspace=0; 
    slideCache[picNO].vspace=0;
    slideCache[picNO].style.position = "absolute";
    slideCache[picNO].style.zIndex = 50000;
		//newImage=slideCache[picNO];
	  newImage=document.body.appendChild(slideCache[picNO]);
//oldImage
		//slideCache[picNO-1].width *= 1.1;
		//slideCache[picNO-1].height *= 1.1;
		slideCache[picNO-1].style.top = y  + "px";
    slideCache[picNO-1].style.left =  x + "px";
		ratio=slideCache[picNO-1].width / slideCache[picNO-1].height;
    slideCache[picNO-1].id = "Pic" + (picNO - 1);
    slideCache[picNO-1].style.visibility="visible";
    slideCache[picNO-1].width=slideCache[picNO-1].width;
    slideCache[picNO-1].height=slideCache[picNO-1].height;
    slideCache[picNO-1].hspace=0; 
    slideCache[picNO-1].vspace=0;
    slideCache[picNO-1].style.position = "absolute";
    slideCache[picNO-1].style.zIndex = 50000;
		//oldImage=slideCache[picNO-1];
	  oldImage=document.body.appendChild(slideCache[picNO-1]);
   fadeout.speed = (browser=="IE")?50:50;  fadeout.finalOpacity = 0;  fadeout.currentOpacity =  (browser=="IE")?100:1;     fadeout.init( oldImage );
	}
else if(picNO == picALL - 1) document.body.removeChild(slideCache[picNO-1]);
  }
  catch(e) {}
	
	return oldImage;

}//function showRandomIMG

function removeRandomIMG(img){
	if(img) { document.body.removeChild(img); }
}


var p = null;
function animatedRandomIMG(picNO,picALL,txt) {

		Slidecounter++;			 
		
 		var newImage;
		var oldImage;
		var randomX = Math.random( );  
		var randomY = Math.random( ); 
    //var soundFile = whichBrowser() ? "../sound/TICKTWO.WAV" : "sound/TICKTWO.WAV"
    //var soundFile = whichBrowser() ? "http://aitkenandassociates.com.au/sound/TICKTWO.WAV" : "http://aitkenandassociates.com.au/sound/TICKTWO.WAV"
    
  try{ 
      var upperboundX = document.body.offsetWidth;
      var lowerboundX = 150;
      var upperboundY = document.body.offsetHeight;
      var lowerboundY = 100;
			var x = Math.floor(((upperboundX - lowerboundX - slideCache[picNO-1].width) * randomX) + 120);
			var y = Math.floor(((upperboundY - lowerboundY - slideCache[picNO-1].height) * randomY) + 100);
		  
			window.parent.document.getElementById("SlideShowText").style.left = 240;
			window.parent.document.getElementById("SlideShowText").style.top =  104 + slideCache[picNO-1].height;
			newTXT = window.parent.document.getElementById("SlideShowText").innerHTML = "<p id='p_1'  style='color:#6FB795; font-family:Arial Black, verdana, sans-serif; font-size:20px' >"+txt+"</p>";

	if(picNO < picALL - 1) { p = animatePIC(slideCache[picNO].src,x,y); }
	else if(picNO == picALL - 1) p.remove(); 
  }
  catch(e) {}
	
	
	return p;

}//function animateRandomIMG

function removeAnimatedIMG(img){
	if(img) { img.remove(); } //Remove SVG / VML object
}




//**********************************************************           P   O   P   U   P      W   I   N   D   O   W           ************************************

//var oFeatures = "height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes";
function fb_popupWindow(oURL, oName, oFeatures) {
  window.open(oURL, oName, oFeatures);
}















