function documentClickFunctions() {
// Funkcje wykonują się za każdym kliknięciem w dokument;
closeSuggestionsDiv();
}
function displayObject(oObj, strObj) {
// Funkcja pomocnicza do wyświetlania struktury obiektów
var text = '';
for(var prop in oObj) {
var strTemp = oObj[prop]+"\n";
if(strTemp.search('function') != -1) {
text += strObj+'.'+prop+': function'+"\n";
}else{
text += strObj+'.'+prop+': '+oObj[prop]+"\n";
}
}alert(text);
}
function objectOffsetTopLeft(oObj) {
// Funkcja oblicza i zwraca odległość obiektu od górnej 
// i lewej krawędzi obszaru roboczego przeglądarki
var iOffsetTop = 0;
var iOffsetLeft = 0;
while(oObj.nodeName != 'BODY' && oObj.nodeName != 'HTML') {
if(oObj.offsetTop != undefined && oObj.offsetTop != null) {
iOffsetTop += oObj.offsetTop;
iOffsetLeft += oObj.offsetLeft;
oObj = oObj.offsetParent;
}
}
return {offsetTop: iOffsetTop, offsetLeft: iOffsetLeft};
}
function getTargetElement(e) {
if(e != null && e.srcElement) {
return e.srcElement;
}else{
return e.target;
}
}
function checkIfAllowElement(e) {
var oTargetElem = getTargetElement(e);
if( e != null && 
oTargetElem.id == 'link-new-account' || 
oTargetElem.id == 'link-forgotten-pass' || 
oTargetElem.id == 'link-remember-me' || 
oTargetElem.name == 'remember_me' || 

oTargetElem.name == 'userid' || 
oTargetElem.name == 'userpassword' || 
oTargetElem.name == 'login_submit' || 
oTargetElem.name == 'countryForPercentSpecification' || 
oTargetElem.name == 'checkForCheaperProducts' || 
oTargetElem.tagName == 'OPTION') { return true; }else{ return false; }
}
function preventAnyUserAction(e) {
var oTargetElem = getTargetElement(e);
if(oTargetElem.href != undefined && oTargetElem.href.search('javascript:') == -1) {
TARGET_URL_ADDRESS = oTargetElem.href;
}
if(checkIfAllowElement(e)) { return false; }

(e.preventDefault) ? e.preventDefault() : (e.returnValue = false);
}
function getVarrayValueFromURL(varrayName) {
var strAttr = document.location.search; strAttr = strAttr.replace('?','');
var ampersand = (strAttr == '') ? '' : '&';
var posOfAttr = strAttr.search(varrayName);
if(posOfAttr == -1) {
return -1;
}else{
var posEqual        = strAttr.indexOf('=',posOfAttr);
var posAmpersand    = (strAttr.indexOf('&',posOfAttr) == -1) ? strAttr.length : strAttr.indexOf('&',posOfAttr);
var lengthOfValue   = posAmpersand - posEqual - 1;
var varrayValue     = strAttr.substr((posEqual + 1),lengthOfValue)
return varrayValue;
}
}
function showWherePriceIsLower(resetOption) {
var oSelectCountry = document.getElementById('countryForPercentSpecification');
if(resetOption) {
var countryValue = 0;
}else{
var countryValue = oSelectCountry.options[oSelectCountry.selectedIndex].value;
}
if(countryValue == 0 && !resetOption) {
alert('You have to choose country of comparison!');
return false;
}
var strAttr = document.location.search;
strAttr = strAttr.replace('?','');
var ampersand = (strAttr == '?') ? '' : '&';
var countryURLValue = getVarrayValueFromURL('compCountry');
if(countryURLValue == -1) {
strAttr += ampersand + 'compCountry=' + countryValue;
}else{
strAttr = strAttr.replace('compCountry=' + countryURLValue, 'compCountry=' + countryValue);
}
f_js_changeLocation('./index.php',strAttr)
if(!resetOption) {
getHold();  // Pokaż strone oczekiwania
}
}
function addEvent(obj, type, fn) {
if (obj.addEventListener) {
obj.addEventListener(type, fn, false);
} else if (obj.attachEvent) {
obj["e"+type+fn] = fn;
obj[type+fn] = function() {obj["e"+type+fn](window.event); }
obj.attachEvent("on"+type, obj[type+fn]);
}
}
function removeEvent(obj, type, fn) {
if (obj.removeEventListener) {
obj.removeEventListener(type, fn, false);
} else if (obj.detachEvent) {
obj["e"+type+fn] = fn;
obj[type+fn] = function() {obj["e"+type+fn](window.event); }
obj.detachEvent("on"+type, obj[type+fn]);
}
}
function getHold(action,e) {
if(e != undefined && e != null && checkIfAllowElement(e)) {
return false;
}
var tmp = '';
var oBody   = document.body;
var oDivForContent = document.createElement("div");
// __oPCT_LANG - obiekt zdefiniowany w pliku xhtml_index.tpl
if(action == 'chooseDestinationCountry') {
var oSELECT_COUNTRIES = document.createElement("select");
var oDiv = document.getElementById("div-block-user-operations");
oDiv.style.left = '0px';
for(prop in COUNTRIES_ARRAY) {
if(prop == '______array') { continue; }
var oOption = document.createElement("option");
oOption.appendChild(document.createTextNode(COUNTRIES_ARRAY[prop]));
oOption.setAttribute("value", prop);
oSELECT_COUNTRIES.appendChild(oOption);
}
oDivForContent.innerHTML = __oPCT_LANG.BLOCK_USER_ACTIONS + ' <select onchange="location.href = \''+CURRENT_URL_ADDRESS+'&compCountry=\'+this.options[selectedIndex].value+\'&targetURI=\'+escape(TARGET_URL_ADDRESS);">'+oSELECT_COUNTRIES.innerHTML+'</select>';
}
else if(action == 'destCountryChangedAutomatically') {
//var oDiv = document.getElementById("div-block-user-operations");
var oDiv = document.getElementById("destCountryChangedAutomatically");
oDiv.innerHTML = __oPCT_LANG.DEST_COUNTRY_CHANGED.replace('[PRFLN]',__oPCT_LANG.PREFERED_LANGUAGE_SET_IN_BROWSER) + 
'<br /><br /><strong>'+__oPCT_LANG.DEST_COUNTRY_NAME_INFO+' <span>'+__oPCT_LANG.DEST_COUNTRY_NAME+'</span></strong><br /><br />'+
'<input type="button" class="button" value="'+__oPCT_LANG.MAIN_CLOSE+'" onclick="var oDiv = document.getElementById(\'destCountryChangedAutomatically\'); oDiv.style.display = \'none\'; oDiv.innerHTML = \'\';" />';
//'<input type="button" class="button" value="'+__oPCT_LANG.MAIN_CLOSE+'" onclick="document.getElementById(\'div-block-user-operations\').style.display = \'none\'; document.body.scrolling = true; document.body.style.overflow = \'scroll\';" />';
oDiv.style.display = 'block';
return true;
}else{
var oDiv = document.getElementById("div-for-show-loading-progress");
oDivForContent.innerHTML = __oPCT_LANG.CALCULATION_IN_PROGRESS + '<br /><img src="./image/loading_bar.gif" border="0" />';
}
oDiv.innerHTML = '<!--[if lte IE 6.5]><iframe></iframe><![endif]-->';
oDiv.style.position = 'absolute';
oDiv.style.top      = '0px';
oDiv.style.width    = YAHOO.util.Dom.getViewportWidth()+40+'px';
oDiv.style.height   = YAHOO.util.Dom.getDocumentHeight()+'px';
oDiv.appendChild(oDivForContent);
oDivForContent.style.textAlign      = 'center';
oDivForContent.style.position       = 'absolute';
oDivForContent.style.width          = '400px';
oDivForContent.style.top            = '20em';
oDivForContent.style.left           = (oBody.scrollWidth / 2 - 200) + 'px';
oDivForContent.style.border         = '2px ridge';
oDivForContent.style.padding        = '2em';
oDivForContent.style.backgroundColor= '#FFF';
location.href = '#';
document.body.scrolling = false;
document.body.style.overflow = 'hidden';
oDiv.style.display = 'block';
return true;
}
function changeMultipleRowsCssClass(oRow, iRowsAmount, iRowNo, strCssClass) {
var relatedIndex = 0;
var currentIndex = oRow.rowIndex;
for(var ii = 1; ii <= iRowsAmount; ii++) {
var tempThisRowIndex = currentIndex + (ii - iRowNo);
oRow.parentNode.rows[tempThisRowIndex].className = strCssClass;
}
}
function changeParentRowCssClass(oObj, strCssClass) {
var oParentTR = oObj.parentNode;
while (oParentTR != null) {
if(oParentTR.tagName == 'TR') {
oParentTR.className = strCssClass;
return true;
}
oParentTR = oParentTR.parentNode;
}
return false;
}
function f_js_confirm(text,urlPath){
del = confirm(text);
if (del) {
var ie = (document.all) ? 1 : 0;
if(ie) { window.event.returnValue = false; }
window.location.href = urlPath;
}
return del;
}
function f_js_writeIntoTextfield(formFor,checkB,textB){
var checkBox = document.forms[formFor][checkB];
var textBox  = document.forms[formFor][textB];
if(checkBox.checked == true){
textBox.value = checkBox.value;
}else{
textBox.value = '';
}
}
function showHide_page_element(strElement, displayType){
var objElement = (document.getElementById(strElement)) ? document.getElementById(strElement) : null;
if(objElement != null){
objElement.style.display = displayType;
return true;
}else{
return false;
}
}                            
function f_js_Counter(f_formularz,f_poleTekstowe,f_licznikPole,f_licznikWartosc){
var poleTekstowe = document.forms[f_formularz][f_poleTekstowe];
var licznik = document.forms[f_formularz][f_licznikPole];
var val = poleTekstowe.value.length;
if ((poleTekstowe.value.slice(val-1) == ';')||
(poleTekstowe.value.slice(val-1) == '/')||
(poleTekstowe.value.slice(val-1) == '\\')|| /*'*/
(poleTekstowe.value.slice(val-1) == '#')||
(poleTekstowe.value.slice(val-1) == '@')||
(poleTekstowe.value.slice(val-1) == '<')||
(poleTekstowe.value.slice(val-1) == '>')||
(poleTekstowe.value.slice(val-1) == '?')){
poleTekstowe.value = poleTekstowe.value.substring(0,val-1);
alert("Forbidden characters: ;\\/#@<>?");
}
val = f_licznikWartosc - val;
if (val < 0){
poleTekstowe.value = poleTekstowe.value.substring(0,f_licznikWartosc);
alert("You have been crossed the maximum number of characters!!!");
val = 0;
}
licznik.value = val;
}
// Do wyświetlania chmórki z obrazkiem produktu
function show_hide_picture_popup(action,base_div,absolute_div,div_id_number,evt) {
var ie = (document.all) ? true : false;
var evt = (evt) ? evt : (window.event) ? window.event : '';
var oBase_div = document.getElementById(base_div + div_id_number);
var aBase_divXY = YAHOO.util.Dom.getXY(oBase_div);
var iViewportHeight = parseInt(YAHOO.util.Dom.getViewportHeight());
var oAbsolute_div = document.getElementById(absolute_div + div_id_number);
if(action == 'SHOW') {
oAbsolute_div.style.display = 'block';
oAbsolute_div.style.left = 36 + 'px';
if((iViewportHeight - evt.clientY) < 200) {
var iFromTop = aBase_divXY[1] - oAbsolute_div.offsetHeight + 24;
}else{
var iFromTop = aBase_divXY[1];
}
YAHOO.util.Dom.setY(oAbsolute_div,parseInt(iFromTop));
}
else if(action == 'HIDE') {
oAbsolute_div.style.display = 'none';
}
}
// Dodawanie wierszy do tabeli 
function appendRow(tableBody, values) {
insertTableRow(tableBody, -1, values)
}
function addRow(tableBody, insertIndex, values) {
insertTableRow(tableBody, insertIndex, values)
}
function removeRow(tableBody, rowNr) {
tableBody.deleteRow(rowNr);
}
function insertTableRow(tableBody, where, values) {
var newCell
var newRow = tableBody.insertRow(where)
for (var i = 0; i < values.length; i++) {
newCell = newRow.insertCell(i)
newCell.innerHTML = values[i]
}
}
function clearTable(tableBody,tabHeadersExists,tabFootExists) {
var first_row_index = 1;
var last_row_index = tableBody.rows.length - 1;
if (!tabHeadersExists) {
first_row_index = 0;
}
if (tabFootExists) {
last_row_index = last_row_index - 1;
}
for (var i = last_row_index; i >= first_row_index; i--) {
tableBody.deleteRow(i);
}
}
function setPointer(row, overColor){
row.style.background = overColor;
}
function f_js_changeLocation(strPath,strAttr){
window.location = strPath + '?' + strAttr;
}
// Javascript używany w pliku rejestracja.php ***************************************************
function existingLogin_checkbox(oCheckbox, oForm) {
if (oCheckbox.checked) {
oForm.existing_pass.disabled = false;
oForm.existing_login.disabled = false;
oForm.check_existing_log_pass.disabled = false;
oForm.check_existing_log_pass.style.color = '#000';
oForm.check_existing_log_pass.style.fontWeight = 'bold';
} else {
oForm.existing_pass.disabled = true;
oForm.existing_login.disabled = true;
oForm.check_existing_log_pass.disabled = true;
oForm.check_existing_log_pass.style.color = '#999';
oForm.check_existing_log_pass.style.fontWeight = 'normal';
}
}
function send_exisingLogin(oForm, alr_1, alr_2) {
if(oForm.existing_login.value == "login") {
alert(alr_1);
}
else if(oForm.existing_pass.value == "password") {
alert(alr_2);
} else {
oForm.check_existing_log_pass.click();
}
}
// JavaScript używany podczas przeszukiwania bazy odno¶nie cech materiałów w grupie /////////////
function check_feature_for_search(oForm,oSelect,id_feature) {
if(oSelect.selectedIndex == 0) {
oForm.elements["ch_for_search_" + id_feature].checked = false;
}else{
oForm.elements["ch_for_search_" + id_feature].checked = true;
}
return 1;
}
// JavaScript używany do ustawiania i odczytywania COOKIES //////////////////////////////////////
function writePTC_cookie(cookie_name,cookie_val) {
dzis = new Date();
dzis.setTime(dzis.getTime() + 20*24*60*60*1000); // Wygasa za 20 dni
s = dzis.toGMTString();
document.cookie = cookie_name + "=" + escape(cookie_val) + "; expires=" + s;
}

function readPTC_cookie(cookie_name) {
var start = document.cookie.indexOf(cookie_name + "=");
var len = start + cookie_name.length + 1;
if ((!start) && (document.cookie.substring(0, cookie_name.length) != cookie_name)) {
return null;
}
if (start == -1) {
return null;
}
var end = document.cookie.indexOf(";", len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len, end));
}
function tabs_navigation(id_tab_to_activate, array_tabs_no) {
writePTC_cookie('desc_tabs', id_tab_to_activate);
// Ze względu na to, że w IE nie da sie poprostu zmienic klasy CSS elementowi
for(prop in array_tabs_no) {
tabs_navigation_style_inactive('tab_' + array_tabs_no[prop]);
document.getElementById("div_info_" + array_tabs_no[prop]).style.display = 'none';
if(id_tab_to_activate ==  array_tabs_no[prop]) {
tabs_navigation_style_active('tab_' + array_tabs_no[prop]);
document.getElementById("div_info_" + array_tabs_no[prop]).style.display = 'block';
}
}
}
function tabs_navigation_style_active(id_tab) {
var tab = document.getElementById(id_tab);
tab.style.color = '#444';
tab.style.cursor = 'normal';
tab.style.borderBottom = '#FFE 1px solid';
tab.style.backgroundColor = '#FFE';
tab.setAttribute("class","div-tab-active",true);
}
function tabs_navigation_style_inactive(id_tab) {
var tab = document.getElementById(id_tab);
tab.style.cursor = 'pointer';
tab.style.color = '#666';
tab.style.border = 'black 1px solid';
tab.style.backgroundColor = '#E6E6D6';
tab.setAttribute("class","div-tab-inactive",true);
}
////////////////////////////
function containsDOM (container, containee) {
var isParent = false;
do {
if ((isParent = container == containee))
break;
containee = containee.parentNode;
}
while (containee != null);
return isParent;
}
function checkMouseEnter (element, evt) {
if (element.contains && evt.fromElement) {
return !element.contains(evt.fromElement);
}
else if (evt.relatedTarget) {
return !containsDOM(element, evt.relatedTarget);
}
}
function checkMouseLeave (element, evt) {
if (element.contains && evt.toElement) {
return !element.contains(evt.toElement);
}
else if (evt.relatedTarget) {
return !containsDOM(element, evt.relatedTarget);
}
}
////////////////////////////
function f_js_noweOkno(strWin,strPath,intHeight,intWidth,strScrollbars,intTop,intLeft,strResizable){
if(strResizable == undefined) strResizable = '0';
var newWindow = open(strPath,strWin,'toolbar=0,menubar=0,location=0,personalbar=0,status=1,resizable='+strResizable+',scrollbars='+strScrollbars+',copyhistory=0,width='+intWidth+',height='+intHeight+',top='+intTop+',left='+intLeft);
newWindow.focus();
return newWindow;
}

