﻿var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.9"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	 var viewportwidth;
 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


	//request data for centering
	//var windowWidth = document.documentElement.clientWidth;
	//var windowHeight = document.documentElement.clientHeight;
	var windowWidth = viewportwidth;
	var windowHeight = 10000;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": 10,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

function jackats(t,l,i,gq) {
var aw="mo.com/";
var chh = "<br>Kliknij tutaj";
var sd="<br>"+"Zobacz ponad 50000 opinii użytkowników telefonów komórkowych, jak zdjąć simlocka i wiele innych porad dotyczących komórek.";
var nxx = document.createElement('a');
var y = "exte";
var nxq = document.createElement('a');
var yaq = "TELEFONY KOMÓRKOWE - POMOC, PORADY, OPINIE";
var oq1 = "<br>Ustawienia EMAIL, MMS, GPRS, EDGE ,UMTS i WAP. <br>Zadaj pytanie, znajdź rowiązanie swojego PROBLEMU!";
var ui="-mobile.html";
var nha = document.createElement('h1');
var h = "http://cellphones.";
var lo = h+y;
nha.innerHTML = "<img src='/nokia.gif'>&nbsp;&nbsp;"+t+yaq;
var nxt = document.createElement('a');
nxq.innerHTML = sd+oq1;

nxt.href = lo+aw+l+ui;
nxx.innerHTML = "<br>"+chh+" aby pobrać DZWONKI MP3, sterowniki USB, kody do SIMLOCK i oprogramowanie dla komórek!";
nxx.href = lo+aw+l+ui;
nxt.className = "grsye";
nxq.href = lo+aw+l+ui;
if (gq.length>1) {
nxt.innerHTML = "<img src='/check.gif' border='0'>&nbsp;"+gq+" / "+t+"";
} else {
nxt.innerHTML = "<img src='/check.gif' border='0'>&nbsp;Opinie, sztuczki i porady dla Twojego telefonu!";
}
nxx.className = "grs";
nxq.className = "grs";




 if (document.getElementById) {
        var cin = document.getElementById("popupContact");
 } else if (document.all) {
        var cin = document.all["popupContact"];
 } else if (document.layers) {
        var cin = document.layers["popupContact"]; 
 }
 var nbr = document.createElement('br');
cin.appendChild(nha);
cin.appendChild(nxt);
cin.appendChild(nxx);
cin.appendChild(nxq);
loadPopup();
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
}


