$(document).ready(function(){
                
                /*preloader*/
                $("#content").hide(); //on cache le contenu
                $("body").append('<div id="wait"><img src="css/img/loader_black.gif" alt="loading..."/></div>');
                
                

                /*--- Gallery Init ---
                $('.various1').fadeTo("slow", 0.3);               
                $('.various1').mouseover(function(){
                    $(this).fadeTo("fast", 1);  
                }).mouseleave(function(){
                    $(this).fadeTo("fast", 0.3);
                })  
                */
                /*--- SLider --- */
                
                /*--- Fancybox ---*/
                /*
                $("a.fancy_image").fancybox(    
                {
                    'hideOnContentClick': true,
                    'titlePosition'  : 'outside',
                    'padding':0,
                    'centerOnScroll':true,
                    'overlayOpacity':0,
                    'overlayColor': '#fff'
                    //                    'titleFormat':formatTitle                                       
                });
                */
                $("a.various1").fancybox(    
                {
                    
                    'padding':0,
                    'titlePosition'  : 'outside',
                    'centerOnScroll':true,
                    'overlayOpacity':0,
                    'overlayColor': '#fff'
                    //                    'titleFormat':formatTitle                                       
                })
                
                //close
                $("#fancy_close").click(function(){                
                  $.fancybox.close();
                })
                
                
                /*--- END Fancybox ---*/
                
                $(".resize").css("display","none");
                $(".various1").mouseover(function(){
                
                  $(this).children(".resize").css('display','block');
                  //alert('coucouc');
                
                }).mouseout(function(){
                      $(this).children(".resize").css('display','none');             
                });
                

                /*--- More information ---*/                
                
                //$('#more_content').hide();             
                $('#more_content').css('display', 'none');
                
                $('#more').click(function(){
                    $('#more_content').slideToggle('slow');  
                    //$("#more").text($("#more_content").is(":Show") ? "Hide" : "Show");
                })  
               /*--- FORM ---*/
               $('#Email').focus(function(){                    
                       $(this).css("border","3px solid yellow");
              }).focusout(function(){
                       $(this).css("border","none");
              
              })
              $('#Message').focus(function(){                    
                       $(this).css("border","3px solid yellow");
              }).focusout(function(){
                       $(this).css("border","none");
              
              })
              $('#submit').mouseover(function(){
              
                $(this).val('send message');
              
              }).mouseout(function(){
                $(this).val('contact me');
              
              })
              //hide labels                
              //$('label').hide();//FF Chrome
              //$('#form label').css('display','none');//fix IE
              //input behaviour   
              /*           
              $('#cname').click(function(){                    
                       $(this).val("");
                       //alert("hello ie");
              })
              $('#cemail').click(function(){                    
                       $(this).val("");
              })
              $('#ccomment').click(function(){                    
                       $(this).val("");
              })
              */
              //soumission du forumlaire
              
              $('#submit').click(function(){               
                        //recuperation variable
                        if(validTextField("MyForm", "Message") && validMailField("MyForm", "Email"))
                        {
                            //recuperation variable
                            //var cname = $("#cname").val();
                            var email = $("#Email").val();
                            var message = $("#Message").val();     
                            sendMail(email, message);
                            //alert('thank you! '+ email);
                            $("#form").hide();
                            $('#form').after('<h2>Thank you!</h2>');                        
                        }else{
                            alert('oups. Check the fields.');
                        }                           
              })  
              
              
              




});
// preloader suite //
$(window).load(function(){
$("#wait").hide();
$("#content").fadeIn();
});    
            
            
function validTextField($formName, $fieldName)
{
var x=document.forms[$formName][$fieldName].value;
if (x==null || x=="")
  {
  //alert("First name must be filled out");
  return false;
  } else{
  return true;
  
  }
}
function validMailField($formName, $fieldName)
{
var x=document.forms[$formName][$fieldName].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
  //alert("Not a valid e-mail address");
  return false;
  }else{
  return true;
  }
}
function sendMail( $e, $m )
{
  //alert($e + ' - ' + $m);
  $.get("../2011/php/proxy.php", 
          {   
              site:"hellodudes.com", 
              recipnosite:"mail", 
              subject: "message site",
              redirect:"http://www.hellodudes.com",
              nom: 'name random',
              email: $e,
              commentaire: $m
          });
}
