$(document).ready(main);

function main()
{

	registerEvents();
	resizeIframe();
}

function getIframeUrl()
{

	
	return "http://tydi.nl/site/index.php";
}

function registerEvents()
{
	$(window).resize( function() {resizeIframe();} );
	$("#back").bind("click",function(){window.history.back();});
	$("#arrow").bind("click",onArrow);

	$("#close").bind("click", function(){window.location.href = "http://tydi.nl/site/index.php";});
	
}

var arrawState = "up";

function onArrow()
{
	if( arrawState == "up" ) onDownArrow();
		else onUpArrow();
}

function onDownArrow()
{
	
	$("#toolbar").animate(
		{
			height: 70
		}, 1000, "swing", function()
			{
				$("#arrow").css("background-position", "-32px 0");
				resizeIframe();
				arrawState = "down";
			});
}

function onUpArrow()
{
	$("#toolbar").animate(
		{
			height: 18
		}, 1000, "swing", function()
			{
				$("#arrow").css("background-position", "-16px 0");
				resizeIframe();
				arrawState = "up";
			});
}

function onSearch()
{
	var qs = $("#qs").val();
	$('iframe').attr('src', 'http://www.google.com/search?q='+qs);	
}


function resizeIframe()
{
	$("#iframe").height( WindowHeight() - getObjHeight(document.getElementById("toolbar")) );
}

function WindowHeight()
{
	var de = document.documentElement;
	return self.innerHeight || 
		(de && de.clientHeight ) ||
		document.body.clientHeight;
}

function getObjHeight(obj)
{
	if( obj.offsetWidth )
	{
		return obj.offsetHeight;
	}		
	return obj.clientHeight;
}



