    /**
     * @author Ahmet ONOL
     * @copyright 2010 - ICON Perception Managemet Co.
     * @company ICON Perception Managemet Co.
     * @email contact@icon-pm.com
     * @web http://www.icon-pm.com
     * @project Moonlight
     * @version 
     * @created 2010.5.5 11:19
     * @modified 2010.5.5
     * @modifier Ahmet ONOL
    **/

(function($){
    $.fn.iconAccordionMenu = function(options){
        var opts = $.extend({}, $.fn.iconAccordionMenu.defaults, options);
        
        return this.each(function(){
            var $menu = $(this);
			var o = opts;
			
			var header = o.header;
			var close = o.close;
            var closeOther = o.closeOther;
            var active = o.active;
            var content = o.content;
            
            $menu.find(content).hide();
            $menu.find(active + ' ' + content).show();
            
            $menu.find(header).click(function(){
                var submenu = $(this).parent().find(content);
                
                if(submenu.is(':visible') && close == true){
                    submenu.slideUp();
                    $(this).removeClass('hover');
                }
                
                else{
                    if(closeOther == true){
                        $menu.find(content).slideUp();
                        $menu.find('.hover').removeClass('hover');
                        $menu.find('.current-nav').removeClass('current-nav');
                    }
                    submenu.slideDown();
                    $(this).addClass('hover');
                }
                
                return false;                
            });
        });
    },
    
   	$.fn.iconAccordionMenu.defaults = {
		close: true,
        closeOther: true,
        header: 'span.category',
        content: 'ul',
        active: '.current-nav'
	};
})(jQuery);
 
$(function(){
        jQuery('.list_products').jcarousel({
        vertical: true,
        scroll: 2
    });    
    
    oTable  = $('#project_list_table').dataTable({
        "aaSorting": [[ 0, "asc" ]],
        "bInfo": false,
        "bLengthChange": false,
        "bFilter": false,
        "bSort": false,
        "sPaginationType": "full_numbers"            
    });
    $("#product_content").height(700)
    if($("#product_content").height() < $("#related_products").height())
    {
        
    }    
    $("#project_list_top label.all").live('click',function(){       
       $("ul#location").slideToggle("fast");          
    })
    
    $("#project_list_top span.ok").live('click',function(){       
       $("ul#location").slideToggle("fast");          
    }) 
    
    $("#project_list_top li a").live('click',function(){
        
       oTable.fnFilter($(this).attr('rel'), 1); 
        
       $("#project_list_top label.all").text($(this).text())
       $("ul#location").slideToggle("fast");  
        
    })    
    Cufon('h1.title, #product_details #right h2, #project_relations h2, h4.news-date, #error404 h1, #projects-category li h1'); 
    
    $("#news-ticker").ntTabsAndSlides({ pages : '.news-pages', navigation : '.news-nav', transition: 'none', autoSlide: false, transitionSpeed : '1000' });    
    
    $("#product_details").ntTabsAndSlides({ pages : '.product-pages', navigation : '.right-nav', transition: 'none', autoSlide: false, transitionSpeed : '1000' });    
   
    $("#products a").hover(function(){        
        $(this).find("img").css('border-bottom', '1px solid #eb0005');    
    },function(){
       $(this).find("img").css('border-bottom', '1px solid #cccccc'); 
    })   
    
    /** Search Form **/
    
    $("#search #q").focus(function()
    {            
       $("#search label").hide();            
    });
    
    $("#search #q").blur(function()
    {        
       if ($(this).val() == "")
       {
         $("#search label").show(); 
       }        
    });       
    
    /** Search Form **/
    var newscontent_height = $("#news-ticker").height();
    $(".news-nav").height(newscontent_height);
    
    /** Search Form **/
    
    $("#newsletter-form #email").focus(function()
    {            
       $("#newsletter-form label").hide();            
    });
    
    $("#newsletter-form #email").blur(function()
    {        
       if ($(this).val() == "")
       {
         $("#newsletter-form label").show(); 
       }        
    });       
    
    /** Search Form **/ 
    
    setTimeout(function() {
        $(".warningwrap").animate({ height: 'hide', opacity: 'hide' }, 'fast');
    }, 5000);        
    
    $('#side-nav').iconAccordionMenu({ header: '.category > a', active: '.current-nav' });
})
