// javascript 

var northern = {
	
	init : function()
	{
		
		var flashvars = {pageId:pageID,
						 timerInterval:'5'};
		var params = { 
						align:'middle',
						height:'100%',
						scale:'noscale',
						width:'100%',
						wmode:'transparent'
					};
		var attributes = {};

		 swfobject.embedSWF("/swf/NorthernConcrete_Slider.swf", "flashcontent", "100%", "287", "9.0.0","/js/swfobject/expressInstall.swf", flashvars, params, attributes);
		
		swfobject.embedSWF("/swf/concrete_builder.swf", "virtualmason", "550", "440", "9.0.0","/js/swfobject/expressInstall.swf", flashvars, params, attributes);
		
		$("#mainmenu img:not('.active')").bind('mouseover', northern.over_menu)
						.bind('mouseout', northern.out_menu);
		$("a[rel=example_group]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
			}
		});
	},
	
	over_menu : function()
	{
		var btn = $(this);
		var src = btn.attr('src').replace('.gif','');
		var newsrc = src+'_active.gif';
		btn.attr('src',newsrc);
		
			
	},
	
	out_menu : function()
	{
		var btn = $(this);
		var newsrc = btn.attr('src').replace('_active','');
		btn.attr('src',newsrc);
	},
	
	validate_vm : function(form)
	{
		
		
		if(!form) form = document.forms[0];
		var submit_it = true;
		$(form).find(".REQUIRED").each(function(req)
		{
			if(($(this).attr('type')!='checkbox' && this.value == '') || 
				($(this).attr('type')=='checkbox' && !this.checked))
			{
				$(this).parents("div.formfield").addClass('error');
				submit_it = false;
			}
			else
			{	
				$(this).parents("div.formfield").removeClass('error');
			}			
		});
		if( !submit_it ) {
			$('#error_message').fadeIn(250);
		} else {
			var timestamp = Number(new Date());
			var p = "http://www.northernconcreteinc.goelementbeta.com/uploads/" + timestamp + ".jpg";
			$("#buildsnap").val(p);
			
			function thisMovie(movieName) {
				if (navigator.appName.indexOf("Microsoft") != -1) {
		        	return window[movieName];
		        } else {
		        	return document[movieName];
		        }
		     }
			
			
 			thisMovie('virtualmason').sendToActionscript(timestamp);
		}
	
		return submit_it;
	},
	
	validate_form : function(form)
	{	
		if(!form) form = document.forms[0];
		var submit_it = true;
		$(form).find(".REQUIRED").each(function(req)
		{
			if(($(this).attr('type')!='checkbox' && this.value == '') || 
				($(this).attr('type')=='checkbox' && !this.checked))
			{
				$(this).parents("div.formfield").addClass('error');
				submit_it = false;
			}
			else
			{	
				$(this).parents("div.formfield").removeClass('error');
			}			
		});
		if( !submit_it ) $('#error_message').fadeIn(250);
		return submit_it;
	}

}

$(function() { northern.init() });


	
