
//

$(document).ready(function(){

	//var href = $("li.home a").attr("href");
	//$('li.home a').removeAttr('href');
	//$('li.home a').addClass('disabled');

	//$("html").css("backgroundColor","#000");
	//$("body").css("display", "none");
	//$("body").fadeIn(1000);
	
	$(window).bind("unload", function() {});
	$("body").css({"overflow":"hidden" , "display":"none"})
	//$('body').css({display:'block', opacity:1});
	$("body").hide();
	$("body").fadeIn(1000);
	
	$("li.transition a, a.transition").click(function(event){
        event.preventDefault();
        linkLocation = this.href;
        $("body").fadeOut(500, redirectPage);
	});
 
    function redirectPage() {
        window.location = linkLocation;
    }
	
	//Ipad touch Home Start
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		$("#menu-menu li.home").bind('touchstart touchend', function(e) {	  
			e.preventDefault();
			$('div.home').stop().animate({
				bottom: '60px',
				height: '36px',
				boxShadow: '0 0 5px #000'
			});
			$('#products_menu').stop().animate({
				bottom:'0',
				height:'56px',
				boxShadow: '0 0 0px #000'
			});
		});
	}
	//Ipad touch Home End
	
	$("#menu-menu li.home, div.home").mouseover(function() {
	
		$('div.home').stop().animate({
			bottom: '60px',
			height: '36px',
			boxShadow: '0 0 5px #000'
		});
	}).mouseout(function() {
		$('div.home').stop().animate({
			bottom: '0',
			boxShadow: '0 0 0px #000'
		});
	});
	
	//Ipad touch Gallery Start
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		$(".menu li.gallery").bind('touchstart touchend', function(e) {
			e.preventDefault();
			$('#products_menu').stop().animate({
				bottom: '60px',
				height: '90px',
				boxShadow: '0 0 5px #000'
			});
			$('div.home').stop().animate({
				bottom: '0',
				boxShadow: '0 0 0px #000'
			});
		});
	}
	//Ipad touch Gallery End
	
	$('.menu li.gallery, #products_menu').mouseover(function() {
		$('#products_menu').stop().animate({
			bottom: '60px',
			height: '90px',
			boxShadow: '0 0 5px #000'
		})
	}).mouseout(function() {
		$('#products_menu').stop().animate({
			bottom:'0',
			height:'56px',
			boxShadow: '0 0 0px #000'
		});
	});
	
	// Stabileste latimea bandei de produs in functie de rezolutie
	
	var screen_width = $(document).width();
	var screen_height = $(document).height();
	var screen_height =  ((screen_height/2)-56) - 213;
	$('div.ngg-galleryoverview').css('top', screen_height+'px');
	var products_width = screen_width - 78;
	$('div#products').css('width', products_width+'px');
	var about_us_width = screen_width - 600;
	var about_us_height = screen_height - 200;
	$('div#about_us_content').css('width', about_us_width+'px' );
	var products_list = $('#menu-products').width();
	var to_scroll = products_list - products_width ;
	$(window).resize(function() {
		var screen_width = $(document).width();
		var products_width = screen_width - 78;
		var screen_height = $(document).height();
		var screen_height =  ((screen_height/2)-56) - 213;
		$('div#products').css('width', products_width+'px');
		$('div.ngg-galleryoverview').css('top', screen_height+'px');
		var about_us_width = screen_width - 600; 
		$('div#about_us_content').css('width', about_us_width+'px' );
		var products_list = $('#menu-products').width();
		var to_scroll = products_list - products_width ;
		var products_list = $('#menu-products').width();
		var to_scroll = products_list - products_width ;
	});	
	
	//Determina pozitia HOT DEALS $ NEW ARRIVALS
	var screen_height_a = $(document).height() - 56;
	var el_height = $('div#hot_deals div.page').height();
	var div_height = screen_height_a - 200 ;
	var margin_top = (screen_height_a - div_height)/2 -35;
	$('div#hot_deals .page').css('height', div_height+'px');
	$('div#hot_deals .page').css('top', margin_top+'px');
	$(window).resize(function() {
		var screen_height_a = $(document).height() - 56;
		var el_height = $('div#hot_deals div.page').height();
		var div_height = screen_height_a - 200 ;
		var margin_top = (screen_height_a - div_height)/2 -35;
		$('div#hot_deals .page').css('height', div_height+'px');
		$('div#hot_deals .page').css('top', margin_top+'px');
	});
	//alert(el_height);
	//------------------------------------------
	
	$("div#right").mouseover(function() {
	$("#products ul.menu").stop().animate({
		marginLeft : "-"+to_scroll+"px" //'-566px'
		},2000);
	}).mouseout(function()	{
		$("#products ul.menu").stop();
	});

	$("div#left").mouseover(function() {
		$("#products ul.menu").stop().animate({
			marginLeft : '0px'
		},2000);
		}).mouseout(function()	{
		$("#products ul.menu").stop();
	});
	
	/* $('#home_content, #about_us_content').animate({
		bottom:'80px',
		opacity:1
	},800); */
	
	//Gallery Effects
	$('#gallery').fadeIn(1500);
	
	
	$('#access a, .prev, .next, .ngg-navigation a').click(function() {
		$('#gallery').fadeOut(800);
	});
	$('#gallery .ngg-gallery-thumbnail a').mouseover(function(){ 
		$(this).children('img').stop().css({zIndex:10}).animate({
			marginTop:'-39px',
			marginLeft:'-52px',
			marginRight:'-52px',
			marginBottom:'-39px',
			boxShadow: '0 0 15px #000',
			width:'259px',
			height:'188px'
		},500);
		$(this).children('.thumbnail_title').stop().css({zIndex:11}).animate({
			opacity:0.6,
			width:'259px',
			marginLeft:'-51px',
			marginTop:'-39px'
		},500);
		
	}).mouseout(function(){
		$(this).children('img').stop().animate({
			width:'146px',
			height:'110px',
			boxShadow: '0 0 5px #888',
			marginRight:'0',
			marginLeft:'0',
			marginBottom:'0',
			marginTop:'0'
		},500, function() { $(this).stop().css('zIndex','') });
		$(this).children('.thumbnail_title').stop().animate({
			opacity: 0,
			width: '147px',
			marginLeft:'0',
			marginTop:'0px'
		},500, function() { $(this).stop().css('zIndex','') });
	});
	
	$('.ngg-singlepic').mouseover(function() {
		$(this).stop().animate({
		    boxShadow: '0 0 10px #FFF',
			opacity: 0.8
		});
	}).mouseout(function() {
		$(this).stop().animate({
		    boxShadow: '0 0 0px #FFF',
			opacity: 1
		});
	});
	
	
	//Page Transition Effects
	/* $('a').click(function() {
		$('#home_content, #about_us_content').animate({
			bottom: '0',
			opacity:0			
		})
	}) */
});
