// galeria de imagens
function abre(id){
	    ultimaFoto = parseInt(fotos.length) - 1;
  if (id == "proxima"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtual').value) + 1;
    if (proximaFoto > ultimaFoto)
        proximaFoto = 0;
    document.getElementById('imgGrande').src = fotos[proximaFoto][0];
    document.getElementById('hddFotoAtual').value = proximaFoto;
  }else if (id == "anterior"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtual').value) - 1;
    if (proximaFoto < 0)
        proximaFoto = ultimaFoto;
    document.getElementById('imgGrande').src = fotos[proximaFoto][0];
    document.getElementById('hddFotoAtual').value = proximaFoto;
  }else{
    document.getElementById('imgGrande').src = fotos[id][0];
    document.getElementById('hddFotoAtual').value = id;	        
  }
}

function abreSecurity(id){
	    ultimaFoto = parseInt(fotosSecurity.length) - 1;
  if (id == "proxima"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualSecurity').value) + 1;
    if (proximaFoto > ultimaFoto)
        proximaFoto = 0;
    document.getElementById('imgGrandeSecurity').src = fotosSecurity[proximaFoto][0];
    document.getElementById('hddFotoAtualSecurity').value = proximaFoto;
  }else if (id == "anterior"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualSecurity').value) - 1;
    if (proximaFoto < 0)
        proximaFoto = ultimaFoto;
    document.getElementById('imgGrandeSecurity').src = fotosSecurity[proximaFoto][0];
    document.getElementById('hddFotoAtualSecurity').value = proximaFoto;
  }else{
    document.getElementById('imgGrandeSecurity').src = fotosSecurity[id][0];
    document.getElementById('hddFotoAtualSecurity').value = id;	        
  }
}

function abreComfort(id){
	    ultimaFoto = parseInt(fotosComfort.length) - 1;
  if (id == "proxima"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualComfort').value) + 1;
    if (proximaFoto > ultimaFoto)
        proximaFoto = 0;
    document.getElementById('imgGrandeComfort').src = fotosComfort[proximaFoto][0];
    document.getElementById('hddFotoAtualComfort').value = proximaFoto;
  }else if (id == "anterior"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualComfort').value) - 1;
    if (proximaFoto < 0)
        proximaFoto = ultimaFoto;
    document.getElementById('imgGrandeComfort').src = fotosComfort[proximaFoto][0];
    document.getElementById('hddFotoAtualComfort').value = proximaFoto;
  }else{
    document.getElementById('imgGrandeComfort').src = fotosComfort[id][0];
    document.getElementById('hddFotoAtualComfort').value = id;	        
  }
}

function abreDesign(id){
	    ultimaFoto = parseInt(fotosDesign.length) - 1;
  if (id == "proxima"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualDesign').value) + 1;
    if (proximaFoto > ultimaFoto)
        proximaFoto = 0;
    document.getElementById('imgGrandeDesign').src = fotosDesign[proximaFoto][0];
    document.getElementById('hddFotoAtualDesign').value = proximaFoto;
  }else if (id == "anterior"){
    proximaFoto = parseInt(document.getElementById('hddFotoAtualDesign').value) - 1;
    if (proximaFoto < 0)
        proximaFoto = ultimaFoto;
    document.getElementById('imgGrandeDesign').src = fotosDesign[proximaFoto][0];
    document.getElementById('hddFotoAtualDesign').value = proximaFoto;
  }else{
    document.getElementById('imgGrandeDesign').src = fotosDesign[id][0];
    document.getElementById('hddFotoAtualDesign').value = id;	        
  }
}



// conta caracteres
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
  var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
  
  var countBody = opt_countBody ? opt_countBody : "countBody";
  var maxSize = opt_maxSize ? opt_maxSize : 600;
  
  var field = document.getElementById(countedTextBox);
  
  if (field && field.value.length >= maxSize) {
    field.value = field.value.substring(0, maxSize);
  }
  var txtField = document.getElementById(countBody);
  if (txtField) {
    txtField.innerHTML = field.value.length;
  }
}


//corrige problema do ajax na troca das abas
function titleFlash(){

  jQuery('.titleFlash:not(.button), .titleFlashb span').flash(
    { 
        src: '_swf/VWHeadline-Blk.swf', 
        wmode: 'transparent',
        flashvars: { 
            css: [
                '* { color: #ffffff; }',
            ].join(' ')
        }
    },
    { version: 7 },
    function(htmlOptions) {
        htmlOptions.flashvars.txt = this.innerHTML;
        this.innerHTML = '<div>'+this.innerHTML+'</div>';
        var $alt = $(this.firstChild);
        htmlOptions.height = $alt.height();
        htmlOptions.width = $alt.width();
        $alt.addClass('alt');
        $(this)
            .addClass('flash-replaced')
            .prepend($.fn.flash.transform(htmlOptions));						
    }
  );


}

//scroll automático
function scrollTo(selector) {
  var targetOffset = $(selector).offset().top;
  $('html,body').animate({scrollTop: targetOffset}, 500);
}

function showSitemap(){
  $('body.homepage #sitemap').show(function(){
    scrollTo('#sitemap');
  });
  
  $('body:not(.homepage) #sitemap').slideDown('slow',function(){
    scrollTo('#sitemap');
  });
}
function closeSitemap(){
  $('body:not(.homepage) #sitemap').slideUp('fast');
  $('body.homepage #sitemap').hide();
}

function show(iten){
  
  if( $('.'+iten).hasClass('show') ){
    $('.'+iten).removeClass('show').children('.cnt').slideUp('slow');
  } else {
    $('.'+iten).addClass('show').children('.cnt').slideDown('slow');
  }
  
}

function showFaq(iten){
  
  if( $('.'+iten).hasClass('show') ){
    $('.'+iten).removeClass('show').children('.cnt').slideUp('slow');
  } else {
    $('.'+iten).addClass('show').children('.cnt').slideDown('slow');
  }

}


function showHideEspecification(iten){

  if( $('.'+iten).hasClass('show') ){
    $('.'+iten).removeClass('show').children('.cnt').slideUp('slow');
  } else {
    $('.'+iten).addClass('show').children('.cnt').slideDown('slow');
  }

}

jQuery(document).ready(function(){	

	// titulos gerais
	jQuery('.size20b span, .size20, .size18, .size18withImage:not(.no-flash) span, .size14, .size16').flash(
    { 
      src: '_swf/VWHeadline-Blk.swf', 
      wmode: 'transparent',
      flashvars: { 
        css: [
          '* { color: #ffffff; }',
        ].join(' ')
      }
    },
    { version: 7 },
    function(htmlOptions) {
      htmlOptions.flashvars.txt = this.innerHTML;
      this.innerHTML = '<div>'+this.innerHTML+'</div>';
      var $alt = $(this.firstChild);
      htmlOptions.height = $alt.height();
      htmlOptions.width = $alt.width();
      $alt.addClass('alt');
      $(this)
      .addClass('flash-replaced')
      .prepend($.fn.flash.transform(htmlOptions));						
    }
  );
    
    
  jQuery('.tit-results .results').flash(
    { 
      src: '_swf/VWHeadline-Blk.swf', 
      wmode: 'transparent',
      flashvars: { 
        css: [
          '* { color: #fee300; }',
        ].join(' ')
      }
    },
    { version: 7 },
    function(htmlOptions) {
      htmlOptions.flashvars.txt = this.innerHTML;
      this.innerHTML = '<div>'+this.innerHTML+'</div>';
      var $alt = $(this.firstChild);
      htmlOptions.height = $alt.height();
      htmlOptions.width = $alt.width();
      $alt.addClass('alt');
      $(this)
      .addClass('flash-replaced')
      .prepend($.fn.flash.transform(htmlOptions));						
    }
  );

  
  //SIFR Nova geracao
    // flash blue - #6f91c0
      jQuery('.txtblue').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #6f91c0; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash gray - #909090
      jQuery('.txtgray').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #909090; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash gray two - #e9e9e9
      jQuery('.txtgraytwo').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #e9e9e9; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash white - #ffffff
      jQuery('.txtwhite').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #ffffff; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );   
	  
	// flash white - #ffffff
      jQuery('.txtwhitedois').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #ffffff; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );   
});

function titleFlashNovaGeracao(){

jQuery(document).ready(function(){	

	// titulos gerais
	jQuery('.size20b span, .size20, .size18, .size18withImage:not(.no-flash) span, .size14, .size16').flash(
    { 
      src: '_swf/VWHeadline-Blk.swf', 
      wmode: 'transparent',
      flashvars: { 
        css: [
          '* { color: #ffffff; }',
        ].join(' ')
      }
    },
    { version: 7 },
    function(htmlOptions) {
      htmlOptions.flashvars.txt = this.innerHTML;
      this.innerHTML = '<div>'+this.innerHTML+'</div>';
      var $alt = $(this.firstChild);
      htmlOptions.height = $alt.height();
      htmlOptions.width = $alt.width();
      $alt.addClass('alt');
      $(this)
      .addClass('flash-replaced')
      .prepend($.fn.flash.transform(htmlOptions));						
    }
  );
    
    
  jQuery('.tit-results .results').flash(
    { 
      src: '_swf/VWHeadline-Blk.swf', 
      wmode: 'transparent',
      flashvars: { 
        css: [
          '* { color: #fee300; }',
        ].join(' ')
      }
    },
    { version: 7 },
    function(htmlOptions) {
      htmlOptions.flashvars.txt = this.innerHTML;
      this.innerHTML = '<div>'+this.innerHTML+'</div>';
      var $alt = $(this.firstChild);
      htmlOptions.height = $alt.height();
      htmlOptions.width = $alt.width();
      $alt.addClass('alt');
      $(this)
      .addClass('flash-replaced')
      .prepend($.fn.flash.transform(htmlOptions));						
    }
  );

  
  //SIFR Nova geracao
    // flash blue - #6f91c0
      jQuery('.txtblue').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #6f91c0; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash gray - #909090
      jQuery('.txtgray').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #909090; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash gray two - #e9e9e9
      jQuery('.txtgraytwo').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #e9e9e9; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
    // flash white - #ffffff
      jQuery('.txtwhite').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #ffffff; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
   
});

}



function titleFlashVehicles(){
	jQuery('.txtblue span').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #6f91c0; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );   
	jQuery('.size20b span').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #ffffff; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );   
	jQuery('.txtwhite span').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #ffffff; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var $alt = $(this.firstChild); htmlOptions.height = $alt.height(); htmlOptions.width = $alt.width(); $alt.addClass('alt'); $(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions)); } );
}