﻿var offX = 1;          // X offset from mouse position
var offY = 1;    
var over = true;
function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}
function mouseLeaves (element, evt) {
if (typeof evt.toElement != 'undefined' && typeof element.contains !=
'undefined') {
return !element.contains(evt.toElement);
}
else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
return !contains(element, evt.relatedTarget);
}
}

function contains (container, containee) {
while (containee) {
if (container == containee) {
return true;
}
containee = containee.parentNode;
}
return false;
}

function mostraInfo(event,arg) {
	obj = document.getElementById("info");
	obj.style.visibility = "visible";
	obj.style.left  = (parseInt(mouseX(event))+offX) + 'px';
	obj.style.top  = (parseInt(mouseY(event))+offY) + 'px';
	obj.innerHTML = arg;
}

function hideInfo(event) {
obj = document.getElementById("info");
	if (mouseLeaves(obj, event)) { 
	obj.style.visibility='hidden';
	}
}

function trocaValor(obj,texto,textoalt) {
	if(obj.value==texto){ obj.value=textoalt; }
	obj.style.background = "#fdfafd";
	}
	function trocaValor2(obj,texto,textoalt) {
	if(obj.value=='') { obj.value=texto;}
	obj.style.background = "#fef6fd";
	}
		function calculaTotal() { 
		numero = document.getElementById('quantidade').value * 89.90;
		document.getElementById('total').innerHTML = 'R$'+numero;
	}
function abrirJanela(URL) {

  var width = 600;
  var height = 400;

  var left = 99;
  var top = 99;

  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function compartilhar(link,texto,servico) {
	var url;
	switch(servico) {
		case 'twitter':
			url = 'http://twitter.com/share?text='+texto+'&url='+link;
		break;
		case 'facebook':
			url = 'http://www.facebook.com/sharer.php?u='+link+'&t='+texto;
		break;
	}
	abrirJanela(url);

}
function abreJanela(theurl,x,y,s,u) {
	var t = (screen.height - y) / 2;
	var e = (screen.width - x) / 2;
	window.open(theurl,x+y+s,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');
	if(u==1){
	//	window.focus();
	}
}
function myTimestamp(){
    tstmp = new Date();    
    return tstmp.getTime();
} 

var carregando = false;
function abrirpagina() {
	if(!carregando) {
	$('#carregarMais').addClass('hide');
	$('#carregarMais').next().removeClass('hide');
	pagina = $('#carregarMais').attr('title');
	carregando = true;
	$.ajax({type: "GET", url: "paginas.php?pag="+pagina+"&avoidcache="+myTimestamp(), success: function(result) {
		$('#paginas').append(result);
		carregando = false;
	$('#carregarMais').removeClass('hide');
	$('#carregarMais').next().addClass('hide');
	}});
	pagina2 = parseInt(pagina)+1;
	$('#carregarMais').attr('title',pagina2);
	}

}
function abreSiteUnder() {
//	$('#afilioiframe').attr('src','http://gossipgirldownload.net/afilio.html');
}

$(document).ready(function() {


	var tamanho = $(document).height();
	
	var scroll;
	
	if(document.location.href=='http://gossipgirldownload.net' || document.location.href=='http://www.gossipgirldownload.net' || document.location.href=='http://gossipgirldownload.net/' || document.location.href=='http://www.gossipgirldownload.net/') {
			$(window).scroll(function() {
			carregarMais = $('#carregarMais').offset().top;
			scroll = $(window).scrollTop();
				
				if(scroll >= carregarMais-700) {
					abrirpagina(2);
				}
			
			});
		}
	$('#premium').hover(function() {
	//	$('#premium-info').fadeIn('fast');
	},function() {
	//	$('#premium-info').fadeOut('fast');		
	});





});
