var chart;

$(document).ready(function() {
  $('.sign_up').click(function() {
	
	  $('#contact-popup').fadeIn();
		
		return false;		
		
	});
	
	$('.try_meaningtool').click(function() {
	
	  $('#contact-popup').fadeIn();
		
		return false;		
		
	});
	
	$('.back').click(function() {
	
	  $('#contact-popup').fadeOut();
	
		return false;		
				
	});
	
	$('.slideshow').cycle({ fx:'fade', speed:600, timeout:5000, next: '.nav .next', prev: '.nav .prev'});
	
	
	if ($("#chart-1").length > 0) {
	
		chart = new Highcharts.Chart({
	     chart: {
	        renderTo: 'chart-1', 
	        defaultSeriesType: 'area'
	     },
	     title: {
	        text: 'Juice Brand Campaign 2010'
	     },

			colors: [
				'#73c9e5', 
				'#fbbbe1', 
				'#89A54E', 
				'#80699B', 
				'#3D96AE', 
				'#DB843D', 
				'#92A8CD', 
				'#A47D7C', 
				'#B5CA92'
			],

	     xAxis: {
	       type: 'datetime',
	       dateTimeLabelFormats: { //custom date formats for different scales
	           second: '%H:%M:%S',
	           minute: '%H:%M',
	           hour: '%H:%M',
	           day: '%e. %b',
	           week: '%e. %b',
	           month: '%b', //month formatted as month only
	           year: '%Y'
	       }           
	     },
			 yAxis: {
			         title: {
			            text: 'Percent'
			         }
			      },
		
			      tooltip: {
			         formatter: function() {
			
									var d1=new Date(this.x);
			
									return Highcharts.dateFormat('%b %Y', this.x + 6 * 24 * 3600 * 1000) +': '+ this.y +'%';
								
			         }
			      },
	     plotOptions: {
	        area: {

	           marker: {
	              enabled: false,
	              symbol: 'circle',
	              radius: 2,
	              states: {
	                 hover: {
	                    enabled: true
	                 }
	              }
	           }
	        }
	     },

	     series: [{                                   
	       name: 'CTR with Popego',
		      data: [
	        {x: Date.UTC(2010, 9, 1), y: 23}, //one data point for each month
	        {x: Date.UTC(2010, 10, 1), y: 23},
	        {x: Date.UTC(2010, 11, 1), y: 24},
	        {x: Date.UTC(2010, 12, 1), y: 26},
	        {x: Date.UTC(2011, 1, 1), y: 26},
	        {x: Date.UTC(2011, 2, 1), y: 29},
	        {x: Date.UTC(2011, 3, 1), y: 27},
	        {x: Date.UTC(2011, 4, 1), y: 24},
	        {x: Date.UTC(2011, 5, 1), y: 28},
	        {x: Date.UTC(2011, 6, 1), y: 28},
	        {x: Date.UTC(2011, 7, 1), y: 28},
	        {x: Date.UTC(2011, 8, 1), y: 33},
	        {x: Date.UTC(2011, 9, 1), y: 30},
	        {x: Date.UTC(2011, 9, 1), y: 28}
		        ]                          
	     },{
	        name: 'CTR Average',
		      data: [
		            {x: Date.UTC(2010, 9, 1),  y: 24}, //one data point for each month
		            {x: Date.UTC(2010, 10, 1), y: 21},
		            {x: Date.UTC(2010, 11, 1), y: 25},
		            {x: Date.UTC(2010, 12, 1), y: 26},
		            {x: Date.UTC(2011, 1, 1),  y: 17},
		            {x: Date.UTC(2011, 2, 1),  y: 13},
		            {x: Date.UTC(2011, 3, 1),  y: 10},
		            {x: Date.UTC(2011, 4, 1),  y: 11},
		            {x: Date.UTC(2011, 5, 1),  y: 13},
		            {x: Date.UTC(2011, 6, 1),  y: 17},
		            {x: Date.UTC(2011, 7, 1),  y: 13},
		            {x: Date.UTC(2011, 8, 1),  y: 22},
		            {x: Date.UTC(2011, 9, 1),  y: 14}
		        ]                                 
	     }]                              
	  });

	};	

});


function checkEmail(email) { 
  var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var emailVal = $("#" + email).val();
  return pattern.test(emailVal);
}

