var flashvars = {xml_doc:'index.html'};
var params = {
  menu: "false",
  align: "middle"
};
var attributes = {
  id: "content",
  name: "content"
};
swfobject.embedSWF("golden3.swf", "content", "800", "494", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

//jQuery
$(function()
{
	$('div#content').show();
	//browser detection
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone =  ((agent.indexOf('iphone')!=-1));
	//is_iphone = true;

	if (is_iphone)
	{
		$('.description').css({'border-top': '1px solid #ddd', 'border-left': 0});
		//$('#josephsantoriButton, katjuneButton').hide();
	}
	else
	{
		$("#SWFobject_container").css({'overflow' : 'hidden'});
		$(".website .description").hide();
		$(".website").hover(function(){
				$('.description:hidden', this)
					.css({'position': 'relative', 'right': 200, 'margin-right': 0})
					.show('slide', {direction: 'right'}, 500)
					.css({'right': 0, 'margin-right': 200});
			},
			function () {
				$('.description', this).css({'right': 200, 'margin-right': 0}).hide('slide', {direction: 'right'}, 800);
			}
		);
	}

	init();

	$("a").hover(function(){
		$(this).css({opacity: 0});
		$(this).animate({opacity: 1}, 1000);
	}, function(){
		//noting
	});
	$("#websites_link").click(function(e)
	{
		init();

		if ( ! is_iphone)
		{
			$("#content").bind('mousemove', autoscroll);
			$("#websites").css({'margin-top': '0', 'position': 'absolute', 'top': 200, 'right' : 12});
		}
		$("#websites").show();
		e.preventDefault();
	});
	$("#contact_link").click(function(e)
	{
		init();
		$("#contact").show();
		e.preventDefault();
	});

});

function init() 
{
	$("#websites, #contact").hide();
	$("#content").unbind('mousemove', autoscroll);
}

function autoscroll(e) 
{
	var y = e.pageY-100;
	//$("#websites").stop();
	var scroll_margin = 185;

	if (y < scroll_margin) 
	{
		scroll_it(200);
	}
	else if (y < 494 - scroll_margin)
	{
		$("#websites").stop();
		old_top = 0;
	}
	else
	{
		scroll_it(-630)
	}	
}

var old_top;
function scroll_it(new_top) 
{
	if (old_top != new_top)
	{
		$("#websites").animate({top: new_top},  5000);
		old_top = new_top;
	}
}


