
var embdImgLoader=new ImagePreloader(embdImageLoaderCallBack);var embdOpacityFadeEffect=null;var embdPhotoPath=null;var embdPhotos=null;var embdPhotoDescriptions=null;var embdLoadingNum=0;var embdCurrentPhotoNum=-1;var embdOverlay=null;var embdCenterLeftPos=0;var embdStaticLeftPos=0;var embdCenterWidth=480;var embdCenteredDivMode=false;var embdFilemode=true;var embdNextTitle=null;var embdURIPhotoNextTitle=null;var embdOldBodyBg=null;var embdOverlayDisabled=false;function createOverlay(cxPhoto,cyPhoto,iStartPhoto){blurAnyInput();closeEmbeddedPhotoGallery();var cxPreferred=cxPhoto+0;var cyPreferred=cyPhoto+50;var centeredDiv=document.getElementById("CenteredContent");if(!centeredDiv)
centeredDiv=document.getElementById("CenteredArticle");if(!centeredDiv)
return;if(!embdOverlayDisabled){if(!embdOverlay){embdOverlay=document.createElement("div");embdOverlay.id="overlay_pgembd";embdOverlay.className="overlay_pgembd";embdOverlay.onclick=function(){closeEmbeddedPhotoGallery();return false;};var h=getPageHeight();embdOverlay.style.height=h+"px";centeredDiv.style.height=h+"px";if(document.getElementById("CenteredContent")&&document.getElementById("CenteredArticle")){centeredDiv.style.background="black";embdOverlay.style.width=document.getElementById("CenteredContent").clientWidth+"px";}}
var className="overlay";if(document.getElementById("CenteredContent")&&document.getElementById("CenteredArticle")){className="overlaynopopup";}
document.body.className=className;centeredDiv.appendChild(embdOverlay);}else
document.body.className="nooverlay";setElementsByIdsHidden("gradient_bg");var content=document.createElement("div");content.id="content_pgembd";content.className="content_pgembd";content.style.height=cyPreferred+"px";content.style.width=cxPreferred+"px";var left=0;if(embdCenteredDivMode){if(embdStaticLeftPos>0)
left=embdStaticLeftPos;else
left=Math.floor((embdCenterWidth-cxPreferred)/2)+embdCenterLeftPos;}else
left=Math.floor((document.documentElement.clientWidth-(cxPreferred+10))/2)+embdCenterLeftPos;if(left<0)
left=0;content.style.marginLeft=left+"px";var st=getPageScrollTop();var wsz=getWindowSize();var y=Math.floor((wsz[1]-cyPreferred)/2);if(y<0)
y=0;content.style.top=(y+st[1])+"px";var str="<div style='position: relative; padding: 0px; '>";str+="<table cellpadding='0' cellspacing='0' width='"+cxPhoto+"' style='height: "+cyPhoto+"px'>";str+="<tr><td align='center'>";str+="<img id='pgembd_photo' style='vertical-align: center; filter:alpha(opacity=100); -moz-opacity:1.0; opacity:1.0;' border='0' src='/images/indicator_circle_ball4.gif' alt='' />";str+="</td></tr>";str+="</table>";str+="</div><div id='pgembd_photo_title'></div><div class='pgembd_cp'>";if(embdPhotos.length>1)
str+="<table cellpadding='0' cellspacing='0' width='131' align='center'><tr><td><div style='position: relative;'><a class='pgembd_left' href='javascript: void(0);' onclick='embeddedPhotoGalleryPrev()'><img class='elemFader0Step20' width='17' height='17' src='/images/artiklar/images/photo_left_hover.gif'/></a><a href='javascript: void(0);' class='pgembd_close' onclick='closeEmbeddedPhotoGallery()'><img class='elemFader0Step20' width='17' height='17' src='/images/artiklar/images/photo_close_hover.gif'/></a><a href='javascript: void(0);' class='pgembd_right' onclick='embeddedPhotoGalleryNext()'><img class='elemFader0Step20' width='17' height='17' src='/images/artiklar/images/photo_right_hover.gif'/></a></div></td></tr></table>";else
str+="<center><a href='javascript: void(0);' onclick='closeEmbeddedPhotoGallery()'>Stäng</a></center>";str+="</div>";content.innerHTML=str;if(embdCenteredDivMode)
centeredDiv.appendChild(content);else
document.body.appendChild(content);embdLoadingNum=iStartPhoto;return true;}
function loadEmbeddedPhotoGallery(cxPhoto,cyPhoto,iStartPhoto,path,photos){embdFilemode=true;embdPhotoPath=path;embdPhotos=new Array();for(var i=4;i<arguments.length;i++){embdPhotos.push(arguments[i]);}
var flashDivs=document.getElementsByTagName("div");for(var i=0;i<flashDivs.length;i++){if(flashDivs[i].className=="flash"){flashDivs[i].style.visibility="hidden";}}
if(createOverlay(cxPhoto,cyPhoto,iStartPhoto)){if(embdPhotoDescriptions){embdNextTitle=embdPhotoDescriptions[iStartPhoto];embdURIPhotoNextTitle=embdPhotoPath+embdPhotos[iStartPhoto];}
embdImgLoader.preload(path+embdPhotos[iStartPhoto]);}}
function loadEmbeddedPhotoGalleryDB(cxPhoto,cyPhoto,iStartPhoto,pgid,photos){embdFilemode=false;embdPgid=pgid;embdPhotos=new Array();for(var i=4;i<arguments.length;i++){embdPhotos.push(arguments[i]);}
if(createOverlay(cxPhoto,cyPhoto,iStartPhoto)){embdLoadingNum=iStartPhoto;embeddedGetPhotoWithPid(pgid,embdPhotos[iStartPhoto]);}}
function setEmbeddedPhotoDescriptions(descriptions){embdPhotoDescriptions=new Array();for(var i=0;i<arguments.length;i++){embdPhotoDescriptions.push(arguments[i]);}}
function closeEmbeddedPhotoGallery(){var overlay=document.getElementById("overlay_pgembd");var content=document.getElementById("content_pgembd");var el=document.getElementById("CenteredContent");if(!el)
el=document.getElementById("CenteredArticle");if(el&&content){if(!embdOverlayDisabled&&overlay){document.body.className="";el.removeChild(overlay);}else if(embdOverlayDisabled)
document.body.className="";content.parentNode.removeChild(content);var flashDivs=document.getElementsByTagName("div");for(var i=0;i<flashDivs.length;i++){if(flashDivs[i].className=="flash"){flashDivs[i].style.visibility="visible";}}
setElementsByIdsVisible("gradient_bg");}}
function embeddedPhotoGalleryPrev(){if(embdCurrentPhotoNum>0){embdLoadingNum=embdCurrentPhotoNum-1;if(embdFilemode){if(embdPhotoDescriptions){embdNextTitle=embdPhotoDescriptions[embdLoadingNum];embdURIPhotoNextTitle=embdPhotoPath+embdPhotos[embdLoadingNum];}
embdImgLoader.preload(embdPhotoPath+embdPhotos[embdLoadingNum]);}else
embeddedGetPhotoWithPid(embdPgid,embdPhotos[embdLoadingNum]);}}
function embeddedPhotoGalleryNext(){if(embdCurrentPhotoNum+1<embdPhotos.length){embdLoadingNum=embdCurrentPhotoNum+1;if(embdFilemode){if(embdPhotoDescriptions){embdNextTitle=embdPhotoDescriptions[embdLoadingNum];embdURIPhotoNextTitle=embdPhotoPath+embdPhotos[embdLoadingNum];}
embdImgLoader.preload(embdPhotoPath+embdPhotos[embdLoadingNum]);}else
embeddedGetPhotoWithPid(embdPgid,embdPhotos[embdLoadingNum]);}}
function embeddedGetPhotoWithPid(pgid,pid){return new AJAXRequest("POST","/photo2.jspax","pgid="+pgid+"&pid="+(pid),"http://www.vaxjopuls.se/blogg",processEmbeddedGetPhotoXML);}
function embdImageLoaderCallBack(bLoaded,image){embdCurrentPhotoNum=embdLoadingNum;var elPhoto=document.getElementById('pgembd_photo');if(elPhoto){if(elPhoto.filters)
elPhoto.filters.alpha.opacity=0;elPhoto.style.opacity=0;if(embdOpacityFadeEffect==null){embdOpacityFadeEffect=new OpacityFadeEffect();}
embdOpacityFadeEffect.startFadeEffect(elPhoto,image);if(embdNextTitle){if(image.src.indexOf(embdURIPhotoNextTitle)>=0){var el=document.getElementById("pgembd_photo_title");if(el){el.innerHTML=embdNextTitle;return;}}}
var el=document.getElementById("pgembd_photo_title");if(el)
el.innerHTML="";}}
function blurAnyInput(){var inputs=document.getElementsByTagName('input');if(inputs&&inputs[0]&&inputs[0].blur){inputs[0].blur();}}
function processEmbeddedGetPhotoXML(myAJAX){if(myAJAX.readyState==4){if(myAJAX.status==200){var xml=myAJAX.responseXML;if(xml.documentElement){var status=xml.documentElement.getAttributeNode("status").nodeValue;if(status=="OK"){pid=xml.documentElement.getAttributeNode("pid").nodeValue;var photoURI=xml.documentElement.getElementsByTagName("uri")[0].firstChild.nodeValue;var titles=xml.documentElement.getElementsByTagName("title");if(titles.length){embdNextTitle=titles[0].firstChild.nodeValue;embdURIPhotoNextTitle=photoURI;}else{embdNextTitle=null;}
if(photoURI){embdImgLoader.preload(photoURI);}}else if(status=="login"){openLoginForm(loggedInNowCallback,"mg",false,1);}}}}}
