function addOnload(fn) {
	var nowOnload = window.onload;
	window.onload = function() {
		fn();
		if(nowOnload != null && typeof(nowOnload) == 'function') nowOnload();
	}
}

function addOnresize(fn) {
	var nowOnresize = window.onresize;
	window.onresize = function() {
		fn();
		if(nowOnresize != null && typeof(nowOnresize) == 'function') nowOnresize();
	}
}

function popLayerAlert(parameter){

// Post-TAG 1300
var ADM_rnd_1300 = Math.round(Math.random() * 9999);
var ADM_post_1300 = new Image();
ADM_post_1300.src = 'http://ia.nspmotion.com//ptag/?pt=1300&value=[number]&cvalues=[key|value,key|value]&r='+ADM_rnd_1300;

	document.getElementById('alertArea').style.visibility='hidden';

	var	obj2 = document.getElementById('bgGeralAlpha');
	var	obj3 = document.getElementById('bgGeralAlphaSob');

	var chk1 = document.body.scrollHeight;
	var chk2 = document.body.offsetHeight;
	var chk3 = document.getElementById('container').offsetHeight;

	var chkw1 = document.body.scrollWidth;
	var chkw2 = document.body.offsetWidth;
	var chkw3 = document.getElementById('container').offsetWidth;

	if(chk3 > chk1 || chk3 > chk2){
		y = document.getElementById('container').offsetHeight;
	}else{
		if (chk1 > chk2){
			y = document.body.scrollHeight;
		}else{
			y = document.body.offsetHeight;
		}
	}

	if(chkw3 > chkw1 || chkw3 > chkw2){
		x = document.getElementById('container').offsetWidth;
	}else{
		if (chk1 > chk2){
			x = document.body.scrollWidth;
		}else{
			x = document.body.offsetWidth;
		}
	}

	altura = y - 4;

	document.getElementById('alertArea').style.display='block';
	document.getElementById('popLayer').style.display='block';
	setTimeout(function(){
		var chkpop = document.getElementById('popLayer').offsetHeight;

		posicao = chkpop / 2;


		obj2.style.height = altura+"px";
		obj3.style.height = altura+"px";

		obj2.style.width = x+"px";
		obj3.style.width = x+"px";

		//document.getElementById('popLayer').style.marginTop=-posicao+'px';
		document.getElementById('alertArea').style.visibility='visible';

		return false;
	},100);
}

function popLayerAlert2(parameter){

	// Llamada al Post-TAG 4695 - NO CAMBIAR
	var ADM_rnd_4695 = Math.round(Math.random()*9999);
	var ADM_post_4695 = new Image();
	ADM_post_4695.src = 'http://nspmotion.com/post.aspx?p=4695&r='+ADM_rnd_4695;

	document.getElementById('alertArea2').style.visibility='hidden';

	var	obj2 = document.getElementById('bgGeralAlpha2');
	var	obj3 = document.getElementById('bgGeralAlphaSob2');

	var chk1 = document.body.scrollHeight;
	var chk2 = document.body.offsetHeight;
	var chk3 = document.getElementById('container').offsetHeight;

	var chkw1 = document.body.scrollWidth;
	var chkw2 = document.body.offsetWidth;
	var chkw3 = document.getElementById('container').offsetWidth;

	if(chk3 > chk1 || chk3 > chk2){
		y = document.getElementById('container').offsetHeight;
	}else{
		if (chk1 > chk2){
			y = document.body.scrollHeight;
		}else{
			y = document.body.offsetHeight;
		}
	}

	if(chkw3 > chkw1 || chkw3 > chkw2){
		x = document.getElementById('container').offsetWidth;
	}else{
		if (chk1 > chk2){
			x = document.body.scrollWidth;
		}else{
			x = document.body.offsetWidth;
		}
	}

	altura = y - 4;

	document.getElementById('alertArea2').style.display='block';
	document.getElementById('popLayer2').style.display='block';
	setTimeout(function(){
		var chkpop = document.getElementById('popLayer2').offsetHeight;

		posicao = chkpop / 2;

		obj2.style.height = altura+"px";
		obj3.style.height = altura+"px";

		obj2.style.width = x+"px";
		obj3.style.width = x+"px";

		//document.getElementById('popLayer').style.marginTop=-posicao+'px';
		document.getElementById('alertArea2').style.visibility='visible';

		return false;
	},100);
}

function chkbgpoplayer(){

	var chk1 = document.body.scrollHeight;
	var chk2 = document.body.offsetHeight;
	var chk3 = document.getElementById('container').offsetHeight;

	if(chk3 > chk1 || chk3 > chk2){
		y = document.getElementById('container').offsetHeight;
	}else{
		if (chk1 > chk2){
			y = document.body.scrollHeight;
		}else{
			y = document.body.offsetHeight;
		}
	}

	if (y > document.getElementById('bgGeralAlpha').offsetHeight){
		document.getElementById('bgGeralAlpha').style.height=y+'px';
	}

}

addOnresize(chkbgpoplayer);

function chkscroll(){
//	alert("teste");
	posicao = getInnerSize()[1]/2+getScrollXY()[1]-15;
	if(document.getElementById('popLayer'))
	document.getElementById('popLayer').style.top=posicao+'px';
	if(document.getElementById('popLayerDica'))
	document.getElementById('popLayerDica').style.top=posicao+'px';
}

function closePopLayer(parameter){
	if(document.getElementById('alertArea'))
		document.getElementById('alertArea').style.display='none';

	if(document.getElementById('alertArea2'))
		document.getElementById('alertArea2').style.display='none';

	if(document.getElementById('popLayerSucesso'))
		document.getElementById('popLayerSucesso').style.display='none';

	if(document.getElementById('box-resultado'))
		document.getElementById('box-resultado').style.display='none';


	if(document.getElementById('swf_side_menu'))
		document.getElementById('swf_side_menu').style.visibility='visible';


}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  return [ scrOfX, scrOfY ];

}

function getInnerSize(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth,myHeight];
}

window.onscroll = chkscroll;

function local_loja(){
	popUpWindow('http://www.vichy.com/br/slocator/search.asp','imprensa',405,465);
	// Post-TAG 1299
var ADM_rnd_1299 = Math.round(Math.random() * 9999);
var ADM_post_1299 = new Image();
ADM_post_1299.src = 'http://ia.nspmotion.com//ptag/?pt=1299&value=[number]&cvalues=[key|value,key|value]&r='+ADM_rnd_1299;
}

function opencadastro(){
	window.open('http://www.vichybrasil.com.br/register/check_registration.aspx?bid=005');
	// Llamada al Post-TAG 4692 - NO CAMBIAR
	var ADM_rnd_4692 = Math.round(Math.random()*9999);
	var ADM_post_4692 = new Image();
	ADM_post_4692.src = 'http://nspmotion.com/post.aspx?p=4692&r='+ADM_rnd_4692;
}

function openvichy(){
	window.open('http://www.publicidadeinterativa.com/aplicativos/mediacounter/adclick.asp?id=189&chave=qn6e3ym1b1k742au0x9c&URLSafe=http://www.vichy.com.br/');
	// Llamada al Post-TAG 4693 - NO CAMBIAR
	var ADM_rnd_4693 = Math.round(Math.random()*9999);
	var ADM_post_4693 = new Image();
	ADM_post_4693.src = 'http://nspmotion.com/post.aspx?p=4693&r='+ADM_rnd_4693;
}

function maisdetalhes(){
// Post-TAG 1298
var ADM_rnd_1298 = Math.round(Math.random() * 9999);
var ADM_post_1298 = new Image();
ADM_post_1298.src = 'http://ia.nspmotion.com//ptag/?pt=1298&value=[number]&cvalues=[key|value,key|value]&r='+ADM_rnd_1298;
}





