$(document).ready(function() {
	var rooturl = "/"
	// sidebar effects
	if($(".sidebar").length>0) {
		$(".sidebar h3 a").click(function() {
			$("a.active").removeClass("active");
			$(this).addClass("active");
			expand = $(this).parent().next();
			//if fix for slideDown images
			if($.browser.msie) {
				if($(".block:visible img").length>0) {
					$(".block:visible .framer").hide("fast", function() {
						$(".block:visible img, .block:visible .frames").hide("fast",function(){
							$(".block:visible").hide("fast",function() {
								expand.find(".frames, img, .framer").show();
								expand.show();							
							});	
						});
					});
				} else {
					$(".block:visible").hide("fast",function() {
						expand.find(".frames, img, .framer").show();
						expand.show();
					});	
				}

			}
			//normal slideup and down
			else {
				$(".block:visible").slideUp("slow", function() {
					expand.slideDown();
				});
			}
		});
		/*$(".frames a").hover(function() {
			$(this).append('<img src="'+rooturl+'img/interface/frame.gif" class="frame" />');
		}, function(){
			$(this).find(".frame").remove();
		});*/
	}
	
	// parts slide
	var totalParts = new Array();
	var currentPart = new Array();
	$(".parts").each(function() {
		partName = $(this).attr("id");
		$("#"+partName+"1").show();
		totalParts[partName] = $(this).find(".part").length;
		if(totalParts[partName]>1) $("a[class='gonext'][rel='"+partName+"']").show(); 
		currentPart[partName] = 1;
		//$("h1").append("asd"+partName+"'dan:"+totalParts[partName]);
	});
	$(".gonext").click(function() {
		changePart = $(this).attr("rel");
		if(currentPart[changePart]>0) { $("a[class='goprev'][rel='"+changePart+"']").show(); }
		if(currentPart[changePart]==totalParts[changePart]-1) { $("a[class='gonext'][rel='"+changePart+"']").hide(); }
		$("#"+changePart+currentPart[changePart]).fadeOut("slow",function() {
			currentPart[changePart]++;
			//$("h1").append("gidecegim yer:"+currentPart[changePart]);
			$("#"+changePart+currentPart[changePart]).fadeIn();
		});
	});
	$(".goprev").click(function() {
		changePart = $(this).attr("rel");
		$("a[class='gonext'][rel='"+changePart+"']:hidden").show();
		if(currentPart[changePart]==2) { $("a[class='goprev'][rel='"+changePart+"']").hide(); }
		$("#"+changePart+currentPart[changePart]).fadeOut("slow",function() {
			currentPart[changePart]--;
			$("#"+changePart+currentPart[changePart]).fadeIn();
		});
	});
	$(".gofirst").click(function() {
		changePart = $(this).attr("rel");
		$("a[class='goprev'][rel='"+changePart+"']").hide();
		$("#"+changePart+currentPart[changePart]).fadeOut("slow",function() {
			currentPart[changePart]=1;
			$("#"+changePart+currentPart[changePart]).fadeIn();
		});
	});
	
	// lightboxes
	$(".frames .part a, .image a, a[@rel*=lightbox]").lightbox();
	
	// diagonistics
	//$("h1").append(" test");
});