// JavaScript Document

var imgID = 0;
function animate_ad(){
		
	switch(imgID){
		case 0: imgID = 1; break;
		case 1: imgID = 0; break;
	}
	
	//switch the ads
	if(imgID){
		$("#ad_roller1").fadeOut("slow");
		$("#ad_roller2").fadeIn("slow");
	}
	else{
		$("#ad_roller2").fadeOut("slow");
		$("#ad_roller1").fadeIn("slow");
	}
	
	setTimeout("animate_ad()", 15000);
}

$(document).ready(function(){
	
	var dialogOpts = {
		autoOpen: false,
		modal: true
	};
	//animate the image in the ad space
	setTimeout ( "animate_ad()", 15000 );
	
	$("#message").dialog( dialogOpts );
	$(":submit").hover(
		function() {
			$(this).addClass('ui-state-hover');
			$(this).removeClass('ui-state-default');
		},
		function() {
			$(this).addClass('ui-state-default');
			$(this).removeClass('ui-state-hover');
		}
	);
	
	$("li").hover(
		function() {
			$(this).addClass('nav_hover');
		},
		function() {
			$(this).removeClass('nav_hover');
		}
	);
	
	$("input, textarea").livequery("focus", function(){
		$(this).removeClass('ui-state-content');
		$(this).addClass('ui-state-active');
	});

	$("input, textarea").livequery("blur", function(){
		$(this).removeClass('ui-state-active');
		$(this).addClass('ui-state-content');
	});
	
	//scroll up the ad window
	$("#advertisement").animate({
		left:800
	});
	/*
	$(".nav_none A").live("click", function(e){
		e.preventDefault();
		var id = $(this).attr("id");
		$("#portfolio_projects").fadeOut("slow", function(){
			$(this).load('/portfolio/page.php?id=' + id, function(){
				$("#portfolio_projects").fadeIn("slow");
			});
		});
	});
	*/
	$(".example A").live("click", function(e){
		e.preventDefault();
		var id = $(this).attr("id");
		
		$("#message").load("/portfolio/?a=ex&id=" + id, function(){
			$(this).fadeIn("slow");
		});
	});
});