//Front end Java Script File

jQuery(document).ready(function() {

	/* first level side menu */
		jQuery('#side-menu > ul >li').each(function(){
			if(jQuery(this).hasClass('selected')){
	
			}else{
				jQuery(this).children('ul').css('display','none');
			}
		});
		/* second level side menu */
		jQuery('#side-menu > ul >li > ul >li').each(function(){
				if(jQuery(this).hasClass('selected')){
					jQuery(this).parent('ul').css('display','block');
				}else{
					
				}
			});
	
	// carousel intialization
	jQuery('#mycarousel').jcarousel();

	// Enable Pretty Photo effect for Images
	jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed : 'normal',  		/* fast/slow/normal */
		padding : 30,  					/* padding for each side of the picture */
		opacity : 0.35,  					/* Value betwee 0 and 1 */
		showTitle : true,  				/* true/false */
		allowresize : false,  			/* true/false */
		counter_separator_label : ' - ',  /* The separator for the gallery counter 1 "of"
		 * 2 */
		theme : 'light_rounded' 			/* light_rounded / dark_rounded / light_square /
		 * dark_square */
	});
	
	if($('.gallery_slideshow a').size() == 1)
	  {
	  $('.gallery_slideshow a').attr('rel','prettyPhoto'); 
	  }
	  
	if($('#gallery a').size() == 1)
	  {
	  $('#gallery a').attr('rel','prettyPhoto'); 
	  }
		        
	/* safari lightbox issue script */
	
		var userAgent = navigator.userAgent.toString().toLowerCase();
        if ((userAgent.indexOf('safari') != -1) && !(userAgent.indexOf('chrome') != -1)) 
        {
        	var videoHeight=jQuery(".video_upload iframe").height();
       		jQuery(".video_upload").css("height",videoHeight+"px");
        	jQuery('.yoxview').click(function()
        			{
						if(jQuery('.video_upload iframe').show())
							{
							jQuery('.video_upload iframe').hide();
							}
							
						jQuery("#yoxview_menuPanel a img").click(function()
							{
							if(jQuery('.video_upload iframe').hide())
								{
								setTimeout(function() { jQuery('.video_upload iframe').css('display','block'); }, 500);
								}
							});
							
						jQuery("#yoxview_popupWrap").click(function()
							{
							if(jQuery('.video_upload iframe').hide())
								{
								setTimeout(function() { jQuery('.video_upload iframe').css('display','block'); }, 500);
								}
							});		
        			});
        }
	
	// start contact form validation script //
		jQuery("#contactSubmitValue").click(function(){
			 var contactName=jQuery("#contactName").val(); 
		     var contactSurname=jQuery("#contactSurname").val();
		     var contactCompany=jQuery("#contactCompany").val();	
			 var contactPhone=jQuery("#contactPhone").val(); 
			 var contactEmail=jQuery("#contactEmail").val();
			 var contactComments=jQuery("#contactComments").val(); 
		     var error_color = "1px solid #ff0000";
			 var regEmail=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
			 var regPhone =/^((\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$)/i;
		     var errors="";
		     
		     if(contactName=="" || contactName==null)
				{
		         	jQuery("#contactName").css("border",error_color);
		         	errors+="<li>"+"Vul voornaam in"+"</li>"; 
				}
			
			else if(contactName!=="")
				{
					jQuery("#contactName").css("border","1px solid #D6D6D6");
				}
			 
			 if(contactSurname=="" || contactSurname==null)
			    {
			    	jQuery("#contactSurname").css("border",error_color);
					errors+="";
		        	errors+="<li>"+"Vul achternaam in"+"</li>"; 
				}
				
			 else if(contactSurname!=="")
			 	{
			 		jQuery("#contactSurname").css("border","1px solid #D6D6D6");
			 	}
			
			if(contactCompany=="" || contactCompany==null)
				{
			 		jQuery("#contactCompany").css("border",error_color);
					errors+="";
		        	errors+="<li>"+"Vul bedrijfsnaam in"+"</li>"; 
				}
				
			else if(contactCompany!=="")
				{
					jQuery("#contactCompany").css("border","1px solid #D6D6D6");
				}
			
			if(contactPhone=="" || contactPhone==null)
				{
			 		jQuery("#contactPhone").css("border",error_color);	
			    	errors+="";
		        	errors+="<li>"+"Vul telefoonnummer in."+"</li>"; 
				}
		    
		    else if(!regPhone.test(contactPhone))
				{
			 		jQuery("#contactPhone").css({border:error_color,color:"black"}).val("Vul telefoonnummer in");
					errors+="";
		        	errors+="<li>"+"Vul telefoonnummer in."+"</li>"; 
				}
				
			else if(contactPhone!=="" || regPhone.test(contactPhone))
				{
					jQuery("#contactPhone").css("border","1px solid #D6D6D6");
				}
			
		    if(contactEmail=="" || contactEmail==null)
				{
			 		jQuery("#contactEmail").css("border",error_color);
					errors+="";
		            errors+="<li>"+"Vul e-mailadres in"+"</li>"; 
				}
			
			else if(!regEmail.test(contactEmail))
				{
			 		jQuery("#contactEmail").val("Vul e-mailadres in").css({border:error_color,color:"black"});
			        errors+="";
		            errors+="<li>"+"Vul e-mailadres in"+"</li>"; 
				}
				
			else if(contactEmail!=="" || regEmail.test(contactEmail))
				{
					jQuery("#contactEmail").css("border","1px solid #D6D6D6");
				}
		    
		    if(contactComments=="" || contactComments==null)
				{
			 		jQuery("#contactComments").css("border",error_color);
					errors+="";
		            errors+="<li>"+"Vul opmerkingen in"+"</li>"; 
				}
				
			else if(contactComments!=="")
				{
					jQuery("#contactComments").css("border","1px solid #D6D6D6");
				}
		   	
		    if(errors!=="")
				{ 
		        	jQuery('body').scrollTo( {top:'560px', left:'0px'}, 800 ); 
		        	jQuery("#msg").html(errors);
					return false;
		        }
		    else if(errors=="")
				{
			  		return true;
		        }
			});
			
			// end contact form validation script //

});

