// JavaScript Document
$(function()
	{
	
		
		//Round corners
		$('#contentarea').corner();
		$('.tab').corner('top');
		$('#contactus').corner();
		//$('#thenews').corner();
		//set default easing
		jQuery.easing.def = "easeOutQuad";
		
		//make accordian pretty
		$("#accordion").accordion();
		
		//check for iphone
		var agent1=(navigator.userAgent.toLowerCase()); 
		var is_iphone = (agent1.indexOf('iphone')!=-1);
		var is_firefox = (agent1.indexOf('firefox')!=-1);
		
		if(is_firefox)
			$('.tab').css('font-size','90%');
			
		
		

		//setup javascript elements on page
		setupPage(whichpage, is_iphone);
		
		//setTimeout("screenshotfade();", 4000);
	
		
		
		$('#testcycle').cycle({ 
			fx:      'scrollLeft', 
			speed:    500, 
			timeout:  4000 
		});

		
	  
	});
	
	function setupPage(whichpage, is_iphone)
	{
		
		//console.log(whichpage);
		if(whichpage >= 0)
			$('#buttonarea' + whichpage).addClass("selected");
		
		
		if(!is_iphone)
		{
			$('#buttonarea' + 1 ).hover(function(){animateup('#buttonarea' + 1);}, function(){animatedown('#buttonarea' + 1);});
			$('#buttonarea' + 2 ).hover(function(){animateup('#buttonarea' + 2);}, function(){animatedown('#buttonarea' + 2);});
			$('#buttonarea' + 3 ).hover(function(){animateup('#buttonarea' + 3);}, function(){animatedown('#buttonarea' + 3);});
			$('#buttonarea' + 4 ).hover(function(){animateup('#buttonarea' + 4);}, function(){animatedown('#buttonarea' + 4);});
			$('#buttonarea' + 5 ).hover(function(){animateup('#buttonarea' + 5);}, function(){animatedown('#buttonarea' + 5);});
			$('#buttonarea' + 0 ).hover(function(){animateup('#buttonarea' + 0);}, function(){animatedown('#buttonarea' + 0);});
		
			$('#icon1' ).hover(function(){animateup('#buttonarea' + 1);}, function(){animatedown('#buttonarea' + 1);});
			$('#icon2').hover(function(){animateup('#buttonarea' + 2);}, function(){animatedown('#buttonarea' + 2);});
			$('#icon3').hover(function(){animateup('#buttonarea' + 3);}, function(){animatedown('#buttonarea' + 3);});
			$('#icon4').hover(function(){animateup('#buttonarea' + 4);}, function(){animatedown('#buttonarea' + 4);});
			
			
				
		
			for(var i=0; i<=5; i++)
			{
				if(i != whichpage)
				{	
					$('#buttonarea' + i).css('top', '10px');
					
				}
				
				
				
			}
		
		}
			
			
		
		
	}
		
	function validateForm()
	{
		
		$("#contactform").validate();
	
	}
	
	function animateup(what) 
	{
		if(what != ("#buttonarea" + whichpage))
			$(what).stop().animate({top:0}, menuspeed);
		
	}
		
	function animatedown(what)
	{
		if(what != ("#buttonarea" + whichpage))
			$(what).stop().animate({top:10}, menuspeed);
		
	}
	
/*
	function screenshotfade()
	{
		numScreenShots = screenshots.length;
		
		if(current == numScreenShots)
			current = 0; 
		
		//$('#screenshot').fadeOut("slow");
		$('#screenshot').animate({ opacity: 0.0	}, 2000);

					
		
		//alert(numScreenShots);
		setTimeout("screenshotfade2()", 2000);
	}
	
	
	function screenshotfade2()
	{
		
		$('#screenshot').attr("src","http://kvapps.com/res/images/" + screenshots[current] + "");
		//$('#screenshot').fadeIn("slow");
		$('#screenshot').animate({ opacity: 1.0 }, 2000);
		
		current++;
			
		
		//alert(numScreenShots);
		setTimeout("screenshotfade()", 5000);	
		
	}
	
	
	*/