function rs() {
	var be = jQuery('#brand-extension');
	var ct = jQuery('#contact');
			

	var bw = jQuery('body').width() * 1;
	if (bw < 1017) {
		bw = 1017;
	}
	be.css('left', (bw - 100) + 'px');
	ct.css('left', (bw - 100) + 'px');
}
window.onresize = function() {
	rs();
}


$(document).ready(function() {
	var pathname = window.location.pathname;
	if (pathname.match(/index.html$/)) {
		$('#content #contentclose').remove();
	}
	
	if (!$.cookie('faded')) {
		$("#wrapper").hide();
		$("#brand").animate({"left": "0"}, 800);
		$("#advert").animate({"left": "100"}, 800);
		$("#brand-extension").animate({"right": "0"}, 800);
		$("#contact").animate({"right": "6"}, 800, function() {
			rs();
		});
		$('#wrapper').delay(800).fadeIn();
	} else {
		$("#brand").css({"left": "0px"});
		$("#advert").css({"left": "100px"});
		$("#brand-extension").css({"right": "0px"});
		$("#contact").css({"right": "6px"});
		rs();
	}
	$.cookie('faded', true);
	
	
	$("a[rel=fancybox]").fancybox({
		'titlePosition'		: 'outside',
		'overlayColor'		: '#dedd39',
		'padding'	    	: '3',
		'overlayOpacity'	: 0.9,
		'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? title : '') + '<span style="float: right;">' + (currentIndex + 1) + '/' + currentArray.length + '</span></span>';
		}
	});
	$("a[rel=youtube]").fancybox({ });
	$("a[rel=youtube]").click(function() {
        $.fancybox({
        	'titleShow'         : true,
        	'title'             : this.title,
	    	'titlePosition'		: 'outside',
			'overlayColor'		: '#dedd39',
			'padding'	    	: '3',
			'overlayOpacity'	: 0.9,
	        'width'             : 680,
	        'height'            : 495,
	        'href'              : this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
	        'type'              : 'swf',
	        'swf'               : {'allowfullscreen':'true', 'wmode':'transparent'},
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">' + (title.length ? title : '') + '<span style="float: right;">' + (currentIndex + 1) + '/' + currentArray.length + '</span></span>';
			}
        });
    }); 
});
