
function delayPics(picName,picNumber) {
	var randomNum = 0;
    setTimeout("choosePic('"+picName+"',"+picNumber+","+randomNum+");",3000);
}

function choosePic(picName,picNumber,randomNum) {
    randomNum = randomNum+1;
	if (randomNum == picNumber) {
	  randomNum = 0;
	}
	  document.getElementById('randomImage').src='images/image_'+picName+randomNum+'.jpg';
      setTimeout("choosePic('"+picName+"',"+picNumber+","+randomNum+");",3000);
}

function choosePicMaintenance() {
    HomePics = new Array('images/image_maintenance_0.jpg','images/image_maintenance_1.jpg','images/image_maintenance_2.jpg');
    imgCt = HomePics.length;
    var randomNum = Math.floor((Math.random() * imgCt));
	document.getElementById('randomImage').src='images/image_maintenance_'+randomNum+'.jpg';
    setTimeout("choosePicMaintenance();",3000);
}

function choosePicTestimonials() {
    HomePics = new Array('images/image_testimonial_0.jpg','images/image_testimonial_1.jpg','images/image_testimonial_2.jpg');
    imgCt = HomePics.length;
    var randomNum = Math.floor((Math.random() * imgCt));
	document.getElementById('randomImage').src='images/image_maintenance_'+randomNum+'.jpg';
    setTimeout("choosePicTestimonials();",3000);
}

if (document.getElementById) {
	visible = 'visible';
	hidden = 'hidden';
} else if (document.layers) {
	visible = 'show';
	hidden = 'hide';
} else if (document.all) {
	visible = 'visible';
	hidden = 'hidden';
}
function reveal(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;	 
 } else if (document.layers) {
		var theMenu = document.layers[menu];		
	} else if (document.all) {
		var theMenu = document.all[menu].style;	 
}
	if (theMenu.visibility == visible) {
		theMenu.visibility = visible;
	} else {
		theMenu.visibility = visible;
	}
}

function hide(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;
		
	} else if (document.layers) {
		theMenu = document.layers[menu];
		
	} else if (document.all) {
		theMenu = document.all(menu).style;
}
	if (theMenu.visibility == hidden) {
		theMenu.visibility = hidden;
	} else {
		theMenu.visibility = hidden;
	}
}

function writeContent(text,layerName) {
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
if (ie4) {
document.all[layerName].innerHTML = text;
}
if (ns4) {
document[layerName].document.write(text);
document[layerName].document.close();
}
if (ns6) {
over = document.getElementById([layerName]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(text);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
   }
}

function newWindow(pomguard) {
    wtechWindow = window.open(pomguard, 'Pomguard', 'width=685,height=500,scrollbars=no,status=no,menubar=no,marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,rightmargin=0')
    wtechWindow.focus()
}


function photoReveal(text,layerName) {
    newWidth = parseInt(document.getElementById('photos').style.width);
    newLeft = parseInt(document.getElementById('photos').style.left);
    if (newWidth < 400) {
	      reveal('photos');
		  reveal('blackLayer');
          newWidth=newWidth+10;
          newLeft=newLeft-5;
          document.getElementById('photos').style.width=newWidth+"px";
          document.getElementById('photos').style.left=newLeft+"px";
          setTimeout("photoReveal('"+text+"','"+layerName+"');",0);            
}
    else if (newWidth == 400) {
          document.getElementById('photos').style.width=400+"px";
          setTimeout("writeContent('"+text+"','"+layerName+"');",0);            
    }
}

function checkPosition(text,layerName) {
   baseLeft = parseInt(document.getElementById('photos').style.left);
   backLeft = parseInt(document.getElementById('mainLayer').style.left);
   layerPosition = baseLeft - backLeft;
   if (layerPosition == 215) {
	  reveal('photoSecondary');
      writeContent(text,layerName);            
        setTimeout("showImgsCenter('"+text+"','"+layerName+"');",0);            
   }
   else {
        setTimeout("showImgsLeft('"+text+"','"+layerName+"');",0);            
   }
}

function showImgsCenter(text,layerName) {
    baseLeft = parseInt(document.getElementById('photos').style.left);
    secondaryLeft = parseInt(document.getElementById('photoSecondary').style.left);
    backLeft = parseInt(document.getElementById('mainLayer').style.left);
    if (baseLeft > backLeft + 25) {
		baseLeft = baseLeft - 10;
		secondaryLeft = secondaryLeft + 10;
        document.getElementById('photos').style.left=baseLeft+"px";
        document.getElementById('photoSecondary').style.left=secondaryLeft+"px";
        setTimeout("showImgsCenter('"+text+"','"+layerName+"');",0);            
}
    else {
           lineLeftOriginal = parseInt(document.getElementById('photoLine').style.left);
           lineTopOriginal = parseInt(document.getElementById('photoLine').style.top);
           document.getElementById('photoLine').style.left=lineLeftOriginal+lineLeft+"px";
           document.getElementById('photoLine').style.top=lineTopOriginal+lineTop+"px";
           document.getElementById('photoLine').style.width=lineWidth+"px";
          reveal('photoLine');
    }
}

function showImgsLeft(text,layerName) {
    baseLeft = parseInt(document.getElementById('photos').style.left);
    secondaryLeft = parseInt(document.getElementById('photoSecondary').style.left);
    backLeft = parseInt(document.getElementById('mainLayer').style.left);
    if (baseLeft < backLeft + 225) {
		baseLeft = baseLeft + 10;
		secondaryLeft = secondaryLeft - 10;
        document.getElementById('photos').style.left=baseLeft+"px";
        document.getElementById('photoSecondary').style.left=secondaryLeft+"px";
        setTimeout("showImgsLeft('"+text+"','"+layerName+"');",0);            
}
    else {
		writeContent(text,layerName);            
        setTimeout("showImgsCenter('"+text+"','"+layerName+"');",500);            
    }
}

function closePhotos(closeType) {
	if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}
var totalW=winW-850;
var halfW=totalW/2;
var rightPosition=Math.round(halfW);
var totalH=winH-600;
var halfH=totalH/2;
var topPosition=Math.round(halfH);

if (topPosition < 0) {
	topPosition = 0;
}
if (rightPosition < 0) {
	rightPosition = 0;
}

if (closeType == 1) {
	   hide('photos');
	   hide('blackLayer');
       document.getElementById("photos").style.left=rightPosition+415+"px";
       document.getElementById("photos").style.width=0+"px";
	   writeContent('','photos');            

}
if (closeType == 2) {
	   hide('photos');
	   hide('photoSecondary');
	   hide('blackLayer');
       document.getElementById("photos").style.left=rightPosition+415+"px";
       document.getElementById("photos").style.width=0+"px";
	   document.getElementById("photoSecondary").style.left=rightPosition+225+"px";
	   writeContent('','photos');            
}
}
