// JavaScript Document
function menuOn(obj) {
document.getElementById(obj).style.display = '';
}

function menuOff(obj) {
document.getElementById(obj).style.display = 'none';
}

function allOff(obj1, obj2, obj3) {
document.getElementById(obj1).style.display = 'none';	
document.getElementById(obj2).style.display = 'none';	
document.getElementById(obj3).style.display = 'none';	
}

function filler() {
browseWidth=document.body.clientWidth;
document.fred.width = browseWidth-10;
}

function imgOff(obj) {
document.getElementById('ss').href = 'style.css';
document.getElementById(obj).innerHTML= '';
document.getElementById(obj).style.display = 'none';
}
function showPro(box, id, limit) { 
//key press listener
nn=(document.layers)?true:false;
ie=(document.all)?true:false;
function keyDown(e) {
	var evt=(e)?e:(window.event)?window.event:null;
	if(evt){
		var key=(evt.charCode)?evt.charCode:
			((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
		if(key=="27") {imgOff('gallery');resetNav();}
		if(key=="32" || key=="39" || key=="40") {
			document.getElementById('gallery').innerHTML= '';
			id++;
			if(id >= limit){
			id=1;	
			}
			showPro('gallery', id, limit); 
			}
		if(key=="8" || key=="37" || key=="38") {
			document.getElementById('gallery').innerHTML= '';
			id--; 
			if(id == 0){
			id=limit;
			}
			showPro('gallery', id, limit);
			}
	}
}
document.onkeydown=keyDown;
if(nn) document.captureEvents(Event.KEYDOWN);
//end key press listener

			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request")
			 return
			 }
			document.getElementById('ss').href = 'g/a.css';
			document.getElementById('gallery').style.display = '';
			var url="getInfo.php"
			url=url+"?q="+id
			url=url+"&sid="+Math.random()
			xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
			}
			function stateChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 setTimeout("",1250);
			 document.getElementById('gallery').innerHTML=xmlHttp.responseText 
			 } 
			}
			function GetXmlHttpObject()
			{
			var xmlHttp=null;
			try
			 {
			 // Firefox, Opera 8.0+, Safari
			 xmlHttp=new XMLHttpRequest();
			 }
			catch (e)
			 {
			 //Internet Explorer
			 try
			  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			 catch (e)
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			 }
			return xmlHttp;
			}	

goLeft=false;
goRight=true;
function autoMove2(){
if(goLeft==true && goRight==false){
divElement=document.getElementById("div3");
currentPosition=divElement.offsetLeft;
if(currentPosition==23){
goLeft=false;
goRight=true;
clearTimeout(timer);
currentPosition+=15;
}
currentPosition-=15;
divElement.style.left=currentPosition+"px";
timer=setTimeout("autoMove2()",50);
}
}
function autoMove1(){
if(goLeft==false && goRight==true){
divElement=document.getElementById("div3");
currentPosition=divElement.offsetLeft;
if(currentPosition==233){
goLeft=true;
goRight=false;
clearTimeout(timer);
}
currentPosition+=15;
divElement.style.left=currentPosition+"px";
timer=setTimeout("autoMove1()",50);
}
}

function randOrd(){
return (Math.round(Math.random())-0.5); }
var pictures = new Array ("http://www.johnpicone.com/images/header/1.jpg", "http://www.johnpicone.com/images/header/2.jpg", "http://www.johnpicone.com/images/header/3.jpg", "http://www.johnpicone.com/images/header/4.jpg", "http://www.johnpicone.com/images/header/5.jpg", "http://www.johnpicone.com/images/header/6.jpg", "http://www.johnpicone.com/images/header/7.jpg", "http://www.johnpicone.com/images/header/8.jpg", "http://www.johnpicone.com/images/header/9.jpg", "http://www.johnpicone.com/images/header/10.jpg", "http://www.johnpicone.com/images/header/11.jpg", "http://www.johnpicone.com/images/header/12.jpg", "http://www.johnpicone.com/images/header/13.jpg", "http://www.johnpicone.com/images/header/14.jpg", "http://www.johnpicone.com/images/header/15.jpg", "http://www.johnpicone.com/images/header/16.jpg", "http://www.johnpicone.com/images/header/17.jpg", "http://www.johnpicone.com/images/header/18.jpg", "http://www.johnpicone.com/images/header/19.jpg", "http://www.johnpicone.com/images/header/20.jpg", "http://www.johnpicone.com/images/header/21.jpg", "http://www.johnpicone.com/images/header/22.jpg", "http://www.johnpicone.com/images/header/23.jpg", "http://www.johnpicone.com/images/header/24.jpg", "http://www.johnpicone.com/images/header/25.jpg", "http://www.johnpicone.com/images/header/27.jpg", "http://www.johnpicone.com/images/header/28.jpg", "http://www.johnpicone.com/images/header/29.jpg", "http://www.johnpicone.com/images/header/30.jpg", "http://www.johnpicone.com/images/header/31.jpg");
pictures.sort(randOrd);
var picture_num = 1;
var time = 4000;
var current_picture = new Image();
function start_show() 
{
setInterval("slideshow()", time);
current_picture.src = pictures[0];
document["rotating_picture"].src = current_picture.src;
}
function slideshow() 
{
	picture_num++;
		if (picture_num == pictures.length) 
		{
		picture_num = 0;
		}
		current_picture.src = pictures[picture_num];
		document["rotating_picture"].src = current_picture.src;
}

function resetNav()
{
divElement=document.getElementById("div3");
divElement.style.left="23px";
}
