$(document).ready(function()
{
	
	$("#event-registration-form").submit(function ()
	{ 
		if( $("#fullname_contact").val() == "" )
		{
			alert("Please enter your Name");
			return false;
		}
		if( $("#company_contact").val() == "" )
		{
			alert("Please enter your Company Name");
			return false;
		}
		if( !isValidEmailAddress( $("#email_contact").val()) )
		{
			alert("Please make sure your E-mail Address is correct");
			return false;
		}
		if( $("#attendance").val() == "" )
		{
			alert("Please enter your attendance date");
			return false;
		}
	});
	
	$("#right-side .inner h2:first").addClass("pagetitle");

	// Safari CSS
	if ( $.browser.safari )
	{
		$("head").append('<link href="css/safari.css" media="screen" rel="stylesheet" type="text/css" />');
	}

	// Tables
	$("table tr").each(function()
	{
		if ( !$(".middle",this).length )
		{
			$("td",this).eq(1).addClass("middle");
		}
	});

	// Top Menu
	$("ul").each(function(){
		 $(this).children("li:last").css({borderRight:"0", borderBottom:"0"});
	});
	$("#navigator li").not(".on").children("ul").hide();
	$("#navigator li").hover
	(
		function()
		{
			if ( !$(this).parents("li").length ){ $("#navigator li ul").hide(); }; 
			$(this).addClass("on");
		},
		function()
		{
			$(this).removeClass("on");
			$("#navigator li.on ul").show();
		}
	);
	
	$("#rss-help").tooltip("RSS is an easy way to keep up to date with all your favourite websites. Please visit http://www.whatisrss.com/ for further information.");

	// fix png for IE
	$('img, div, #tooltip').ifixpng();
	// quoes
	$.quotes.sw();
});

function isValidEmailAddress(emailAddress)
	{
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}
	
var detect = navigator.userAgent.toLowerCase();
var os_ = navigator.platform.toLowerCase();
var browser,thestring;

if (checkIt('safari')) browser = "Safari"
else browser = "not Safari"

if ( os_ == 'macppc' || os_ == 'macintel' ) os = "Mac"
else os = "not Mac"

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
