/* Author:  Oguz Semerci

*/
 $(function(){
        
                                     
          var config = {    
                over: function (){
                     $(this).children('ul').slideDown("normal");
                },
                out: function () {
                     $(this).children('ul').hide();
                }
            };


            $('#top_menu>ul>li').hoverIntent(config);                   
        
        
             $("form.enews").submit(function(){
                     
                        var email = $(this).find('input:text').val();      
                        var sent_data = "email="+email;                  

                               $.ajax({
                                  type:'POST',
                                  url: ENEWS_URL,
                                  data: sent_data,
                                  success: function(data){  
                                             if( data == 'passed'){
                                                 $('.enews_error').hide();
                                                 $('.enews_same').hide();
                                                 $('#e-news span').hide();
                                                 $('#e-news form').hide();
                                                 $('.enews_invalid').hide();
                                                 $('.enews_success').fadeIn(1000);
                                             }     
                                            else if ( data == 'error'){
                                                $('.enews_invalid').hide();
                                                 $('.enews_same').hide();
                                                 $('.enews_error').fadeIn(1000);
                                            }
                                            else if (data == 'same') {
                                                $('.enews_invalid').hide();
                                                 $('.enews_same').hide();
                                                 $('.enews_error').hide();
                                                 $('.enews_same').fadeIn(1000);
                                            }
                                            else{
                                                $('.enews_invalid').hide();
                                                 $('.enews_error').hide();
                                                 $('.enews_same').hide();
                                                 $('.enews_invalid').html(data).fadeIn(1000);
                                            }
                                  }
                            });
                       
                                return false;
                     });
                     
                     
                     
           $('.search_submit').click(function(){

                      var langId=$('#lang_id').val();

                      if($('.search_txt').val()==""){
                         if(langId=='tr'){
                              $('#dialog-box p').html('Arama için veri giriniz!');
                              $('#dialog-box').dialog('open');
                              $('#dialog-box').dialog({  
                                                modal: true,
                                                height: 140,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
                                                        }   
                                            });
                         return false;
                         }
                         else{
                              $('#dialog-box p').html('Please enter the search data!');
                              $('#dialog-box').dialog('open'); 
                              $('#dialog-box').dialog({  
                                                modal: true,
                                                height: 140,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
                                                        }   
                                            });
                         return false;
                         }
                      }else{
                         return true;
                      }
                   });

                     $('.search_submit').click(function(){

                      var n = $('.search_txt').val().length;

                         if( n != 0 && n < 3){
                            $('#dialog-box p').html('Yetersiz bilgi - Lack of information !');
                            $('#dialog-box').dialog('open'); 
                              $('#dialog-box').dialog({  
                                                modal: true,
                                                height: 140,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
                                                        }   
                                            });
                         return false;
                         }
                         else if( n > 100){
                            $('#dialog-box p').html('Çok uzun bilgi - Too long information !');
                            $('#dialog-box').dialog('open'); 
                              $('#dialog-box').dialog({  
                                                modal: true,
                                                height: 140,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
                                                        }   
                                            });
                         return false;
                         }
                         else{
                         return true;
                      }
                   });
                   
                   $('#top_menu>ul>li').each(function(){
                                        var mainWidth = $(this).width(); 
                                        $(this).children('ul').width(mainWidth);
                   });
                   
                   
                   $('.scroll-pane').jScrollPane();
                   
                   
                  
                    
                   

 })























