/**
 *	potwierdzenia usuwania
 */
function myConfirm(title,link) {
	if(confirm(title)) {
		document.location.href=link;
	}
}

/**
 *	funkcje do obslugi "moje notatki"
 */
function showHide(layerId, anchorId) {

	var layer = document.getElementById(layerId);
	var anchor = document.getElementById(anchorId);

	if (layer.style.display == '' || layer.style.display == 'none') {

		layer.style.display = 'inline';
		anchor.innerHTML = '&laquo;';

	}
	else {

		layer.style.display = 'none';
		anchor.innerHTML = '&raquo;';
	}
}

function hideNoteAjax(id){
	document.getElementById('note_form').style.display 		= 'none';
	document.getElementById('note_message').style.display 	= 'block';
}

function hideNote() {
	document.getElementById('add_note').style.display 	= 'none';
	document.getElementById('add_note').style.top 		= '22%';
	document.getElementById('add_note').style.left 		= '25%';
}

function showNote() {
	document.getElementById('noteContent').value 			= '';
	document.getElementById('note_message').style.display 	= 'none';
	document.getElementById('add_note').style.display 		= 'block';
	document.getElementById('note_form').style.display 		= 'block';
}

/*
 *	funkcje do obslugi szybkiego pola szukaj
 */
function searchItem() {
	var searchField = document.getElementById('searchItem');
	var searchWhat = searchField.value;
	document.location.href = 'index.php?m=Product&search='+searchWhat;
}
function sendAfterEnter(event) {
	if (event.keyCode == 13) {
		searchItem();
	}
}

/*
 * Clock functions
 */
function stopclock (){
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning = false;
}
function showtime () {
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var timeValue = hours
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
	clock = document.getElementById('clock');
	if(clock)
	clock.innerHTML = timeValue;
	timerID = setTimeout("showtime()",1000);
	timerRunning = true;
}
function startclock() {
	stopclock();
	showtime();
}

/*
 *	Funkcej uinwersalne
 */
function getAbsoluteTop(oElement){
	if(isIE){
		if(oElement.offsetParent == null){
			return oElement.offsetTop;
		} else {
			return oElement.offsetTop + getAbsoluteTop(oElement.offsetParent);
		}
	} else if(isNS){
		return oElement.y;
	} else {
		return oElement.offsetTop;
	}
}

function getAbsoluteLeft(oElement){
	if(isIE){
		if(oElement.offsetParent == null){
			return oElement.offsetLeft;
		}
		else{
			return oElement.offsetLeft + getAbsoluteLeft(oElement.offsetParent);
		}
	}
	else if(isNS){
		return oElement.x;
	}
	else{
		return oElement.offsetLeft;
	}
}

/*
 *	Obsługa warstwy komunikatu
 */
function showKomunikat(){

	var war = document.getElementById('komunikat');
	war.style.left = ((screen.width)-550)+'px';
	war.style.top = '70px';
	war.style.display = 'block';
	setTimeout('hideKomunikat()', 3000);
}
function hideKomunikat(){
	var war = document.getElementById('komunikat');
	war.style.display = 'none';
}
