
//really not important (the first two should be small for Opera's sake)
var PositionX = 10;
var PositionY = 10;
var defaultWidth  = 600;
var defaultHeight = 400;

//kinda important
var AutoClose = true;

//don't touch
function HH_popImage(imageURL,imageTitle){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { alert("Din läsare tillåter inte popup-fönster!");return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

function HH_popImage_yt(imageTitle){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { alert("Din läsare tillåter inte popup-fönster!");return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur=""':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/cZDcBBSj33Q&rel=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/cZDcBBSj33Q&rel=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

var HH_preFetchImages = new Array();

// when: 0   before page is displayed
//       1.. in the background
function HH_cacheImage(url, phase) {
	var _obj = new Object();
	_obj.url = url;
	_obj.phase = phase;
	_obj.complete = false;
	HH_preFetchImages[HH_preFetchImages.length] = _obj;
	HH_preFetchImages[url] = _obj;
};

function HH_loaded(pict) {
	if ( HH_preFetchImages[pict] == null ) { return false; }
	return HH_preFetchImages[pict].complete;
};

function HH_fetch(url,objIdx) {
	window.status ="Laddar "+url;
	(new Image()).src = url;
	HH_preFetchImages[objIdx].complete = true;
	//alert("Laddar "+url);
	window.status = "";
}

function HH_doPreFetch() {
	var _len = HH_preFetchImages.length;
	var _period = 1000;	
	var _obj = null;
	
	var _i = _len-1;
	while ( _i >= 0 ) {
	
		_obj = HH_preFetchImages[_i];
		if ( _obj.phase == 0 ) {
			window.status="Preloading "+_obj.url;
			(new Image()).src = _obj.url;
			window.status="";
			_obj.complete = true;
		} 
		_i = _i-1;
	}
	
	for (_i=0; _i<_len;_i++) {
		_obj = HH_preFetchImages[_i];
		if ( _obj.phase > 0 ) {
			setTimeout("HH_fetch(\""+_obj.url+"\","+_i+")",_period*_obj.phase);
		}
	}
}

var HH_qpTimer;

function HH_openFloatPict(pict) {

        if ( HH_qpTimer != null) { clearTimeout(HH_qpTimer); }
        if ( HH_loaded(pict) == false ) {
                document.floatPictArea.src="../images/loading_ani2.gif";
        }
       	

    
        if ( document.floatPictArea.filters) {
             document.floatPictArea.filters.blendTrans.apply();
         }
         	

        document.floatPictArea.src=pict;
            document.floatPictArea.style.visibility="visible";
      if ( document.floatPictArea.filters ) {
             document.floatPictArea.filters.blendTrans.play();
       }
       

}

function HH_closeFloatPictExec() {
	document.floatPictArea.style.visibility="hidden";
}

//-----------------------------------------

function HH_closeFloatPict(id) {

        HH_qpTimer=setTimeout("HH_closeFloatPictExec();",200);
        document.floatPictArea.src="../images/blank.jpg";
        }

function HH_showloading() {
	var elem=document.getElementById("eloadingMsg");
	elem.style.visibility = "visible"; 
}

function HH_hideloading() {
var elem=document.getElementById("eloadingMsg");
	elem.style.visibility = "hidden"; 
}



function HH_readData() {
	var srchString = unescape(location.search.substring(1,location.search.length));
	if (srchString.length > 0 ) {
		return srchString; };
	return "";		 
}

function HH_printWindow() {
	if ( HH_readData() == "print" ) {
	window.print();
	}
}

var HH_childWin = null;

function HH_closeWin() {
	if ( HH_childWin != null ) {
			HH_childWin.close();
			HH_childWin = null;
	}
}

var HH_img = new Image();
var HH_winTimer = null;

function HH_openWin(url,name,opt) {
	return HH_popImage(url,"Loading... "+url);
}

function HH_openWin_prev(url,name,opt) {
	HH_childWin = window.open(url,name,opt);
	HH_img.src = url;
	HH_childWin.resizeTo(600,400);
	if ( HH_img.complete ) {
		HH_childWin.resizeTo(HH_img.width+70,HH_img.height+60); }
	else {
		setTimeout("HH_openWinComplete(500)",500);
	}
	HH_childWin.focus();
}

function HH_openWinComplete(timeout) {
	if ( HH_img.complete ) {
	HH_childWin.resizeTo(HH_img.width+70,HH_img.height+60); }
	else {
		setTimeout("HH_openWinComplete("+timeout+")",timeout);
	}
};

