// --------------------------------------------------------- 
// Apertura/chiusura blocchi info 'onClick'
// Richiede i vettori {blockStatus_Array}, {blockDivs_Array} 
// Utilizzo: '/company/mills.php', '/company/history.php' 
// --------------------------------------------------------- 
	$(document).ready( 
		function() {
			var slideTime = 400;
			
			if ( this.href == '#' ) {
				alert( 'Sorry!\n\nNo link available' );
				return false;
			}	
				
			// Tipo popup 
			$("div.newsListingBox a.newsPopup").click(
				function () {
					window.open( this.href, 'details', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=800, height=600'); 
					return false;
				});
				// End {"click"}
				
			$("div.newsListingBox a.newsDiv").click(
				function () {
					
					var myLoad = this.href;
					$( "div#newsDetails" ).show( slideTime, 
						function () {
							$( "div#newsDetails" ).append('<div id="newsLoading">...loading...</div>');
							$( "div#newsDetails" ).load( myLoad, 
								function () {
									$( "div#newsLoading" ).remove();
									
									
									// --------------------------------------------------------
									// VIDEO 
									// --------------------------------------------------------
									$( 'div#overlay' ).animate( {opacity: "0.8"}, 1 );
											
									$( "a.video_link, a.group" ).click(
										function () {
												
											var popup_href = this.href;
											
											$( "div#overlay" ).fadeIn( slideTime, 
												function () {
													$( "div#productGallery" ).fadeIn( slideTime, 
														function () {
														
															// ::: Lettura popup video ::: 
															$( "div#galleryBoardImg" ).append('<div id="loadingImage">...loading...</div>');
															
															var myProperties = { width: popup_w, height: popup_h };
																		
															$( "div#galleryBoardImg" ).load( popup_href, 
																function () {
																	$( "div#galleryBoardImg-inner" ).animate( myProperties, 100, 
																		function () {
																			$( "div#loadingImage" ).remove();
																			
																			//alert(popup_href);
																		});
																	// End {"animate popup"}	
																});
															// End {"load popup"}	
															// ::: // Lettura popup video ::: 		
																	
															// ::: Tasto "chiudi" :::
															$( "div#productGallery a.close" ).click(
																function () {
																	$( "div#productGallery" ).fadeOut( slideTime, 
																		function () {
																			$( "div#overlay" ).fadeOut( slideTime,
																				function () {
																					$( "div#galleryArrowsImg" ).empty();
																				});
																			// End {"fadeOut overlay"}	
																		});
																	// End {"fadeOut productGallery"}	
																});
															// End {"click close"}		
															// ::: // Tasto "chiudi" :::
															
							
														});
													// End {"fadeIn productGallery"}
												});
											// End {"fadeIn overlay"}	
											
											return (false);
								
										});
									// End {"click video"}	
									// --------------------------------------------------------
									
									
									// --------------------------------------------------------
									// SEND TO FRIEND 
									// --------------------------------------------------------
									$('div#newsUtilities a#utilitySendToFriend').click( 
										function() {
															
											var myLoad = this.href;
											
											$( "div#overlay" ).fadeIn( slideTime, 
												function () {
													$( "div#sendToFriend" ).fadeIn( slideTime, 
														function () {
																										
															$( "div#sendToFriendBoard" ).load( myLoad, 
																function () {
																			
																	// ::: Tasto "chiudi" :::
																	$( "div#sendToFriend a.close" ).click(
																		function () {
																			$( "div#sendToFriend" ).fadeOut( slideTime, 
																				function () {
																					$( "div#overlay" ).fadeOut( slideTime,
																						function () {
																							$( "div#sendToFriendBoard" ).empty();
																						});
																					// End {"fadeOut overlay"}	
																				});
																			// End {"fadeOut productGallery"}	
																		});
																	// End {"click close"}			
																	// ::: // Tasto "chiudi" :::
																	
																	
																	// ::: Submit Form :::
																	$( "a#formSubmit" ).click(
																		function(){
																		
																			if ( SendToFriend_Validator( document.sendToFriendForm ) ) {
																							
																				$.ajax({
																					url: "inc_sendToFriend.php",
																					type: "POST", 
																					scriptCharset: "iso-8859-1", 
																					//scriptCharset: "iso-8859-1", 
																					data:  $("#sendToFriendForm").serialize(),
																					contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1",
																					dataType: "html",
																					success:
																						function( html ){
																							
																							$("div#sendToFriendBoard").empty().append( html ).show( 100, 
																								function(){
																									
																									// --------------------------------------
																									// Tasto "chiudi"
																									// --------------------------------------
																									$( "div#sendToFriend a.close" ).click(
																										function () {
																											$( "div#sendToFriend" ).fadeOut( slideTime, 
																												function () {
																													$( "div#overlay" ).fadeOut( slideTime,
																														function () {
																															$( "div#sendToFriendBoard" ).empty();
																														});
																													// End {"fadeOut overlay"}	
																												});
																											// End {"fadeOut productGallery"}	
																										});
																									// End {"click close"}			
																									// --------------------------------------
																										
																								});
																							// End {"Hide Attendere"}
																						}
																						// End {"Ajax success send"}
																				});
																				// End {"Ajax"}
																			
																			}
							
																			return (false);
																				
																		});
																	// End {"Click"}
																	// ::: // Submit Form :::
																						
																});
															// End {"load"}
														});
													// End {"load"}
												});
											// End {"fadeIn overlay"}
											
											return (false);
							
										});
									// End {"click send to friend"}
									// --------------------------------------------------------
									
									
									// --------------------------------------------------------
									// PRINT PAGE 
									// --------------------------------------------------------
									$('div#newsUtilities a#utilityPrint').click( 
										function() {
											window.open( this.href, 'printpage', 'toolbars=1, scrollbars=1, location=1, statusbars=0, menubars=1, resizable=1, width=800, height=600' ); 
											return (false);
										});
									// End {"click"} 
									// --------------------------------------------------------
									
									
									
									// --------------------------------------------------------
									// TASTO "chiudi" dettaglio 
									// --------------------------------------------------------
									$( "div#newsClose a" ).click(
										function () {
											$( "div#newsDetails" ).empty().hide( slideTime );
											return false;
										});		
									// End {"click close"}		
									// --------------------------------------------------------
															
								});
								// End {"load"}
						});
						// End {"show"}
								
					return false;
				});
				// End {"click"}
			
			
			
			
		});
		// End {"ready"}
		
// --------------------------------------------------------- 
// --------------------------------------------------------- 



// --------------------------------------------------- 	
// CHECK SEND TO FRIEND FORM  	
// --------------------------------------------------- 	
	function SendToFriend_Validator( theForm ) {	
		// Nome
		if ( theForm.elements[ 'new_name' ].value == "" ) {
			
			$( "div#formSearchCeck" ).fadeIn( 100, 
				function(){
					$( "div#formSearchCeck" ).empty().append( 'Invalid or missing Name.' ).fadeIn( 100, 
						function(){
							theForm.elements[ 'new_name' ].focus();
							
							$( "div#dealersSearchCech a.close" ).click(
								function(){
									$( "div#formSearchCeck" ).empty().fadeOut( 100 );
								});
							// End {"click close"}
						});
					// End {"fadeIn MSG"}
				});
			// End {"fadeIn Slert box"}
			return (false);
		}
		// Nome //			
		
		// E-mail
		if ( ( !( theForm.elements[ 'new_email' ].value.search(/^\w+((\+\w+)|(-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.([A-Za-z0-9])([A-Za-z0-9]?)([A-Za-z0-9]?)$/)!= -1)) || ( theForm.elements[ 'new_email' ].value == "" ) ) {  
			
			$( "div#formSearchCeck" ).fadeIn( 100, 
				function(){
					$( "div#formSearchCeck" ).empty().append( 'Invalid or missing E-mail.' ).fadeIn( 100, 
						function(){
							theForm.elements[ 'new_email' ].focus();
							
							$( "div#dealersSearchCech a.close" ).click(
								function(){
									$( "div#formSearchCeck" ).empty().fadeOut( 100 );
								});
							// End {"click close"}
						});
					// End {"fadeIn MSG"}
				});
			// End {"fadeIn Slert box"}
			return (false);
		}
		// E-mail //		
		
		
		// E-mail Amico
		if ( ( !( theForm.elements[ 'new_friend_email' ].value.search(/^\w+((\+\w+)|(-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.([A-Za-z0-9])([A-Za-z0-9]?)([A-Za-z0-9]?)$/)!= -1)) || ( theForm.elements[ 'new_friend_email' ].value == "" ) ) {  
			
			$( "div#formSearchCeck" ).fadeIn( 100, 
				function(){
					$( "div#formSearchCeck" ).empty().append( 'Invalid or missing E-mail.' ).fadeIn( 100, 
						function(){
							theForm.elements[ 'new_friend_email' ].focus();
							
							$( "div#dealersSearchCech a.close" ).click(
								function(){
									$( "div#formSearchCeck" ).empty().fadeOut( 100 );
								});
							// End {"click close"}
						});
					// End {"fadeIn MSG"}
				});
			// End {"fadeIn Slert box"}
			return (false);
		}
		// E-mail Amico //			
		
		
		// Messaggio
		if ( theForm.elements[ 'description' ].value == "" ) {
			
			$( "div#formSearchCeck" ).fadeIn( 100, 
				function(){
					$( "div#formSearchCeck" ).empty().append( 'Invalid or missing Messagge.' ).fadeIn( 100, 
						function(){
							theForm.elements[ 'description' ].focus();
							
							$( "div#dealersSearchCech a.close" ).click(
								function(){
									$( "div#formSearchCeck" ).empty().fadeOut( 100 );
								});
							// End {"click close"}
						});
					// End {"fadeIn MSG"}
				});
			// End {"fadeIn Slert box"}
			return (false);
		}
		// Messaggio //					
			
		
		
		
		//theForm.okForm.value = true;
		return (true);
	}
// --------------------------------------------------- 	
// --------------------------------------------------- 
