
function isIE () {
	return (navigator.userAgent.indexOf("MSIE")!=-1) ? true : false;
}
function isFF () {
	return (navigator.userAgent.indexOf("Firefox")!=-1) ? true : false;
}

function flashWindow(urlFlash, width, height) {
	var width = parseInt(width);
	var height = parseInt(height);
	var width = (isNaN(width) ? 420 : width+40);
	var height = (isNaN(height) ? 420 : height+40);

	var Win = window.open('',"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left=350, top=100' );
	Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Flash Player</title></head><body style="background-color:navy" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');

	Win.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align=center><table bgcolor="white" style="padding:4px;border:silver 1px solid"><tr><td>\
	<object width="'+width+'" height="'+height+'">\
	<param name="movie" value="'+urlFlash+'">\
	<embed src="'+urlFlash+'" width="'+width+'" height="'+height+'">\
	</embed>\
	</object>\
	</td></tr></table></td></tr></table>');

	Win.document.write('</body></html>');

};

function parsePriceField (field) {
	field.value = field.value ? field.value.replace(",",".") : '';
	field.value = field.value ? field.value.replace(/[^0-9.]/g,"") : '';
}

function isdefined( variable) {
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function showMovies(field) {
	 url = 'ftpmovies.php?f='+field.name;
	 w = window.open(url,'okienko','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars=yes,width=400,height=400,menubar=no')
	 w.focus();
}


function changeRowColor(rowId,changeColor) {
	if(changeColor)
		document.getElementById(rowId).className='st-selected';
	else
		document.getElementById(rowId).className='';
}

function checkEmailAddress(field) {
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (goodEmail){
	  return true
	} else {
    field.focus()
    field.select()
    return false
  }
}

function changeBg (el) {
	el.style.backgroundColor = '#ffecec';
}
function changeBgTr (el) {
	el.style.backgroundColor = 'white';
}

function goTo (l) {
	location.href=l;
}

function blankSrc (l) {
	window.open(l)
}



function transTab (l) {
	 w = window.open(l,'transTab','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars=yes,width=700,height=500,menubar=yes')
	 w.focus();
}

function produkty(idsklep) {
	with(document.ind) {
		action = 'sh-products.php';
		ids.value=idsklep;
		submit();
	}
}

function kategorie(idsklep) {
	with(document.ind) {
		action = 'sh-categories.php';
		ids.value=idsklep;
		submit();
	}
}

function edytuj(idsklep) {
	with(document.ind) {
		action = 'sh-shop.php';
		ids.value=idsklep;
		submit();
	}
}
function skasuj(idsklep) {
	with(document.ind) {
		del.value=idsklep;
		submit();
	}
}
function okienko(url,width,height,sb){
	 w = window.open(url,'okienko','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars='+sb+',width='+width+',height='+height+',menubar=no')
	 w.focus();
}
function addComment (par) {
	window.open('forumPopUp.php'+par,'forum','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars=yes,width=400,height=400,menubar=no')
}
/* Strony categories */
function cts_dodaj(idcv) {
	with(document.ind) {
		action = 'sh-category.php';
		idc.value=idcv;
		submit();
	}
}

function cts_produkty(idcv) {
	with(document.ind) {
		action = 'sh-products.php';
		idc.value=idcv;
		submit();
	}
}

function cts_naGore(idp) {
	with(document.ind) {
		ng.value=idp;
		submit();
	}
}

function cts_kasuj(idp) {
	with(document.ind) {
		if(confirm('Do you really want to delete it?')) {
			del.value=idp;
			submit();
		}
	}
}

function cts_kasujpod(idp) {
	with(document.ind) {
		if(confirm('Do you really want to delete it?')) {
			delpod.value=idp;
			submit();
		}
	}
}
function cts_kasujAll(idp) {
	with(document.ind) {
		if(confirm('Do you really want to delete it?')) {
			okienko('categories-delete-all.php?idc='+idp,500,300,'yes');
		}
	}
}

/* produkty */
function prd_dodaj(idp) {
	with(document.ind) {
		action = 'sh-product.php';
		SPR_ID.value=idp;
		submit();
	}
}

function prd_dodajKat() {
	with(document.ind) {
		action = 'sh-category.php';
		submit();
	}
}
function prd_edytujKat() {
	with(document.ind) {
		action = 'sh-categories.php';
		submit();
	}
}

function prd_naGore(idp) {
	with(document.ind) {
		ng.value=idp;
		submit();
	}
}

function prd_kasuj(idp) {
	with(document.ind) {
		if(confirm('Do you really want to delete it?')) {
			del.value=1;
			submit();
		}
	}
}

/* dostawa */
function dst_edytuj(iddv) {
	with(document.ind) {
		idd.value=iddv;
		submit();
	}
}

function dst_naGore(idp) {
	with(document.ind) {
		ng.value=idp;
		submit();
	}
}

function dst_kasuj(idp) {
	with(document.ind) {
		if(confirm('Do you really want to delete it?')) {
			del.value=idp;
			submit();
		}
	}
}

function storeCaret (textEl) {
  if (textEl.createTextRange && document.selection)
    textEl.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret (textEl,text) {

	//var textEl = document.rekord.NNS_TEXT;

  if (textEl.createTextRange && textEl.caretPos) {
    var caretPos = textEl.caretPos;
    caretPos.text =
      caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
        text + ' ' : text;
  }
  else {
    textEl.value  =  textEl.value + text;
	}

	textEl.focus();
}

function wstawZal(tform) {
	with(document.rekord) {
		if(zal) {
			ali = al.selectedIndex>0 ? ' align='+al.options[al.selectedIndex].value : '';
			if(zal.length>0) {
				for(i=0;i<zal.length;i++)
					if(zal[i].checked)
						zalid = zal[i].value;
			} else {
				zalid = zal.value;
			}
			insertAtCaret (tform,'<img '+ali+' src="'+zalid+'" border=0>')
		}
	}
}
function wstawImg() {
	with(document.rekord) {
		if(zal) {
			ali = al.selectedIndex>0 ? ' align='+al.options[al.selectedIndex].value : '';
			if(zal.length>0) {
				for(i=0;i<zal.length;i++)
					if(zal[i].checked)
						zalid = zal[i].value;
			} else {
				zalid = zal.value;
			}
			html_text.focus();
			var sel = html_text.document.selection.createRange();
			sel.pasteHTML('<img '+ali+' src="'+zalid+'" border=0>');
		}
	}
}

function wstawImgMailing() {
	with(document.rekord) {
		if(zal) {
			ali = al.selectedIndex>0 ? ' align='+al.options[al.selectedIndex].value : '';
			if(zal.length>0) {
				for(i=0;i<zal.length;i++)
					if(zal[i].checked)
						zalid = zal[i].value;
			} else {
				zalid = zal.value;
			}
			html_text.focus();
			var sel = html_text.document.selection.createRange();
			sel.pasteHTML('<img '+ali+' src="'+zalid+'" srccid="cid:'+zalid+'" alt="'+zalid+'" border=0>');
		}
	}
}

function etitAtt (idatt) {
	with(document.rekord) {
		txt = prompt('Zmień opis','');
		if(txt != null) {
			attDesc.value = txt ? txt : '';
			attAct.value = 'desc'
			ida.value = idatt;
			submit();
		}
	}
}

/* uzytkownicy */
function delUser (f) {
	if(confirm('Do you really want to delete this user?')) {
		f.deleteUser.value=1;
		f.submit();
	}
}

/* ankiety */
function delAnk (f,ida) {
	if(confirm('Do you really want to delete it?')) {
		f.kasuj.value=ida;
		f.submit();
	}
}

/* galerie */
function galWin(url,name,width,height,sb){
	var w = window.open(url,name,'align=center,toolbar=0,status=0,location=0,directories=0,resizable=0,scrollbars='+sb+',width='+width+',height='+height+',menubar=no')
	w.focus();
}

function delPic(idz) {
	with(document.zdjGal) {
		delFG.value = idz;
		submit();
	}
}

function checkedAll() {
	with (document.zdjGal){
		for(i=0; i<t.length; i++) {
			pole = eval("z"+t[i]+"add");
			pole.checked=true;
		}
	}
}
function unCheckedAll() {
	with (document.zdjGal){
		for(i=0; i<t.length; i++) {
			pole = eval("z"+t[i]+"add");
			pole.checked=false;
		}
	}
}
