var reEmail = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/

function isEmail(s) {
	return reEmail.test(s)
}

function validateContactForm() {
	
	var error = "";

	if (!isEmail($("email").value))
		{
			error =error + "\nPlease enter a valid e-mail address.";
		}
		
	if ($("subject").value=="" || $("subject").value.length<4)
		{error =error + "\nSubject";}
	if ($("comment").value=="" || $("comment").value.length<10)
		{error =error + "\nComment";}

	if (error != "")
	{
		error = "Please enter required fields on below:\n" + error + "\n";
		alert(error);
		return false;
	}
	return true;
	
}




window.addEvent('domready', function() {
																		 
	
	
// set nav links

$$('#nav li a').addEvents({
										'mouseover' : function() {
																		this.setStyle('opacity','0.5');
																	},
										'mouseout' : function() {
																		this.setStyle('opacity','1');
																	}							
																	
});
// end set nav links



	if ($('content_area')) {
		
				var menu_prefix = "submenu-";
				var content_prefix = "content-";
							
				$(content_prefix + current_id).setStyle('position','static');
				$(content_prefix + current_id).setStyle('visibility','visible');
				$(menu_prefix + current_id).addClass('active');
			

					$$('.submenu-element').each(function(el) {
								el.addEvents({
												'click' : function() {
														record_id = el.id.replace(menu_prefix,''); // find content id
											
														if ($(content_prefix + record_id).getStyle('visibility') == "hidden" ) {
															
															$(content_prefix + current_id).set('morph',{ // hide opened content
																																 duration: 500, 
																																 transition: 'sine:out',
																																 onStart : function() {
																																	 $(menu_prefix + current_id).removeClass('active');
																																	 $(menu_prefix + record_id).addClass('active');
																																 },
																																	onComplete: function() {
																																							$(content_prefix + record_id).setStyle('position','static');
																																	 						$(content_prefix + current_id).setStyle('position','absolute');
																																							
																																							$(content_prefix + record_id).set('morph', {
																																																											duration: 300,
																																																											transition: 'sine:in'
																																																											}).morph({
																																																															opacity: [0,1]
																																																															});
									
																																																												current_id =  record_id;
																																									 																		}
																																}).morph({opacity: [1,0]});
				
														} // end if
				
														return false;
														
												} // end click func
														 
								}); // end add events																 
					}); // end each
	}
		//set slide effect for index

	if ($('panel')) {
				var panel = new gallery($('panel'), {
					timed: true,
					showArrows: false,
					showCarousel: false,
					embedLinks: false,
					showInfopane:false,
					fadeDuration: 2500,
					delay:3000	
				});
				var slogan = new gallery($('slogan'), {
					timed: true,
					showArrows: false,
					showCarousel: false,
					embedLinks: false,
					showInfopane:false,
					fadeDuration: 2500,
					delay:3000	
				});
		
		
				var newsSlider = new slider({
					slideTimer: 7000,
					transitionTime: 2000,
					isPaused: false,
					container: $('news-slider'),
					items: $$('.news')
				}).start();
		}
// end set slide effect for index																	 


});
