﻿var IntervalId;
var galFrameId = 1;
var max_galFrameId = 5;
var LastTabOpen = "tab1";

var headline_count;
var headline_interval;
var current_headline = 0;
var old_headline = 0;



$(document).ready(function() {

    $('div.largeImage a').lightBox();
    
    $('li.hover').hover(
    function() {
    //$(this).children("ul.hide").slideDown("fast").addClass("sub");
    $(this).children("ul.hide").show();
    },
    function() {
    //$(this).children("ul.hide").slideUp("fast").removeClass("sub");
    $(this).children("ul.hide").hide();
    });

    $('div.menu ul li').hover(
    function() {
    $(this).addClass('menuHover');
    },
    function() {
    $(this).removeClass('menuHover');
    }); 
    
    // second hand yacht details
    $('div.SecYachtDetails img').each(function() {
        var thisImgScSrc = $(this).attr('src');
        $(this).wrap('<a href="#"></a>');
        $(this).parent('a').attr('href' , thisImgScSrc).lightBox();
    });   
    
    
    //gallery
	$(".smallImage a").click(function(){
	
		var largePath = $(this).attr("href");
		$("#theImage").attr({ src: largePath });
		 return false;
	});

        $("#theImage").error(function() {
        $("div.newsGalleryLarge").addClass("noBg");
        
});

    $('div.linkPage ul li a').click(function() { this.target = "_blank"; });

    //submenu
    
    $('div.subMenu ul li:first-child').css('border-right','0');
    
    $('div.saleItemLineL p:eq(0)').addClass('saleFirst');
    $('div.saleItemLine p:eq(0)').addClass('saleFirst');
    
    $('div.menu ul li:first').addClass('yacht_sale');
    $('div.menu ul li ul.hide li:first').removeClass('yacht_sale');
    $('div.menu ul li:last-child').addClass('post_msgs');
    $('div.menu ul li ul.hide li:last').removeClass('post_msgs'); 
    
    $('ul.yachtTabs li').click(function() {
        $('ul.yachtTabs li').removeClass('tabActive');  
            
     if (LastTabOpen != this.className) {
     
        $('#ctl00_ContentPlaceHolder1_' + LastTabOpen ).hide();
        $('#ctl00_ContentPlaceHolder1_' + this.className).show();
         LastTabOpen = this.className;
        }
        $('ul.yachtTabs li.' + this.className).addClass('tabActive'); 
        
    }); 
    
    $('table.saleBuy tr:first td').css('border-top','0');
    $('table.saleBuy tr:last-child td').css('border-bottom','1px solid #E1E1E1');
    
    //french scroll top
	$('a.backTop').click(function(){
    $('html, body').animate({scrollTop:0}, 'slow');
    });
    
    $('ul.frenchPlaces li a , ul.linksPlaces li a').click(function(){
    var curent = $(this).attr("href");
    $('html, body').scrollTo( curent , 'slow' );
    });       
     $('a[href^=#]').click(function () {return false;});
   
    
    $('table.saleBuy tr').hover(
        function() {
        $(this).css('background-color','#F6F6F6');
        },
        function() {
        $(this).css('background-color','#F1F1F1');
        });
    
    $('div.sideMenu ul.sideMenuNav li').hover(
        function() {
        $(this).addClass('sideActive');
        },
        function() {
        $(this).removeClass('sideActive');
        });
        
    $('div.yachtGalBox').hover(
        function() {
        $(this).css('background-color','#C5D1DD');
        },
        function() {
        $(this).css('background-color','#E3E9EF');
        });
        
    $('ul.yachtTabs li').hover(
        function() {
        $(this).css('background-color','#C4CDD8');
        },
        function() {
        $(this).css('background-color','#E3E9EF');
        });  
        
        //msg_board table td open
        $('tr.postOpen').hide();
        $('table.saleBuyOpen tr').toggle(
            function() {
            $(this).next('tr.postOpen').show();
            $(this).children('td.tdDetails').html('סגור חלון');
            },
            function() {
            $(this).next('tr.postOpen').hide();
            $(this).children('td.tdDetails').html('לפרטים נוספים');
            });
            
            
        //index scrolling news - NEW
  headline_count = $("div.newsArticle").size();
  $("div.newsArticle:eq("+current_headline+")").css('top', '2px');
 
  headline_interval = setInterval(headline_rotate,5500);
  $('div.newsInner').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,5500);
    headline_rotate();
  });
function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count;
  $("div.newsArticle:eq(" + old_headline + ")")
    .animate({top: -150},"slow", function() {
      $(this).css('top', '155px');
    });
  $("div.newsArticle:eq(" + current_headline + ")")
    .animate({top: 2},"slow");  
  old_headline = current_headline;
}
    
    //slideshow numbers buttons
      $('.switchNav ul li').click(function() {
        var id = $(this).text();
        if(id != galFrameId)
        {
        clearInterval(IntervalId);
        galleryClick(id);
        }
    });  
    
    //search page click button - show result
    $('.search_but').click(function() {
        $('div.searchResult').show();
        return false;
    });
    

       var prm = Sys.WebForms.PageRequestManager.getInstance();   
        prm.add_endRequest(function(s, e) {   
        //click on yacht details text - form in toggle
        $('p.priceToggle').click(function() {
            $('div.searchForm').toggle();
        });
     }); 
    



        //Gultim Page Validation    
        $(".butFormGul").click(function() {  
        return checkFormGul();         
        });  
     
    function checkFormGul()
    {
    
         FirstCheckGul = false;
        check = true;


        $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateUntill , input#tbDateUntill").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateUntill , input#tbDateUntill").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateUntill , input#tbDateUntill").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateUntill , input#tbDateUntill").focus();  
         check = false;
       }                   
        $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateFrom , input#tbDateFrom").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateFrom , input#tbDateFrom").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateFrom , input#tbDateFrom").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbDateFrom , input#tbDateFrom").focus();  
         check = false;
       }                   
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulEmail , input#tbMail").prev('span').removeClass();   
         var email20 = $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulEmail , input#tbMail").val();   
           if (email20 == "" || !(emailChek(email20)) ) {  
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulEmail , input#tbMail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulEmail , input#tbMail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulPhone , input#tbGulPhone").prev('span').removeClass(); 
         var phone20 = $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulPhone , input#tbGulPhone").val();   
           if (phone20.length < 7 || !(IsNumeric(phone20))) {            
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulPhone , input#tbGulPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulPhone , input#tbGulPhone").focus();  
         check = false;
       }   
        $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulAddress , input#tbGulAddress").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulAddress , input#tbGulAddress").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulAddress , input#tbGulAddress").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulAddress , input#tbGulAddress").focus();  
         check = false;
       }                  
        $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulName , input#tbGulName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulName , input#tbGulName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulName , input#tbGulName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactGultim_tbGulName , input#tbGulName").focus();  
         check = false;
       }            
       return check;                 
    }
    
    
    
    //Canal Page Validation    
        $(".butFormCan").click(function() {  
        return checkFormCan();         
        });  
     
    function checkFormCan()
    {
    
         FirstCheckCan = false;
        check = true;


        $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateUntill , input#tbCanDateUntill").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateUntill , input#tbCanDateUntill").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateUntill , input#tbCanDateUntill").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateUntill , input#tbCanDateUntill").focus();  
         check = false;
       }                   
        $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateFrom , input#tbCanDateFrom").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateFrom , input#tbCanDateFrom").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateFrom , input#tbCanDateFrom").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanDateFrom , input#tbCanDateFrom").focus();  
         check = false;
       }                   
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanEmail , input#tbMail").prev('span').removeClass();   
         var email21 = $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanEmail , input#tbMail").val();   
           if (email21 == "" || !(emailChek(email21)) ) {  
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanEmail , input#tbMail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanEmail , input#tbMail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanPhone , input#tbCanPhone").prev('span').removeClass(); 
         var phone21 = $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanPhone , input#tbCanPhone").val();   
           if (phone21.length < 7 || !(IsNumeric(phone21))) {            
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanPhone , input#tbCanPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanPhone , input#tbCanPhone").focus();  
         check = false;
       }   
        $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanAddress , input#tbCanAddress").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanAddress , input#tbCanAddress").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanAddress , input#tbCanAddress").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanAddress , input#tbCanAddress").focus();  
         check = false;
       }                  
        $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanName , input#tbCanName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanName , input#tbCanName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanName , input#tbCanName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContactCanal_tbCanName , input#tbCanName").focus();  
         check = false;
       }            
       return check;                 
    }
    
    
        //Self Page Validation    
        $(".butFormSelf").click(function() {  
        return checkFormSelf();         
        });  
     
    function checkFormSelf()
    {
    
         FirstCheckSelf = false;
        check = true;


        $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateUntill , input#tbSelfDateUntill").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateUntill , input#tbSelfDateUntill").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateUntill , input#tbSelfDateUntill").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateUntill , input#tbSelfDateUntill").focus();  
         check = false;
       }                   
        $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateFrom , input#tbSelfDateFrom").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateFrom , input#tbSelfDateFrom").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateFrom , input#tbSelfDateFrom").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfDateFrom , input#tbSelfDateFrom").focus();  
         check = false;
       }                   
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfEmail , input#tbMail").prev('span').removeClass();   
         var email22 = $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfEmail , input#tbMail").val();   
           if (email22 == "" || !(emailChek(email22)) ) {  
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfEmail , input#tbMail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfEmail , input#tbMail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfPhone , input#tbSelfPhone").prev('span').removeClass(); 
         var phone22 = $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfPhone , input#tbSelfPhone").val();   
           if (phone22.length < 7 || !(IsNumeric(phone22))) {            
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfPhone , input#tbSelfPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfPhone , input#tbSelfPhone").focus();  
         check = false;
       }   
        $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfAddress , input#tbSelfAddress").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfAddress , input#tbSelfAddress").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfAddress , input#tbSelfAddress").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfAddress , input#tbSelfAddress").focus();  
         check = false;
       }                  
        $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfName , input#tbSelfName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfName , input#tbSelfName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfName , input#tbSelfName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_SideContactSelf_tbSelfName , input#tbSelfName").focus();  
         check = false;
       }            
       return check;                 
    }    


        //Madhef Page Validation    
        $(".butFormMad").click(function() {  
        return checkFormMad();         
        });  
     
    function checkFormMad()
    {
    
         FirstCheckMad = false;
        check = true;

         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadEmail , input#tbMadEmail").prev('span').removeClass();   
         var email30 = $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadEmail , input#tbMadEmail").val();   
           if (email30 == "" || !(emailChek(email30)) ) {  
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadEmail , input#tbMadEmail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadEmail , input#tbMadEmail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadPhone , input#tbMadPhone").prev('span').removeClass(); 
         var phone30 = $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadPhone , input#tbMadPhone").val();   
           if (phone30.length < 7 || !(IsNumeric(phone30))) {            
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadPhone , input#tbMadPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadPhone , input#tbMadPhone").focus();  
         check = false;
       }                
        $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadName , input#tbMadName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadName , input#tbMadName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadName , input#tbMadName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMadhef_tbMadName , input#tbMadName").focus();  
         check = false;
       }            
       return check;                 
    }  


        //Mefrasim Page Validation    
        $(".butFormMef").click(function() {  
        return checkFormMef();         
        });  
     
    function checkFormMef()
    {
    
         FirstCheckMef = false;
        check = true;

         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefEmail , input#tbMefEmail").prev('span').removeClass();   
         var email30 = $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefEmail , input#tbMefEmail").val();   
           if (email30 == "" || !(emailChek(email30)) ) {  
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefEmail , input#tbMefEmail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefEmail , input#tbMefEmail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefPhone , input#tbMefPhone").prev('span').removeClass(); 
         var phone30 = $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefPhone , input#tbMefPhone").val();   
           if (phone30.length < 7 || !(IsNumeric(phone30))) {            
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefPhone , input#tbMefPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefPhone , input#tbMefPhone").focus();  
         check = false;
       }                
        $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefName , input#tbMefName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefName , input#tbMefName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefName , input#tbMefName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideCanaeMefrasim_tbMefName , input#tbMefName").focus();  
         check = false;
       }            
       return check;                 
    }       
    
    
    
    
        //postmsg_form Validation    
        $(".searchFormBut2").click(function() {  
        return checkForm();         
        });  
     
    function checkForm()
    {
    
         FirstCheckPost = false;
        check = true;

        $("textarea#ctl00_ContentPlaceHolder1_tbMsg , textarea#tbMsg").prev('span').removeClass();    
           if ($("textarea#ctl00_ContentPlaceHolder1_tbMsg , textarea#tbMsg").val() == "") {  
         $("textarea#ctl00_ContentPlaceHolder1_tbMsg , textarea#tbMsg").prev('span').addClass('fieldhover');    
         $("textarea#ctl00_ContentPlaceHolder1_tbMsg , textarea#tbMsg").focus();  
         check = false;
       }                     
         $("input#ctl00_ContentPlaceHolder1_tbMail , input#tbMail").prev('span').removeClass();   
         var email = $("input#ctl00_ContentPlaceHolder1_tbMail , input#tbMail").val();   
           if (email == "" || !(emailChek(email)) ) {  
         $("input#ctl00_ContentPlaceHolder1_tbMail , input#tbMail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbMail , input#tbMail").focus();  
         check = false;
       }              
          $("input#ctl00_ContentPlaceHolder1_tbPhone , input#tbPhone").prev('span').removeClass(); 
         var phone = $("input#ctl00_ContentPlaceHolder1_tbPhone , input#tbPhone").val();   
           if (phone.length < 7 || !(IsNumeric(phone))) {            
         $("input#ctl00_ContentPlaceHolder1_tbPhone , input#tbPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbPhone , input#tbPhone").focus();  
         check = false;
       }   
        $("input#ctl00_ContentPlaceHolder1_tbAdress , input#tbAdress").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbAdress , input#tbAdress").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbAdress , input#tbAdress").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbAdress , input#tbAdress").focus();  
         check = false;
       }                  
        $("input#ctl00_ContentPlaceHolder1_tbName , input#tbName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbName , input#tbName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbName , input#tbName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbName , input#tbName").focus();  
         check = false;
       }            
       return check;                 
    }
    
        //yachtPrice Form Validation
        $(".searchFormBut").click(function() {  
        return checkForm11();         
        });  
     
    function checkForm11()
    {
         SecondCheckYachPrice = false;
        check = true;
                 
          $("input#ctl00_ContentPlaceHolder1_tbPricePhone , input#tbPricePhone").prev('span').removeClass(); 
         var phone44 = $("input#ctl00_ContentPlaceHolder1_tbPricePhone , input#tbPricePhone").val();   
           if (phone44.length < 7 || !(IsNumeric(phone44))) {            
         $("input#ctl00_ContentPlaceHolder1_tbPricePhone , input#tbPricePhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbPricePhone , input#tbPricePhone").focus();  
         check = false;
       }                
         $("input#ctl00_ContentPlaceHolder1_tbPriceEmail , input#tbPriceEmail").prev('span').removeClass();   
         var email44 = $("input#ctl00_ContentPlaceHolder1_tbPriceEmail , input#tbPriceEmail").val();   
           if (email44 == "" || !(emailChek(email44)) ) {  
         $("input#ctl00_ContentPlaceHolder1_tbPriceEmail , input#tbPriceEmail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbPriceEmail , input#tbPriceEmail").focus();  
         check = false;
       }         
        $("input#ctl00_ContentPlaceHolder1_tbPriceName , input#tbPriceName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbPriceName , input#tbPriceName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbPriceName , input#tbPriceName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbPriceName , input#tbPriceName").focus();  
         check = false;
       }                                
       return check;                 
    }     




        //more info box Form Validation
        $(".butForm , .butFormS").click(function() {  
        return checkForm3();         
        });  
     
    function checkForm3()
    {
         FirstCheckMain = false;
        check = true;
                
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbEmail , input#tbEmail").prev('span').removeClass();   
         var email3 = $("input#ctl00_ContentPlaceHolder1_sideContact_tbEmail , input#tbEmail").val();   
           if (email3 == "" || !(emailChek(email3)) ) {  
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbEmail , input#tbEmail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbEmail , input#tbEmail").focus();  
         check = false;
       }   
          $("input#ctl00_ContentPlaceHolder1_sideContact_tbPhone , input#tbPhoneL").prev('span').removeClass(); 
         var phone3 = $("input#ctl00_ContentPlaceHolder1_sideContact_tbPhone , input#tbPhoneL").val();   
           if (phone3.length < 7 || !(IsNumeric(phone3))) {            
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbPhone , input#tbPhoneL").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbPhone , input#tbPhoneL").focus();  
         check = false;
       }         
        $("input#ctl00_ContentPlaceHolder1_sideContact_tbName , input#tbName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_sideContact_tbName , input#tbName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbName , input#tbName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_sideContact_tbName , input#tbName").focus();  
         check = false;
       }                                
       return check;                 
    } 
    
  
    
        //Contact form Validation    
        $(".contactBut").click(function() {  
        return checkForm9();         
        });  
     
    function checkForm9()
    {
         FirstCheckContact = false;
        check = true;

        $("input#ctl00_ContentPlaceHolder1_tbConSubject , input#tbConSubject").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbConSubject , input#tbConSubject").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbConSubject , input#tbConSubject").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbConSubject , input#tbConSubject").focus();  
         check = false;
       }           
        $("input#ctl00_ContentPlaceHolder1_tbConContact , input#tbConContact").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbConContact , input#tbConContact").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbConContact , input#tbConContact").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbConContact , input#tbConContact").focus();  
         check = false;
       }                
          $("input#ctl00_ContentPlaceHolder1_tbConPhone , input#tbConPhone").prev('span').removeClass(); 
         var phone9 = $("input#ctl00_ContentPlaceHolder1_tbConPhone , input#tbConPhone").val();   
           if (phone9.length < 7 || !(IsNumeric(phone9))) {            
         $("input#ctl00_ContentPlaceHolder1_tbConPhone , input#tbConPhone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbConPhone , input#tbConPhone").focus();  
         check = false;
       }                  
         $("input#ctl00_ContentPlaceHolder1_tbConEmail , input#tbConEmail").prev('span').removeClass();   
         var email9 = $("input#ctl00_ContentPlaceHolder1_tbConEmail , input#tbConEmail").val();   
           if (email9 == "" || !(emailChek(email9)) ) {  
         $("input#ctl00_ContentPlaceHolder1_tbConEmail , input#tbConEmail").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbConEmail , input#tbConEmail").focus();  
         check = false;
       }           
        $("input#ctl00_ContentPlaceHolder1_tbConName , input#tbConName").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbConName , input#tbConName").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbConName , input#tbConName").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbConName , input#tbConName").focus();  
         check = false;
       }                                
       return check;                 
    }      
    

        //Yacht Price Form Validation
        $(".yachtPriceBut").click(function() {  
        return checkForm4();         
        });  
     
    function checkForm4()
    {
         FirstCheckYachPrice = false;
        check = true;
                
         $("input#ctl00_ContentPlaceHolder1_tbYp_Email , input#tbYp_Email").prev('span').removeClass();   
         var email4 = $("input#ctl00_ContentPlaceHolder1_tbYp_Email , input#tbYp_Email").val();   
           if (email4 == "" || !(emailChek(email4)) ) {  
         $("input#ctl00_ContentPlaceHolder1_tbYp_Email , input#tbYp_Email").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbYp_Email , input#tbYp_Email").focus();  
         check = false;
       }   
          $("input#ctl00_ContentPlaceHolder1_tbYp_Phone , input#tbYp_Phone").prev('span').removeClass(); 
         var phone4 = $("input#ctl00_ContentPlaceHolder1_tbYp_Phone , input#tbYp_Phone").val();   
           if (phone4.length < 7 || !(IsNumeric(phone4))) {            
         $("input#ctl00_ContentPlaceHolder1_tbYp_Phone , input#tbYp_Phone").prev('span').addClass('fieldhover');         
         $("input#ctl00_ContentPlaceHolder1_tbYp_Phone , input#tbYp_Phone").focus();  
         check = false;
       }    
        $("input#ctl00_ContentPlaceHolder1_tbYp_Address , input#tbYp_Address").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbYp_Address , input#tbYp_Address").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbYp_Address , input#tbYp_Address").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbYp_Address , input#tbYp_Address").focus();  
         check = false;
       }              
        $("input#ctl00_ContentPlaceHolder1_tbYp_Name , input#tbYp_Name").prev('span').removeClass();    
           if ($("input#ctl00_ContentPlaceHolder1_tbYp_Name , input#tbYp_Name").val() == "") {  
         $("input#ctl00_ContentPlaceHolder1_tbYp_Name , input#tbYp_Name").prev('span').addClass('fieldhover');    
         $("input#ctl00_ContentPlaceHolder1_tbYp_Name , input#tbYp_Name").focus();  
         check = false;
       }                                
       return check;                 
    } 
        

       
    
    function emailChek(str)
    {

		    var at="@"
		    var dot="."
		    var lat=str.indexOf(at)
		    var lstr=str.length
		    var ldot=str.indexOf(dot)
		    if (str.indexOf(at)==-1){
    		  
		       return false
		    }

		    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    		   
		       return false
		    }

		    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    		    
		        return false
		    }

		     if (str.indexOf(at,(lat+1))!=-1){

		        return false
		     }

		     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		        return false
		     }

		     if (str.indexOf(dot,(lat+2))==-1){

		        return false
		     }
    		
		     if (str.indexOf(" ")!=-1){
    		    
		        return false
		     }

 		     return true					
    }
    
    function IsNumeric(inputVal) 
    {
         if (isNaN(parseFloat(inputVal))) 
         { 
              return false;
         }
         else
         {
            return true;
         }
    }        

});


function slideShow() {   
  
    
    $('#gallery a').css({opacity: 0.0});   
    $('#gallery a:first').css({opacity: 1.0});   
    $('#gallery .caption').css({opacity: 0.8});   
    $('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});   
    $('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))   
    .animate({opacity: 0.7}, 400);    
    document.getElementById('frameBut'  + galFrameId).className = 'switchActive';
    IntervalId = setInterval('gallery()',5000);
           
}   
  
function gallery() 
{
   
    var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));   
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));       
    var caption = next.find('img').attr('rel');    
     
    next.css({opacity: 0.0})   
    .addClass('show')
    .animate({opacity: 1.0}, 1000)
   
    current.animate({opacity: 0.0}, 1000)   
    .removeClass('show');
       
    $('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });    
       
    $('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );   
       
    $('#gallery .content').html(caption);
    
    // changing numbers buttons class
    document.getElementById('frameBut'  + galFrameId).className = '';
    if(galFrameId < max_galFrameId)
    {
        galFrameId++;
    }
    else
    {
        galFrameId = 1;
    }
    document.getElementById('frameBut'  + galFrameId).className = 'switchActive';
           
}  

  
function galleryClick(divId) {   
       
    var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));   
    var next = $('#a' + divId);

    var caption = $('#a' + divId).find('img').attr('rel');    
    
    next.css({opacity: 0.0})   
    .addClass('show')   
    .animate({opacity: 1.0}, 1000);   
   
    current.animate({opacity: 0.0}, 1000)   
    .removeClass('show');   
       
    $('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });    
       
    $('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );   
       
    $('#gallery .content').html(caption);   
    
    // changing numbers buttons class
    document.getElementById('frameBut'  + galFrameId).className = '';
    galFrameId = divId;
    document.getElementById('frameBut'  + galFrameId).className = 'switchActive';
   
}




/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 *
 * @projectDescription Easy element scrolling using jQuery.
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * Tested with jQuery 1.2.6. On FF 2/3, IE 6/7, Opera 9.2/5 and Safari 3. on Windows.
 *
 * @author Ariel Flesler
 * @version 1.4
 *
 * @id jQuery.scrollTo
 * @id jQuery.fn.scrollTo
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
 *	  The different options for target are:
 *		- A number position (will be applied to all axes).
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
 * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *	 @option {Number} duration The OVERALL length of the animation.
 *	 @option {String} easing The easing method for the animation.
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
 *	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *	 @option {Function} onAfter Function to be called after the scrolling ends. 
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @desc Scroll to a fixed position
 * @example $('div').scrollTo( 340 );
 *
 * @desc Scroll relatively to the actual position
 * @example $('div').scrollTo( '+=340px', { axis:'y' } );
 *
 * @dec Scroll using a selector (relative to the scrolled element)
 * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
 *
 * @ Scroll to a DOM element (same for jQuery object)
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
 *			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
 *				alert('scrolled!!');																   
 *			}});
 *
 * @desc Scroll on both axes, to different values
 * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
 */
;(function( $ ){
	
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'y',
		duration:1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
	$scrollTo.window = function( scope ){
		return $(window).scrollable();
	};

	// Hack, hack, hack... stay away!
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn.scrollable = function(){
		return this.map(function(){
			// Just store it, we might need it
			var win = this.parentWindow || this.defaultView,
				// If it's a document, get its iframe or the window if it's THE document
				elem = this.nodeName == '#document' ? win.frameElement || win : this,
				// Get the corresponding document
				doc = elem.contentDocument || (elem.contentWindow || elem).document,
				isWin = elem.setInterval;

			return elem.nodeName == 'IFRAME' || isWin && $.browser.safari ? doc.body
				: isWin ? doc.documentElement
				: this;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };
			
		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue && settings.axis.length > 1;
		
		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this.scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(px)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target 
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					Dim = axis == 'x' ? 'Width' : 'Height',
					dim = Dim.toLowerCase();

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					
					attr[key] += settings.offset[pos] || 0;
					
					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[dim]() * settings.over[pos];
				}else
					attr[key] = targ[pos];

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );

				// Queueing axes
				if( !i && settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});			
			animate( settings.onAfter );			

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};
			function max( Dim ){
				var attr ='scroll'+Dim,
					doc = elem.ownerDocument;
				
				return win
						? Math.max( doc.documentElement[attr], doc.body[attr]  )
						: elem[attr];
			};
		}).end();
	};

	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};

})( jQuery );











/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
(function($) {
	/**
	 * $ is an alias to jQuery object
	 *
	 */
	$.fn.lightBox = function(settings) {
		// Settings to configure the jQuery lightBox plugin how you like
		settings = jQuery.extend({
			// Configuration related to overlay
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to navigation
			fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
			// Configuration related to images
			imageLoading:			'UserFiles/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'UserFiles/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'UserFiles/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'UserFiles/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'UserFiles/images/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'of',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Don´t alter these variables in any way
			imageArray:				[],
			activeImage:			0
		},settings);
		// Caching the jQuery object with all elements matched
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
		/**
		 * Initializing the plugin calling the start function
		 *
		 * @return boolean false
		 */
		function _initialize() {
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
			return false; // Avoid the browser following the link
		}
		/**
		 * Start the jQuery lightBox plugin
		 *
		 * @param object objClicked The object (link) whick the user have clicked
		 * @param object jQueryMatchedObj The jQuery object with all elements matched
		 */
		function _start(objClicked,jQueryMatchedObj) {
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			// Call the function to create the markup structure; style some elements; assign events in some elements.
			_set_interface();
			// Unset total images in imageArray
			settings.imageArray.length = 0;
			// Unset image active information
			settings.activeImage = 0;
			// We have an image set? Or just an image? Let´s see it.
			if ( jQueryMatchedObj.length == 1 ) {
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references		
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			// Call the function that prepares image exibition
			_set_image_to_view();
		}
		/**
		 * Create the jQuery lightBox plugin interface
		 *
		 * The HTML markup will be like that:
			<div id="jquery-overlay"></div>
			<div id="jquery-lightbox">
				<div id="lightbox-container-image-box">
					<div id="lightbox-container-image">
						<img src="../fotos/XX.jpg" id="lightbox-image">
						<div id="lightbox-nav">
							<a href="#" id="lightbox-nav-btnPrev"></a>
							<a href="#" id="lightbox-nav-btnNext"></a>
						</div>
						<div id="lightbox-loading">
							<a href="#" id="lightbox-loading-link">
								<img src="UserFiles/images/lightbox-ico-loading.gif">
							</a>
						</div>
					</div>
				</div>
				<div id="lightbox-container-image-data-box">
					<div id="lightbox-container-image-data">
						<div id="lightbox-image-details">
							<span id="lightbox-image-details-caption"></span>
							<span id="lightbox-image-details-currentNumber"></span>
						</div>
						<div id="lightbox-secNav">
							<a href="#" id="lightbox-secNav-btnClose">
								<img src="UserFiles/images/lightbox-btn-close.gif">
							</a>
						</div>
					</div>
				</div>
			</div>
		 *
		 */
		function _set_interface() {
			// Apply the HTML markup into body tag
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"></div></div></div></div>');	
			// Get page sizes
			var arrPageSizes = ___getPageSize();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	settings.overlayBgColor,
				opacity:			settings.overlayOpacity,
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
			// Get page scroll
			var arrPageScroll = ___getPageScroll();
			// Calculate top and left offset for the jquery-lightbox div object and show it
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
				left:	arrPageScroll[0]
			}).show();
			// Assigning click events in elements to close overlay
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();									
			});
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				// Style overlay and show it
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox div object and show it
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			});
		}
		/**
		 * Prepares image exibition; doing a image´s preloader to calculate it´s size
		 *
		 */
		function _set_image_to_view() { // show the loading
			// Show the loading
			$('#lightbox-loading').show();
			if ( settings.fixedNavigation ) {
				$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			} else {
				// Hide some elements
				$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			}
			// Image preload process
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
			};
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
		};
		/**
		 * Perfomance an effect in the image container resizing it
		 *
		 * @param integer intImageWidth The image´s width that will be showed
		 * @param integer intImageHeight The image´s height that will be showed
		 */
		function _resize_container_image_box(intImageWidth,intImageHeight) {
			// Get current width and height
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
			// Get the width and height of the selected image plus the padding
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
			// Diferences
			var intDiffW = intCurrentWidth - intWidth;
			var intDiffH = intCurrentHeight - intHeight;
			// Perfomance the effect
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);	
				}
			} 
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
		};
		/**
		 * Show the prepared image
		 *
		 */
		function _show_image() {
			$('#lightbox-loading').hide();
			$('#lightbox-image').fadeIn(function() {
				_show_image_data();
				_set_navigation();
			});
			_preload_neighbor_images();
		};
		/**
		 * Show the image information
		 *
		 */
		function _show_image_data() {
			$('#lightbox-container-image-data-box').slideDown('fast');
			$('#lightbox-image-details-caption').hide();
			if ( settings.imageArray[settings.activeImage][1] ) {
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
			}
			// If we have a image set, display 'Image X of X'
			if ( settings.imageArray.length > 1 ) {
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
			}		
		}
		/**
		 * Display the button navigations
		 *
		 */
		function _set_navigation() {
			$('#lightbox-nav').show();

			// Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
			
			// Show the prev button, if not the first image in set
			if ( settings.activeImage != 0 ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage - 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnPrev').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage - 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			
			// Show the next button, if not the last image in set
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage + 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnNext').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage + 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			// Enable keyboard navigation
			_enable_keyboard_navigation();
		}
		/**
		 * Enable a support to keyboard navigation
		 *
		 */
		function _enable_keyboard_navigation() {
			$(document).keydown(function(objEvent) {
				_keyboard_action(objEvent);
			});
		}
		/**
		 * Disable the support to keyboard navigation
		 *
		 */
		function _disable_keyboard_navigation() {
			$(document).unbind();
		}
		/**
		 * Perform the keyboard actions
		 *
		 */
		function _keyboard_action(objEvent) {
			// To ie
			if ( objEvent == null ) {
				keycode = event.keyCode;
				escapeKey = 27;
			// To Mozilla
			} else {
				keycode = objEvent.keyCode;
				escapeKey = objEvent.DOM_VK_ESCAPE;
			}
			// Get the key in lower case form
			key = String.fromCharCode(keycode).toLowerCase();
			// Verify the keys to close the ligthBox
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
				_finish();
			}
			// Verify the key to show the previous image
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
				// If we´re not showing the first image, call the previous
				if ( settings.activeImage != 0 ) {
					settings.activeImage = settings.activeImage - 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
			// Verify the key to show the next image
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
				// If we´re not showing the last image, call the next
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
					settings.activeImage = settings.activeImage + 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
		}
		/**
		 * Preload prev and next images being showed
		 *
		 */
		function _preload_neighbor_images() {
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
				objNext = new Image();
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
			}
			if ( settings.activeImage > 0 ) {
				objPrev = new Image();
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
			}
		}
		/**
		 * Remove jQuery lightBox plugin HTML markup
		 *
		 */
		function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		/**
		 / THIRD FUNCTION
		 * getPageSize() by quirksmode.com
		 *
		 * @return Array Return an array with page width, height and window width, height
		 */
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		 / THIRD FUNCTION
		 * getPageScroll() by quirksmode.com
		 *
		 * @return Array Return an array with x,y page scroll values.
		 */
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		 /**
		  * Stop the code execution from a escified time in milisecond
		  *
		  */
		 function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		 };
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
		return this.unbind('click').click(_initialize);
	};
})(jQuery); // Call and execute the function immediately passing the jQuery object
