
// When the document is ready
$(document).ready(function() {
	//$(document).pngFix();
	
	// Compose path to flash movie:
	var flashMovieSource = JQueryBaseHref + 'flash/header.swf';
	if(typeof headerXmlSource != 'undefined') {
		flashMovieSource += '?def=' + headerXmlSource;
	}
	
	// Show flash in banner:
	/**/
	if(navigator.userAgent.indexOf("Win") != -1) {
		document.getElementById('banner').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="900" height="206" id="site" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" /><param name="movie" value="'+ flashMovieSource +'" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><embed src="'+ flashMovieSource +'" quality="high" bgcolor="#FFFFFF" width="900" height="206" name="site" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	} else {
		$('#banner').flash({
			src : flashMovieSource,
			width : 900,
			height : 206,
			wmode : 'transparent'
		});
	}
	
	// Do carousel
	$("#carousel").fadeIn(300).jcarousel();
	
	// Create lightbox interface out of all links that carry the 
	// "lightbox" class:
	$('a.lightbox').lightBox();
	
	// Do focus/blur of input fields
	$('input[@type=text], textarea').focus(function() {
		showInputFrame($(this));
	});
	
	$('input[@type=text], textarea').blur(function() {
		hideInputFrame($(this));
	});
});

function showInputFrame($inputControl) {
	// Local variables
	var offset, tWidth, tHeight;
	
	// Get the input control's position on the page:
	offset = $inputControl.offset();
	
	// Target width + height of the frame:
	tWidth  = $inputControl.width();
	tHeight = $inputControl.height() + 6;
	
	// Create frame, if not existing yet:
	if(! document.getElementById('inputControlFrame')) {
		//$('body').append('<div id="inputControlFrame" style="display: none"></div>');
		$('body').append('<div id="inputControlFrame"></div>');
		$('#inputControlFrame').css({
			width: tWidth + 'px',
			height: tHeight + 'px',
			position: 'absolute',
			top: (offset.top - 20),
			left: offset.left,
			border: '2px solid #acbe29',
			opacity: 0
		});
	}
	
	// Stop any ongoing animation:
	$('#inputControlFrame').stop();
	
	// We animate the frame, adjusting position and size
	$('#inputControlFrame').animate({ 
        width : tWidth  + 'px',
        height : tHeight + 'px',
        top : offset.top,
        left : offset.left,
        opacity: 1
	}, 200);
}

function hideInputFrame($inputControl) {
	$('#inputControlFrame').stop();
	$('#inputControlFrame').fadeOut(500);
}
