$(document).ready(function() {
	$("#form-signin").validate({
		rules:
		{
			login_username:
			{
				required: true,
				rangelength: [2, 25],
				loginRegex: true
			},
			login_password:
			{
				required: true,
				rangelength: [2, 25]
			}
		}
	});
});

$.validator.addMethod("loginRegex", function(value, element) {
        return this.optional(element) || /^[a-z0-9\-]+$/i.test(value);
    }, "Username must contain only letters, numbers, or dashes.");

var gGraphWidth = 620;
function getGraph(method, graphType, elementID, tableID, inputData, graphWidth)
{
	gGraphWidth = graphWidth ? graphWidth : 620;
	$.post("/ajax/"+method, inputData, function(data)
	{
		var obj = jQuery.parseJSON(data);
		$('#'+elementID).html(obj.html);
		jQuery('#' + tableID).gvChart({
			chartType: graphType,
			gvSettings:
			{
				vAxis:
				{
					title: 'Viewers',
					titleTextStyle: {color: '#b69245' },
					textStyle: {color: '#796544', fontName: 'Tahoma, Arial, sans-serif'}
				},
				hAxis:
				{
					title: 'Time',
					titleTextStyle: {color: '#b69245' },
					textStyle: {color: '#796544', fontName: 'Tahoma, Arial, sans-serif'},
					baselineColor: 'white'
				},
				width: gGraphWidth, //620,//860
				height: 300,
				backgroundColor: '#280000',
				colors: ['#d99400','#d93f02','#dd0000','#dd0049'],
				legendTextStyle: {color: '#d4b788', fontName: 'Tahoma, Arial, sans-serif'},
				titleTextStyle: {color: '#d99400'},
			}
		});
		
	});
}
