/**
 * @author Mirosław Bogacz
 * @version 1.0
 * @data 03-09-2008r.
 */
/**
 * @namespace InfoBrowser
 * @version 0.4 beta
 * @see
 */
var InfoBrowser = new function InfoBrowser(){
    if (window.navigator.userAgent.indexOf('Firefox') != -1) {
        this.Name = 'Firefox';
        this.Version = window.navigator.userAgent.substring(window.navigator.userAgent.indexOf('Firefox') + 8, window.navigator.userAgent.indexOf('.', window.navigator.userAgent.indexOf('Firefox') + 8))
        this.FullVersion = window.navigator.userAgent.substring(window.navigator.userAgent.indexOf('Firefox') + 8, window.navigator.userAgent.length)
    }
    else 
        if (window.navigator.userAgent.indexOf('Opera') != -1) {
            this.Name = 'Opera';
            this.Version = window.navigator.appVersion.substring(0, window.navigator.appVersion.indexOf('('), 0);
            this.FullVersion = window.navigator.appVersion.substring(0, window.navigator.appVersion.indexOf('.'));
        }
        else 
            if (window.navigator.userAgent.indexOf('MSIE') != -1) {
                this.Name = 'Microsoft Internet Explorer';
                this.Version = window.navigator.appVersion.substring(window.navigator.appVersion.indexOf('MSIE') + 4, window.navigator.appVersion.indexOf(';', window.navigator.appVersion.indexOf('MSIE') - 1))
                this.FullVersion = window.navigator.appVersion.substring(window.navigator.appVersion.indexOf('MSIE') + 4, window.navigator.appVersion.indexOf('.', window.navigator.appVersion.indexOf('MSIE') - 1))
            }
            else 
                if (window.navigator.userAgent.indexOf('Safari') != -1) {
                    this.Name = 'Safari';
                    this.Version = window.navigator.userAgent.substring(window.navigator.userAgent.indexOf('Version/') + 8, window.navigator.userAgent.indexOf('S') - 1, window.navigator.userAgent.indexOf('Version/' + 9))
                    this.FullVersion = window.navigator.userAgent.substring(window.navigator.userAgent.indexOf('Version/') + 8, window.navigator.userAgent.indexOf('.', window.navigator.userAgent.indexOf('Version/')))
                }
};

/**
 * @namespace Ulubione
 * @version 1.0 beta 1
 * @see
 */
var Ulubione = {
    Ustawienia: {
        Tytul: '',
        Adres: '',
        Id: ''
    },
    Dodaj: function(){
        if (document.getElementById(Ulubione.Ustawienia.Id)) {
            if (window.sidebar) {
                document.getElementById(Ulubione.Ustawienia.IdLink).onclick = function(){
                    window.sidebar.addPanel(Ulubione.Ustawienia.Tytul, Ulubione.Ustawienia.Adres, "");
                };
            }
            else 
                if (window.external) {
                    document.getElementById(Ulubione.Ustawienia.Id).onclick = function(){
                        window.external.AddFavorite(Ulubione.Ustawienia.Adres, Ulubione.Ustawienia.Tytul);
                    };
                }
                else 
                    if (window.opera && window.print) {
                        var e = document.getElementById(Ulubione.Ustawienia.Id);
                        e.setAttribute('href', Ulubione.Ustawienia.Adres);
                        e.setAttribute('title', Ulubione.Ustawienia.Tytul);
                        e.setAttribute('rel', 'sidebar');
                    }
        }
    }
};

/**
 * @namespace RovelImg
 * @version 0.9
 * @see
 */
var RovelImg = {
    start: function(){
        var e = document.getElementsByTagName('img');
        for (var i = 0; i < e.length; i++) {
            if (e[i].className.match(/([RovelImg])/gi) && e[i].src.match(/(_off.)/gi)) {
                RovelImg.over(e[i]);
                RovelImg.out(e[i]);
            }
        }
    },
    over: function(e){
        e.onmouseover = function(){
            this.src = this.src.replace('_off.', '_on.');
        }
    },
    out: function(e){
        e.onmouseout = function(){
            this.src = this.src.replace('_on.', '_off.');
        }
    }
};


function WindowOpen(dir){
	
	email_znajomego=document.getElementById('email_znajomego').value;
	
	if(email_znajomego=='Podaj adres e-mail'){
	email_znajomego='';	
	}
	
    ContentWhite = document.createElement('div');
    ContentWhite.style.width = '626px';
    ContentWhite.style.height = '445px';
	ContentWhite.id = 'ContentWhite';
    iframe = document.createElement('iframe');
    iframe.src = dir+'form.php5?email_znajomego='+email_znajomego;
    iframe.style.width = '626px';
    iframe.style.height = '475px'; 
    iframe.className = 'iframe01'
    MASK = document.createElement('div');
	MASK.id = 'MASK';
	ContentWhite.innerHTML = "<table><tr><td width='502' height='25'><span class='style1'>Poleć znajomemu</span></td><td width='94' valign='bottom'><span class='style3' style='cursor:pointer;' onClick='WindowClose();'>zamknij okno</span></td></tr></table>"
    
    document.body.appendChild(ContentWhite);
    ContentWhite.appendChild(iframe);
    document.body.appendChild(MASK);
    
    ContentWhite.className = 'ContentWhite';
    MASK.style.width = document.documentElement.clientWidth + 'px';
    MASK.style.height = document.documentElement.clientHeight + 'px';
    MASK.className = 'MASK';
    if (window.innerWidth || window.innerHeight) {
        if (!document.documentElement.scrollHeight < document.body.offsetHeight) {
            MASK.style.width = document.body.offsetWidth + 'px';
            MASK.style.height = (document.documentElement.scrollHeight - document.body.offsetHeight) + document.body.offsetHeight + 'px';
            
        }
        else {
            MASK.style.width = document.body.offsetWidth + 'px';
            MASK.style.height = document.body.offsetHeight + 'px';
        }
    }
    else {
        if (document.documentElement.clientHeight < document.documentElement.scrollHeight) {
            MASK.style.width = document.body.clientWidth + 'px';
            MASK.style.height = (document.documentElement.scrollHeight - document.documentElement.clientHeight) + document.body.clientHeight + 'px';
            
        }
        else {
            MASK.style.width = document.body.clientWidth + 'px';
            MASK.style.height = document.body.clientHeight + 'px';
        }
    }
    if (window.innerHeight) {
        ContentWhite.style.top = ((window.innerHeight / 2) - (ContentWhite.offsetHeight / 2)) + (document.documentElement.scrollTop) + 'px';
        ContentWhite.style.left = ((window.innerWidth / 2) - (ContentWhite.offsetWidth / 2)) + (document.documentElement.scrollLeft) + 'px';
    }
    else {
        ContentWhite.style.top = ((document.documentElement.scrollTop) + (document.documentElement.clientHeight / 2)) - (ContentWhite.offsetHeight / 2) + 'px';
        ContentWhite.style.left = ((document.documentElement.scrollLeft) + (document.documentElement.clientWidth / 2)) - (ContentWhite.offsetWidth / 2) + 'px';
    }
}

function WindowClose() {
	document.body.removeChild(document.getElementById('ContentWhite'));
	document.body.removeChild(document.getElementById('MASK'));
}

var mAlert = function(text, title, akcja) {
	if (document.getElementById('mAlert')) {
		document.body.removeChild(document.getElementById('mAlert'));
	}
	
	this.mAlert = document.createElement('div');
		this.mAlert.Title = document.createElement('div');
		this.mAlert.Content = document.createElement('div');
			this.mAlert.Content.Btn = document.createElement('div');
				this.mAlert.Content.Btn.TAK = document.createElement('span');
				this.mAlert.Content.Btn.NIE = document.createElement('span');
				this.mAlert.Content.Btn.ZAMKNIJ = document.createElement('span');
				this.mAlert.Content.Btn.ZAMKNIJ.innerHTML = 'Przeczytaj informację prasową';
				
	this.mAlert.id = 'mAlert';
	this.mAlert.style.position = 'absolute';
	this.mAlert.style.zIndex = '990';		
	this.mAlert.style.width = 300 + 'px';
	this.mAlert.style.background = '#ffffff';
	this.mAlert.style.border = '1px solid #b48211';
	
	this.mAlert.Content.style.padding = 10 + 'px';
	this.mAlert.Content.style.textAlign = 'left';
	this.mAlert.Content.style.lineHeight = 17 + 'px';
	
	
	this.mAlert.Title.style.padding = '5px 0px 5px 10px';
	this.mAlert.Title.style.borderBottom = '1px solid #b48211';
	this.mAlert.Title.style.background = '#ebaa18';
	this.mAlert.Title.style.fontWeight = 'bold';
	
	this.mAlert.Content.Btn.style.textAlign = 'center';
	this.mAlert.Content.Btn.style.padding = '10px 0px 5px 0px';
		
		this.mAlert.Content.Btn.ZAMKNIJ.style.border = '1px solid #b48211';
		this.mAlert.Content.Btn.ZAMKNIJ.style.background = '#ebaa18';
		this.mAlert.Content.Btn.ZAMKNIJ.style.padding = '2px 10px';
		this.mAlert.Content.Btn.ZAMKNIJ.style.cursor = 'pointer';
	
	document.body.appendChild(this.mAlert);
		this.mAlert.Title.innerHTML = title + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0);' style='color:black;' onclick=document.body.removeChild(document.getElementById('mAlert'))>X</a>";
		this.mAlert.Content.innerHTML = text;
		this.mAlert.appendChild(this.mAlert.Title);
		this.mAlert.appendChild(this.mAlert.Content);
			this.mAlert.Content.appendChild(this.mAlert.Content.Btn);
				this.mAlert.Content.Btn.appendChild(this.mAlert.Content.Btn.ZAMKNIJ);
	if (window.innerHeight) {
        this.mAlert.style.top = (((window.innerHeight / 2) - (this.mAlert.offsetHeight / 2)) + (document.body.scrollTop))-80 + 'px';
        this.mAlert.style.left = ((window.innerWidth / 2) - (this.mAlert.offsetWidth / 2)) + (document.body.scrollLeft) + 'px';
    }
    else {
        this.mAlert.style.top = (((document.body.scrollTop) + (document.body.clientHeight / 2)) - (this.mAlert.offsetHeight / 2))-280 + 'px';
        this.mAlert.style.left = ((document.body.scrollLeft) + (document.body.clientWidth / 2)) - (this.mAlert.offsetWidth / 2) + 'px';
    }
	
	this.mAlert.Content.Btn.TAK.onclick = function() {
		document.body.removeChild(document.getElementById('mAlert'));
		window.open('http://sprawdzpromile.pl/ankieta/');
	}
	
	this.mAlert.Content.Btn.NIE.onclick = function() {
		document.body.removeChild(document.getElementById('mAlert'));
		
	}
	
	this.mAlert.Content.Btn.ZAMKNIJ.onclick = function() {
		document.body.removeChild(document.getElementById('mAlert'));
		document.location.href='aktualnosci.html';
	}
};

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}