// 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 titleFlashGeral(){
	
	// 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 jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );
    
    // 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 jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.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 jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.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 jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );
    
    // flash gray three - #5d5d5e
      jQuery('.txtgraythree').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #5d5d5e; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );
		
		// flash gray two - #dedede
      jQuery('.txtgrayfour').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #dedede; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );
			
	// flash white - #fee300
      jQuery('.txtyellow').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 jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );  	  
      
      jQuery('.txtblack').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #000000; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );

	 // flash gray footer - #dedede
      jQuery('.txtgrayfoot').flash( { src: '_swf/VWHeadline-Blk.swf', wmode: 'transparent', flashvars: { css: [ '* { color: #bcbcbc; }', ].join(' ') } }, { version: 7 }, function(htmlOptions) { htmlOptions.flashvars.txt = this.innerHTML; this.innerHTML = '<div>'+this.innerHTML+'</div>'; var jQueryalt = jQuery(this.firstChild); htmlOptions.height = jQueryalt.height(); htmlOptions.width = jQueryalt.width(); jQueryalt.addClass('alt'); jQuery(this).addClass('flash-replaced').prepend(jQuery.fn.flash.transform(htmlOptions)); } );


}


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));						
    }
  );

/* jQuery('.button.titleFlash span').flash(
        { 
            src: '_swf/VWHeadline-Blk-Tab.swf', 
            wmode: 'transparent',
            flashvars: { 
                css: [
                    '* { color: #ffffff; }',
                    'a:hover { text-decoration: underline; }'
                ].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(){
  $('#sitemap').slideDown('slow',function(){
    scrollTo('#sitemap');
  });  
}
function closeSitemap(){
  $('#sitemap').slideUp('fast');
}

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));						
        }
    );
    
	
	// links de botao
    /*jQuery('.button span').flash(
        { 
            src: '_swf/VWHeadline-Blk-Tab.swf', 
            wmode: 'transparent',
            flashvars: { 
                css: [
                    '* { color: #ffffff; }',
                    'a:hover { text-decoration: underline; }'
                ].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));						
        }
    );*/
    
    
    
  //show hide de technical specs
/*  $('.showHide .tit').click(function(){
    
    if( $(this).parent('.iten').hasClass('show') ){
      $(this).parent('.iten').removeClass('show').children('.cnt').slideUp('slow');
    } else {
      $(this).parent('.iten').addClass('show').children('.cnt').slideDown('slow');
    }    
    
  })*/




});

