It looks like you need to remove this code:
Code:
<script type="text/javascript">
$(document).ready(function(){
if (document.cookie.indexOf('visited=true') === -1) {
var expires = new Date();
expires.setDate(expires.getDate()+30);
document.cookie = "visited=true; expires="+expires.toUTCString();
$("a[rel='welcomehun']").colorbox({transition:"fade", open:"true",
scrolling:false, innerWidth:480, innerHeight:385, opacity:.5});
}
});
</script>
because if the cookie isn't present, it tries to load colorbox, which isn't there, so it ends up throwing an error and other scripts (like the accordion) don't work as expected. That's why on reload (after the cookie is set) the accordion works.
Now on to the AJAX issue. I'm surprised it works at all like that. Here's what to do. Forget about loadobjs, you can load any scripts or styles that you want in the head of the page in the normal manner with external script tags and stylesheet links. Use this version of the script which removes loadobjs and adds a success function argument:
Code:
function ajaxpage(url, containerid, success){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid, success)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid, success){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
document.getElementById(containerid).innerHTML=page_request.responseText
if(typeof success == 'function'){
success();
}
}
}
Then instead of doing this:
Code:
<a href="javascript:ajaxpage('HUN/termekek/kehely02.php', 'contentarea');" onClick="Galleria.run('#galleria2');">Vitrum et Anima</a>
Do:
Code:
<a href="HUN/termekek/kehely02.php" onclick="ajaxpage(this.href, 'contentarea', function(){Galleria.run('#galleria2');}); return false;">Vitrum et Anima</a>
The browser cache may need to be cleared and/or the page refreshed to see changes.
Bookmarks