Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/glosboken.se/releases/release-4.1/script/script.php on line 7
/************************************************ **** MIXED JAVASCRIPT FOR RUNNING EXERCISES **** **** Copyright (c) HL Web 2006-2008 **** ************************************************/ // Global javacript variables var helpText = new Array(help0); var helpBoxWidth = 500; var cursorPosX = 0; var cursorPosY = 0; var showHelpLinkList = false; var hideDropDown = false; var helpBoxTimer = false; var tmpTimer = new Array(); // Set Modal Loader properties window.onbeforeunload = modalLoader_startTimer; var modalLoaderTimer = false; /** * Compricer ads variables */ var compricerSectionNames = new Array(); var compricerSectionValues = new Array(); compricerSectionNames[0] = 'Alla kategorier'; compricerSectionValues[0] = "combo"; compricerSectionNames[1] = 'Böcker'; compricerSectionValues[1] = "books"; compricerSectionNames[2] = 'DVD'; compricerSectionValues[2] = "dvd"; compricerSectionNames[3] = 'Spel'; compricerSectionValues[3] = "games"; compricerSectionNames[4] = 'Hemelektronik'; compricerSectionValues[4] = "electronics"; compricerSectionNames[5] = 'Mobiltelefoner'; compricerSectionValues[5] = "phones"; compricerSectionNames[6] = 'Foto'; compricerSectionValues[6] = "photo"; compricerSectionNames[7] = 'Lån'; compricerSectionValues[7] = "loan"; compricerSectionNames[8] = 'Linser'; compricerSectionValues[8] = "lens"; /** * Hide Compricer drop-down list * @param string id is the id of the object to hide */ function hideTimedObject(objName) { if (hideDropDown == true) { DHTMLObj(objName).style.display = "none"; } } /** * Start timer for hiding Compricer drop-down list * @param string id is the id of the object to hide */ function startHideTimer(objName) { hideDropDown = true; setTimeout("hideTimedObject('" + objName + "')", 500); } /** * Set the hideDropDown value to false to avoid the dropdown from turning invisible * @param string objName is the dhtml id of the object to keep visible */ function keepVisible(objName) { if (hideDropDown == true) { hideDropDown = false; } if (DHTMLObj(objName).style.display != "block") { DHTMLObj(objName).style.display = "block"; } } /** * Set the section / category to run a given search query in. * This function will set the section value in the form and print the section name for the user. * @param int index for the array in the compricerSectionValue and compricerSectionName arrays */ function compricerSetSection(index) { DHTMLObj('compricerSectionValue').value = compricerSectionValues[index]; DHTMLObj('compricerSectionName').innerHTML = compricerSectionNames[index]; DHTMLObj('compricerDropDown').style.display = "none"; DHTMLObj('compricerSearch').focus(); compricerHideValue = true; } /** * Skapar en dhtml-referens till ett givet objekt */ function DHTMLObj(object) { if (document.all) { // Explorer 4,5 return document.all[object]; } else if (document.getElementById) { // Netscape 6 return document.getElementById(object); } else if (document.layers) { // Övriga läsare document[object].open(); return document[object]; } } /** * Displays or hides a div with a description of a selected area * @param int showText is an int representation the index deciding what description to display * @param string setDisplay is a string representation of the css display state */ function displayHelpBox(showText, setDisplay, width) { // Stop the timer if (helpBoxTimer) { clearTimeout(helpBoxTimer); } // The css "visibility" state was used earlier, so we have to modify the state to valid display format if (setDisplay == "visible") { setDisplay = "block"; } else if (setDisplay == "hidden") { setDisplay = "none"; } // Hack för att gömma select-box i Explorer if (showText == 0) { if (setDisplay == "block") { DHTMLObj("selectBox").style.visibility = "hidden"; } else { DHTMLObj("selectBox").style.visibility = "visible"; } } helpBoxWidth = width; DHTMLObj('helpBoxContent').innerHTML = helpText[showText]; var obj = DHTMLObj("helpBox"); obj.style.width = width + "px"; obj.style.display = setDisplay; } /** * En tom funktion som gör att inget händer när man klickar på vissa länkar */ function doNothing() { return; } /** * Get vertical scroll position * @return int value of the vertical scrolled offset */ function getScrollOffset() { var b = document.body; var d = document.documentElement; if (b && b.scrollTop) return body.scrollTop; if (d && d.scrollTop) return d.scrollTop; if (window.pageYOffset) return window.pageYOffset; return 0; } /** * Öppnar ett nytt fönster med given hjälptext */ function help(medVad) { egenskaper="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no"; egenskaper+=",width=450"; egenskaper+=",height=220,top=150,left=150"; unik=new Date(); unik=unik.getSeconds()+"_"+unik.getMinutes()+"_"+unik.getHours(); window.open("http://glosboken.se/pages/help.php?vad="+medVad,unik,egenskaper); } /** * Öppnar ett nytt fönster med given bredd och höjd */ function newWin (openPage, w, h, scroll) { var centerScreen = Math.floor((screen.width / 2) - (w/2)); var properties="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" +scroll+ ",resizable=no"; properties+=",width=" + w + ",height=" + h + ",top=15,left=" +centerScreen; unik=new Date(); unik=unik.getSeconds()+"_"+unik.getMinutes()+"_"+unik.getHours(); window.open("http://glosboken.se/" + openPage, unik, properties); } /** * Open a modal box to indicate that the new page is loading. */ function modalLoader_startTimer() { modalLoaderTimer = setTimeout("modalLoader_display()",500); } /** * Stop the modal loader timer */ function modalLoader_stopTimer() { if (modalLoaderTimer) { modalLoaderTimer=false; } } /** * Close a modal box to indicate that the new page is loading. */ function modalLoader_display() { if (modalLoaderTimer) { if (DHTMLObj('frm_modal_loader')) { var topPosition = 200 + getScrollOffset(); DHTMLObj('img_loader').style.top = topPosition + 'px'; DHTMLObj('img_loader').style.display = 'block'; DHTMLObj('frm_modal_loader').style.display='block'; } modalLoaderTimer = false; } } /** * sendForm() * Änvänds för att enkelt skicka en form via tex onclick eller en href * @author: Fredrik Lundmark, 2005-12-14 * @param: formID Den aktuella formens id * @retun: */ function script_sendForm(formID){ DHTMLObj(formID).submit(); } /** * Set the position of a given object. The position is given as a number of pixles from the left and top margins * @param string obj is the DHTML id of the object to update the position for * @param int posX is the number of pixles from the left margin to position the given object * @param int posY is the number of pixles from the top margin to position the given object */ function setObjectPosition(obj, posX, posY) { var object = DHTMLObj(obj); object.style.left = posX + "px"; object.style.top = posY + "px"; } /** * Start trace of cursor position (X and Y coordinates). */ function startCursorTracer() { if (document.all || document.getElementById) { document.body.onmousemove = traceCursor; //document.onmousemove = traceCursor; } else if (document.layers) { window.captureEvents(Event.MOUSEMOVE); window.onMouseMove = traceCursor; } } /** * Switch a relation block in the buddyList to visible/hidden and update the corresponding image * @param string objName is the id of the DHTML object id to switch position for * @param string pos1 is the x and y coordinates to compare the real world against * @param string pos2 is the x and y coordinates to set if the coordinates given in pos1 does not match the real world */ function switchBgPosition(objName, pos1, pos2) { var obj = DHTMLObj(objName); if (obj.style.backgroundPosition == pos1) { obj.style.backgroundPosition = pos2; } else { obj.style.backgroundPosition = pos1; } } /** * Switch a given checkbox from unchecked to checked or from checked to unchecked * @param string object is the DHTML object id of the checkbox to switch checked state for */ function switchCheckbox (object) { object.checked ? object.checked = false : object.checked = true; } /** * Swtich a given dhtml object into a new css class * @param string objName is the DHTML id of the object to set a new class for * @param string cssClassName is the css id of the class to set the object to */ function switchClass(objName, cssClassName) { var obj; if (typeof objName == 'string') { obj = DHTMLObj(objName); } else if (typeof objName == 'object') { obj = objName; } if (obj.className != cssClassName) { obj.className = cssClassName; } } /** * Switch the css dislay property for a given object [block -> none, none -> block] * @param string objName is the DHTML id of the object to switch display for */ function switchDisplay(objName) { var obj = DHTMLObj(objName); if (obj.style.display != 'block') { obj.style.display = 'block'; } else { obj.style.display = 'none'; } } /** * Switch to a new tab. * This will change the appearance of the tabs and switch to a new set of subTabs * @param string tabId is the post-part of the tab DHTML id of the tab to switch to */ function switchTab(tabId) { for (i=0; i<5; i++) { if (DHTMLObj("subTab_" + (i+1))) { DHTMLObj("subTab_" + (i+1)).style.display = 'none'; } if (DHTMLObj("topTab_" + i)) { DHTMLObj("topTab_" + i).className = ""; DHTMLObj("topTab_" + i + "_image").style.display = 'none'; DHTMLObj("topTab_" + i + "_text").style.display = 'block'; DHTMLObj("topTab_div_" + i).style.backgroundPosition = '0px 44px'; } } if (DHTMLObj("subTab_" + (tabId+1))) { DHTMLObj("subTab_" + (tabId+1)).style.display = 'inline'; } if (DHTMLObj("topTab_" + tabId)) { DHTMLObj("topTab_" + tabId).className = 'active'; DHTMLObj("topTab_div_" + tabId).style.backgroundPosition = '0px 0px'; DHTMLObj("topTab_" + tabId + "_text").style.display = 'none'; DHTMLObj("topTab_" + tabId + "_image").style.display = 'block'; } if (tabId > 0) { DHTMLObj("topTab_div_" + (tabId-1)).style.backgroundPosition = '0px 22px'; } } /** * Trace cursor position for nice display of e.g. help boxes * @param event event is the cursor object to use when checking for its position */ function traceCursor(myEvent) { myEvent = myEvent || window.event; if(myEvent.pageX || myEvent.pageY){ cursorPosX = myEvent.pageX; cursorPosY = myEvent.pageY; } else { cursorPosX = myEvent.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; cursorPosY = myEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop //cursorPosX = myEvent.clientX; //cursorPosY = myEvent.clientY; } //cursorPosY += getScrollOffset(); posX = cursorPosX - (helpBoxWidth - 50); posY = cursorPosY + 25; if (posX < 1) { posX = cursorPosX - 50; } setObjectPosition('helpBox',posX, posY); } function GetXmlHttpObject(handler) { var objXmlHttp = null; if (navigator.userAgent.indexOf("Opera") >= 0) { alert("Den här funktionen fungerar tyvärr inte i Opera. Använd Internet Explorer eller Mozilla Firefox istället."); return; } if (navigator.userAgent.indexOf("MSIE") >= 0) { var strName = "Msxml2.XMLHTTP" if (navigator.appVersion.indexOf("MSIE 5.5") >= 0) { strName = "Microsoft.XMLHTTP"; } try { objXmlHttp = new ActiveXObject(strName); objXmlHttp.onreadystatechange = handler; return objXmlHttp; } catch(e) { alert("Kopieringsscriptet kan inte köras. Script för ActiveX kan vara avstängt."); return; } } if (navigator.userAgent.indexOf("Mozilla") >= 0) { objXmlHttp = new XMLHttpRequest(); objXmlHttp.onload = handler; objXmlHttp.onerror = handler; return objXmlHttp; } }