
function stretchInputs() {
	$('.stretch-x').each(function(){
		var newWidth = $(this).parent().width() - $(this).outerWidth() + $(this).width();
		$(this).css({'margin-right':0,'width':newWidth});
	});
}


function makeSublist(parent,child,isSubselectOptional,childVal)
{
	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));

	var parentValue = $('#'+parent).attr('value');
	$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child).val(childVal).attr('selected','selected');

	$('#'+parent).change(function(){
		var parentValue = $('#'+parent).attr('value');
		$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
		
		if(isSubselectOptional) $('#'+child).prepend("<option value='none' selected='selected'> -- Select -- </option>");
		
		$('#'+child).trigger("change");
		$('#'+child).focus();
	});
}






$(document).ready(function(){

	makeSublist('child','grandsun', true, '');	
	makeSublist('parent','child', false, '1');	

	
	base_uri=$('#uri').val();

stretchInputs();

	// Hide all subfolders at startup
	$(".php-file-tree").find("UL").hide();
	
	$(".pft-directory A").click( function() {
		$(this).parent().find("UL:first").slideToggle("medium");
		if( $(this).parent().attr('className') == "pft-directory" ) return false;
	});

  $('a.a-links').click(
        function()
        {
  toLoad = $(this).attr('href');  
  		$('#content').hide('fast');
		 $.ajax({ 
                url: toLoad, 
                dataType: "text/html", 
                success: 
                    function(html)
                    {
					$('#content').show('normal');
                        $("#content").replaceWith(html); 
						//alert(toLoad);
                    }
                }
            
            ); 
        }
    );


		
//Navi
sY = 24; 
fY = 185;
animate (fY);

$("#slide .sub").click(function() {
	if (this.className.indexOf('clicked') != -1 ) {
		animate(sY);
		$(this)			.removeClass('clicked')
						.css("background", "#605D5C url("+base_uri+"content/gfx/out.gif) no-repeat 5px 8px")
						.css("color", "white");
		}
		else {
		animate(sY);
		$('.clicked')	.removeClass('clicked')
						.css("background", "#605D5C url("+base_uri+"content/gfx/out.gif) no-repeat 5px 8px")
						.css("color", "white");
		$(this)			.addClass('clicked');

		animate(fY);
		//alert($(this).children("div").height());
	}
});

function animate(pY) {
$('.clicked').animate({"height": pY + "px"}, 500);
}

$("#slide .sub")		.hover(function(){
$(this)					.css("background", "#605D5C url("+base_uri+"content/gfx/down.gif) no-repeat 5px 8px")
						.css("color", "white");
},function(){
if (this.className.indexOf('clicked') == -1) {
$(this)					.css("background", "#605D5C url("+base_uri+"content/gfx/out.gif) no-repeat 5px 8px")
						.css("color", "white");
}
});


	$.easy.tooltip();
	$.easy.popup();

	$("#slider").easySlider({
		prevText:'Zurück',
		nextText:'Weiter',
		orientation:'vertical'
	});

    $('a[href~="http://"]:not([href~=base_uri])').attr({target: "_blank"}).
    addClass("external");


});


