function okno_generic_size(link, nazwa, w, h){
    w=window.open(link,nazwa,'resizable=yes,scrollbars=yes,width='+w+',height='+h+',screenX=0, screenY=0,left=0,top=0');
    w.focus();
    return false
}

function okno_generic(link, nazwa) {
    return okno_generic_size(link,nazwa,780,590)
}

function okno_generic(link) {
    return okno_generic(link,'popup')
}

function okno_graj(id){
    okno_generic_size('http://www.radioinfor.pl/graj.php?id='+id,'GrajWindow', 400, 450);
    return false;
}

function show(id){
    if(document.getElementById && document.getElementById(id)){
        document.getElementById(id).style.visibility = 'visible'
    }
}
function hide(id){
    if(document.getElementById && document.getElementById(id)){
        document.getElementById(id).style.visibility = 'hidden'
    }
}
function switch_image(img_src) {
	this.src=img_src;
}
// Obsluga wyślij znajomemu
function formularz() {
    this.lista_pol = new Array(false, false);
    
    function weryfikuj(input, pole) {
        this.lista_pol[pole] = input.value;
        if(input.value != "") {
            if(pole == 'wyslij_email_1' || pole == 'wyslij_nadawca')
                input.style.backgroundColor='#ffffff';
            if(!this.checkMail(input.value))
                input.style.color = "#000000";
            else
                input.style.color = "#000000";
        } else {
            if(pole == 'wyslij_email_1' || pole == 'wyslij_nadawca')
                input.style.backgroundColor='#f2b7be';
        }
        if(pole == 'wyslij_nadawca' && this.checkMail(input.value))
            this.lista_pol[0] = true;
        
        if(pole == 'wyslij_email_1' && this.checkMail(input.value))
            this.lista_pol[1] = true;
    }
    
    function sprawdz_pola(input) {
        if(this.lista_pol[0] == true && this.lista_pol[1] == true) {
            return true;
        } else {
            return false;
        }
    }
    function checkMail(email)
    {
    	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    	if (filter.test(email)) 
            return true;
    	else 
            return false;
    }
    this.weryfikuj = weryfikuj;
    this.sprawdz_pola = sprawdz_pola;
    this.checkMail = checkMail;
}
                
// Obsluga komentowania artykułu              
function komentarz_sprawdzenie() {
    var input_podpis = document.getElementById('komentarz_podpis');
    var input_tresc = document.getElementById('komentarz_tresc');
    
    var info_podpis = document.getElementById('info_autor');
    var info_tresc = document.getElementById('info_tresc');
    
    var error = false;
    
    if(input_podpis.value != '')
        info_podpis.innerHTML='';
    else {
        info_podpis.innerHTML = 'Proszę wypełnić pole <b>Autor</b>.';
        error = true;
    }
    if(input_tresc.value != '')
        info_tresc.innerHTML='';
    else {
        info_tresc.innerHTML = 'Proszę wypełnić pole <b>Treść</b>.';
        error = true;
    }
    if(error == true)
        return false;
    else
        return true;
}

// Ciasteczka           
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);
}

function kalkulator_emerytur(opcja) {
    if(opcja == 1) {
        for(i=0; i <= 60; i++) { //po nowym roku +1
            tmp_id = 'text_'+i;
            inputfield = document.getElementById(tmp_id);
            inputfield.disabled = true;
            inputfield.style.backgroundColor = "#eee";
            inputfield.style.border = "2px solid #ddd";
            
            tmp_id = "box_"+i;
            select_box = document.getElementById(tmp_id);
            select_box.innerHTML = '';
            
            radiobox = document.createElement('input'); 
            radiobox.setAttribute('type','radio');
            radiobox.setAttribute('name','rok');
            radiobox.setAttribute('value',(1950+i));
            radiobox.temp = i;
            if(i > 49) radiobox.setAttribute('disabled',true); // nie można wybrac mniej niż 10 lat
            radiobox.onclick = function() {
                kalkulator_emerytur_input_text(this, 1);
            };
            select_box.appendChild(radiobox);
        }
    } else {
        var liczba_zaznaczonych = 0;
        for(i=0; i <= 60; i++) { //po nowym roku +1
            tmp_id = 'text_'+i;
            inputfield = document.getElementById(tmp_id);
            inputfield.disabled = true;
            inputfield.style.backgroundColor = "#eee";
            inputfield.style.border = "2px solid #ddd";
            
            tmp_id = "box_"+i;
            select_box = document.getElementById(tmp_id);
            select_box.innerHTML = '';
            
            checkbox = document.createElement('input'); 
            checkbox.setAttribute('type','checkbox');
            checkbox.setAttribute('name','rok['+(1950+i)+']');
            checkbox.temp = i;
            checkbox.onclick = function() {
                kalkulator_emerytur_input_text(this, 2);
            }
            select_box.appendChild(checkbox);
        }
    }
}
function kalkulator_emerytur_input_text(elem, opcja) {
    if(opcja == 1) {
        for(x=0; x <= 59; x++) {
            tmp_id = 'text_'+x;
            inputfield = document.getElementById(tmp_id);
            if(x >= elem.temp && x < elem.temp+10) {
                inputfield.disabled = false;
                inputfield.style.backgroundColor =  "#fff";
                inputfield.style.border = "2px solid #ddd";
            }else {
                inputfield.disabled = true;
                inputfield.style.backgroundColor = "#eee";
                inputfield.style.border = "2px solid #ddd";
            }
        }
    }
    else {
        tmp_id = 'text_'+elem.temp;
        inputfield = document.getElementById(tmp_id);
        if(elem.checked == true) {
            inputfield.disabled = false;
            inputfield.style.backgroundColor =  "#fff";
            inputfield.style.border = "2px solid #ddd";
        } else {
            inputfield.disabled = true;
            inputfield.style.backgroundColor = "#eee";
            inputfield.style.border = "2px solid #ddd";
        }
    }
    return true;
}
function kalkulator_emerytury_poradnik(elem) {
    poradnik = document.getElementById('jak_wyliczyc');
    if(poradnik.style.display == 'none') {
        poradnik.style.display = 'block';
    } else {
       poradnik.style.display = 'none';
    }
}

