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='#141313';
}

function setFieldTxt(elem,value) {
	elem.value=value;
	elem.style.color='#8F938F';
}

function setEmptyTxt(elem,value) {
	if (elem.value=='') {
		elem.value=value;
		elem.style.color='#141313';
	}
}

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;
}





