﻿// execute your scripts when the DOM is ready. this is mostly a good habit
$(function() {

	// initialize scrollable
	$(".scrollable").scrollable();

});

$(document).ready(function() {
    $('.slideShow').cycle({ 
	    fx:     'fade', 
	    timeout: 8000, 
	    delay:  -2000 
	});
});

$(function() {
	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});

jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        vertical: true,
        scroll: 2,
		easing: 'BounceEaseOut',
        animation: 1000
    });
});

function openInter(pag,no,larg,alt) {
	//pega a resolucao do visitante
	w = screen.width;
	h = screen.height;
	//divide a resolucao por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;
	//diminui o valor da metade da resolucao pelo tamanho da janela, fazendo com q ela fique centralizada
	alt2 = alt/2;
	larg2 = larg/2;
	meio1 = meio_h-alt2;
	meio2 = meio_w-larg2;
	//abre a nova janela, ja com a sua devida posicao
	window.open(pag,no,'height=' + alt + ', width=' + larg + ', top='+meio1+', left='+meio2+', status=yes');
}

function addFavoritos(){
	var urlsite = "http://www.pollydiversao.com.br";
	
	if(window.sidebar) {
		window.sidebar.addPanel("Polly Diversão",urlsite,"");
	}else if(window.opera && window.print){
		
		var tags = document.createElement('a');
		tags.setAttribute('rel','sidebar');
		tags.setAttribute('href',urlsite);
		tags.setAttribute('title',"Polly Diversão");
		tags.click();
		
	}else if(document.all){
		 window.external.AddFavorite(urlsite,"Polly Diversão");
	}

}

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 : 155;
    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 = 155 - field.value.length;
    }

}  
