/* Desenvolvido por Bruno Bincoletto - BeDigital.com.br - Soluções Web */

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2.5+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

$(document).ready(function(){

	// GENERAL VARS
	var htmlWidth = $('html').width();
	var htmlHeight = $('html').height();
	var winWidth = $(window).width();
	var winHeight = $(window).height();
	
	$('#categories ul li ul li:has(ul)').addClass('subCategories');
	$('#categories ul li ul li:has(ul)').prepend('<span class="close">+</span>');
	
$('.subCategories').bind("click", function(ev){
		if (!$(this).hasClass("open")){
			$(this).addClass("open");
			$(this).children('ul').fadeIn();
			$(this).children('span').html('-');
		} else {
			$(this).removeClass("open");
			$(this).children('ul').fadeOut('normal');
			$(this).children('span').html('+');
		}
	});


	$('#payOverlay').css('width',htmlWidth);
	$('#payOverlay').css('height', htmlHeight);
	$('#payFrame').css('height', winHeight-60);
	$('#payFrame').corner();
	$('#payFrame iframe').css('height', winHeight-80);
	
	$('#payFrame').css('width', winWidth-60);
	$('#payFrame iframe').css('width', winWidth-60);
	$('#payOverlay, #payFrame .cacelPay').click(function() {
	  $('#payOverlay').fadeOut();
	});
	$('#pagamentodigital .paySubmit').click(function() {
	  $('#payOverlay').fadeIn();
	});
	
	$('#page').fadeIn('slow');
	

    if ($('html').width() > 1400){
		$('#wrapper').css('width', '1400');
		$('#wrapper').css('boder-left', '1px solid #EEE');
		$('#wrapper').css('boder-right', '1px solid #EEE');
	}
	else {
		$('#wrapper').css('width', 'auto');
	};
	
	
	// NAVBAR
	
	$('#navbar li').hover(function(){
		$(this).children('ul').slideToggle('fast');
	},function(){
		$(this).children('ul').slideUp('fast');
	});
	
	$('#navbar li ul').corner('5px br bl');
	
	// GENERAL RANDED CORNER
	
	$('#navbar li ul').corner('5px bl br');
	
});
