$(document).ready(function(){
    //$.preloadCssImages();
    /* FOOTER */
    if (typeof lang == 'undefined')
        lang = 'es/';
    
    var serverPath = location.protocol +'//' +location.host;  //returns http://localhost:8080
    var pathName = location.pathname;
    var delimiter = pathName.indexOf('/', 1);
    serverPath += pathName.substring(0, delimiter);
    //alert(serverPath);
    
    var serverPathWithoutLanguage;
    if (serverPath.indexOf("/es", serverPath.length -3) > 0) {
    	serverPathWithoutLanguage = serverPath.substring(0,serverPath.length-3);
    } else {
    	serverPathWithoutLanguage = serverPath;
    }
    
    
    $('.map').load(serverPathWithoutLanguage+'/HTML/'+lang+'footer.jsp',function(){
        if($.section!=''){            
            if (!$.interna)
                $('.'+$.section).find('a').attr('href','javascript:;').addClass(' act').attr('href','javascript:;');
            $.sectionHeader = $('.'+$.section).parents('ul').attr('class');
            $('.'+$.section).parents('ul').attr('class','act');

            /* HEADER */
            $('.header').load(serverPathWithoutLanguage+'/HTML/' + lang + 'header.jsp?' + new Date().getTime(), function () {
                $(this).find('.' + $.sectionHeader).attr('class', $.sectionHeader + '_act');
                //alert("header load");
                if (typeof(pageJs) != 'undefined') {
                    $(this).find('#hEs').attr('href', '../es/' + pageJS + '.html');
                    $(this).find('#hEn').attr('href', '../en/' + pageJS + '.html');
                } else {
                	var pathname = window.location.pathname;
                    //alert('pathname='+pathname);
                	var pos = pathname.lastIndexOf('/');
                    var urlPath = pathname.substring(pos);
                    //$(this).find('#hEs').attr('href', '../es' + urlPath);
                    //$(this).find('#hEn').attr('href', '../en' + urlPath);
                    $(this).find('#hEs').attr('href', serverPath+'/es' + urlPath);
                    $(this).find('#hEn').attr('href', serverPath+'/en' + urlPath);
                }
			
                if (!$.interna) $(this).find('.' + $.section + ' a').addClass(' act').attr('href', 'javascript:;');
                $('.header .submenu_cont').css({
                    visibility: 'hidden'
                });
 //begin str               
//              var islogin=false;
//              var cookieArray = document.cookie.split(';');
//              for(i=0;i<cookieArray.length;i++){
//                  cookiePair = cookieArray[i].split('=');
//                  cookiePair[0]=cookiePair[0].replace(/^\s+/,'').replace(/\s+$/,'');//trim
//                  if(cookiePair[0]=='customerAuth'){
//                      var valueArray = cookiePair[1].split('|');
//                      var userID = valueArray[0];
//                      islogin=true;
//                      break;
//                  }
//              }
              
//end str                
                
                $('.company, .company_act, .products, .products_act, .client, .client_act, .contact, .contact_act').hover(function () {
                	$('.header .submenu_cont').hide();
                    
                	$(this).find('.submenu_cont').css({
                          visibility: 'visible',
                          display: 'none'
                        }).slideDown('fast');
                }, function () {
                    $('.submenu_cont').css({
                        visibility: 'hidden'
                    });
                });
				
//                if (!islogin) {
//                	$(this).find('.requires_login').css({
//                        visibility: 'hidden'
//                    });
//                } 
                
                /*Agrega el div para el div con el popup*/
                /*if($.section!="contact_get"){
                    $('body').append('<div id="opaque-cont"></div>');
                    $('#opaque-cont').load('../HTML/' + lang + 'opaque.html', function () {
                        $('.contact_get a, .cont3col_right a, #prod-person').click(function () {
                            $('#opaque').css({
                                height:$(document).height()+'px',
                                opacity:'0.7'
                            }).fadeIn('slow',function(){
                                $('#opaque_img').css({
                                    display:'block'
                                }).pngFix();
                            });
							
                            return false;
                        });
                        $('#opaque, #opaque_img').click(function(){
                            $('#opaque_img').css({
                                display:'none'
                            });
                            $('#opaque').fadeOut();
                        });
                    });
                };*/
            	/*Fin Agrega el div para el div con el popup*/
            });
        /* /HEADER */
        }
    });
    /* /FOOTER */

    $('.breadcrumb a').click(function(){        
        closing=false;
    });
    
    $('.prev_next a').click(function(){        
        closing=false;
    });
});

