$(window).ready(function() {
		 
	if($("#pageright").length > 0  && $(".size").length > 0 ) {
		var pH = $("#pageright").height();
		var pW = $("#pageright").width();
		
		if(pH > pW) {
			$(".size").css({ "height" : pH + "px", "width" : pH + "px" });
		} else {
			$(".size").css({ "height" : pW + "px", "width" : pW + "px" });
		}
	}
	
	if($("#accordion").length > 0 ) {
		$("#accordion").accordion({ active: false, autoHeight: false, change: function(event, ui) { 
				var innerH = $(".inner").height();
				$(".inner").animate({ "margin-top" : Math.round(innerH / 2)*-1 },300);																		
			} 
		});
	}
	
	if($("#accordion2").length > 0 ) {
		$("#accordion2").accordion({ active: 0, autoHeight: false, change: function(event, ui) { 
				var innerH = $(".inner").height();
				$(".inner").animate({ "margin-top" : Math.round(innerH / 2)*-1 },300);																		
			} 
		});
	}
		
		
	if($(".inner").length > 0 ) {
		 var innerH = $(".inner").height();
		 $(".inner").css({ "margin-top" : Math.round(innerH / 2)*-1 });
		 }
});




$(window).load(function() {


 	if($("#gallerySlider").length > 0 ) {
		var gsH = $('#gallerySlider').height();
		var gsScrollH = $('#gallerySlider > div').height();
		var ghStep = Math.round(gsScrollH / gsH);
		if(gsH < gsScrollH) {
			$("#gallerySlider").mousewheel(function(objEvent, dir){
			    if (dir > 0){
				   slidenow(1);
				}
			    else if (dir < 0){
				   slidenow(-1);
				} 
			});
			$(".dottop").click(function(){slidenow(1);});
			$(".dotbot").click(function(){slidenow(-1);});
			$(".dotbot").show();	
		} 
		
		var sliding = false;
		
		slidenow = function(a) {
			if(!sliding) {	
				sliding = true;
				var istPos = parseInt($('#gallerySlider > div').css("margin-top"));
				//var newPos = istPos + (a*Math.floor((gsScrollH-gsH)/ghStep));
				
				if(a == -1 || a == 1) {
					var newPos = istPos + (132*a);
				} else {
					var jumper = $("."+a).offset().top;
					var newPos = (jumper * -1) + istPos;
				}
				//alert(newPos-gsH+":"+gsScrollH)
				if(-gsScrollH <= (newPos) && newPos <= 0) {
					$(".dottop").show();
					$(".dotbot").show();
					$('#gallerySlider > div').animate({
						"margin-top" : newPos
					  }, 250, function() {
						sliding = false;
						var newIstPos = parseInt($('#gallerySlider > div').css("margin-top"));
						if(newIstPos > -10) {
							$(".dottop").hide();
						}
						//alert(gsScrollH +":"+(newIstPos-gsH-20));
						if(-gsScrollH >= (newIstPos-132)) {
							$(".dotbot").hide();
						}
					  });					
				} else {
					sliding = false;						
				}
			}
		}
		
		$('#gallerySlider > div > a').click(function(){
			$("#bigpic").html("&nbsp;");
			var picurl = this.href;
			var pictitle = this.title;
			var newPic = '<img src="'+picurl+'" />';
			if(pictitle) {
				var newTitle = '<div>'+pictitle+'</div>';
			} else {
				var newTitle = '';			
			}
			$("#bigpic").html(newPic + newTitle);
			$("#bigpic").css({ "opacity" : 0 });
			var bindpics = setInterval(function() {
				var bpH = $("#bigpic").height();
				if(bpH > 50) {
					clearInterval(bindpics);
					$("#bigpic").animate({ "opacity" : 1 , "margin-top" : Math.round(bpH / 2)*-1 },300);
					$("#gallerybg").animate({ "opacity" : .2 },300);
				}
			},100);
			return false;
			});
		
		
		$('.influenceslider').mouseover(function(){
			var posname = $(this).html();	
			slidenow(posname);
		});
	}
		
	$("#logo").click(function(){ location.href="index.htm"; });

});















