//function showTimeline(){
//    $("#aboutsec").hide();
//    $("#timeline").show("slow");
//    $("#tababout").removeClass("tabon");
//    $("#tabtimeline").addClass("tabon");
//}
//function showAbout(){
//    $("#aboutsec").show("slow");
//    $("#timeline").hide();
//    $("#tababout").addClass("tabon");
//    $("#tabtimeline").removeClass("tabon");
//}
///*function showUnits(){
//	$("#units").show("slow");
//	$("#wall").hide();
//	$("#tabUnits").addClass("tabon");
//	$("#tabWall").removeClass("tabon");
//}
//function showWall(){
//	$("#units").hide();
//	$("#wall").show("slow");
//	$("#tabUnits").removeClass("tabon");
//	$("#tabWall").addClass("tabon");
//}*/
//function showSection(section){
//    $(".cate").hide();
//    $("#"+section).show("slow");
//    $(".catelink").removeClass("cateon");
//    $("#tab"+section).addClass("cateon");
//
//}
//
///*function showIMG(){
//	$("#bigpdf").hide();
//	$("#bigcad").hide();
//	$("#bigimg").show("slow");
//	$("#tabpdf").removeClass("tabon");
//	$("#tabcad").removeClass("tabon");
//	$("#tabimg").addClass("tabon");
//}
//function showCAD(){
//	$("#bigpdf").hide();
//	$("#bigimg").hide();
//	$("#bigcad").show("slow");
//	$("#tabpdf").removeClass("tabon");
//	$("#tabimg").removeClass("tabon");
//	$("#tabcad").addClass("tabon");
//}
//function showPDF(){
//	$("#bigcad").hide();
//	$("#bigimg").hide();
//	$("#bigpdf").show("slow");
//	$("#tabimg").removeClass("tabon");
//	$("#tabcad").removeClass("tabon");
//	$("#tabpdf").addClass("tabon");
//}*/
//function showHead() {
//
//    $("#tabstate").removeClass("tabon");
//    $("#tabhead").addClass("tabon");
//    $("#state").hide();
//    $("#head").show("slow");
//    $("#googlemap").show();
//}
//function showState() {
//    $("#tabhead").removeClass("tabon");
//    $("#tabstate").addClass("tabon");
//    $("#head").hide();
//    $("#googlemap").hide();
//    $("#state").show("slow");
//}
//
//function show(sec){
//    $("div.std").hide();
//    $("#c"+sec).show();
//    $(".lion").removeClass("lion");
//    $("#lic"+sec).addClass("lion");
//}
//function out(){
//    var idname = $(".lion").attr("id");
//    idname = idname.substr(3,1)
//    show(idname);
//}

$(document).ready(function() {
    
    $('.sub-nav > a').live('click',function(){
		
		var parent =  $(this).parent().find('.sub-nav-inner')[0];
	
		$('.sub-nav-inner').each( function() {
				
			if( this !== parent ) {
				$(this).parent().removeClass('expanded');
				$(this).slideUp(500);			
			} else {
	
			}
		});
									
        $(this).parents('li').find('.sub-nav-inner').slideDown(500);
        $(this).parents('li').addClass('expanded');
        $(this).parents('li').removeClass('collapsed');
    });
	
    $('.sub-nav.expanded > a').live('click',function(){
													
        $(this).parents('li').find('.sub-nav-inner').slideUp(500);
        $(this).parents('li').addClass('collapsed');
        $(this).parents('li').removeClass('expanded');
    });
    
    Cufon.replace('h2, h3, h4,  #nav li > a, .btn-link', {
        fontFamily: 'DIN Bold'
    });
    Cufon.replace('h1, #innerBanner h2, .sub-nav h3', {
        fontFamily: 'DIN'
    });

    //IE 7,8 javascript is too slow for this.
    if(!($.browser.msie && $.browser.version < 9.0)) {
        Cufon.replace('#nav  a', {
            fontFamily: 'DIN Bold'
        });
        $('#nav td').mouseover(function() {
            Cufon.replace('.sub-nav-inner a', {
                fontFamily: 'DIN Bold'
            });
        });

        $('#nav td').mouseout(function() {
            Cufon.replace('.sub-nav-inner a', {
                fontFamily: 'DIN Bold',
                color:'#fff'
            });
        });
    }

   

    $('#fancybox-outer .prev').live('click', function(){
        $.fancybox.prev();
        return false;
    });
    $('#fancybox-outer .next').live('click', function(){
        $.fancybox.next();
        return false;
    });


                
});

$(document).ready(function() {
	
		//$('.product_scroll_text .title').mezdooz(120);
	/*
		$('#products_scroll_wrapper').bind('mouseenter', function() {
			$('#products_scroll_wrapper').stop(true,false);
		});
		
		$('#products_scroll_wrapper').bind('mouseleave', function() {
			scrolling();
		});
	
		scrolling();
*/
});
		
function onScroll()
{
	var target = document.body;
	var scrollTop = 0, scrollLeft = 0;
	while (target != null)
	{
		scrollTop += target.scrollTop ? target.scrollTop : 0;
		scrollLeft += target.scrollLeft ? target.scrollLeft : 0;
		target = target.parentNode;
	}

	var top = 0, left = 0;
	var el = document.getElementById("footer");

	do {
		top += el.offsetTop;
		left += el.offsetLeft;
	}
	
	while (el = el.offsetParent);
	
	var ch = document.body.clientHeight;
	
	el = document.getElementById("products_scroll");
	
	if (scrollTop+$(window).height() >= top )
	{
		el.className = "";
	}
	else
	{

		el.className = "locked";
	}
	
}

/*

window.onscroll = onScroll;

window.onresize = onScroll;

window.onload = onScroll;

*/
		
function scrolling() {

	scroll_time = 4000;
	
	ticker_left = Math.abs( cleanpx($('#products_scroll_wrapper').css('left')));

	if(ticker_left > 0) {
			
		remaining = $('#products_scroll_wrapper a:first').outerWidth() - ticker_left;
		speed = $('#products_scroll_wrapper a:first').outerWidth() / remaining;
		scroll_time /= speed;
		
	}
	
	$('#products_scroll_wrapper').animate({ 'left' : - $('#products_scroll_wrapper a:first').outerWidth() }, scroll_time  , 'linear', function () {
		
			$('#products_scroll_wrapper').append( $('#products_scroll_wrapper a:first') ); 
			$('#products_scroll_wrapper').css({ 'left' : '0' });
			scrolling();
	}); 
}

function cleanpx(px) {

	var i = (px).indexOf('px');
	
	var x = px.substring(0,i);
	//alert(x);
	return x;
}

(function($){
 
    $.fn.extend({
        
        mezdooz: function(options) {

            var truncate_width = options;

    
             this.each(function() {
               
                display = $(this).css('display');
                $clone = $('<span></span>').css({ 'display' : 'fixed', 'left' : -100000, 'top' : -100000});
                $clone.html(this.innerHTML);
           
                $('body').append($clone);
               
                if( $clone.width() > truncate_width ) {
                   
                    this.title = this.innerHTML;
                   
                    while( $clone.width() > truncate_width) {
                       
                        $clone.html( $clone.html().substring(0, $clone.html().length - 1));
                       
                    }
                   
                    this.innerHTML = $clone.html();
                    this.innerHTML += this.innerHTML + '...';
               
                }
               
                $clone.remove();
               
                $(this).css({'display' : display});
                     
             });       
          
        }
    });
    
})(jQuery);

