var httpAjax = false; function compricerAjax(url) { httpAjax = false; handler = false; if(window.XMLHttpRequest) { httpAjax = new XMLHttpRequest(); if(httpAjax.overrideMimeType) { httpAjax.overrideMimeType('text/xml'); /*httpAjax.overrideMimeType('text/xml; charset=iso-8859-1');*/ } } else if(window.ActiveXObject) { try { httpAjax = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpAjax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Couldnt build an AJAX instance."); return false; } } } try { httpAjax.onreadystatechange = getState(); } catch(e) { alert("onreadystatechange didnt go well!"); return false; } try { httpAjax.open("GET", url, true); /*httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");*/ /*if(!httpAjax.getResponseHeader("Date")) { var cached = httpAjax; httpAjax = new XMLHttpRequest(); var ifModifiedSince = cached.getResponseHeader("Last-Modified"); ifModifiedSince = (ifModifiedSince) ? ifModifiedSince : new Date(0); // January 1, 1970 httpAjax.open("GET", url, false); httpAjax.setRequestHeader("If-Modified-Since", ifModifiedSince); httpAjax.send(""); if(httpAjax.status == 304) { httpAjax = cached; } }*/ } catch(e) { /*document.getElementById("ajaxmessage").innerHTML = "kan inte ladda sidan.";*/ alert("Couldnt open url. FFS!!!"); return false; } try { httpAjax.send(null); } catch(e) { alert("Couldnt send request."); return false; } return true; } function getState() { /* * 0 (uninitialized) * 1 (loading) * 2 (loaded) * 3 (interactive) * 4 (complete) */ if(httpAjax.readyState == 4) { document.getElementById("ajaxmessage").innerHTML = httpAjax.responseText; return true; } else { document.getElementById("ajaxmessage").innerHTML = "Sidan laddas. Var god vänta..."; } } function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date < millis); } function addLoadEvent( func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function(){ if(oldonload) { oldonload( ); } func(); } } } var maxloops = 1500; var startloops = 0; function runLoop(functionName, time){ if(startloops > maxloops) return false; startloops++; t=setTimeout('runLoop(\"'+functionName+'\", \"'+time+'\")', time); eval(functionName); } var oldresponse; function getRecentSearches(targetId, url, requestType) { var xmlHttp; try { xmlHttp = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP'); } catch (e2) { try { xmlHttp = new XMLHttpRequest(); } catch (e3) { xmlHttp = false; } } } xmlHttp.onreadystatechange=function(){ if( xmlHttp.readyState==4) { target = document.getElementById(targetId); var fadeOutTime = new Date().getTime(); //var str1 = target.innerHTML; // oldresponse = xmlHttp.responseText; var splitted = xmlHttp.responseText.split('|'); //alert(splitted[0]); //alert(hej); //if(target.innerHTML.substr(0,110) != xmlHttp.responseText.substr(0,110)){ if(xmlHttp.responseText.length > 10 && oldresponse != splitted[0]){ oldresponse = splitted[0]; var myTimer = setTimeout("FadeOutRecentSearch('"+targetId+"', '" + splitted[1] +"', '"+fadeOutTime+"')"); } } } if(requestType == 'POST') xmlHttp.open('POST',url,true); else xmlHttp.open('GET',url,true); xmlHttp.send( null); } function FadeOutRecentSearch(targetId, responseText, fadeOutTime) { var myElement = document.getElementById(targetId); var myImage = document.getElementById('recentsearchimageid'); var timeDiff = (new Date).getTime() - fadeOutTime; if (timeDiff < 500) { myElement.style.opacity = 1 - timeDiff / 500; myElement.style.filter = "alpha(opacity=" + (100 - timeDiff / 5) + ")"; myImage.style.opacity = 1 - timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (100 - timeDiff / 5) + ")"; var myTimer = setTimeout("FadeOutRecentSearch('"+targetId+"', '" + responseText + "', '" + fadeOutTime + "')", 50); } else { var fadeTime = (new Date).getTime(); document.getElementById(targetId).innerHTML = responseText; document.getElementById('recentsearchimageid').src = document.getElementById('newrecentsearchimageid').src; var myTimer = setTimeout("FadeInRecentSearch('"+targetId+"','" + fadeTime + "')", 30); } } function FadeInRecentSearch(targetId, fadeInTime) { var myElement = document.getElementById(targetId); var myImage = document.getElementById('recentsearchimageid'); var timeDiff = (new Date).getTime() - fadeInTime; if (timeDiff < 500) { myElement.style.opacity = timeDiff / 500; myElement.style.filter = "alpha(opacity=" + (timeDiff / 5) + ")"; myImage.style.opacity = timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (timeDiff / 5) + ")"; var myTimer = setTimeout("FadeInRecentSearch('"+targetId+"', '" + fadeInTime + "')", 50); }else{ myElement.style.opacity = 1; myElement.style.filter = "alpha(opacity=" + 100 + ")"; myImage.style.opacity = 1; myImage.style.filter = "alpha(opacity=" + 100 + ")"; } } function getExpertQuestion(expertPanelStartId, maxId){ expertQuestionStartid++; if(expertQuestionStartid > maxId) expertQuestionStartid = 0; var fadeOutTime = new Date().getTime(); var myTimer = setTimeout("FadeOutExpertQuestion('"+expertQuestionStartid+"', '"+fadeOutTime+"')"); } function FadeOutExpertQuestion(expertQuestionid, fadeOutTime) { var myImage = document.getElementById("expertquestion_img"); /* var timeDiff = (new Date).getTime() - fadeOutTime; if (timeDiff < 500) { myImage.style.opacity = 1 - timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (100 - timeDiff / 5) + ")"; var myTimer = setTimeout("FadeOutExpertQuestion('"+expertQuestionid+"', '" + fadeOutTime + "')", 50); } else { */ var fadeTime = (new Date).getTime(); if( document.getElementById('expertquestion_'+expertQuestionid) != null ) { myImage.innerHTML = document.getElementById('expertquestion_'+expertQuestionid).innerHTML; } else { return false; } //var myTimer = setTimeout("FadeInExpertQuestion('" + fadeTime + "')", 30); /* } */ } function FadeInExpertQuestion(fadeInTime) { var myImage = document.getElementById("expertquestion_img"); var timeDiff = (new Date).getTime() - fadeInTime; if (timeDiff < 500) { myImage.style.opacity = timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (timeDiff / 5) + ")"; var myTimer = setTimeout("FadeInExpertQuestion('" + fadeInTime + "')", 30); }else{ myImage.style.opacity = 1; myImage.style.filter = "alpha(opacity=" + 100 + ")"; } } function getLatestExpertpanel(expertPanelStartId, maxId) { expertPanelStartId_real++; expertPanelStartId = expertPanelStartId_real; if(expertPanelStartId > maxId){ expertPanelStartId = 1; expertPanelStartId_real = 1; } var fadeOutTime = new Date().getTime(); var myTimer = setTimeout("FadeOutLatestExpertpanel('"+expertPanelStartId+"', '"+fadeOutTime+"')"); } function FadeOutLatestExpertpanel(expertPanelStartId, fadeOutTime) { var myElement = document.getElementById('expertpanel_rndcontent'); var myImage = document.getElementById("expertpanelauthorimg_src"); var timeDiff = (new Date).getTime() - fadeOutTime; if (timeDiff < 500) { myElement.style.opacity = 1 - timeDiff / 500; myElement.style.filter = "alpha(opacity=" + (100 - timeDiff / 5) + ")"; myImage.style.opacity = 1 - timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (100 - timeDiff / 5) + ")"; var myTimer = setTimeout("FadeOutLatestExpertpanel('"+expertPanelStartId+"', '" + fadeOutTime + "')", 50); } else { var fadeTime = (new Date).getTime(); document.getElementById('expertpanel_rndcontent').innerHTML = document.getElementById('expertpanel_'+expertPanelStartId).innerHTML;; document.getElementById('expertpanelauthorimg_src').src = document.getElementById('expertpanelauthorimg_'+expertPanelStartId).src; var myTimer = setTimeout("FadeInLatestExpertpanel('"+expertPanelStartId +"','" + fadeTime + "')", 30); } } function FadeInLatestExpertpanel(expertPanelStartId, fadeInTime) { var myElement = document.getElementById('expertpanel_rndcontent'); var myImage = document.getElementById("expertpanelauthorimg_src"); var timeDiff = (new Date).getTime() - fadeInTime; if (timeDiff < 500) { myElement.style.opacity = timeDiff / 500; myElement.style.filter = "alpha(opacity=" + (timeDiff / 5) + ")"; myImage.style.opacity = timeDiff / 500; myImage.style.filter = "alpha(opacity=" + (timeDiff / 5) + ")"; var myTimer = setTimeout("FadeInLatestExpertpanel('"+expertPanelStartId +"','" + fadeInTime + "')", 30); }else{ myElement.style.opacity = 1; myElement.style.filter = "alpha(opacity=" + 100 + ")"; myImage.style.opacity = 1; myImage.style.filter = "alpha(opacity=" + 100 + ")"; } }