function requestObj() { var req = false; try { req = new XMLHttpRequest(); } catch(e) { try { req = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} } return req; } function send_xmlhttprequest(obsluha, method, url, content, headers) { var xmlhttp = requestObj(); if (!xmlhttp) { return false; } xmlhttp.open(method, url, true); xmlhttp.onreadystatechange = function() { obsluha(xmlhttp); }; if (headers) { for (var key in headers) { xmlhttp.setRequestHeader(key, headers[key]); } } xmlhttp.send(content); return true; } function sendClassicRequest( post_params, get_params ) { var headers = new Array(); headers['Content-Type'] = 'application/x-www-form-urlencoded'; var url = './ajax-request.php'; if (get_params != '') { url = url + '?' + get_params; } var content = 'mode=ajax'; if (post_params != '') { content = content + '&' + post_params; } send_xmlhttprequest(function_process, 'POST', url, content, headers); } function sendUpdateHTMLRequest(functionProcess, postParams, getParams) { var headers = new Array(); headers['Content-Type'] = 'application/x-www-form-urlencoded'; var url = './index.php'; if (getParams != '') url = url+'?'+getParams; var content = 'mode=ajax'; if (postParams != '') content = content+'&'+postParams; send_xmlhttprequest(functionProcess, 'POST', url, content, headers); } function getUrl() { var url = document.getElementById('get').value; if (url.substring(0, 1) == '?') { url = url.substring(1, url.length); } return url; } function winH() { if (window.innerHeight) /* NN4 a kompatibilní prohlížeče */ return window.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) /* MSIE6 v std. režimu - Opera a Mozilla již uspěly s window.innerHeight */ return document.documentElement.clientHeight; else if (document.body && document.body.clientHeight) /* starší MSIE + MSIE6 v quirk režimu */ return document.body.clientHeight; else return null; } function isMozila() { if (window.innerHeight) return true; else if (document.documentElement && document.documentElement.clientHeight) return false; return false; } function clear_menu_items() { var menu_items = document.getElementsByTagName('a'); for (var i=0; i < menu_items.length; i++) { var menu_item = menu_items[i]; var menu_item_id = menu_item.getAttribute('id'); if ((menu_item_id != '') && (menu_item_id != null) && (menu_item_id.substring(0, 5) == 'menu_') && (menu_item.className == 'current')) { menu_item.className = ''; } } } function function_process(xmlhttp) { if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { var form_name = ''; var redirect = ''; var result = xmlhttp.responseXML.getElementsByTagName('result'); for (var i=0; i < result.length; i++) { var child = result[i]; if (child.firstChild != null) { var child_name = child.getAttribute('name'); // identifikace formulare if (child_name == 'form_name') { form_name = child.firstChild.data; } // presmer if (child_name == 'redirect') { document.location.href = child.firstChild.data; } // spusteni nejake funkce if (child_name == 'function') { var child_function_name = child.firstChild.data; // vycisteni vsech polozek menu if (child_function_name == 'clear_menu_items') { clear_menu_items(); } // zobrazeni fckeditoru } // generovani funkce pro ajax if (child_name == 'sendClassicRequest') { var params = child.getAttribute('param'); sendClassicRequest('', params); } // chybova hlaska if (child_name == 'alert_message') { if (child.firstChild.data != '' ) { } } // uprava nejakeho objektu if (child_name == 'change_element') { var elemnt_id = child.getAttribute('id'); var elemnt = document.getElementById(elemnt_id); if (elemnt != null) { var elemnt_param = child.getAttribute('param'); //var child = child.firstChild; //var child_value = child.firstChild.data; if ((elemnt_param == 'innerHTML') || (elemnt_param == 'value')) { element_data = child.getElementsByTagName('data'); element_innerhtml = ''; if ((element_data == null) || (element_data.length == 0)) { element_innerhtml = child.firstChild.data; } if (element_data != null) { for (var d=0; d < element_data.length; d++) { element_innerhtml = element_innerhtml + element_data[d].firstChild.data; } } if (elemnt_param == 'innerHTML') { elemnt.innerHTML = element_innerhtml; } if (elemnt_param == 'value') { elemnt.value = element_innerhtml; } } if (elemnt_param == 'href') { elemnt.href = child.firstChild.data; } if (elemnt_param == 'clear_value') { elemnt.value = ''; } if (elemnt_param == 'class') { elemnt_class = child.firstChild.data; if ((elemnt.getAttribute('if_class') != null) && (elemnt.getAttribute('if_class') != '') && (elemnt.className != elemnt.getAttribute('if_class'))) { elemnt_class = elemnt.className; } elemnt.className = elemnt_class; } if (elemnt_param == 'style.display') { elemnt.style.display = child.firstChild.data; } if (elemnt_param == 'selectedIndex') { elemnt.selectedIndex = child.firstChild.data; } } else { } } if ((child_name == 'change_form_item') && (form_name != '') && (child.getAttribute('id') != '')) { var form_item_id = child.getAttribute('id'); var form_item = document.forms[form_name][form_item_id]; if (form_item != null) { var elemnt_param = child.getAttribute('param'); if (elemnt_param == 'value') { form_item.value = child.firstChild.data; } } } if (child_name == 'displayPopupWindow') { element_data = child.getElementsByTagName('data'); element_innerhtml = ''; if ((element_data == null) || (element_data.length == 0)) { element_innerhtml = child.firstChild.data; } if (element_data != null) { for (var d=0; d < element_data.length; d++) { element_innerhtml = element_innerhtml + element_data[d].firstChild.data; } } if (element_innerhtml != '') { if ( !document.getElementById( 'popupWindowForm' ) ) { var popupWindowForm = document.createElement( 'div' ); popupWindowForm.setAttribute( 'id', 'popupWindowForm' ); document.body.appendChild( popupWindowForm ); } showPopupWindowForm(element_innerhtml); } } if (child_name == 'closePopupWindow') { hidePopupWindowForm(); } } } if (redirect != '') { document.location.href = redirect; } if (document.getElementById('table_formular') != null) { var table = document.getElementById('table_formular'); if (table != null) { var elements = table.getElementsByTagName('td'); if (elements != null) { for (var i=0; i < elements.length; i++) { var element_td = elements[i]; if (element_td != null) { element_td.disabled = false; } if (document.getElementById('input_'+i)!=null) { document.getElementById('input_'+i).disabled = false; } } } } } } } function encodeString(value) { return encodeURIComponent(value); } function selectFormSubmitButton( form_name, submitButtonName ) { if ((document.forms[form_name] != null) && (document.forms[form_name].formSubmitButton != null)) { document.forms[form_name].formSubmitButton.value = submitButtonName; } } function sendFormSubmitRequest( form_name, get_params, submitButtonName ) { var headers = new Array(); headers['Content-Type'] = 'application/x-www-form-urlencoded'; var url = './index.php'; if (get_params != '') { url = url + '?' + get_params; } var content = 'mode=ajax&url=http://www.bigbazar.cz/&path=/var/www/bigbazar.cz/web/&language=&resolution_width='; for (var i=0; i < document.forms[form_name].length; i++) { var item = document.forms[form_name][i]; if ((item.type!='submit') || ((item.type=='submit') && (item.name==submitButtonName))) { var item_value = item.value; if (item.name.indexOf('[]')>0) { item_value = ''; for (var j=0; j < item.length; j++) { if (item.options[j].selected == true) { if (item_value != '') { item_value = item_value + ';'; } item_value = item_value + item.options[j].value; } } } if (content != '') { content = content + '&'; } if (item.type == 'checkbox') { if (item.checked == true) { item_value = 'on'; } else { item_value = ''; } } content = content + item.name + '=' + encodeString(item_value); } } if (!send_xmlhttprequest(function_process, 'POST', url, content, headers)) { return false; } } function showPopupWindowForm(formContent) { if ( !document.getElementById( 'xdivmasking' ) ) { var divEle = document.createElement( 'div' ); divEle.setAttribute( 'id', 'xdivmasking' ); document.body.appendChild(divEle); var divSty = document.getElementById( 'xdivmasking' ).style; divSty.position = 'absolute'; divSty.top = '0px'; divSty.left = '0px'; divSty.zIndex = '46'; divSty.opacity = '.50'; divSty.backgroundColor = '#000'; divSty.filter = 'alpha(opacity=50)'; var divFram = document.createElement( 'iframe' ); divFram.setAttribute( 'id', 'xmaskframe' ); document.body.appendChild( divFram ); divSty = document.getElementById( 'xmaskframe' ).style; divSty.position = 'absolute'; divSty.top = '0px'; divSty.left = '0px'; divSty.zIndex = '45'; divSty.border = 'none'; divSty.filter = 'alpha(opacity=0)'; } divobj = document.getElementById( 'xdivmasking' ); waitifrm = document.getElementById( 'xmaskframe' ); waitifrm.style.display = divobj.style.display = 'block'; if ( document.getElementById( 'formDiv' ) == null ) { var formDiv = document.createElement( 'div' ); formDiv.setAttribute( 'id', 'formDiv' ); document.body.appendChild( formDiv ); } var formDiv = document.getElementById( 'formDiv' ); formDiv.className = 'popupWindowForm'; formDiv.innerHTML = formContent; formDiv.innerHTML = '
'+ ''+ '
Formulář
'+ '
'+ '
'+ ''+ ''+ formContent+ '
'; formDiv.style.display = 'block'; formDiv.style.top = (((document.documentElement.clientHeight/2) + document.documentElement.scrollTop) - (formDiv.clientHeight/2))+'px'; formDiv.style.left = (((document.documentElement.clientWidth/2) + document.documentElement.scrollLeft) - (formDiv.clientWidth/2))+'px'; document.getElementById('formContent').style.width = (formDiv.clientWidth-14)+'px'; document.getElementById('formContent').style.height = (formDiv.clientHeight-61)+'px'; Drag.init(document.getElementById('formDivTitle'), formDiv); resizePopupWindowForm(); } function hidePopupWindowForm() { var divobj = document.getElementById( 'xdivmasking' ); var waitifrm = document.getElementById( 'xmaskframe' ); var formDiv = document.getElementById( 'formDiv' ); waitifrm.style.display = divobj.style.display = formDiv.style.display = 'none';} function resizePopupWindowForm() { var divobj = document.getElementById( 'xdivmasking' ); var waitifrm = document.getElementById( 'xmaskframe' ); if ((waitifrm!=null) && (divobj!=null)) waitifrm.style.display = divobj.style.display = 'none'; var dsh = document.documentElement.scrollHeight; var dch = document.documentElement.clientHeight; var dsw = document.documentElement.scrollWidth; var dcw = document.documentElement.clientWidth; var bdh = ( dsh > dch ) ? dsh : dch; var bdw = ( dsw > dcw ) ? dsw : dcw; if ((waitifrm!=null) && (divobj!=null)) { waitifrm.style.height = divobj.style.height = dch/*bdh*/ + 'px'; waitifrm.style.width = divobj.style.width = dcw/*bdw*/ + 'px'; waitifrm.style.display = divobj.style.display = 'block'; } }