jQuery(document).ready(function () {
    jQuery('#webapp-products .product-overview-list .product:nth-child(3n+3)').addClass('last');
	jQuery('.features li:nth-child(3n+3)').addClass('last');
	jQuery('.productline .product:last-child').addClass('last');

    var sideheight = jQuery('#sidebar').height();
    var pageheight = jQuery('#webpage-content').height();

    if (pageheight < sideheight) {
        jQuery('#webpage-content').height(sideheight);
    }
	

    jQuery('#search input[type="text"]').focus(function () {
        jQuery(this).val(' ');
    });

    var sideheightLeft = jQuery('#sidebar.left').height();
    var contentheight = jQuery('#content').height();

    if (sideheightLeft < contentheight) {
        jQuery('#sidebar.left').height(contentheight);
    }


    //check if product has link to video or form
    if (jQuery('.sidebar-box.loadvideo a').attr('href')) {
        jQuery('.sidebar-box.loadvideo').show();
    } else {
        jQuery('.sidebar-box.loadvideo').hide();
    }
    if (jQuery('.sidebar-box.loadorderform a').attr('href')) {
        jQuery('.sidebar-box.loadorderform').show();
    } else {
        jQuery('.sidebar-box.loadorderform').hide();
    }

    //tooltip
   jQuery('.product').each(function(index) {
    jQuery(".product").mousemove(function(e){
			var checkdescription = jQuery(this).attr('description');
			if(checkdescription !=""){
			jQuery("#tooltip").show();
			jQuery("#tooltip").css({
				top: (e.pageY + 15) + "px",
				left: (e.pageX + 15) + "px"
			});
			
	var tooltiptext = jQuery(this).attr('description');
	 jQuery("#tooltip").text(tooltiptext);
}
		});
	
	jQuery("#tooltip").hide();
   
	
    
    jQuery(".product").mouseout(function(e){
        jQuery("#tooltip").hide();
    });
	
    });

   //overview list display links

     jQuery('#webapp-products .product-overview-list .product .order a').each(function(index) {
	  var checkOrderform = jQuery(this).attr('href');

       if (checkOrderform == "") {
        jQuery(this).parent().hide();
    } else {
        jQuery(this).parent().show();
    }
     });
   
    jQuery('#webapp-products .product-overview-list .product .video a').each(function(index) {
	  var checkOrderform = jQuery(this).attr('href');

       if (checkOrderform == "") {
        jQuery(this).parent().hide();
    } else {
        jQuery(this).parent().show();
    }
     });
	//video
	jQuery(".videoLink").colorbox({
        iframe: true,
        innerWidth: 600,
        innerHeight: 400
    });

    //set video overlay
   
	
	
	jQuery("#main-nav ul li ul").mouseover(function () {
        jQuery('#nav-lightcovers').addClass('selected');
    });
    jQuery("#main-nav ul li ul").mouseout(function () {
        jQuery('#nav-lightcovers').removeClass('selected');
    });

	 jQuery(".webform br").remove();
	 
 
 
    jQuery('input[type="submit"]').addClass('submit');
    jQuery('input[type="text"]').addClass('text');
	 jQuery('textarea').addClass('textarea');
	  jQuery('select').addClass('select');
	   jQuery('input[type="radio"]').addClass('radio');
	    jQuery('input[type="checkbox"]').addClass('checkbox');
		
		//datasheet
		var datasheetlink = jQuery('#datasheet').attr('href');
        if(datasheetlink==""){
			jQuery('#datasheet').hide();	
		}
		else {
			jQuery('#datasheet').show();		
		}
		
		
		//showgallery
		var photogalleryItemContent = jQuery('table.photogalleryTable td.photogalleryItem').html();
		
		if(photogalleryItemContent=="This photo gallery has no pictures."){
			jQuery('#gallery').hide();	
		}
		else {
			jQuery('#gallery').show();		
		}		
		
});
