$(document).ready(function(){
	
	
	// Force div width for floats
	function resize_boxes(){
		var set_width = (Math.floor( ($(window).width()-70) /155)*155) - 20;
		if(set_width < 755){
			set_width = 755;
		}
		$('.force_width').width(set_width);
	}
	
	$(window).resize(function() {
		resize_boxes();
	});
	
	resize_boxes();
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Rollovers for images
	
	$('.roll').hover(function(){
		$(this).attr("src", $(this).attr("src").replace(/_off/, '_on'));
	},function(){
		$(this).attr("src", $(this).attr("src").replace(/_on/, '_off'));
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Hover for Image
	
	$("#work div.item").hover(
		function () {
			id = $(this).find('.smoke').attr('group');
			
			$('.'+id).find('.smoke').stop(true, true).fadeTo(200, 0.0);
			$('.'+id).find('.info').stop(true, true).fadeTo(200, 1.0);
		}, 
		function () {
			id = $(this).find('.smoke').attr('group');
			
			$('.'+id).find('.smoke').delay(200).fadeTo(200, 1.0);
			$('.'+id).find('.info').delay(200).fadeTo(200, 0.0);
		}
	);
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Hover for Rows
	
	$('.result').hover(function(){
		$(this).css("background-color", "#e9eaea");
	},function(){
		$(this).css("background-color", "#f2f4f4");
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Search Field Actions
	
	$("#search").focus(function(){	
		if($(this).val() == 'Search'){
			$(this).val('');
		}
	});
	
	$("#search").blur(function(){
		if($(this).val() == ''){
			$(this).val('Search');
		}
	});
	
	$("#search").keydown(function(event){
		if(event.keyCode == 13){
			needle = $(this).val();
			document.location.href='http://domain.com/search/'+needle+'/';
		}
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Toggle Item (FAQ)
	
	$(".question").click(function () {
		$('#answer_'+this.id).slideToggle(200);
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// For slideshow
	
	$('#slideshow').cycle({ 
		timeout: 10000,
		delay:   2000, 
		speed:   2000 
	}); 
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// AJAX Log in
	
	function log_in(){
		username = $('#site_username').val();
		password = $('#site_password').val();
		
		$.ajax({
			type: "POST",
			url: "http://domain.com/inc/login.php",
			data: "username="+username+"&password="+password,
			success: function(msg){
				if(msg == 'success'){
					//window.location="index.php";
					//alert('You have successfully logged in!');
					window.location.reload(true);
				} else {
					alert('Incorrect: Please check your username or password.');
				}
			}
		});
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
});

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

