/*
JSTarget function by Roger Johansson, www.456bereastreet.com
*/
var JSTarget = {
	init: function(att,val) {
		if (document.getElementById && document.createElement && document.appendChild) {
			var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
			var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
			var arrLinks = document.getElementsByTagName('a');
			var oLink;
			var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
			for (var i = 0, il = arrLinks.length; i < il; i++) {
				oLink = arrLinks[i];
				if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
					oLink.onclick = JSTarget.openWin;
				}
			}
			oWarning = null;
		}
	},
	openWin: function(e) {
		var event = (!e) ? window.event : e;
		if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
		else {
		    var oWin = window.open(this.getAttribute('href'), '_blank');
			if (oWin) {
				if (oWin.focus) oWin.focus();
				return false;
			}
			oWin = null;
			return true;
		}
	}
};

reflectionInit = function() {
	$('#ContentRight.gallery img').reflect( {height: '0.45', opacity: '0.3'} );
}

		

$(function() {
 
	$(document).ready(function(){
		
		// gallery list scroll
		$("div.windowg").scrollable({
			size: 5,
			items: 'div',
			prev: '.slideLeft',
			next: '.slideRight',
			speed: 200,
			scrollSpeed: 100,
			easing: 'swing',
			clickable: true,
			keyboard: false
		});	
		
		// gallery thumbnails width
		$("#galleryscroll ul").width(($("#galleryscroll").find('li').length*127)+'px');

		// gallery lightbox
		$('.gallery .thumbs li a').lightBox({	
			imageLoading: 'i/mediaunio_loading.gif',
			imageBtnClose: 'i/lightbox_close.png',
			imageBtnPrev: 'i/lightbox_prev.png',
			imageBtnNext: 'i/lightbox_next.png',
			txtImage: '',
			txtOf: ' / ',
			navHeight: 80
		});			

		// download scroll
		var windowdSize = 3;
		$("#sajto div#ContentRight.nosubmenu, div#ContentRight .members").each(function(){ windowdSize = 4; });
		$("#mediatamogatok div#ContentRight.nosubmenu").each(function(){ windowdSize = 6; });
		$("div.windowd").not('#mediatamogatok div.windowd, .members div.windowd').scrollable({
			size: windowdSize,
			items: 'ul',
			prev: '.slideLeft',
			next: '.slideRight',
			speed: 200,
			scrollSpeed: 100,
			easing: 'swing',
			clickable: true
		});
		
		$('#mediatamogatok div.windowd, .members div.windowd').scrollable({
			size: windowdSize,
			items: 'div.scrollable',
			prevPage: '.slideLeft',
			nextPage: '.slideRight',
			speed: 400,
			easing: 'swing',
			clickable: false
		});
		
		// contact
		$("#Header dl.contact dt a").click(function() {
			$(this).blur();
			$("#Header dl.contact").animate({left: '490px'},400);
			$("#Header dl.contact dd").slideDown('slow');
		});
		
		JSTarget.init("rel", "external");
		
		/*@cc_on if (false) { @*/
		reflectionInit();
		/*@cc_on } @*/		
							   
	})
});







(function(jQuery) {

	var options;
	
	var HoverScroller = function( element ){
		this.container = element;
		this.element = element.find(options.items);
		if (this.container.outerHeight({margin:true})<this.element.outerHeight({margin:true})) {
			var that = this;	
			this.container.mousemove(function(e){
				jQuery(e).stopEvent();
				that.over(e)
			}); 
		}
	}
		
	HoverScroller.prototype.over = function(e){
		var ratio = ((e.clientY - this.element.offset().top) / this.element.height());
		var t = (this.element.height() - this.container.height()) * ratio * -1.05;
		if (t>-5) t = 0;
		this.element.css({
			top: t
		});
	}	

	function init( i, obj ){
		new HoverScroller( jQuery(obj) );
	}
	
	jQuery.prototype.hoverScroll = function( opts ) { 
		options = opts;
		this.each(init);
		return this; 		
	};
			
	
})(jQuery);