function log(input)
{
    return console.log(input);
}

function changeLanguage( lang, return_url )
{
    $.ajaxSetup({
      xhr: !window.ActiveXObject ?
			function() {
				return new window.XMLHttpRequest();
			} :
			function() {
				try {
					return new window.ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {}
			}
    });

    $.ajax({
    type: "POST",
    url: "switch.php",
    data: "lang=" + lang,
    success: function( response ){
        document.location = return_url;
    }
});
}

function showPopup( obj )
{
    $( '#page' ).animate( {opacity: 'toggle'} );
    $( obj ).css( 'display', 'block' );
    var popupLeft = parseInt( $('#page').offset().left );
    $( obj ).css( 'left', popupLeft );

    return false;
}

function hidePopup( obj )
{
    $( '#page' ).animate( {opacity: 'toggle'} );
    $( obj ).css( 'display', 'none' );
    return false;
}

function toggleSubProducts( category_id )
{
    $( '.sub_list:not( "ul[id=\'product_sub_list_' + category_id + '\']" )' ).addClass( 'invisible' );
    $( "ul[id='product_sub_list_" + category_id + "']" ).removeClass( 'invisible' );
    
    $( '.main_list:not( "li[id=\'product_group_' + category_id + '\']" )' ).removeClass( 'selected' );
    $( "#product_group_" + category_id ).addClass( 'selected' );
}

function showProduct( category_id, product_id, description, name, image, promo, presentation, brochure, quick_man, tech_man, comm_guide, report, software )
{
    $( '.listed_product:not( "li[id=\'product_sub_group_' + category_id + '_' + product_id + '\']" )' ).removeClass( 'selected' );
    $( "li[id='product_sub_group_" + category_id + '_' + product_id + "']" ).addClass( 'selected' );
    
    $( '#product_description' ).html( description );
    $( '#product_image' ).attr( 'src', image );
    
    $( '.dl_buttons' ).removeClass( 'invisible' );
    
    if ( promo ){ $( '.dl_promo' ).attr( 'href', promo ).removeClass( 'invisible' ); } else { $( '.dl_promo' ).addClass( 'invisible' ); }
    if ( presentation ){ $( '.dl_presentation' ).attr( 'href', presentation ).removeClass( 'invisible' ); } else { $( '.dl_presentation' ).addClass( 'invisible' ); }
    if ( brochure ){ $( '.dl_brochure' ).attr( 'href', brochure ).removeClass( 'invisible' ); } else { $( '.dl_brochure' ).addClass( 'invisible' ); }
    if ( quick_man ){ $( '.dl_quick_man' ).attr( 'href', quick_man ).removeClass( 'invisible' ); } else { $( '.dl_quick_man' ).addClass( 'invisible' ); }
    if ( tech_man ){ $( '.dl_tech_man' ).attr( 'href', tech_man ).removeClass( 'invisible' ); } else { $( '.dl_tech_man' ).addClass( 'invisible' ); }
    if ( comm_guide ){ $( '.dl_modbus' ).attr( 'href', comm_guide ).removeClass( 'invisible' ); } else { $( '.dl_modbus' ).addClass( 'invisible' ); }
    if ( report ){ $( '.dl_test_report' ).attr( 'href', report ).removeClass( 'invisible' ); } else { $( '.dl_test_report' ).addClass( 'invisible' ); }
    if ( software ){ $( '.dl_software' ).attr( 'href', software ).removeClass( 'invisible' ); } else { $( '.dl_software' ).addClass( 'invisible' ); }
    
    return false;
}

$(document).ready(function()  {

	$("#header li, #footer li").hover(function()	
	{
        $(this).addClass( 'hover' );
    	}, function() {
    	    $(this).removeClass( 'hover' );
	});	
	
} );
