var reg = new RegExp("^(http|https)://([^/]+)(.*)$","g");
var tab_reg = reg.exec(window.document.location.href);
var tab_path = tab_reg[3].split('#');
var SERVER_NAME = tab_reg[2];
var DOMAIN_NAME = SERVER_NAME.replace('localhost.', '');
var DOMAIN_NAME = DOMAIN_NAME.replace('beta.', '');
var DOMAIN_ANCHOR = tab_path[1];
var LANGUAGE = $('meta[http-equiv=content-language]').attr('content');
var MINWIDTH = 980;
var	MINHEIGHT = 600;

$(document).ready(function() {
	/*==========================================================================
				* SLIDESHOW *
	==========================================================================*/
	var playAutoSlideshow = true;
	var slideshowAllLoaded = false
	var slideShow = new SlideShow({
		containerId:'slideshow', //Required
		itemIdPrefix:'img_',
		timerBetweenSlide:5000, 
		timerFadeTransition:1000, 
		itemClassName:'slideme',
		playAuto:playAutoSlideshow,
		minWidth:MINWIDTH,
		minHeight:MINHEIGHT,/**/
		onAfterFirstLoad:function() {
			if ($.browser.msie && $.browser.version.slice(0,1) <= 8) {
				/*$('#loaderPanel').css('display', 'none');
				$('#header').css('display', 'block');
				$('#footer').css('display', 'block');*/
			}
			else {
				/*$('<img />').attr('src', '/images/main_bg.png').load(function() {
					$('#loaderPanel').css('display', 'none');
					$('#header').fadeIn('slow');
					$('#footer').css('display', 'block');
					$('#footer').css('bottom', '-70px');
					$('#footer').animate({bottom: '0px'}, 300);
				});*/
			}
		},
		onBeforeLoad:function() {
			;
		}, 
		onAfterLoad:function() {
			/*actionResize(MINWIDTH, MINHEIGHT);
			slideshowAllLoaded = true;
			$('#slideshow-cpt').html('1.'+slideShow.itemNb);
			$('#slideshow-nav').fadeIn('slow');*/
		},
		onBeforeSlide:function(position) {
			//$('#slideshow-cpt').html(position+'.'+slideShow.itemNb);
			if(!slideShow.isPlaying() && playAutoSlideshow) slideShow.play();
		} ,
		onAfterSlide:function(position) {
			;
		} 
	});
	/*==========================================================================
				* RESIZE *
	==========================================================================*/
	function actionResize() {
		windowWidthMin = MINWIDTH;
		windowHeightMin = MINHEIGHT;
		
		windowWidth = $(window).width();
		windowHeight = $(window).height();
		
		if(windowWidth <= windowWidthMin) {			
			windowWidth = windowWidthMin;
			$('html').css('overflow-x', 'auto');
		} else {
			$('html').css('overflow-x', 'hidden');
		}
		
		if(windowHeight <= windowHeightMin) {
			windowHeight = windowHeightMin;
			$('html').css('overflow-y', 'auto');
		} else {
			$('html').css('overflow-y', 'hidden');
		}
		
		$('body').css('width', windowWidth);
		$('html').css('width', windowWidth);
		$('html').css('height', windowHeight);
	
		slideShow.resize(windowWidth, windowHeight);
	}
	
	$(window).resize(function(){ 
        actionResize();
    });
	
	actionResize();
});
