function wylacz(){
	
	input = document.getElementById('firma');
	input.disabled="disabled";
	input.value="";
	input.style.backgroundColor="#aaaaaa";
}

function wlacz(){
	document.getElementById('firma').disabled="";
	input.style.backgroundColor="";
}

function tekst1()
{
	opener.document.form.link.value = document.form1.zmien.value;
}

function tekst3()
{
	opener.document.form.link1.value = document.form1.zmien.value;
}

function tekst4()
{
	opener.document.form.link2.value = document.form1.zmien.value;
}



function tekst2(z)
{
	document.form1.zmien.value = z;
	
}

function tekst5(z,z1)
{
	document.form1.zmien.value = z;
	document.getElementById('nazwa_p').value=z1;
	
	
}

function tekst7()
{
	opener.document.form.Nazwa.value=document.getElementById('nazwa_p').value;
	opener.document.form.link.value = document.form1.zmien.value;
}

var win_popups = new Array();

function window_open(adres, nazwa, par) {
	if(nazwa in win_popups && !win_popups[nazwa].closed) {
		win_popups[nazwa].focus();
	} else {
		var win=window.open(adres, nazwa, par);
		win_popups[nazwa] = new Object(win);
	}
}


function load_data_ifarea(id) {
	document.getElementById(id+'_area').contentWindow.document.body.innerHTML=document.getElementById(id).value;
}


function delete_tresc(id) {
	if(confirm("Czy napewno usunąć ?")) {
		document.location.href="index.php?d="+id;
	}
}

function file_open(img) {
	window_open("popup/plik.php?img="+img, "zt", "width=200,height=90,left=10,top=10");
}

function rollover_ini() {
	rollovers = new Array();
	var img=document.body.getElementsByTagName('img');
	for(var i=0; i<img.length; i++) {
		if(img[i].className=='rollover') {
			img[i].src.match(/(.*)\.([a-z0-9]+)$/i);
			var src_act=RegExp.$1+'_act.'+RegExp.$2;
			rollovers[i]=document.createElement('img');
			rollovers[i].src=src_act;
			img[i].alt=src_act;
			img[i].onmouseover = function () {
				var buff= new String(this.src);
				this.src=this.alt;
				this.alt=buff; 	
			}
			
			img[i].onmouseout = function () {
				var buff= new String(this.src);
				this.src=this.alt; 
				this.alt=buff;	
			}
			
			
		}
	}
}

function Init() {
	rollover_ini();
}

function drukuj(id) {
	var id_el=document.getElementById(id);
	if(id_el == undefined ) {
		alert("Opcje nie dostępna");
	} else {
		window_open("popup/popup.php?id=drukuj;"+id.toString(), 'drukowanie', 'width=600,height=500,scrollbars=yes,menubar=yes,status=yes,toolbar=no');
	}
}

function sklep_licz_koszt(obj) {
	var towar=document.getElementById('suma_all');
	if(typeof towar !== "object") {
		return false;
	}
	
	var koszt=document.getElementById("koszt_"+obj.value);
	if(!koszt) return false;
	
	var kwota=document.getElementById("kwota_cala");
	if(!kwota) return false;	
	
	var koszt_all=parseFloat(koszt.value) + parseFloat(towar.value);
	koszt_all=koszt_all.toFixed(2);
	
	var koszt_node=document.createTextNode(koszt_all.toString());
	
	if(kwota.firstChild == null) {
		kwota.appendChild(koszt_node);
	} else {
		kwota.replaceChild(koszt_node, kwota.firstChild);
	}
	
	
	
	
	
		
}


function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no,menubar=no' );
}



function spr_kontakt(){
	var email = document.getElementById("email_kon");
	var temat = document.getElementById("temat_kon");
	var tresc = document.getElementById("tresc_kon");
	var submit = document.getElementById("submit_kon");
	var miasto = document.getElementById("miasto_kon");
	var firma = document.getElementById("firma_kon");
	
	Wzor = /^[a-zA-Z0-9.\-_]+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,4}$/;
	
	if(Wzor.test(email.value) == false){
			alert('Adres Email nie poprawny. Proszę wypełnić poprawnie pole >>Twój Email<<');
			submit.disabled = true;
	}else{

		if(email.value!="" && temat.value!="" && miasto.value!="" && firma.value!=""){
			submit.disabled = false;
		}else{
			submit.disabled = true;
		}
	}
}