//Controls for homepage slideshow

var pause2 = false;
var indx;
var indx1;
var indx2;
var indx3;
var indx4;
var indx5;

function initializeVars()
{
	pause2 = false;
	indx = 0;
	indx1 = 0;
	indx2 = 0;
	indx3 = 0;
	indx4 = 0;
	indx5 = 0;
	
}

function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function fadeLgCap(fname, x)
{
	//$(".cover", '.boxgrid.captionfull').stop().animate({top:'386px'},{queue:false,duration:500});
	//$("#largeImg").fadeTo(1000, 0.0);
	
		//largeImgLoad(fname, x);

	$("#largeImg").fadeTo(1000, 0.0,function(){
		largeImgLoad(fname, x);
		});
		
}

function largeImgLoad(fname, x) 
{
	//$(".cover", '.boxgrid.captionfull').stop().animate({top:'386px'},{queue:false,duration:500});
	//$("#largeImg").hide();

	var x1;
	
	var xhr=createXHR();
	xhr.open("GET", fname,true);
	xhr.onreadystatechange=function() 
	{
		if (xhr.readyState == 4) 
		{
			if (xhr.status != 404) 
			{

				indx = indx * 1;
				var data=eval("(" + xhr.responseText + ")");
				var objCount=0;
				objCount = data.images.length;
				objCount = objCount - 1;							
						
				if (indx == "")
				{
					indx = 0;
				}

				if (isNaN(indx))
				{
					indx = 0;
				}
			if (BrowserDetect.browser == "Firefox")
				{
					if (indx > objCount)
					{
						indx = 0;
					}
					else if(indx < 0) 
					{
						indx = objCount - 1;
					}
				}	
			else
				{
					if (indx >= objCount)
					{
						indx = 0;
					}
					else if(indx < 0) 
					{
						indx = objCount - 1;
					}

				}

				$("#largeImg").attr({ src: data.images[indx].fileName, alt: data.images[indx].captitle }); 
				//$("#largeImg").css('z-index', -1); 
				$("#largeLink").attr('href', data.images[indx].link);
				$("#prevlink").attr('href', data.images[indx].link);
				$("#largeLink").attr('target', "_blank");
				$("#prevlink").attr('target', "_blank");
				
				if (BrowserDetect.browser == "Firefox")
				{
					$("#prev").html('<div  align="center" id="prev" style="position:absolute;z-index:2"><a id="prev" href=javascript:largeImgPrev("hpjsonfile.asp"); onCLick="this.blur();" style="z-index:2;"><img src="hpgraphics/prev.png" border=0 style="position:absolute;left:330;z-index:3"></a><a id="prev" href=javascript:largeImgNext("hpjsonfile.asp"); style="position:absolute;left:370px;z-index:3"  onCLick="this.blur();"><img src="hpgraphics/next.png" border=0  style="z-index:3;"></a></div>')
					//$("#largeImgCap").html('<span style="font-size:12px;font-family:Arial;color:#eeee00;text-decoration:none;">&nbsp;&nbsp;' + data.images[indx].captitle + '<br></span><br><span style="font-size:16px;font-family:Arial;color:#ffffff;text-decoration:none;">&nbsp;&nbsp;' + data.images[indx].cap + '<br></span><div style="font-size:11px;position:absolute;left:0px;color:#ffffff;text-decoration:none;font-family:Arial;">&nbsp;&nbsp;&nbsp;' + data.images[indx].capsub + '</div><div valign=top align=right style="font-size:11px;position:absolute left:330px;top:0px;color:#eeee00;text-decoration:none;font-family:Arial;"><a href="'+ data.images[indx].link +'" style="color:#eeee00;text-decoration:none;">+ More Info</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>');
				}
				else
				{
					//$("#largeImgCap").html('<span style="font-size:12px;font-family:Arial;color:#eeee00;text-decoration:none;">&nbsp;&nbsp;' + data.images[indx].captitle + '<br></span><br><span style="font-size:16px;font-family:Arial;color:#ffffff;text-decoration:none;">&nbsp;&nbsp;' + data.images[indx].cap + '<br></span><div style="font-size:12px;color:#ffffff;text-decoration:none;font-family:Arial;font-weight:normal;">&nbsp;&nbsp;&nbsp;' + data.images[indx].capsub + '</div><div style="position:relative;"><div valign=top align=right style="font-family:Arial;font-size:11px;left:620px;top:-10px;color:#eeee00;position:absolute;text-decoration:none;"><a style="color:#eeee00;text-decoration:none;" href="'+ data.images[indx].link +'">+ More Info</a></span>&nbsp;&nbsp;&nbsp;&nbsp;</div></div>');
					$("#prev").html('<div  align="center" id="prev" style="position:absolute;z-index:2"><a id="prev" href=javascript:largeImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="hpgraphics/prev.png" border=0 style="position:absolute;left:-20;z-index:3"></a><a id="prev" href=javascript:largeImgNext("hpjsonfile.asp"); style="position:absolute;left:20px;z-index:3"  onCLick="this.blur();"><img src="hpgraphics/next.png" border=0></a></div>')
				}
				//$("#largeImgCap").attr('href', data.images[indx].link);
				//$("#largeImg").slideDown(1000);
				$("#largeImg").fadeTo(1000, 1.0);
					
				indx = indx * 1 + 1;				
				
				
			} 
			else 
			{
				alert( fname + " not found");
			}
		}
	}
	xhr.send(null);	
	

	setTimeout('showhidecap()', 10)
}

function showhidecap()
{	
		$(".cover", '.boxgrid.captionfull').stop().animate({top:'304px'},{queue:false,duration:900});

}

function largeImgPrev(fname)
{
	largeImgLoad(fname, document.indexer.ndx.value - 2);
}

function largeImgNext(fname)
{
	largeImgLoad(fname, document.indexer.ndx.value);
}

function smallImgPrev(fname)
{
	smallImgLoad(fname, document.indexer.ndx2.value - 2);
}

function smallImgNext(fname)
{
	smallImgLoad(fname, document.indexer.ndx2.value);
}


function pause()
{
	pause2 = true;
}

function play()
{
	pause2 = false;
}


function fadeSmCap(fname, x)
{
	$("#sCap1").fadeTo(1000, 0.0);
	$("#sCap2").fadeTo(1000, 0.0);
	$("#sCap3").fadeTo(1000, 0.0);
	$("#sCap4").fadeTo(1000, 0.0);
	$("#sCap5").fadeTo(1000, 0.0,function(){
		smallImgLoad(fname, x);
		});
}

function smallImgLoad(fname, x) 
{
	//$(".cover2", '.smBox.captionfull').stop().animate({top:'194px'},{queue:false,duration:50});
	//$("#sb1").hide();
	//$("#sb2").hide();
	//$("#sb3").hide();
	//$("#sb4").hide();
	//$("#sb5").hide();
	//$("#sCap1").fadeTo(500, 0);
	
	var xhr=createXHR();
	xhr.open("GET", fname,true);
	xhr.onreadystatechange=function() 
	{
		if (xhr.readyState == 4) 
		{
			if (xhr.status != 404) 
			{

				
				var data=eval("(" + xhr.responseText + ")");
				var objCount1=0;
				var objCount2=0;
				var objCount3=0;
				var objCount4=0;
				var objCount5=0;

				objCount1 = data.images2.length;
				objCount1 = objCount1 - 1;				
							
				if (indx1 == "")
				{
					indx1 = 0;
				}

				if (indx1 >= objCount1)
				{
					indx1 = 0;
				}
				else if(indx1 < 0) 
				{
					indx1 = objCount1 - 1;
				}


				objCount2 = data.images.length;
				objCount2 = objCount2 - 1;				
							
				if (indx2 == "")
				{
					indx2 = 0;
				}

				if (indx2 >= objCount2)
				{
					indx2 = 0;
				}
				else if(indx2 < 0) 
				{
					indx2 = objCount2 - 1;
				}

				objCount3 = data.images2.length;
				objCount3 = objCount3 - 1;				
							
				if (indx3 == "")
				{
					indx3 = 0;
				}

				if (indx3 >= objCount3)
				{
					indx3 = 0;
				}
				else if(indx3 < 0) 
				{
					indx3 = objCount3 - 1;
				}

				objCount4 = data.images.length;
				objCount4 = objCount4 - 1;				
							
				if (indx4 == "")
				{
					indx4 = 0;
				}

				if (indx4 >= objCount4)
				{
					indx4 = 0;
				}
				else if(indx4 < 0) 
				{
					indx4 = objCount4 - 1;
				}
				
				objCount5 = data.images.length;
				objCount5 = objCount5 - 1;				
							
				if (indx5 == "")
				{
					indx5 = 0;
				}

				if (indx5 >= objCount4)
				{
					indx5 = 0;
				}
				else if(indx5 < 0) 
				{
					indx5 = objCount5 - 1;
				}
				
				$("#sb1").attr({src: $("#sb1").attr('src')});
				//$("#sb1").attr({ src: data.images2[indx1].fileName, alt: "I Changed" }); 
				////$("#sb1").css('z-index', -1); 
				$("#Link1").attr('href', data.images2[indx1].link);
				
				$("#sCap1").html(data.images2[indx1].cap + '<div style="position:absolute;top:80%;left:0px;"><a class = linkification style="font-size:11px" href="'+ data.images2[indx1].link +'">+ More Info</a></div>');				
				$("#sCap1").attr('href', data.images2[indx1].link);
				//$("#sb1").slideDown(1000);
				$("#sCap1").fadeTo(1000, 1.0);
				
				$("#sb2").attr({src: $("#sb2").attr('src')});
				//$("#sb2").attr({ src: data.images[indx2].fileName, alt: "I Changed" }); 
				////$("#sb2").css('z-index', -1); 
				$("#Link2").attr('href', data.images[indx2].link);
				$("#sCap2").html(data.images[indx2].cap + '<div style="position:absolute;top:80%;left:0px;"><a class = linkification style="font-size:11px" href="'+ data.images[indx2].link +'">+ More Info</a></div>');				
				$("#sCap2").attr('href', data.images[indx2].link);
				//$("#sb2").animate({ width: 'show' }); 
				$("#sCap2").fadeTo(1000, 1.0);

				$("#sb3").attr({src: $("#sb3").attr('src')});
				//$("#sb3").attr({ src: data.images2[indx3].fileName, alt: "I Changed" }); 
				////$("#sb3").css('z-index', -1); 
				$("#Link3").attr('href', data.images2[indx3].link);
				$("#sCap3").html(data.images2[indx3].cap + '<div style="position:absolute;top:80%;left:0px;"><a class = linkification style="font-size:11px" href="'+ data.images2[indx3].link +'">+ More Info</a></div>');				
				$("#sCap3").attr('href', data.images2[indx3].link);
				//$("#sb3").slideDown(1300);
				$("#sCap3").fadeTo(1000, 1.0);

				$("#sb4").attr({src: $("#sb4").attr('src')});
				//$("#sb4").attr({ src: data.images[indx4].fileName, alt: "I Changed" }); 
				////$("#sb4").css('z-index', -1); 
				$("#Link4").attr('href', data.images[indx4].link);
				$("#sCap4").html(data.images[indx4].cap + '<div style="position:absolute;top:80%;left:0px;z-index:-1;"><a class = linkification style="font-size:11px" href="'+ data.images[indx4].link +'">+ More Info</a></div>');				
				$("#sCap4").attr('href', data.images[indx4].link);
				//$("#sb4").animate({ width: 'show' }); 
				$("#sCap4").fadeTo(1000, 1.0);

				$("#sb5").attr({src: $("#sb5").attr('src')});
				//$("#sb5").attr({ src: data.images[indx4].fileName, alt: "I Changed" }); 
				////$("#sb4").css('z-index', -1); 
				$("#Link5").attr('href', data.images[indx4].link);
				$("#sCap5").html(data.images[indx4].cap + '<div style="position:absolute;top:80%;left:0px;z-index:-1;"><a class = linkification style="font-size:11px" href="'+ data.images[indx4].link +'">+ More Info</a></div>');				
				$("#sCap5").attr('href', data.images[indx4].link);
				//$("#sb5").animate({ width: 'show' }); 
				$("#sCap5").fadeTo(1000, 1.0);

				//$("#prev1").html('<center><a id="prev" href=javascript:smallImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="prev.png" border=0 style="position:absolute;left:60;z-index:3;"></a><a id="prev" href=javascript:smallImgNext("hpjsonfile.asp"); style="position:relative;top:1;z-index:3;"  onCLick="this.blur();"><img src="next.png" border=0></a></center>')
				//$("#prev2").html('<center><a id="prev" href=javascript:smallImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="prev.png" border=0 style="position:absolute;left:60;z-index:3;"></a><a id="prev" href=javascript:smallImgNext("hpjsonfile.asp"); style="position:relative;top:1;z-index:3;"  onCLick="this.blur();"><img src="next.png" border=0></a></center>')
				//$("#prev3").html('<center><a id="prev" href=javascript:smallImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="prev.png" border=0 style="position:absolute;left:60;z-index:3;"></a><a id="prev" href=javascript:smallImgNext("hpjsonfile.asp"); style="position:relative;top:1;z-index:3;"  onCLick="this.blur();"><img src="next.png" border=0></a></center>')
				//$("#prev4").html('<center><a id="prev" href=javascript:smallImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="prev.png" border=0 style="position:absolute;left:60;z-index:3;"></a><a id="prev" href=javascript:smallImgNext("hpjsonfile.asp"); style="position:relative;top:1;z-index:3;"  onCLick="this.blur();"><img src="next.png" border=0></a></center>')
				//$("#prev5").html('<center><a id="prev" href=javascript:smallImgPrev("hpjsonfile.asp"); onCLick="this.blur();"><img src="prev.png" border=0 style="position:absolute;left:60;z-index:3;"></a><a id="prev" href=javascript:smallImgNext("hpjsonfile.asp"); style="position:relative;top:1;z-index:3;"  onCLick="this.blur();"><img src="next.png" border=0></a></center>')	
				
				indx1 = indx1 * 1 + 1;
				indx2 = indx2 * 1 + 1;
				indx3 = indx3 * 1 + 1;
				indx4 = indx4 * 1 + 1;
				indx5 = indx5 * 1 + 1;
				
			} 
			else 
			{
				alert( fname + " not found");
			}
		}
	}
	xhr.send(null);
	
	//document.indexer.ndx2.value = x;
	setTimeout('showcap2()', 3000)
}

function showcap2()
{	
		$(".cover2", '.smBox.captionfull').stop().animate({top:'97px'},{queue:false,duration:900});
		
}

$(document).ready(function(){
	initializeVars();
	ndx = document.indexer.ndx.value;
	$("#largeImg").fadeTo(50, 1.0);
	fadeLgCap('hpjsonfile.asp', ndx);
	//smallImgLoad('hpjsonfile.asp', ndx);

	$("body").everyTime("10000ms", function() { 
				if (pause2 == true)
				{
				}
				else
				{
              		fadeLgCap('hpjsonfile.asp', ndx);

				}			
			
            });
	//$("body").everyTime("10000ms", function() { 
				//if (pause2 == true)
				//{
				//}
				//else
				//{

					//fadeSmCap('hpjsonfile.asp', ndx);
				//}			
			
            //});

	
});

$(document).ready(function(){
	
	//Full Caption Sliding (Hidden to Visible)
	//$('.boxgrid.captionfull').hover(function(){
		//$(".navit", this).stop().animate({top:'-100px'},{queue:false,duration:500});
	//}, function() {
		//$(".navit", this).stop().animate({top:'-586px'},{queue:false,duration:400});
	//}
	
	//);

	$('.boxgrid.captionfull').hover(function(){
		$(".navit", this).stop().animate({top:'-100px'},{queue:false,duration:10});
	}, function() {
		$(".navit", this).stop().animate({top:'-586px'},{queue:false,duration:10});
	}
	
	);

	//Full Caption Sliding (Hidden to Visible)
	//$('.smBox.captionfull').hover(function(){
		//$(".navit2", this).stop().animate({bottom:'99px'},{queue:false,duration:500});
	//}, function() {
		//$(".navit2", this).stop().animate({bottom:'127px'},{queue:false,duration:400});
	//});
	
});


<!--
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// -->

