function insert(where,what,centerIdx) {
	var position=where.selectionStart;
	var text=where.value;
	
	text=text.substring(0,position) + what + text.substring(position,text.length);
	where.value=text;
	position+=centerIdx;
	where.selectionStart=position;
	where.selectionEnd=position;
	where.focus();
}


function openWindow(file,x,y) {
	x+=16;
	y+=16;
	var left=(screen.width - x)/2;
	var top=(screen.height - y)/2;
	var options='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+x+',height='+y+',left='+left+',top='+top;
	window.open(file,"Window",options); 
}


function confirmAction(address) {
	if (confirm('Czy na pewno chcesz usunac pozycje ?'))
		window.parent.location=address;
}

function showElement(elem,value) {
	if (value)
		document.getElementById(elem).style.display="block";
	else
		document.getElementById(elem).style.display="none";
}

function trigger(elem) {
	if (document.getElementById(elem).style.display=="block")
		document.getElementById(elem).style.display="none";
	else
		document.getElementById(elem).style.display="block";
}

function cleanField(elem) {
	elem.value='';
	elem.style.color='#545654';
}

function setFieldTxt(elem,value) {
	elem.value=value;
	elem.style.color='#8F938F';
}

function setEmptyTxt(elem,value) {
	if (elem.value=='') {
		elem.value=value;
		elem.style.color='#8F938F';
	}
}

function giveAddress(ac) {
	if (ac==undefined)
		ac='irsa';
	var d='irsa.com.pl';
	var ad=ac+'@'+d;
	document.write(ad);
}

//__________ Special _____________

function getStyle(e,style) {
	if (e.currentStyle)
		var val=e.currentStyle[style];
	else if (window.getComputedStyle)
		var val=document.defaultView.getComputedStyle(e,null).getPropertyValue(style);
	return val;
}

function showOptions() {
	var cho=document.getElementById('chooser');
	var op=document.getElementById('options');
	
	var choH=parseInt(getStyle(cho,'height'));
	var opH=parseInt(getStyle(op,'height'));
	if (isNaN(opH))
		opH=op.offsetHeight; 
	
	if (choH==18)
		cho.style.height=''+(opH+5)+'px';
	else
		cho.style.height='18px';
	
}

function checkIsbn() {
	var isbn=document.getElementById('isbn').value;
	document.location='bookAdd.html?isbn='+isbn;
}

function copy(from,to,filter) {
	var txt=from.value;
	if (filter!=undefined && filter==true) {
		txt=txt.replace(/[áàăâấầẫẩǎåǻäǟãȧǡąāảȁȃạặậḁ]/gi,'a');
		txt=txt.replace(/[ćĉčċçḉȼ]/gi,'c');
		txt=txt.replace(/[ďđ]/gi,'d');
		txt=txt.replace(/[éèĕěêếềễểëẽėȩḝęē]/gi,'e');
		txt=txt.replace(/[íìĭîǐïḯĩiıįīỉȉȋịḭ]/gi,'i');
		txt=txt.replace(/[ǰĵ]/gi,'j');
		txt=txt.replace(/[ł]/gi,'l');
		txt=txt.replace(/[ńǹňñṅņṇṋṉ]/gi,'n');
		txt=txt.replace(/[óòŏôốồỗổǒöȫőõṍṏȭȯȱøǿǫǭōṓṑỏȍȏơớờỡởợọộ]/gi,'o');
		txt=txt.replace(/[śṥŝšṧṡşṣṩș]/gi,'s');
		txt=txt.replace(/[úùŭûǔůüǘǜǚǖűũṹųūṻủȕȗưứừữửựụṳṷṵ]/gi,'u');
		txt=txt.replace(/[źẑžżẓẕƶ]/gi,'z');
		txt=txt.replace(/\s+/g,'-');
		txt=txt.replace(/[^0-9a-zA-Z\-]/g,'');
		txt=txt.toLowerCase();
	}
	to.value=txt;
}
	
function warnURL(form) {
	if (document.getElementById('url').value=='') {
		alert('Pole URL nie może byc puste.');
		return false;
	}
	return true;
}

function odmien(data,pole){
	var nazwy=new Array("stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia");
	var m=data.replace(/[0-9]{4}-([0-9]{2})-[0-9]{2}/,'$1');
	document.getElementById(pole).value=data.replace(/([0-9]{4})-([0-9]{2})-0?([0-9]{1,2})/,'$3 '+nazwy[(m-1)]+' $1');
}
function odmienEn(data,pole){
	var nazwy=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var m=data.replace(/[0-9]{4}-([0-9]{2})-[0-9]{2}/,'$1');
	document.getElementById(pole).value=data.replace(/([0-9]{4})-([0-9]{2})-0?([0-9]{1,2})/,nazwy[(m-1)]+' $3, '+'$1');
}







