﻿/*
Depois de executado a funcao POSITIONS.calculate() voce tera os valores de:
- POSITIONS.head_y 
- POSITIONS.body_y
a funcao POSITIONS.move() pode substituida pela sua, que faz a animacao bonitinha.
*/

var POSITIONS = {
					config : {
							head_id : 'cidadetha_modal_header',
							body_id : 'modal_ativo',
							top  : 60,
					       	foot : 75
					}
			};
POSITIONS.calculate = function(){
	POSITIONS.head_height = 29;
	POSITIONS.body_height = 421;
	var middle = ($(window).height() - (POSITIONS.head_height + POSITIONS.body_height))  / 2;
	middle = middle  + ((POSITIONS.config.top - POSITIONS.config.foot)  );
	middle = (middle < (POSITIONS.config.top+0)) ? (POSITIONS.config.top+0) : middle;
	POSITIONS.left = ($(window).width() - 980/*$('.' + POSITIONS.config.body_id).width()*/)  / 2;
	POSITIONS.head_y = middle - 10;
	POSITIONS.body_y = middle + 35;
	POSITIONS.move();
}
POSITIONS.move = function(){
	if ($('#' + POSITIONS.config.head_id + ':visible').length > 0){
		$('#' + POSITIONS.config.head_id).animate({'top' : POSITIONS.head_y}, 300);
	}
	//if ($('#' + POSITIONS.config.body_id + ':visible').length > 0){
		$('.' + POSITIONS.config.body_id).css('position','absolute');
		$('.' + POSITIONS.config.body_id).animate({'top' : POSITIONS.body_y }, 300);	
	//}
	if(Shopping.isLoaded){
		Shopping.init();
	}
	numerosPosicao();
	legalPosicao();
}

/* listeners */
$( window ).wresize(POSITIONS.calculate); 
