jQuery(document).ready(function($) {
	
	$("#s").val("Search").addClass("default");
	
	$("#s").focus(function() {
		if ($(this).val() == "Search") {
			$(this).val("").removeClass("default");
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).val("Search").addClass("default");
		}
	});
	
	jQuery('<img src="/wp-content/themes/stevenwilshaw/images/ajax-loader.gif" class="ajax-loader"/>').prependTo("#page").hide();
	
	//$("#nav ul li").append('<img src="/wp-content/themes/stevenwilshaw/images/nav-shadow.png" alt="" class="shadow">');

	/*jQuery(window).bind( 'hashchange', function(){
		var location = document.location.hash.replace(/^.*#/, '');
		var url = "/" + location;
		
		var aLinkParts = location.split("/");
		
		if (aLinkParts[0] == "") {
			jQuery("#nav li").removeClass("current_page_item");
			$('#nav a[title="Home"]').parent("li").addClass("current_page_item");
		}
		else {
			//alert(location);
			jQuery("#nav li").removeClass("current_page_item");
			$('#nav a[href$="' + aLinkParts[0] + '/"]').parent("li").addClass("current_page_item");
		}
				
		//$("#nav").find("a[]")
				
		jQuery(".ajax-loader").show();
		jQuery("#content").hide();
		
		jQuery.scrollTo(0, 500);
		
		jQuery.ajax({ url: url, context: document.body, success: function(data){
				
				
				
		        //$(this).addClass("done");
				
				html = jQuery(data).find("#content").html();
				//alert(html);
				jQuery("#content").empty().html(html);
				var iHeight = jQuery("#content").height();
				//alert(iHeight);
				jQuery("#page").animate({height: iHeight}, 500, function() {
					jQuery(".ajax-loader").hide();
					jQuery("#content").fadeIn(500, function() {
						if (location == "about/") {
							loadAboutPage();
						}
					});
				});
		}});
	});
	
	
	if (document.location.hash)
		jQuery(window).trigger( 'hashchange' );
		
			
	jQuery("a").live("click", function() {
		
		if (jQuery(this).attr("target") == "") {
			//var url = jQuery(this).attr("href");
			var ajax_url = jQuery(this).attr("href").replace(/http:\/\/.*?\//,'').replace(/^\//, '');
			window.location.hash = ajax_url;
			return false;
		}		
	});*/
	
	//loadAboutPage();
	loadChart();
	
	
	
});



var chart1; // globally available


function loadChart() {
	var options = {
	    chart: {
            renderTo: 'chart-container-1',
            defaultSeriesType: 'bar',
			backgroundColor: 'none',
			margin: [10,10,50,80]
         },
         title: {
            text: ''
         },
         xAxis: {
            categories: []
			
         },
         yAxis: {
            title: {
               text: ''
            },
			labels: {
				enabled: true
			}
		
         },
		tooltip: {
		         enabled: false
		},
		legend: { 
			enabled: false
			},
		labels: {
			
			items: [{ 
				html: 'Basic Grasp',
				style: {
					left: '10px',
				    top: '345px'
				    }
				}, {
					html:'Solid Grounding',
					style: {
						left: '90px',
					    top: '345px'
					    }
				
				}, {html:'Great',		style: {
							left: '210px',
						    top: '345px'
						    }}, {html:'Awesome!',style: {
								left: '285px',
							    top: '345px'
							    }}]
		},
         series: []
	};
	
	jQuery.get('/wp-admin/admin-ajax.php?action=my_action&object=skills', function(data) {
	    // Split the lines
	    var lines = data.split('\n');

	    // Iterate over the lines and add categories or series
	    jQuery.each(lines, function(lineNo, line) {
	        var items = line.split(',');

	        // header line containes categories
	        if (lineNo == 0) {
	            jQuery.each(items, function(itemNo, item) {
	                if (itemNo > 0) options.xAxis.categories.push(item);
	            });
	        }

	        // the rest of the lines contain data with their name in the first position
	        else {
	            var series = {
	                data: []
	            };
	            jQuery.each(items, function(itemNo, item) {
	                if (itemNo == 0) {
	                    series.name = item;
	                } else {
	                    series.data.push(parseFloat(item));
	                }
	            });

	            options.series.push(series);

	        }

	    });

	    // Create the chart
	    var chart = new Highcharts.Chart(options);
	});
}

 


/*function loadAboutPage() {
	chart1 = new Highcharts.Chart({
         chart: {
            renderTo: 'chart-container-1',
            defaultSeriesType: 'bar',
			backgroundColor: 'none',
			margin: [10,10,50,80]
         },
         title: {
            text: ''
         },
         xAxis: {
            categories: ['PHP', 'MySQL', 'HTML', 'CSS', 'JavaScript', 'jQuery', 'Wordpress', 'Photoshop', 'UX Design']
         },
         yAxis: {
            title: {
               text: ''
            },
			labels: {
				enabled: false
			}
		
         },
		legend: { 
			enabled: false
			},
		labels: {
			items: [{ 
				html: 'Basic Grasp',
				
				style: {
					left: '10px',
				    top: '345px',
					transform: 'rotate(45)',
				    }
				}, {
					html:'Solid Grounding',
					style: {
						left: '90px',
					    top: '345px'
					    }
				
				}, {html:'Great',		style: {
							left: '210px',
						    top: '345px'
						    }}, {html:'Awesome!',style: {
								left: '285px',
							    top: '345px'
							    }}]
		},
         series: [{
            name: 'Skill',
            data: [18, 11, 38, 37, 12, 21, 25, 19, 29]
         }]
      });
}*/



