﻿function pause(ms)
{
	var now = new Date();
	var exitTime = now.getTime() + ms;
	while (true)
	{
		now = new Date();
		if (now.getTime() > exitTime) return;
	}
} 


function add_sth_done(loc)
{
	pause(1000);
	$.prettyPhoto.close();
	if ( loc ) document.location = loc;
}



$(document).ready(function(){

	
		$('#dormansOpera').fbWall({
								  id:'100002336321535',
									accessToken:'206158599425293|8cf2cef365801adb96aa007f.1-100002336321535|-qFPE1188OuHxfbMYMxW2_NdiTU',
								  avatarAlternative:        'avatar-alternative.jpg',
								  avatarExternal:           'avatar-external.jpg',
								  max:                      20,
								  showComments:             true,
								  showGuestEntries:         true,
								  timeConversion:           24,
								  useAvatarAlternative:     false,
								  useAvatarExternal:        false						
								  });
		$('#clubnation').fbWall({
								id:'CLUBNATION1',
								accessToken:'206158599425293|1df31a8727c3377cea29f485.1-100000221135225|YRxEUQA5gDlA4yFvGCBI3IMYO8U',
								showGuestEntries:true,
								showComments:true,
								max:30,
								timeConversion:240
								});


		$(".monthsHolder a, .roundLink").corner("7px");
//		$(".loginbar").corner("top cc:#333 0px").corner("bottom cc:#fff 10px");



		$('.bgImage').delay(0).fadeIn(1000);




		$('.slideshow, .slideshowTop').cycle({ 
			fx:      	'fade',
		    speed:    	1000,
			timeout:  	4000,
			sync:   	0,
		    next:   '#nextSlide', 
		    prev:   '#prevSlide',			
			pause:  	1 
		});


		$('.leftNewsBar').cycle({ 
			fx:      	'scrollUp',
			timeout:  	4000,
			speed:    	1000,
			sync:		0,
			easing: 'backinout', 
//			next:   '.leftFeedbackBar', 
			pause:  	1 
		});		


		$('.leftCommentsBox').cycle({ 
			fx:      	'scrollLeft',
//			timeout:  	4000,
//			speed:    	1000,
//			random:  1,
			sync:		0,
			easing: 'backinout', 
//			next:   '.leftFeedbackBar', 
			pause:  	1 
		});		



$('.LeftOneComment p, .slideshow img, .slideshowTop img, .leftNewsBar img').tooltip({
	track: true,
	delay: 0,
	showURL: false,
	showBody: " - ",
	fade: 250
});







		$("ul.sf-menu").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    27,   // maximum width of sub-menus in em units 
            extraWidth:  1,    // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
			delay:         100
			}).superfish();  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason. 


		$(".monthsHolder a, .fadeLink").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to 100% when the page loads
		$(".monthsHolder a, .fadeLink").hover(function(){
		$(this).fadeTo("fast", 0.4); // This should set the opacity to 60% on hover
		},function(){
		$(this).fadeTo("slow", 1.0); // This should set the opacity back to 1000% on mouseout
		});





	$('.contactmessage, #message').prettyComments({animate: true, maxHeight:250});



/*
//*Nice hover things:

	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(100);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(100);			
		}
	);





	//$("#afterhover").slideUp({ duration: 1000, easing: method, complete: callback}); 

		/*
		$("#mouseout").hover(
			function(e){
				$("#afterhover").slideDown({ duration: 1000 }); 
			},
			function(){
				//$("#afterhover").slideUp({ duration: 1000 }); 
			}
		);
		
		$("#mouseout").click(
			function(e){
				$("#afterhover").slideDown({ duration: 1000 }); 
			}
		);

		$("#afterhover").hover(
			function(){},
			function(){
				$("#afterhover").slideUp({ duration: 1000 }); 
			}
		);
*/
		//$("#afterhover").slideUp({ duration: 1000 }); 
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
	})(jQuery);

            $(function(){
                $('.menuBar a')
                    .css( {backgroundPosition: "0px 10px"} )
                    .mouseover(function(){
                        $(this).stop().animate(
							 { backgroundPosition:"(9px 10px)"},
							 { queue: false,
							   duration: 300,
							   easing: 'easeOutElastic'
						})
                    })
                    .mouseout(function(){
                        $(this).stop().animate({backgroundPosition:"(0px 10px)"}, {duration:400, complete:function(){
                            $(this).css({backgroundPosition: "0px 10px"})
                        }})
                    })
            });







		$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});

});

//			var flashvars = {};
//			var params = {wmode: "transparent"};
//			var attributes = {};
//			swfobject.embedSWF("flash/inproject_bg.swf", "mybg", "950", "550", "9.0.0","expressInstall.swf", flashvars, params, attributes);

