var currentBg = "#home-bg";
$(document).ready(function() {

	//footer logo hover
	$("#footer-logo").hover(
		function(){
			$("#footer-inner").stop().animate({ marginTop: '0' }, 800, 'easeOutCubic');
		},
		function(){
			//$("#footer-inner").animate({ marginTop: '200' }, 800, 'easeOutCubic');
		});
	
	$("#footer").hover(
		function(){
			//$("#footer-inner").animate({ marginTop: '0' }, 800, 'easeOutCubic');
		},
		function(){
			$("#footer-inner").stop().animate({ marginTop: '200' }, 800, 'easeOutCubic');
		});
	
	
	$('.case-study-video').live('click', function(){
           ajax_call('/ajax.case.studies.video.player.php','id=' + $(this).attr('cid'),'showCaseStudy');
        });
	
	//about menu text
	$(".about-link-title").click(function(){
		$(this).next(".about-link-text").slideToggle("slow");
	});
	
	
	//products menu text
	$(".products-link-title").toggle(
		function(){
			$(this).next(".products-link-text").slideDown("slow");
			$(this).parent().find(".products-link-img").find("img").attr("src", "images/small-arrow-down.png");
		},function(){
			$(this).next(".products-link-text").slideUp("slow");
			$(this).parent().find(".products-link-img").find("img").attr("src", "images/small-arrow-right.png");
	});
	
	
	//map
	$(".contact-right-map-image").click(function(){
		$(".contact-right-map-title").stop().animate({opacity: 0}, "slow");
		$(".contact-right-map-text").stop().animate({opacity: 0}, "slow");
		$(".contact-right-map-image").stop().animate({opacity: 0}, "slow");
		$(".big-map").fadeIn("slow");
	});
	
	$(".big-map").click(function(){
		$(".big-map").fadeOut("slow");
		$(".contact-right-map-title").stop().animate({opacity: 1}, "slow");
		$(".contact-right-map-text").stop().animate({opacity: 1}, "slow");
		$(".contact-right-map-image").stop().animate({opacity: 1}, "slow");
	});
	
	
	
	//scroll page with menu links
	$(".menu-link").click(function(){
		var data = $(this).metadata();
		var target = data.target;
		//var target = $(this).attr("target");
		$("#main-wrapper").animate({scrollTop: (target*1000)-115}, 2000, 'easeInOutQuint');
	});
	
	$(".menu-link-footer").click(function(){
		var data = $(this).metadata();
		var target = data.target;
		//var target = $(this).attr("target");
		$("#main-wrapper").animate({scrollTop: (target*1000)-115}, 2000, 'easeInOutQuint');
	});
	
	
	//product over
	$(".product-left").hover(function(){
		$(this).parent().find(".product-right").fadeIn("fast");
                over = $(this).find("img").attr('on');
		$(this).find("img").attr("src",over);
	},function(){
		$(this).parent().find(".product-right").fadeOut("fast");
                off = over = $(this).find("img").attr('off');
		$(this).find("img").attr("src",off);
	});

        $('#keywords').live('click',function(){
            if($(this).val()=="search..."){
                $(this).val('');
            }
        })
        $('#search-submit').live('click', function(){
            location.href="products.php?id=687&l="+$(this).attr('language')+"&search=true&keywords="+$('#keywords').val();
        });
	
});

function ajax_call(url, params, callback){
	$.ajax({
		type: "POST",
		url: url,
		cache: false,
		data: params,
		beforeSend:function() {
			$('#loading_indicator').css('display','inline');
		},
		success: function(result){
			$('#loading_indicator').css('display','none');
			eval(callback + "(result)");
		}
	});
}

function showCaseStudy(data){
    
    $('#case-studies-video-player').html(data);
}
