$(document).ready(function(){
	
	$(".sSubindex").each(function(){
		var newWidth = $(this).width();
		$(this).prev().css("width",newWidth);
		$(this).css("display","none");
	});		
			
				    if(d = 'index')
				    {
	                 var opened = true;				
				    }
					else
					{
						var opened = false;
					}
	//var opened = false;
//	alert(opened);
$(".sNavWrapindex").click(function(){
		if(opened){
			$('#sd').css('background-image', 'url(images/up.png)');
			$(".sNavWrapindex").animate({"top": "+=142px"}, "slow");
		}
		
		else{
		$('#sd').css('background-image', 'url(images/dn.png)');
			$(".sNavWrapindex").animate({"top": "-=142px"}, "slow");
		}
		$(".sSubindex").slideToggle("slow");
$(".sNavWrapindex .close").toggle();

		opened = opened ? false : true;

    });
	
	
	
}); // END THE DOM







$(document).ready(function(){
	/*****************************************************************************
		dealing with the navigation
	*****************************************************************************/	
	
	$(".sSub").each(function(){
		var newWidth = $(this).width();
		$(this).prev().css("width",newWidth);
		$(this).css("display","none");
		//alert( 300 - $(this).height() );
	});
	// Deal with Sub Nav
	//$(".sNavWrap").click(function(){
								  
				/*
				//alert(d);
				
				    if(d = 'index')
				    {
	                 var opened = true;				
				    }
					else
					{
						var opened = false;
					}*/
	var opened = false;
//	alert(opened);
$(".sNavWrap").click(function(){
		if(opened){
			//$(".sNavWrap").css("background-image","images/up.png");
			//$("#myImage").attr("src", "path/to/newImage.jpg");
			// $(this).find(".sd").text("+");
			$('#sd').css('background-image', 'url(images/up.png)');
			$(".sNavWrap").animate({"top": "+=142px"}, "slow");
			
			
		}
		
		else{
		//	$(this).find(".sd").text("-");
			//$(".sNavWrap").css("background-image","images/dn.png");
		//	$("#myImage").attr("src", "path/to/newImage.jpg");
		$('#sd').css('background-image', 'url(images/dn.png)');
			$(".sNavWrap").animate({"top": "-=142px"}, "slow");
		}
		$(".sSub").slideToggle("slow");
$(".sNavWrap .close").toggle();

		opened = opened ? false : true;

		// I Loath you IE fix
		//if ($.browser.msie && $.browser.version.substr(0,1)<8){var minusPX = "33";}
		//else{var minusPX = "32";}
			//alert($(this).children().children(".sSub").height());
		//var newHeight = (440 - $(this).children().children(".sSub").height() ) - minusPX +"px";
		//alert(newHeight);
		/*if(	$(this).children().children(".sSub").id != 'newID')
		   {
			   alert("ddd");
		$(this).animate({top: newHeight}, 440, function() {
			$(this).children().children(".sSub").show();
		}).stop(true, true);
	        $(this).children().children(".sSub").attr('id', 'newID')
		   }
		   else
		   {*/
		 //  $(".sNavWrap").css("top",80);
		// alert(  $(this).children().children(".sSub").height());
			  // alert(newHeight);
			 //  $(this).animate({top: newHeight},440, function() {
		//	$(this).children().children(".sSub").slideToggle();
		//}).stop(true, true);
			/*   }*/
		/*$(this).children().children(".sSub").slideUp(440);
	},function(){
      	$(this).animate({
			top: '410px'
		}, 440, function() {
			$(this).children().children(".sSub").hide();
		}).stop(false, true);
		$(this).children().children(".sSub").slideDown(400);*/
		
		//	$(this).children().children(".sSub").slideUp(440);

    });
	
	
	
}); // END THE DOM


/*
IMPORTANT FUNCTION DO NOT DELETE 
	var opened = false;
$(".sNavWrap").click(function(){
		if(opened){
			$(".sNavWrap").animate({"top": "+=149px"}, "slow");
		}else{
			$(".sNavWrap").animate({"top": "-=149px"}, "slow");
		}
		$(".sSub").slideToggle("slow");
$(".sNavWrap .close").toggle();

		opened = opened ? false : true;

*/




$(document).ready(function(){
	/*****************************************************************************
		dealing with the navigation
	*****************************************************************************/	
	
	$(".sSub2").each(function(){
		var newWidth = $(this).width();
		$(this).prev().css("width",newWidth);
		$(this).css("display","none");
		//alert( 300 - $(this).height() );
	});
	// Deal with Sub Nav
	//$(".sNavWrap").click(function(){
								  
								  
	var opened = false;
$(".sNavWrap2").click(function(){
		if(opened){
			//$(".sNavWrap").css("background-image","images/up.png");
			//$("#myImage").attr("src", "path/to/newImage.jpg");
			// $(this).find(".sd").text("+");
			$('#sd2').css('background-image', 'url(images/up.png)');
			$(".sNavWrap2").animate({"top": "+=145px"}, "slow");
		}else{
		//	$(this).find(".sd").text("-");
			//$(".sNavWrap").css("background-image","images/dn.png");
		//	$("#myImage").attr("src", "path/to/newImage.jpg");
		$('#sd2').css('background-image', 'url(images/dn.png)');
			$(".sNavWrap2").animate({"top": "-=145px"}, "slow");
		}
		$(".sSub2").slideToggle("slow");
$(".sNavWrap2 .close").toggle();

		opened = opened ? false : true;

    });
	
	
	
}); // END THE DOM




$(document).ready(function(){
	/*****************************************************************************
		dealing with the navigation
	*****************************************************************************/	
	
	$(".sSub3").each(function(){
		var newWidth = $(this).width();
		$(this).prev().css("width",newWidth);
		$(this).css("display","none");
		//alert( 300 - $(this).height() );
	});
	// Deal with Sub Nav
	//$(".sNavWrap").click(function(){
								  
								  
	var opened = false;
$(".sNavWrap3").click(function(){
		if(opened){
			//$(".sNavWrap").css("background-image","images/up.png");
			//$("#myImage").attr("src", "path/to/newImage.jpg");
			// $(this).find(".sd").text("+");
			$('#sd3').css('background-image', 'url(images/up.png)');
			$(".sNavWrap3").animate({"top": "+=145px"}, "slow");
		}else{
		//	$(this).find(".sd").text("-");
			//$(".sNavWrap").css("background-image","images/dn.png");
		//	$("#myImage").attr("src", "path/to/newImage.jpg");
		$('#sd3').css('background-image', 'url(images/dn.png)');
			$(".sNavWrap3").animate({"top": "-=145px"}, "slow");
		}
		$(".sSub3").slideToggle("slow");
$(".sNavWrap3 .close").toggle();

		opened = opened ? false : true;

    });
	
	
	
}); // END THE DOM


/*
$(document).ready(function(){

	$(".sSub3").each(function(){
		var newWidth = $(this).width();
		$(this).prev().css("width",newWidth);
		$(this).css("display","none");
		//alert( 300 - $(this).height() );
	});
	// Deal with Sub Nav
	$(".sNavWrap3").hover(function(){
		// I Loath you IE fix
		if ($.browser.msie && $.browser.version.substr(0,1)<8){var minusPX = "33";}
		else{var minusPX = "32";}
		
		var newHeight = (440 - $(this).children().children(".sSub3").height() ) - minusPX +"px";
		//alert(newHeight);
		$(this).animate({
			top: newHeight
		}, 440, function() {
			$(this).children().children(".sSub3").show();
		}).stop(true, true);
		$(this).children().children(".sSub3").slideDown(440);
	},function(){
      	$(this).animate({
			top: '410px'
		}, 440, function() {
			$(this).children().children(".sSub3").hide();
		}).stop(true, true);
		$(this).children().children(".sSub3").slideUp(440);
    });
	
	
	
}); // END THE DOM

*/
/*****************************************************************************
	dealing with the rotating images
*****************************************************************************/	
function mainImageFlow()
{
	// set the opacity of image(s) to 0 (can't see them)
	$('#mainImageBox img').css({opacity: 0.0});
	// set the first image to be seen
	$('#mainImageBox img:first').css({opacity: 1.0});
	// set the function for 'mainImageGallery' to run every 3 seconds.
	setInterval('mainImageGallery()',100000000000000);
	 
}
function mainImageGallery()
{
	// if the images have no class (class='show') then show the first one anyway
	var current = ($('#mainImageBox img.show')?  $('#mainImageBox img.show') : $('#mainImageBox img:first'));
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('sNav'))? $('#mainImageBox img:first') :current.next()) : $('#mainImageBox img:first'));	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 100000000000000);
	//Hide the current image
	current.animate({opacity: 0.0}, 100000000000000)
	.removeClass('show');
	$("#subNavBox").removeClass('show');
}



function mainImageFlow2()
{

  // set the opacity of image(s) to 0 (can't see them)
	$('#mainImageBox img').css({opacity: 0.0});
	// set the first image to be seen
	$('#mainImageBox img:first').css({opacity: 1.0});
	// set the function for 'mainImageGallery' to run every 3 seconds.
	setInterval('mainImageGallerynew()',6000);
}



function mainImageFlow3(d)
{
	$('#sd').css('background-image', 'url(images/dn.png)');
	$(".sNavWrapindex").animate({"top": "-=142px"}, "slow");
		
	$(".sSubindex").slideToggle("slow");
    $(".sNavWrapindex .close").toggle();

			//alert(d);
		

}


function mainImageGallerynew()
{
	// if the images have no class (class='show') then show the first one anyway
	var current = ($('#mainImageBox img.show')?  $('#mainImageBox img.show') : $('#mainImageBox img:first'));
	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('sNav'))? $('#mainImageBox img:first') :current.next()) : $('#mainImageBox img:first'));	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	$("#subNavBox").removeClass('show');
}


