$(document).ready(function(){
  //  $('#nav li:odd').css({'background-color':'#eee'});
    $('.tcewf_table tbody tr:nth-child(2n)').css({'background-color':'#eee'});
    $('.tcewf_table tbody tr:nth-child(2n+1)').css({'background-color':'#fff'});
    
    $('#searchBtn').click(function(){
            document.searchForm.submit();
            return false;    
        });
    
    var dropTimer = 0;
    ShowDate();//display the system date on top 
    $('#txtSearch').data('default',$('#txtSearch').val())
                    .addClass('inactive')
                    .focus(function(){
                            $(this).removeClass('inactive');
                            if($(this).val() == $(this).data('default') || ''){
                                $(this).val('');
                            }
                        })
                    .blur(function(){
                            var default_val = $(this).data('default');
                            if ($(this).val() == ''){
                                $(this).addClass('inactive');
                                $(this).val($(this).data('default'));
                            }
                        });
    
    $('.first_inside_ul').hover(function(e){
            $(this).parent('li').find('.nav_a').addClass('parentHover');
             },
                function(){
                $(this).parent('li').find('.nav_a').removeClass('parentHover');
            
        });
    
    $('.having_child_li,').hoverIntent(function(){
			$(this).children('ul').slideDown("fast");
                },function(){
			$(this).children('ul').slideUp("fast");
		});
    
    $('.having_second_menu').hover(function(e){
			$('.second_inside_ul').hide();//for future use
                        $(this).children('ul').show();
                        clearTimeout(dropTimer);
                        e.stopPropagation();
                },function(){
			//introduce timer here
                        var _thisUl = $(this);
                        //$(this).children('ul').hide();
                        dropTimer = setTimeout(function(){
                            _thisUl.children('ul').hide();
                            },300);
                });
    /*$('.having_second_menu a').click(function(e){
       e.preventDefault();
    });*/
    
    $('.second_inside_ul').hover(function(){
            $(this).parent('li.first_inside_li').find('.first_inside_a').addClass('transHover');
        },function(){
            $(this).parent('li.first_inside_li').find('.first_inside_a').removeClass('transHover');
        });
    
  /*  $('.footer_tcv_Menu').hover(function(){
                    clearTimeout(dropTimer);
                    $(this).children('ul').slideDown("fast");
                    $('.footer_tcv_Menu>a').css({'color':'#229621'});
                    
                
            },function(){
                $('.footer_tcv_Menu>a').css({'color':'#fff'});
                var _thisUl=$(this).children('ul');
                dropTimer=setTimeout(function(){
                    _thisUl.slideUp("fast");},500);
            });
    
    $('.footer_tcv_Menu ul').hover(function(e){
        clearTimeout(dropTimer);
        e.stopPropagation();
        },function(){
            var _thisUl=$(this);
                dropTimer=setTimeout(function(){
                    _thisUl.slideUp("fast");},500);
            });*/
    
});

function ShowDate(){
    var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    var days=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    var today = new Date();
    var curr_date = today.getDate();
    var curr_day=today.getDay();
    var curr_month = today.getMonth();
    var curr_year = today.getFullYear();
    $('#today strong').text(days[curr_day]+"-"+m_names[curr_month] + " " + curr_date +giveSuffix(curr_date)+ ", " + curr_year);
}
function giveSuffix(date){//this is just a function to check what suffix to use
    var modu=date%10;
    var div=Math.floor(date/10);
    if(div==1)
    {
        return "th";//this is to handle 10 to 19
    }
    if((modu)==1)
    {
        return "st";
    }
    else if((modu)==2)
    {
        return "nd";
    }
    else if((modu)==3)
    {
        return "rd";
    }
    else
    {
        return "th";
    }
}
