$(document).ready( function() 
{
     
    var IE_6 = detect_IE_6();
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Check If The Headers Contains 'Best Projects Section' and Show The First One  ////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
     if( document.getElementById( "lps_description_Holder" ) )
     {
     
        $( "#lps_description_Mask, #lps_description_Screen li" ).height( $( "#lps_description_Holder" ).height() );     
            
        $( "#lps_description_Mask" ).scrollTo( "#lps_description_1", 800 );
        
     }  

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Latest Project Panel :: Home Page  ///////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    $( ".lps_data_Block").each( function() 
    {
    
        $( this ).find( ".lps_pagging_p_2" ).show();
        
        $( this ).find( ".lps_pagging_p_2 a:first" ).addClass( "active" );
        
        $( this ).find( ".lps_data_previews_Panel a" ).append( "<span></span>" );
        
        $( this ).find( ".lps_data_previews_Panel span" ).css( { "opacity" : "0" } );
        
        if( IE_6 == true )
        {
        
            if( site_language == 'bg' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background-color" : "#111111" } );   
                    
            } 
            
            if( site_language == 'en' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background-color" : "#111111" } );   
                    
            } 
            
            if( site_language == 'de' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background-color" : "#111111" } );   
                    
            } 
        
        }
        else
        {

            if( site_language == 'bg' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background" : "url(/Graphics/PNG_Graphics/Graphic_03.png) center no-repeat #111111" } );   
                    
            } 
            
            if( site_language == 'en' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background" : "url(/Graphics/PNG_Graphics/Graphic_08.png) center no-repeat #111111" } );   
                    
            } 
            
            if( site_language == 'de' )
            {
                    
                $( this ).find( ".lps_data_previews_Panel a span" ).css( { "background" : "url(/Graphics/PNG_Graphics/Graphic_07.png) center no-repeat #111111" } );   
                    
            } 
            
        }
                                                    
        var windowWidth = $( this ).find( ".lps_data_previews_Panel span" ).width();
        
        var imageSum = $( this ).find( ".lps_data_previews_Panel img" ).size();
        
        var imageReelWidth = windowWidth * imageSum;
        
        
        $( this ).find( ".lps_data_previews_Panel" ).css( { 'width' : imageReelWidth } );
    
    });    
    
    $( ".lps_data_previews_Panel a" ).hover( function() 
    {
        
        $( this ).find( "span" ).stop().animate( { opacity: 0.7 }, 200 ).show();
    
    }, function() 
    {
        
        $( this ).find( "span" ).stop().animate( { opacity: 0 }, 200 );
        
    });
    
    $( ".lps_pagging_p_2 a" ).click( function() 
    {
    
        var triggerID = $( this ).attr( "rel" ) - 1;  
        
        var hlp_index = triggerID + 1;
        
        var imgWidth = $( this ).parent().parent().find( "img" ).width();
        
        var image_reelPosition = triggerID * imgWidth;
               
        if( $( this ).hasClass( "active" ) ) 
        { 
            
        }
        else 
        {
            
            $( this ).parent().parent().find( ".lps_pagging_p_2 a" ).removeClass( "active" );
                           
            $( this ).addClass( "active" );

            $( this ).parent().parent().find( ".lps_data_previews_Panel" ).animate( { left: -image_reelPosition }, 300 );
            
            $( "#lps_description_Mask" ).scrollTo( "#lps_description_" + hlp_index, 800 );  
            
        }
        
        return false;
    
    });
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Latest Project Preview Panel :: Home Page  ///////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    $( ".LSB_preview_Grid.LSB_preview_grid_Caption" ).hover( function()
    {
        
        $( ".LSB_preview_grid_Cover", this ).stop().animate( { top: '100px'}, { queue: false, duration: 160 } );
    
    }, function() 
    {
        
        $( ".LSB_preview_grid_Cover", this ).stop().animate( { top: '155px' }, { queue: false, duration: 160 } );
                
    } );
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Latest Project Preview Panel :: Home Page  ///////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
     $( "#LSB_usful_links_Slider" ).click( function () 
     {
         
         $( "#LSB_usful_Links" ).slideToggle( "slow" );
         
     
     });
     
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Contact Form Engine  /////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    if( IE_6 == true )
    {
        var form_height = "330px";
    }
    else
    {
        var form_height = "400px";
    }
    
    //alert( "Form H: " + form_height );
    
    $( ".example8" ).colorbox( { width: "728px", height: form_height, inline: true, href: "#inline_example1", preloading: true } );

    $( "#click" ).click( function()
    {
        
        $('#click').css( { "background-color" : "#f00", "color" : "#fff", "cursor" : "inherit" } ).text( "Send offer request" );
                    
        return false;
        
    });
                
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Share With a Friend Form  ////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    $( ".example9" ).colorbox( { width: "728px", height: form_height, inline: true, href: "#inline_example2", preloading: true } );

    $( "#click" ).click( function()
    {
        
        $('#click').css( { "background-color" : "#f00", "color" : "#fff", "cursor" : "inherit" } ).text( "Share this website with a friend of yours" );
                    
        return false;
        
    });
                
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Subscribe / Unsubscribe for Company News  ////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    if( document.getElementById( "subscribe_4_CN_Form" ) )
    {
        
        $( ".e_mail_error_Holder" ).hide();
        
        $( ".e_mail_error_Holder_2" ).hide();
        
        $( ".submit_type_1" ).click( function() 
        {
        
            $( ".e_mail_error_Holder" ).hide();
            
            $( ".e_mail_error_Holder_2" ).hide();
            
            var e_mail = $( "input#e_mail" ).val();
            
            var method = $( "input#method" ).val();
            
            var check_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
            
            if( e_mail == "" ) 
            {
            
                $( "label#e_mail_error" ).show();
                
                $( "input#e_mail" ).focus();
                
                return false;
                
            }

            if( check_filter.test( e_mail ) == false ) 
            {
            
                $( "label#e_mail_error_2" ).show();
                
                $( "input#e_mail" ).focus();
                
                return false;
                
            }
            
            var form_data = 'e_mail=' + e_mail + '&method=' + method;
            
        
       
            $.ajax({
                        
                type: "POST",
                url: "/web_support_functions.php",
                data: form_data,
                success: function() 
                {
                
                    switch( site_language )
                    {
    
                        case "bg":
                            success_msg = "Благодарим Ви! Вашата информация е изпратена";
                            break;
                            
                        case "en":
                            success_msg = "Thank You! Your request has been successfully sent.";
                            break;

                        case "de":
                            success_msg = "Thank You! Your request has been successfully sent.";
                            break;
                        
                        default:
                            success_msg = "Благодарим Ви! Вашата информация е изпратена";

                    }
                    
                    $( "#subscribe_4_CN_Labels" ).html( "" );
                    
                    $( "#subscribe_4_CN_Form" ).html( "<div id = 'CF_success_message'></div>");
                    
                    $( "#CF_success_message" ).html( "<h2>" + success_msg + "</h2>" ).hide().fadeIn( 1500, function() 
                    {
                        
                        $( "#CF_success_message" ).append( "<img id = 'checkmark' src = '/Graphics/JPEG_Graphics/Graphic_34.jpg' width = '32' height = '24' border = '0' class = 'LSB_decorator' />" );
                        
                    });
      
                }
      
            });
    
            return false;
    
        });
    
    }
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Send Offer Request Form  /////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    if( document.getElementById( "send_offer_Container" ) )
    {
        
        $( ".contact_name_error_Holder" ).hide();
        $( ".contact_data_error_Holder" ).hide();
        $( ".offer_message_error_Holder" ).hide();
        $( ".security_code_error_Holder" ).hide();
        
        $( "#send_offer_Data" ).click( function() 
        {
            
            $( ".contact_name_error_Holder" ).hide();
            $( ".contact_data_error_Holder" ).hide();
            $( ".offer_message_error_Holder" ).hide();
            $( ".security_code_error_Holder" ).hide();      
           
            
            var contact_name = $( "input#contact_name" ).val();
            var contact_data = $( "input#contact_data" ).val();
            var offer_message = $( "textarea#offer_message" ).val();
            var lang = $( "input#lang_profile" ).val();
            
            var security_code = $( "input#security_code" ).val();    
           
            if( ( contact_name == "" ) || 
                ( contact_data == "" ) || 
                ( offer_message == "" ) || 
                ( security_code == "" ) )
            {
            
                if( contact_name == "" ) 
                {
                
                    $( "label#contact_name_error" ).show();
                    
                    $( "input#contact_name" ).focus();
                    
                }
                
                if( contact_data == "" ) 
                {
                
                    $( "label#contact_data_error" ).show();
                    
                    $( "input#contact_data" ).focus();
                    
                }
                
                if( offer_message == "" ) 
                {
                
                    $( "label#offer_message_error" ).show();
                    
                    $( "textarea#offer_message" ).focus();
                    
                }
                
                if( security_code == "" ) 
                {
                
                    $( "label#security_code_error" ).show();
                    
                    $( "input#security_code" ).focus();     
                    
                }
                
                return false;
            }
    
        });
    
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Share With a Friend Engine  //////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    if( document.getElementById( "share_with_friend_Container" ) )
    {
        
        $( ".reciever_e_mail_error_Holder" ).hide();
        $( ".invalid_reciever_e_mail_Holder" ).hide();
        $( ".your_name_error_Holder" ).hide();
        $( ".security_code_error_Holder_2" ).hide();
		$( ".security_code_match_error_Holder" ).hide();
        
        $( "#send_2_Friend" ).click( function() 
        {
        
            $( ".reciever_e_mail_error_Holder" ).hide();
            $( ".invalid_reciever_e_mail_Holder" ).hide();
            $( ".your_name_error_Holder" ).hide();
            $( ".security_code_error_Holder_2" ).hide();
			$( ".security_code_match_error_Holder_2" ).hide();
        
            var reciever_e_mail = $( "input#reciever" ).val();
            var your_name = $( "input#your_name" ).val();
            var attached_text = $( "textarea#attached_text" ).val();
            var lang = $( "input#language_profile" ).val();
			var shared_link = $( "input#shared_link" ).val();
			var security_code_2 = $( "input#security_code_2" ).val();  
			var security_code_id_2 = $( "input#security_code_id_2" ).val();  
            
            var check_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
        
            
            if( reciever_e_mail == "" ) 
            {
                
                $( "label#reciever_e_mail_error" ).show();
                    
                $( "input#reciever" ).focus();
                    
                return false;
                    
            }
            
            if( your_name == "" ) 
            {
                
                $( "label#your_name_error" ).show();
                    
                $( "input#your_name" ).focus();
                    
                return false;
                    
            }

            if( security_code_2 == "" ) 
            {
                
                 $( "label#security_code_error_2" ).show();
                    
                 $( "input#security_code_2" ).focus();     
                 
                 return false;
                    
            }
            
            if( security_code_2 != security_code_id_2 ) 
            {
                
                 $( "label#security_code_match_error" ).show();
                    
                 $( "input#security_code_2" ).focus();     
                 
                 return false;
                    
            }
                
            if( check_filter.test( reciever_e_mail ) == false ) 
            {
                
                $( "label#invalid_reciever_e_mail" ).show();
                    
                $( "input#reciever" ).focus();
                    
                return false;
                    
            }
        
           
            var share_data = 'lang=' + lang + '&reciever_e_mail=' + reciever_e_mail + '&your_name=' + your_name + '&attached_text=' + attached_text + '&shared_link=' + shared_link + '&security_code_2=' + security_code_2 + '&security_code_id_2=' + security_code_id_2;
            
            $.ajax({
                        
                type: "POST",
                url: "/web_support_functions.php",
                data: share_data,
                success: function() 
                {
                
                    switch( site_language )
                    {
    
                        case "bg":
                            success_msg = "До адреса '" + reciever_e_mail + "' успешно беше изпратена връзка към нашия сайт";
                            break;
                            
                        case "en":
                            success_msg = "A link to our website has been successfully sent to '" + reciever_e_mail + "'";
                            break;

                        case "de":
                            success_msg = "A link to our website has been successfully sent to '" + reciever_e_mail + "'";  
                            break;
                        
                        default:
                            success_msg = "До адреса '" + reciever_e_mail + "' успешно беше изпратена връзка към нашия сайт";      

                    }
                    
                    $( "#share_with_friend_Container" ).html( "" );
                    
                    $( "#share_with_friend_Container" ).html( "<div id = 'SF_success_message'></div>");
                    
                    $( "#SF_success_message" ).html( "<h3>" + success_msg + "</h3>" ).hide().fadeIn( 1500 );
      
                }
      
            });
    
            return false;
    
        });
    
    }
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    
    $( ".category_Link" ).hover(function() 
    {
    
        $( this ).animate({ backgroundColor: "#e8c44d" }, 600 );
    
       
    }, function() 
    {

        $( this ).animate({ backgroundColor: "#5a89ae" }, 400 );

        
    });
    
    if( document.getElementById( "Offer_Send_Success" ) )
    {
       
       var success_msg = $( "#Offer_Send_Success" ).html();
        
       $( "#Offer_Send_Success" ).html( success_msg ).hide().fadeIn( 3000 );
        
    }
       
});

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Font Size Control  ///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function increaseFont()
{
jQuery('div#PP_page_description_Holder div, div#PP_page_description_Holder p, div#PP_page_description_Holder a, div#PP_page_description_Holder span, div#PP_page_description_Holder li, div#PP_page_description_Holder table').each(function(){
var oldf = parseInt( jQuery(this).css('font-size') );
var oldl = parseInt( jQuery(this).css('line-height') );
jQuery(this).css({
'font-size' : oldf + 1 + 'px',
'line-height' : oldl + 1 + 'px'
});
});
}
 
function decreaseFont()
{
jQuery('div#PP_page_description_Holder p, div#PP_page_description_Holder a, div#PP_page_description_Holder span, div#PP_page_description_Holder li, div#PP_page_description_Holder table').each(function(){
var oldf = parseFloat( jQuery(this).css('font-size') );
var oldl = parseFloat( jQuery(this).css('line-height') );
jQuery(this).css({
'font-size' : oldf - 1 + 'px',
'line-height' : oldl - 1 + 'px'
});
});
}

function detect_IE_6()
{
     
    return ( ( window.XMLHttpRequest == undefined ) && ( ActiveXObject != undefined ) );

}
