$(document).ready(function() {
	$('.donde').width($(window).width())
	$('.donde').height($(window).height())
	
	$('.portfolio-overlay').width($(window).width())
	$('.portfolio-overlay').height($(window).height())
				
	$(window).resize(function() {
		$('.donde').width($(window).width())
		$('.donde').height($(window).height())
		
		$('.portfolio-overlay').width($(window).width())
		$('.portfolio-overlay').height($(window).height())
		
	});
	
	/*LATEST TWEETS*/
	// set your twitter id
    var user = 'fusionmadrid';
     
    // using jquery built in get json method with twitter api, return only one result
    $.getJSON('http://twitter.com/statuses/user_timeline.json?screen_name=' + user + '&count=5&callback=?', function(data) {
         
        for(i=0; i<5;i++){
			var tweet = data[i].text;		
			tweet = tweet.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g,function(url) {return '<a href="'+url+'" tartget="_blank">'+url+'</a>'}).replace(/[@]+[A-Za-z0-9-_]+/g, function(reply) {return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'" tartget="_blank">'+reply.substring(1)+'</a>';});
			$("#twitter_update_list").append('<li><p>'+tweet+'</p></li>');
		}
    }); 
	var miTop = 0
	var tweetInterval = setInterval(function(){
		miTop = miTop-50
		$('#twitter_update_list').animate({
			top: miTop,
			  }, 200);
		if (miTop == -200) {
			$('#twitter_update_list').css({top:0})
			miTop = 50
		}
	},5000)
	
	/*CAMBIAR IDIOMA*/
	$("#en").live('click',function(){
			$("body").changeLang({lang: "en", file: "lang/lang-example.xml"});
			$(this).parent().parent().find('.active').removeClass('active');				
			$(this).addClass('active')		
		});
		
	$("#es").live('click',function(){
			$("body").changeLang({lang: "es", file: "lang/lang-example.xml"});
			$(this).parent().parent().find('.active').removeClass('active');				
			$(this).addClass('active')	
		});
	
	var titulos = new Array()
	var cliente = new Array()
	var datos = new Array()
	var miproject
	
	var ptime = false
	
	function pInterval(){
	var miTop = 0
	var portInterval = setInterval(function(){
		miTop = miTop-480
		$('.menu').animate({top: miTop},{duration:700, easing:'easeOutExpo'});
		if (miTop <= 0-($('.menu li').size()-1) * 480) {
			$('.menu').css({top:0})
			miTop = 480
			}
		if(ptime == false) {
			clearInterval(portInterval)
		}
		},10000)
	}
	
	$('.portafolio ul li').live('click', function(){
			miproject = $(this).attr('id')
			var indice = $(this).index()
			$.ajax({
				type: "GET",
				url: "portfolio/"+miproject+".html",
				dataType: "html",
				success: function(data){
					$('body').prepend(data)
					$('.portfolio-overlay').fadeIn('fast');
					$('.portfolio-viewer').fadeIn('fast');
					$('.portafolio ul li').animate({opacity:0.3});
					//$('.portfolio-viewer .datos').fadeIn('fast')
					$('.portfolio-overlay .sidebar').animate({height:'480px'},{duration:500, easing:'easeOutExpo'});
					$('.portfolio-viewer').css({left:'50%', top:'50%', margin:'-240px 0 0 -'+($('.sidebar').width() / 2)+'px'});
					$('.sidebar').css({left:'50%', top:'50%', margin:'-240px 0 0 -'+($('.sidebar').width() / 2)+'px'});
				}
			  });
			ptime = true
			pInterval()
			  
		})
	
		
	$('.portfolio-viewer .cerrar').live('click', function(){
			$('.portfolio-overlay .sidebar').animate({height:'0px'},{duration:800, easing:'easeOutExpo'});
			$('.portfolio-overlay').delay(500).fadeOut();
			$('.portfolio-viewer').animate({height:'0px'},{duration:500, easing:'easeOutExpo'});
			$('.portfolio-viewer .datos').fadeOut(500)
			$('.portafolio ul li').animate({opacity:1},500,function(){$('.portfolio-viewer').hide()});
			setTimeout(removePort, 1000);
			ptime = false
			function removePort() {
				$('.portfolio-viewer').delay(500).remove();
				$('.portfolio-overlay').delay(500).remove();
				clearInterval(portInterval)
			}
		}) 

	/*ROLLOVERS MENU*/	
	$('#primary-nav ul li a:not(.active), #primary-nav ul li ul li a:not(.active)').live("mouseenter", function() {
			if(!$(this).hasClass('active')) {   
	  		$(this).animate({
				paddingRight: 15,
				backgroundColor:'rgba(255,255,255,0.8)'
			  }, 100);
			}
			$(this).css({color:'#515151'})
	}).live("mouseleave", function() {
		if(!$(this).hasClass('active')) {   
	  		$(this).animate({
				paddingRight: 5,
				backgroundColor:'rgba(0,0,0,0.8)'
			  }, 100);
		}
		$(this).css({color:'#FFFFFF'})	
	});   
	
	/*BUTTONS ACTIONS*/
	
	$('#primary-nav li').find('a').hide();
	
	var apartado = 'inicio'
	
	$('#primary-nav ul li a, #primary-nav ul li ul li a').live('click',function(e){
		$('#primary-nav').find('.active').css({color:'#fff', paddingRight:5, backgroundColor:'rgba(0,0,0,0.8)'})
		$('#primary-nav').find('.active').live("mouseenter", function() {
				if(!$(this).hasClass('active')) {   
				$(this).animate({
					paddingRight: 15,
					backgroundColor:'rgba(255,255,255,0.8)'
				  }, 100);
				}
		}).live("mouseleave", function() {
			if(!$(this).hasClass('active')) {   
				$(this).animate({
					paddingRight: 5,
					backgroundColor:'rgba(0,0,0,0.8)'
				  }, 100);
			}
		});   
		$(this).unbind('mouseenter')
		$(this).unbind('mouseleave')
		Cufon.refresh();
		$('#primary-nav').find('.active').removeClass('active');
		$(this).css({color:'#515151'})				
		$(this).addClass('active')
		//$(this).removeAttr('color')
		
		
		if ($(this).text() == 'Inicio' || $(this).text() == 'Home') {
			$('#primary-nav .sub').hide(300);
			$('#primary-nav .sub').animate({
				marginLeft: 32,
				marginTop:0,
			  }, 300);
			closeSection()
			apartado = 'inicio'
			setTimeout(initSection, 1000);
		} else if($(this).text() == 'Sobre Fusion' || $(this).text() == 'About Fusion') {
			$('#primary-nav .sub').hide(300);
			$('#primary-nav .sub').animate({
				marginLeft: 32,
				marginTop:0,
			  }, 300);
			closeSection()
			apartado = 'about'
			setTimeout(initSection, 1000);
		} else if ($(this).text() == 'Dónde estamos' || $(this).text() == 'Where we are') {
			$('#primary-nav .sub').hide(300);
			$('#primary-nav .sub').animate({
				marginLeft: 32,
				marginTop:0,
			  }, 300);
			closeSection()
			apartado = 'where'
			setTimeout(initSection, 1000);			
		} else if ($(this).text() == 'Qué hacemos' || $(this).text() == 'What we do') {
			$('#primary-nav .sub').hide(300);
			$('#primary-nav .sub').animate({
				marginLeft: 32,
				marginTop:0,
			  }, 300);
			closeSection()
			apartado = 'what'
			setTimeout(initSection, 1000);			
		} else if ($(this).text() == 'Nuestro trabajo' || $(this).text() == 'Our work') {
			$('#primary-nav .sub').show(300);
			$('#primary-nav .sub').animate({
				marginLeft: 0,
				marginTop:2,
			  }, 300);
			  $('#contact').fadeOut(400);
			  $('.donde .address').animate({height:'0',padding:'0'},200)
		} else if ($(this).text() == 'Artes' || $(this).text() == 'Arts') {
			closeSection()
			apartado = 'portfolio-arte'
			setTimeout(initSection, 1000);			
		} else if ($(this).text() == 'Lifestyle') {
			closeSection()
			apartado = 'portfolio-lifestyle'
			setTimeout(initSection, 1000);			
		} else if ($(this).text() == 'Quiénes somos' || $(this).text() == 'Who we are') {
			$('#primary-nav .sub').hide(300);
			$('#primary-nav .sub').animate({
				marginLeft: 32,
				marginTop:0,
			  }, 300);
			closeSection()
			apartado = 'who'
			setTimeout(initSection, 1000);			
		}
	})
	
	
	/*MENU ANIMATION*/	
	$('#primary-nav > ul li').find('a').hide();
	var items = 0
	var total = $('#primary-nav li').size()
	var menuInterval = setInterval(function(){
			$('#primary-nav > ul > li').eq(items).find('a:not(.sub)').show(150);
			$('#primary-nav > ul > li').eq(items).find('a:not(.sub)').animate({
				marginLeft: 0,
			  }, 150);
			items = items+1
			if (items == total) {
			clearInterval(menuInterval) ;
			initPhrase();
			}
		},100)
	
	/*PHRASE ANMATION*/
	$('#home h3').hide();
	function initPhrase() {
		$('#home').find('h2').prepend('<p>Bienvenido a Fusion.</p><p>Un estudio de comunicación</p><p>especializado en creatividad, artes</p><p>tendencias y gestión cultural.</p>')
		//$('#home').find('h2').prepend('<p>Bienvenido a Fusion.</p><p>Un estudio donde se crean experiencias</p><p>únicas, un sitio donde unimos la pasión</p><p>y la creatividad como ingredientes</p><p>clave para cada proyecto.</p>')
		$('#home').find('p').hide();
		$('#home').find('.tweets p').show();
		Cufon.refresh()
		var itemsP = 0
		var totalP = $('#home > p').size()
		var phraseInterval = setInterval(function(){
				$('#home p').eq(itemsP).show(90, 'linear');
				$('#home p').eq(itemsP).animate({
					marginRight: 0,
				  }, 90);
					itemsP = itemsP+1
					if (itemsP == totalP) {
					clearInterval(phraseInterval) 
				}
			},60)
		$('.tweets').delay(1300).animate({height:50},{duration:1200, easing:'easeOutExpo'});
		$('#home h3').delay(1000).fadeIn();
	}
	
	/*BG ANIMATION*/
	jQuery(function($){
				$.supersized({
				
					//Functionality
					slideshow               :   1,		//Slideshow on/off
					autoplay				:	1,		//Slideshow starts playing automatically
					start_slide             :   1,		//Start slide (0 is random)
					random					: 	0,		//Randomize slide order (Ignores start slide)
					slide_interval          :   5000,	//Length between transitions
					transition              :   3, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	700,	//Speed of transition
					new_window				:	1,		//Image links open in new window/tab
					pause_hover             :   0,		//Pause slideshow on hover
					keyboard_nav            :   1,		//Keyboard navigation on/off
					performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
					image_protect			:	1,		//Disables image dragging and right click with Javascript
					image_path				:	'images/', //Default image path

					//Size & Position
					min_width		        :   0,		//Min width allowed (in pixels)
					min_height		        :   0,		//Min height allowed (in pixels)
					vertical_center         :   1,		//Vertically center background
					horizontal_center       :   1,		//Horizontally center background
					fit_portrait         	:   1,		//Portrait images will not exceed browser height
					fit_landscape			:   0,		//Landscape images will not exceed browser width
					
					//Components
					navigation              :   1,		//Slideshow controls on/off
					thumbnail_navigation    :   1,		//Thumbnail navigation
					slide_counter           :   1,		//Display slide numbers
					slide_captions          :   1,		//Slide caption (Pull from "title" in slides array)
					slides 					:  	[		//Slideshow Images
														{image : 'images/bg.jpg', title : 'Day 3 by Emily Tebbetts'},  
														{image : 'images/bg01.jpg', title : 'Film by Emily Tebbetts'},
														{image : 'images/bg02.jpg', title : 'Film by Emily Tebbetts'},
												]
												
				}); 
		    });
			
	/*PORTFOLIO OVER / SHOW*/
	
	$('.portafolio li').live("mouseenter", function() {
			$(this).find('.oculto').fadeIn('fast')
			$(this).find('p').fadeIn('fast')
	}).live("mouseleave", function() {
			$(this).find('.oculto').fadeOut('fast')
			$(this).find('p').fadeOut('fast')
	});

	
	
			
	/*APARTADOS*/	
	$('.who').css({left:'59%',margin:'95px 0 0 -'+($('.who').width() / 2)+'px'});	
	$('.who ul li').css({height:0, margin:'175px 0 0 0'});
	$('.who .imgabout').css({height:0})
	
	$('.what').css({left:'59%',margin:'95px 0 0 -'+($('.who').width() / 2)+'px'});
	$('.what > ul > li').css({height:0, margin:'175px 0 0 0'});
	
	$('.portafolio').css({left:'59%',margin:'95px 0 0 -'+($('.who').width() / 2)+'px'});
	
	function initSection() {
		if(apartado == 'inicio') {
			initPhrase()
		} else if(apartado == 'about') {
			var whoitems = 0	
			var whototal = $('.who li').size()	
			$('.who .imgabout').delay(500).animate({height:245},{duration:800, easing:'easeOutExpo'});
			var whoInterval = setInterval(function(){
					//$('.who ul li').eq(whoitems).css({padding:'2%'})
					$('.who ul li').eq(whoitems).animate({"marginTop": "0", "height":"450px"},{duration:800, easing:'easeOutExpo'});
					whoitems = whoitems+1
					if (whoitems == whototal) {
						clearInterval(whoInterval) ;
					}
				},100)
		} else if (apartado == 'what') {
			var whatitems = 0	
			var whattotal = $('.what li').size()
			var whatInterval = setInterval(function(){
					var que = $('.what > ul > li').eq(whatitems)
					$('.what > ul > li').eq(whatitems).css({padding:'2%'})
					$('.what > ul > li').eq(whatitems).animate({marginTop:0, height:que.find('h2').height() + que.find('ul').height()+7},{duration:800, easing:'easeOutExpo'});
					whatitems = whatitems+1
					if (whatitems == whattotal) {
						clearInterval(whatInterval) ;
					}
				},100)
		} else if (apartado == 'who') {
			$('.quienes').fadeIn();
			var whoitems = ['fran','moni','matias']
			var whoheight = [120,120,100]
			var whonumber = 0
			var whoInterval = setInterval(function(){
					$('.quienes').find("."+whoitems[whonumber]).animate({width: whoheight[whonumber], padding:"8px"},{duration:150, easing:'easeOutExpo'});
					whonumber = whonumber+1
					if (whonumber == 3) {
						clearInterval(whoInterval) ;
					}
				},200)			
		} else if (apartado == 'where') {
			$('#contact').fadeIn(200);
			$('.donde .address').delay(500).animate({height:'120px',width:'275px',padding:'2%'},200)
			initialize();
		} else if (apartado == 'portfolio-arte') {
			$('#portfolio-lifestyle').hide()
			$('#portfolio-arte').show()
			var portaitems = 0	
			var portatotal = $('#portfolio-arte li').size()	
			var portaInterval = setInterval(function(){
					$('#portfolio-arte ul li').eq(portaitems).animate({"width": "256px", "height":"208px"},{duration:150, easing:'easeOutExpo'});
					$('#portfolio-arte ul li .nombre').delay(500).fadeIn()
					portaitems = portaitems+1
					if (portaitems == portatotal) {
						clearInterval(portaInterval) ;
					}
				},150)
		} else if (apartado == 'portfolio-lifestyle') {
			$('#portfolio-lifestyle').show()
			$('#portfolio-arte').hide()
			var portaitems = 0	
			var portatotal = $('#portfolio-lifestyle li').size()	
			var portaInterval = setInterval(function(){
					$('#portfolio-lifestyle ul li').eq(portaitems).animate({"width": "256px", "height":"208px"},{duration:150, easing:'easeOutExpo'});
					$('#portfolio-lifestyle ul li .nombre').delay(500).fadeIn()
					portaitems = portaitems+1
					if (portaitems == portatotal) {
						clearInterval(portaInterval) ;
					}
				},150)
		}
	}
	
	function closeSection() {
		if(apartado == 'inicio') {
			$('.tweets').animate({height:0},{duration:150, easing:'easeOutExpo'});
			$('#home h3').fadeOut();
			
			var itemsP = 0
			var totalP = $('#home > p').size()
			var phraseInterval = setInterval(function(){
					$('#home h2 p').eq(itemsP).animate({"width":"0","padding":"0"}, 90);
						itemsP = itemsP+1
						if (itemsP == totalP) {
						clearInterval(phraseInterval) 
					}
				},60)
			
		} else if (apartado == 'about') {		
			var whoitems = 0
			var whototal = 2
			$('.who .imgabout').animate({height:0},{duration:100, easing:'easeOutExpo'});
			var whoInterval = setInterval(function(){
					$('.who ul li').eq(whoitems).animate({"marginTop": "175px", "height":"0px", "padding":"0"},{duration:800, easing:'easeOutExpo'});
					whoitems = whoitems+1
					if (whoitems == whototal) {
					clearInterval(menuInterval)
					}
				},100)	
		} else if (apartado == 'what') {
			var whatitems = 0
			var whattotal = 3
			var whatInterval = setInterval(function(){
					$('.what > ul > li').eq(whatitems).animate({"marginTop": "175px", "height":"0px", "padding":"0"},{duration:800, easing:'easeOutExpo'});
					$('.what h2').fadeOut(800, function(){$('.what h2').show()});
					whatitems = whatitems+1
					if (whatitems == whattotal) {
						clearInterval(whatInterval)
					}
				},100)	
		} else if (apartado == 'who') {
			var whoitems = ['fran','moni','matias']
			var whoheight = [0,0,0]
			var whonumber = 0
			var whoInterval = setInterval(function(){
					$('.quienes').find("."+whoitems[whonumber]).animate({width: whoheight[whonumber], padding:"0"},{duration:150, easing:'easeOutExpo'});
					whonumber = whonumber+1
					if (whonumber == 5) {
						clearInterval(whoInterval);
						$('.quienes').fadeOut();
					}
				},200)		
			
		} else if (apartado == 'where') {
			$('#contact').fadeOut(400);
			$('.donde .address').animate({height:'0',padding:'0'},200)
		} else if (apartado == 'portfolio-arte') {
			var portaitems = 0	
			var portatotal = $('#portfolio-arte li').size()	
			var portaInterval = setInterval(function(){
					$('#portfolio-arte ul li').eq(portatotal).animate({"width": "0", "height":"0"},{duration:150, easing:'easeOutExpo'});
					$('#portfolio-arte ul li .nombre').fadeOut('fast')
					portatotal = portatotal-1
					if (portatotal == -1) {
						clearInterval(portaInterval) ;
					}
				},150)
		} else if (apartado == 'portfolio-lifestyle') {
			var portaitems = 0	
			var portatotal = $('#portfolio-lifestyle li').size()	
			var portaInterval = setInterval(function(){
					$('#portfolio-lifestyle ul li').eq(portatotal).animate({"width": "0", "height":"0"},{duration:150, easing:'easeOutExpo'});
					$('#portfolio-lifestyle ul li .nombre').fadeOut('fast')
					portatotal = portatotal-1
					if (portatotal == -1) {
						clearInterval(portaInterval) ;
					}
				},150)
		}
		
	}
	
	/*QUIENES SOMOS*/
	
	$('.fran').live("mouseenter", function() {
		$(this).find('p').hide()
		if($.browser == 'webkit' && $.client.os == "Windows") {
			$(this).animate({width:"400px", height:"290px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else if($.browser == 'webkit' && $.client.os == "Mac") {
			$(this).animate({width:"400px", height:"260px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else {
			$(this).animate({width:"400px", height:"250px"},{queue: false, duration:150, easing:'easeOutExpo'});
		}
		$(this).find('p').delay(300).fadeIn()
		$(this).parent().parent().find('.matias, .moni').fadeOut()
	}).live("mouseleave", function() { 
	  	$(this).animate({width:"120px", height:"20px"},{queue: false, duration:150, easing:'easeOutExpo'});
		$(this).find('p').delay(300).fadeOut()
		$(this).parent().parent().find('.matias, .moni').fadeIn()
	});
	
	$('.moni').live("mouseenter", function() {
		$(this).find('p').hide()
		if($.browser == 'webkit' && $.client.os == "Windows") {
			$(this).animate({width:"400px", height:"260px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else if($.browser == 'webkit' && $.client.os == "Mac") {
			$(this).animate({width:"400px", height:"230px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else {
			$(this).animate({width:"400px", height:"220px"},{queue: false, duration:150, easing:'easeOutExpo'});
		}
		$(this).find('p').delay(300).fadeIn()
		$(this).parent().parent().find('.matias, .fran').fadeOut()
	}).live("mouseleave", function() { 
	  	$(this).animate({width:"120px", height:"20px", top:"65%"},{queue: false, duration:150, easing:'easeOutExpo'});
		$(this).find('p').delay(300).fadeOut()
		$(this).parent().parent().find('.matias, .fran').fadeIn()
	}); 
	
	$('.matias').live("mouseenter", function() {
		$(this).find('p').hide()
		if($.browser == 'webkit' && $.client.os == "Windows") {
			$(this).animate({width:"400px", height:"310px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else if($.browser == 'webkit' && $.client.os == "Mac") {
			$(this).animate({width:"400px", height:"280px"},{queue: false, duration:150, easing:'easeOutExpo'});
		} else {
			$(this).animate({width:"400px", height:"270px"},{queue: false, duration:150, easing:'easeOutExpo'});
		}
		$(this).find('p').delay(300).fadeIn()
		$(this).parent().parent().find('.moni, .fran').fadeOut()
	}).live("mouseleave", function() { 
	  	$(this).animate({width:"100px", height:"20px", top:"40%"},{queue: false, duration:150, easing:'easeOutExpo'});
		$(this).find('p').delay(300).fadeOut()
		$(this).parent().parent().find('.moni, .fran').fadeIn()
	});  
	
	
	/*MAPA*/
	
	var map = null;
	var utopicus = new google.maps.LatLng(40.41387, -3.70668);

	function initialize() {
	
	  var estilos = [
	  {
		featureType: "all",
		elementType: "all",
		stylers: [
		  { saturation: -100 }
		]
	  },{
		featureType: "all",
		elementType: "all",
		stylers: [
	
		]
	  }
	]
	
	var mapOptions = {
	zoom: 16,
	center: utopicus,
	mapTypeControlOptions: {
		mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'fusion']
	},
	disableDefaultUI:true,
	
	panControl: true,
    panControlOptions: {
        position: google.maps.ControlPosition.RIGHT_CENTER
    },
    zoomControl: true,
    zoomControlOptions: {
        style: google.maps.ZoomControlStyle.LARGE,
        position: google.maps.ControlPosition.RIGHT_CENTER
    },
    scaleControl: true,
    scaleControlOptions: {
        position: google.maps.ControlPosition.RIGHT_CENTER
    },
    streetViewControl: true,
    streetViewControlOptions: {
        position: google.maps.ControlPosition.RIGHT_CENTER
    }
	
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
	
	var styledMapOptions = {name: "fusion"}
	var jayzMapType = new google.maps.StyledMapType(estilos, styledMapOptions);
	var image = new google.maps.MarkerImage(
	  'http://www.fusionagency.com/images/gmapsmarker.png',
		new google.maps.Size(75,99),
		new google.maps.Point(0,0),
		new google.maps.Point(0,99)
	);
	var shadow = new google.maps.MarkerImage(
	  'http://www.fusionagency.com/images/gmapsmarkershadow.png',
		new google.maps.Size(75,99),
		new google.maps.Point(0,0),
		new google.maps.Point(0,99)
	);
	var marker = new google.maps.Marker({
      position: utopicus, 
      map: map,
	  icon:image,
	  shadow:shadow
	});
	
	map.mapTypes.set('fusion', jayzMapType);
	map.setMapTypeId('fusion');
	}	
	
});







//$(function(){
//    $('.sidebar').mousemove(function(e) {
// 
//        //Sidebar Offset, Top value
//        var s_top = parseInt($('.sidebar').offset().top);       
//         
//        //Sidebar Offset, Bottom value
//        var s_bottom = parseInt($('.sidebar').height() + s_top);
//     
//        //Roughly calculate the height of the menu by multiply height of a single LI with the total of LIs
//        var mheight = parseInt($('.menu li').height() * $('.menu li').length);
//     
//        //I used this coordinate and offset values for debuggin
//       // console.log("Y Axis " + e.pageY);
//        console.log(Math.round(((s_top - e.pageY)/100) * mheight / 2));
//             
//        //Calculate the top value
//        //This equation is not the perfect, but it 's very close    
//        var top_value = Math.round(( (s_top - e.pageY) /100) * mheight / 2)
//         
//        //Animate the #menu by chaging the top value
//        $('.menu').animate({top: top_value+100}, { queue:false, duration:500});
//    });
//});

//$(function(){
//    //Get our elements for faster access and set overlay width
//    var div = $('.sidebar')
//	var ul = $('.menu')
//
//    //Get menu width
//    var divHeight = div.width();
//
//    //When user move mouse over menu
//    div.mousemove(function(e){
//		
//      var ulHeight = $('.menu').size() * 480
//
//      var mitop = (e.pageY - div.offset().top) * (ulHeight-divHeight) / divHeight;
//      ul.scrollLeft(mitop);
//    });
//});

					
























































