/* * Autor Daniel Kouba * Version 1.5 */ function redirect(href) { if ( href.substring(0,4)=='http' ) { document.location.href = href; } else { document.location.href = 'http://www.riversideeurope.com/index.php/' + href; } } function disableElement(element) { element.style.border = "1px solid #444;"; } function hideElement(element) { element = getEl(element); if ( element.style.display == "none" ) { $(element).show("slow"); //element.style.display = "block"; } else { $(element).hide("slow"); //element.style.display = "none"; } } function updatesExpand(imgElement) { if ( getEl('tableUpdatesMore').style.display=="none" ) { $('#tableUpdatesMore').show("slow"); //getEl('tableUpdatesMore').style.display="table"; imgElement.src = "images/icons/triangle-down.gif"; } else { $('#tableUpdatesMore').hide("slow"); //getEl('tableUpdatesMore').style.display="none"; imgElement.src = "images/icons/triangle-right.gif"; } } function updatesHide(imgElement) { if ( getEl('divUpdatesTable').style.display=="none" ) { $('#divUpdatesTable').show("slow"); //getEl('divUpdatesTable').style.display="block" imgElement.src = "images/icons/triangle-down.gif"; } else { $('#divUpdatesTable').hide("slow"); //getEl('divUpdatesTable').style.display="none" imgElement.src = "images/icons/triangle-right.gif"; } } // getElementsByClassName(document, "a", "info-links"); function getElementsByClassName(oElm, strTagName, oClassNames){ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); var arrRegExpClassNames = new Array(); if(typeof oClassNames == "object"){ for(var i=0; i < oClassNames.length; i++){ arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)")); } } else{ arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)")); } var oElement; var bMatchesAll; for(var j=0; j < arrElements.length; j++){ oElement = arrElements[j]; bMatchesAll = true; for(var k=0; kminHeight;height--) { setTimeout("setHeight(text,height);", maxHeight*1000 - height*1000); } text.style.display = "none"; //alert(text.style.height); } else { text.style.display = "block"; maxHeight = text.scrollHeight; minHeight = 0; maxHeight = 250; for (height=minHeight;height<=maxHeight;height++) { setTimeout("setHeight(text,height);", height*1000); } }*/ } function setHeight(object,height) { object.style.height = height + 'px'; //alert(object.style.height); } function checkElem(a) { var r = []; // Force the argument into an array, if it isn't already if ( a.constructor != Array ) a = [ a ]; for ( var i = 0; i < a.length; i++ ) { // If there's a String if ( a[i].constructor == String ) { // Create a temporary element to house the HTML var div = document.createElement("div"); // Inject the HTML, to convert it into a DOM structure div.innerHTML = a[i]; // Extract the DOM structure back out of the temp DIV for ( var j = 0; j < div.childNodes.length; j++ ) r[r.length] = div.childNodes[j]; } else if ( a[i].length ) { // If it's an array // Assume that it's an array of DOM Nodes for ( var j = 0; j < a[i].length; j++ ) r[r.length] = a[i][j]; } else { // Otherwise, assume it's a DOM Node r[r.length] = a[i]; } } return r; } function before( parent, before, elem ) { // Check to see if no parent node was provided if ( elem == null ) { elem = before; before = parent; parent = before.parentNode; } // Get the new array of elements var elems = checkElem( elem ); // Move through the array backwards, // because we're prepending elements for ( var i = elems.length - 1; i >= 0; i-- ) { parent.insertBefore( elems[i], before ); } } function findPrevNode(elem) { do { elem = elem.previousSibling; } while ( elem && elem.nodeType != 1 ); return elem; } function findNextNode(elem) { do { elem = elem.nextSibling; } while ( elem && elem.nodeType != 1 ); return elem; } function moveNodeBefore( elem ) { elem = getEl(elem); parent = elem.parentNode; prev = findPrevNode(elem) // Get the new array of elements var elems = checkElem( elem ); // Move through the array backwards, // because we're prepending elements for ( var i = elems.length - 1; i >= 0; i-- ) { parent.insertBefore( elems[i], prev ); } } function moveNodeAfter( elem ) { elem = getEl(elem); parent = elem.parentNode; next = findNextNode(elem) // Get the new array of elements var elems = checkElem( elem ); // Move through the array backwards, // because we're prepending elements for ( var i = elems.length - 1; i >= 0; i-- ) { parent.insertBefore( next , elems[i] ); } } function append( parent, elem ) { // Get the array of elements var elems = checkElem( elem ); // Append them all to the element for ( var i = 0; i <= elems.length; i++ ) { parent.appendChild( elems[i] ); } } function removeNode(elem) { elem = getEl(elem); elem.parentNode.removeChild(elem); } function ajaxInstance() { var ajax = false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { ajax = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { ajax = new ActiveXObject('Microsoft.XMLHTTP'); } catch (E) { ajax = false; } } @end @*/ if (!ajax && typeof XMLHttpRequest != 'undefined') { ajax = new XMLHttpRequest(); } return ajax; } function ajaxReplace(element, url) { element = getEl(element); //element.innerHTML = 'loading' //alert(element); var ajax = ajaxInstance(); if (!ajax) { return false; } ajax.open('GET', url, true); ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest"); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { element.innerHTML = ajax.responseText; } } ajax.send(null); return true; } function ajaxAppend(element, url) { element = getEl(element); //alert(element); var ajax = ajaxInstance(); if (!ajax) { return false; } ajax.open('GET', url, true); ajax.setRequestHeader("X-Requested-With", "XMLHttpRequest"); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { append(element,ajax.responseText); //element.innerHTML = ajax.responseText; } } ajax.send(null); return true; } function getEl(elem) { if (typeof(elem) == 'string' ) { return document.getElementById(elem); } else { return elem; } } function markAll(el,which) { checks = document.getElementsByTagName('input'); for (var i=0; i < checks.length; i++ ) { check = checks[i]; if ( check.type == 'checkbox' && check.name.substring(0, which.length )==which ) { check.checked = el.checked; } } } function setNameFromFile(fileEl,nameEl) { fileEl = getEl(fileEl); nameEl = getEl(nameEl); if ( nameEl.value != "" || true ) { nameEl.value = fileEl.value.substr(0, fileEl.value.length-4 ); } } function clearDefaultValue(element,defaultValue) { if ( element.value == defaultValue ) { element.value=""; } } function getMultiple(selObj) { var selectedArray = new Array(); var i; var count = 0; for (i=0; i < selObj.options.length; i++) { if (selObj.options[i].selected) { selectedArray[count] = selObj.options[i].value; count++; } } return selectedArray.toString(); } function resizeWindow(width,height) { if (parseInt(navigator.appVersion)>3) { if (navigator.appName=="Netscape") { window.innerWidth = width; window.innerHeight= height; } if (navigator.appName.indexOf("Microsoft")!=-1) { document.body.offsetWidth = width; document.body.offsetHeight = height; } } } function getFilenameFromPath(path) { return path.substr(path.lastIndexOf("/")+1,path.length) } // example 1: in_array('van', ['Kevin', 'van', 'Zonneveld'],true); function in_array (needle, haystack, argStrict) { var key = '', strict = !!argStrict; if (strict) { for (key in haystack) { if (haystack[key] === needle) { return true; } } } else { if (typeof(needle)=='string') { str = haystack.toString(); return (str.search(needle) !== false); } for (key in haystack) { if (haystack[key] == needle) { return true; } } } return false; }function setStatementName(value) { if (element = document.getElementById('name').value == "") { element = document.getElementById('name').value = value.substr(0, value.length-4 ); } } function checkEquipmentForm(form) { names = form.getElementsByTagName('input'); for ( var i = 0; i < names.length; i++ ) { if ( names[i].type == 'text' && names[i].value=='' ) { alert(names[i].name +' : Hodnota je prázdná, Toto pole je povinné'); return false; } } return true; }