var mnmod = {	'main_news_name'  : false,
				'main_news_email' : false,
			}	

var mobiles = ['ipod', 'ipad'];
var isMobile = 0;

function IsMobile()
{
	if(isMobile == 0)
	{
		var uagent = navigator.userAgent.toLowerCase();
		for(var i = 0; i < mobiles.length; ++i)
		{
			if(uagent.search(mobiles[i]) > -1)
			{
				isMobile = 1;
				return true;
			}
		}
		isMobile = 2;
		return false;
	}
	else
	{
		return isMobile == 1;
	}
}
			
			
jQuery(document).ready
(
	function()
	{
		currentSection = jQuery("#section_main");
		
		jQuery(".section").each(
			function(index, element)
			{
				try
				{
					eval(jQuery(this).attr("id") + "_onload();");
				}
				catch(e)
				{
				}
			}
		);
		
		$('#main_news_button').click(
			function(e)
			{
				valid = true;
				$('.main_news_input').each(
					function(a, b)
					{
						if($(this).val() == $(this).attr('alt'))
						{
							valid = false;
							$('#main_error').html(mferror[$(this).attr('id')]);
							setTimeout("$('#main_error').html('');", 5000);
						}
					}
				)
				if(valid)
				{
					$('#main_news_loading').show();
					$.post('scripts/php/insert_newsletter.php', $("#main_news_form").serialize(), 
						function(data) 
						{
							$('#main_news_loading').hide();
							$('#main_error').html(data);
							setTimeout("$('#main_error').html('');", 5000);
						}
					);
				}
			
			}
		)
		
		currentSection.fadeIn(500, function(){});
		
		if(!IsMobile())
		{
			jQuery(".navBar .navLink, .formIn, .download, .main_news_in").hover(
				function()
				{
					jQuery(this).children('.nav_over').fadeIn(100);
				},
				function()
				{
					jQuery(this).children('.nav_over').fadeOut(100);
				}
			);
		}
		else
		{
			jQuery('.nav_over').show();
		}
		
		jQuery(".navLink").click(
			function(event)
			{
				var targ = 'section_' + jQuery(this).attr("id");
				DisplaySection(targ, 500);
			}
		);
	}
);
