var path = "images/";  // the path where the page lives.

// load the images.
//uncomment to preload images
//slide1 = new Image(); slide1.src = path + "swap1.jpg";
//slide2 = new Image(); slide2.src = path + "swap2.jpg";
//slide3 = new Image(); slide3.src = path + "swap3.jpg";
//slide4 = new Image(); slide4.src = path + "swap4.jpg";
//slide5 = new Image(); slide5.src = path + "swap5.jpg";
//slide6 = new Image(); slide6.src = path + "swap6.jpg";
//slide7 = new Image(); slide7.src = path + "swap7.jpg";
//slide8 = new Image(); slide8.src = path + "swap8.jpg";
//slide9 = new Image(); slide9.src = path + "swap9.jpg";
//slide10 = new Image(); slide10.src = path + "swap10.jpg";
//slide11 = new Image(); slide11.src = path + "swap11.jpg";


// set up the global variables.
var NumSlides = 11;  // change this to match the number of slides!
var current = 1;    // slide to start with.
var Maxtime = 10; //Maximum time between swaps
var yM_Timer;    // the timer variable.
var rand1
var name1
var name2
var name3

function next(num){  // randomly select a slide from the array
	var randomnumber = Math.random() ;	
	var num = Math.round( (NumSlides -1) * randomnumber) + 1 ;
	return num;
	}


// This is the function that's executed after the delay time is up.
function LoadNext1(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap1(newIndex);
	}

function swap1(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;	
	name1 = name
	if (name2 == name || name3 == name){
		LoadNext1(" + name + ");
		return false;
		}
	document.swapimage1.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext1(" + name + ")",TimeDelay*1000);
        } 


function LoadNext2(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap2(newIndex);
	}
	
function swap2(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;
	name2 = name;
	if (name1 == name || name3 == name){
		LoadNext2(" + name + ");
		return false;
		}
	//alert('no 2: ' + name2 + ' - no 1: ' + name1);
	document.swapimage2.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext2(" + name + ")",TimeDelay*1000);
        } 

function LoadNext3(currentIndex) {
// get the new slide index and swap current image.
	newIndex = next(currentIndex);
	current = newIndex;
	swap3(newIndex);
	}
	
function swap3(name){
	// function to do the image swap .  
	var randomnumber = Math.random() ;	
	var TimeDelay = Math.round( (Maxtime -1) * randomnumber) + 1 ;
	name3 = name;
	if (name1 == name || name2 == name){
		LoadNext3(" + name + ");
		return false;
		}
	document.swapimage3.src = eval("slide" + name + ".src");
	yM_Timer=setTimeout("LoadNext3(" + name + ")",TimeDelay*1000);
        } 

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ieexp=document.all
var ns6exp=document.getElementById && !document.all
var enabletip=false
if (ieexp||ns6exp)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6exp||ieexp){
	//alert('thecolor: ' + thecolor);
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor

tipobj.innerHTML=thetext
enabletip=thetext

//alert(enabletip);
return false
}
}

function positiontip(e){
	//alert('position ok');
if (enabletip){
	//alert(enabletip);
var curX=(ns6exp)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6exp)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ieexp&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ieexp&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ieexp? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ieexp? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6exp||ieexp){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

//document.onmousemove=positiontip



function helppopup(page,width,height) {
	var winleft = (screen.width - width) / 2;
	var winUp = (screen.height - height) / 2;
	var winProp = 'width='+width+',height='+height+',left='+winleft+',top='+winUp+',scrollbars=1,resizable=1';
	var win = window.open(page, 'Help', winProp)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function ChangeToSearch(ServiceID,RegNum,DirName,DirLoc){
   
      alert('Sorry, this function is not available on the demonstration')
    

}

function expandAll(sExpandCollapse) {
	if (document.all) {
		tempColl = document.all.tags("DIV");
	} else if (document.getElementById) {
		tempColl = document.getElementsByTagName("DIV");
	}
	
	for (i=0; i<tempColl.length; i++) {
		if (tempColl[i].className == "child") tempColl[i].style.display = sExpandCollapse;
	}
}

	
// Expands or collapses a section (DIV) using 'display' style attribute.  The unique part of the DIV name
// is passed into the function along with any special instructions such as 'top' or 'last'.

function folderExpand (sDivName,sSpecial) {
	expandChild = getElement(sDivName + "Child");
		
	if (sSpecial != "top") {
		expandTree = getElement(sDivName + "Tree");
		expandFolder = getElement(sDivName + "Folder");
	}
	
	// If collapsed, then expand it otherwise do reverse
	if (expandChild.style.display == "none") {
		expandChild.style.display = "block";
		if (sSpecial != "top") { 
			if (sSpecial == "last") { 
				expandTree.src = "images/ctree_Lminus.gif"; 
			} else { 
				expandTree.src = "images/ctree_Tminus.gif"; 
			}
		} else { 
			getElement("mPTree").src="images/ctree_topminus.gif"
		}
	} else {
		expandChild.style.display = "none";
		if (sSpecial != "top") { 
			if (sSpecial == "last") {
				expandTree.src = "images/ctree_Lplus.gif"; 
			} else { 
				expandTree.src = "images/ctree_Tplus.gif"; 
			}
		} else {
			getElement("mPTree").src="images/ctree_topplus.gif";
		}
	}
}

// Gets a handle on an element that has an ID assigned to it.  Different browsers grab elements
// in different ways, but this covers IE4+ and NS4+.
function getElement(elementId) {
	if (document.getElementById) {
		return document.getElementById(elementId);
	} else if(document.all) {
		return document.all(elementId);
	} else {
		return document.layers[elementId];
	
	}
}

// Request report availability screen for desired company in tree.

function cTreeRequestComp(regnum) {
alert('our code goes here');

	//document.frmCorpTree.DL01_REGNUMBER.value = regnum;
	//document.frmCorpTree.submit();
}
	var p_bSubmit = 0;
	function confirmrequest(credits, reporttype) 
{
	if (p_bSubmit)
	{
		alert("Page is processing, please wait...");
		return false;
	}else
	{
		if (credits>0)
		{
			if (credits == 1)
			{
				credits = credits + ' Credit';
			}else
			{
				credits = credits + ' Credits';
			}
			if (confirm('By clicking OK ' + credits + ' will be deducted from your account.'))
			{
				p_bSubmit = 1;
				//helppopup('/account/reportrequestinprogress.asp','300','100');
				return true;
			}else
			{
				p_bSubmit = 0;
				return false;
			}
		}
	}
}
