
/* formulario de cadastro newsletter */
 
function checkform() {
  for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].type") == "checkbox") {
      if (document.subscribeform.elements[fieldstocheck[i]].checked) {
      } else {
        alert("Please enter your "+fieldnames[i]);
        eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
        return false;
      }
    }
    else {
      if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
        alert("Please enter your "+fieldnames[i]);
        eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
        return false;
      }
    }
  }
  for (i=0;i<groupstocheck.length;i++) {
    if (!checkGroup(groupstocheck[i],groupnames[i])) {
      return false;
    }
  }
  
  return true;
}

var fieldstocheck = new Array();
var fieldnames = new Array();
function addFieldToCheck(value,name) {
  fieldstocheck[fieldstocheck.length] = value;
  fieldnames[fieldnames.length] = name;
}
var groupstocheck = new Array();
var groupnames = new Array();
function addGroupToCheck(value,name) {
  groupstocheck[groupstocheck.length] = value;
  groupnames[groupnames.length] = name;
}

function compareEmail()
{
  return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}
function checkGroup(name,value) {
  option = -1;
  for (i=0;i<document.subscribeform.elements[name].length;i++) {
    if (document.subscribeform.elements[name][i].checked) {
      option = i;
    }
  }
  if (option == -1) {
    alert ("Por favor entre com seu "+value);
    return false;
  }
  return true;
}


/* div auto hide */

$(document).ready(function() {
    $('div.pergunta1').click( function() {
    $('div.resposta1').toggle("slow");
   });
   
    $('div.pergunta2').click( function() {
    $('div.resposta2').toggle("slow");
   });
   
    $('div.pergunta3').click( function() {
    $('div.resposta3').toggle("slow");
   });
   
    $('div.pergunta4').click( function() {
    $('div.resposta4').toggle("slow");
   });
   
    $('div.pergunta5').click( function() {
    $('div.resposta5').toggle("slow");
   });
   
    $('div.pergunta6').click( function() {
    $('div.resposta6').toggle("slow");
   });
   
    $('div.pergunta7').click( function() {
    $('div.resposta7').toggle("slow");
   });

});

/* validacao formulario */

 $(document).ready(function() { 
	      $("#formularioingressofull").validate({ 
        rules: { 
			  attribute1: {
			   required: true,
			   minlength: 10
			  },
			  attribute3: {
				required: true,
				minlength: 7
			  },
			  attribute5: {
			  required: true,
			  number: true,
			  minlength: 5
			},
	          email: { // compound rule 
	          required: true, 
	          email: true 
	        }
	        },
			invalidHandler: function(form, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
			var message = errors == 1
			? 'H&aacute; um erro em seu formul&aacute;rio!'
			: 'H&aacute; ' + errors + ' campos inv&aacute;lidos!';
			$("div.errorform1 span").html(message);
			$("div.errorform1").show();
			} else {
			$("div.errorform1").hide();
			}
			},		
	        messages: { 
			  attribute1: "Nome Inv&aacute;lido." ,
			  attribute3: "Cidade Inv&aacute;lida." ,
			  attribute5: "RG Inv&aacute;lido." ,
			  email: "E-mail inv&aacute;lido." 
	        } 
	      }); 
		  
		$("#formulariosimples").validate({ 
        rules: { 
			  attribute1: {
			   required: true,
			   minlength: 10
			  },
			  attribute3: {
				required: true,
				minlength: 7
			  },
	          email: { // compound rule 
	          required: true, 
	          email: true 
	        }
			},		
	        messages: { 
			  attribute1: "Inv&aacute;lido!" ,
			  attribute3: "Inv&aacute;lido!" ,
			  email: "Inv&aacute;lido!" 
	        } 
	      }); 
}); 

 $(document).ready(function() {
    $("#popuppropaganda").dialog({
        bgiframe: true,
        modal:true,
        resizable:false,
        height:'auto',
        width:'auto',
        close: function() {
            $.cookie("anuncionovaid", "closed", { expires: 1 });
        }
    });
    if ($.cookie("anuncionovaid") == "closed"){ 
        $("#popuppropaganda").dialog("destroy"); 
    }else{ 
        $("#popuppropaganda").dialog("open"); 
    } 
});


/* FancyBOX */

$(document).ready(function() {
		
		$("a#blogimg").fancybox({
				'titleShow'		: false
			});	
		$("a#cartaz").fancybox({
				'titleShow'		: false
		});
		$("a.ads").fancybox({
		'hideOnContentClick': true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'scrolling' 	: 'no',
		'autoDimensions': true,
		'margin'	: 20,
		'overlayShow'	: false
		});
		/* Abre revista em fancybox */
		$("a.revista").fancybox({
		'width'				: '70%',
		'height'			: '95%',
		'autoScale'     	: false,
		    'transitionIn'		: 'none',
		    'transitionOut'		: 'none',
		    'type'			: 'iframe'
		});
		
		$("a[rel=galeria]").fancybox({
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Foto ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + 		'</span>';
				}
			});
			
		$("a#videotube").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 853,
			'height'		: 505,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		
		return false; });	
		
});
		
/*  Slider Cinema */

$(document).ready(function(){	
	$("#slidercinema").easySlider({
		auto: true,
		continuous: true,
		nextId: "slidercinemanext",
		prevId: "slidercinemaprev"
		});
});	
		
jQuery(document).ready(function() {
    jQuery('#cartazes').jcarousel({
	wrap: 'circular'
    });
});


/* oculta e mostra cartazes */

jQuery(document).ready(function() {
	jQuery(".cartazesocultos").delay(3000).slideToggle(1500);
	//slide up and down when hover over heading 2
	jQuery(".showhidecartaz").click(function(){
	// slide toggle effect set to slow you can set it to fast too.
	jQuery(".cartazesocultos").slideToggle("slow");
	return true;
	});
 });
 
/* oculta e mostra smileys */

$(document).ready(function() {
    $(".titulosmileys").toggle(
        function() {
	    $("div#tseCTIsmileys-comment").height('175px'); 
            },
            function() {
            $("div#tseCTIsmileys-comment").height('20px');
            }
         );
 });

/* TOOLTIPS CARREGANDO IMAGEM */

jQuery(document).ready(function () {

    // Image Tooltip
    var offsetX = 25;
    var offsetY = 55;

    jQuery('.tooltip').hover(function (e) {
        tooltip_title = this.title;
        this.title = '';
        image_path = this.rel;
        jQuery('body').append('<div id="tooltip"></div>');
        jQuery('#tooltip').css('top', (e.pageY - offsetY) + 'px').css('left', (e.pageX + offsetX) + 'px').fadeIn('fast');

        // Load image
        var img = new Image();
        jQuery(img).load(function () {
            var image = jQuery(this);
            offsetY = img.height + 20;
            offsetX = -img.width / 2;
            jQuery('#tooltip').animate({
                width: img.width,
                height: img.height
            }, 400, function () {
                jQuery('#tooltip').html(image);
                image.css('opacity', '0.0').stop().animate({
                    opacity: 1.0
                }, 800);
            });
        }).attr('src', image_path);


    }, function () {
        this.title = tooltip_title;
        jQuery('#tooltip').remove();
    });
    jQuery('.tooltip').mousemove(function (e) {
        jQuery('#tooltip').css('top', (e.pageY - offsetY) + 'px').css('left', (e.pageX + offsetX) + 'px');
    });

 });

 
/* Fotos ADs */

$(document).ready(function(){
   $('.fotoadsbig').hide();
   $('.fotoads').hover(
     function(){
       $(this).find('.fotoadsbig').show('slide', { direction: 'up' }, 250)
     },
     function(){
       $(this).find('.fotoadsbig').hide('slide', { direction: 'up' }, 250)
     }
   )
 })
