// JavaScript Overlay
// haff

function getRefToDiv(divID,oDoc) {
  if( document.getElementById ) {
    return document.getElementById(divID); }
  if( document.all ) {
    return document.all[divID]; }
  if( !oDoc ) { oDoc = document; }
  if( document.layers ) {
    if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
      //repeatedly run through all child layers
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        //on success, return that layer, else return nothing
        y = getRefToDiv(divID,oDoc.layers[x].document); }
    return y; } }
  return false;
}

function showDiv(divID_as_a_string) {
  //get a reference as above ...
  myReference = getRefToDiv(divID_as_a_string);
  if( !myReference ) {
    window.alert('Nothing works in this browser');
    return; //don't go any further
  }
  //now we have a reference to it
  if( myReference.style ) {
    //DOM & proprietary DOM
    myReference.style.visibility = 'visible';
  } else {
    //layers syntax
    myReference.visibility = 'show';
  }
}

function hideDiv(divID_as_a_string) {
  //get a reference as above ...
  myReference = getRefToDiv(divID_as_a_string);
  if( !myReference ) {
    window.alert('Nothing works in this browser');
    return; //don't go any further
  }
  //now we have a reference to it
  if( myReference.style ) {
    //DOM & proprietary DOM
    myReference.style.visibility = 'hidden';
  } else {
    //layers syntax
    myReference.visibility = 'show';
  }
}



function overlay() {
	//alert("overlay");
	
	el = document.getElementById("overlay");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
	el.style['z-index'] = 200;
	eldiv= document.getElementById("overlaydiv");
	eldiv.innerHTML ='';
	eldiv.style['z-index'] = 201;
	document.getElementById('content').focus();
	
	
}
function youtube(v){

	document.getElementById("overlaydiv").innerHTML ='<iframe id="overlayframe" name="overlayframe" src="youtube/'+v+'" frameborder="0" marginheight="0" marginwidth="0" width="640" height="505" scrolling="no"> </iframe>';
	el = document.getElementById("overlay");
	el.style.visibility = "visible";
	
}
function closeprintoverlay() {
	//alert("overlay");
	
	el = document.getElementById("printoverlay");
	el.style.visibility = "hidden";
	el.style['z-index'] = 10;
	el.innerHTML ='';
	document.getElementById('content').focus();
	
	
}
function openprint(v){

	//document.getElementById("printoverlaydiv").innerHTML ='<a href="javascript:iprint(printframe);">[print]</a> <iframe id="printframe" name="printframe" src="printview/'+v+'" frameborder="0" marginheight="10" marginwidth="10" width="800" height="100%" scrolling="auto"> </iframe>';
	el = document.getElementById("printoverlay");
	el.style.visibility = "visible";
	//el.style['z-index'] = 200;
	//eldiv= document.getElementById("printoverlaydiv");
	//<a href="javascript:iprint(printframe);">print</a> 
	//eldiv.innerHTML ='<iframe id="printframe" name="printframe" src="printview/'+v+'" frameborder="0" marginheight="10" marginwidth="10" width="800" height="100%" scrolling="auto"> </iframe>';
	// iframe  height="100%" 
	html_str ='<div id="bgcover" style="position: absolute; left: 0px; top:0px; width: 100%; height:100%; visibility: visible; z-index: 345; opacity: 0.999999;" >';
	html_str +='<a href="javascript:closeprintoverlay();" ><img src="http://vmilaaget.dk/overlayassets/overlay_cover.png" style="cursor:ne-resize" border="0" width="100%" height="100%" /></a></div>';
	
	html_str +='<div id="ZoomBox" style="position: absolute; left: 202.316px; top: 65px; visibility: visible; z-index: 499; opacity: 0.999999;">';
	html_str +='<iframe style="border: 0px solid #FFFFFF; outline:none; width: 702.1px; height: 643.1px;" id="printframe" name="printframe" src="http://vmilaaget.dk/printview/';
	html_str +=v;
	html_str +='" scrolling="auto"></iframe></div>';
	
	html_str +='<div id="ZoomClose" style="position: absolute; left: 115px; top: 125px; visibility: visible; opacity: 0.999999; z-index: 1002;">';
	html_str +='<a href="javascript:closeprintoverlay();" ><img src="http://vmilaaget.dk/overlayassets/close_btn.png" style="cursor: pointer;" border="0" height="60" width="110"></a></div>';
  	
	html_str +='<div id="PrintBtn" style="position: absolute; left: 115px; top: 65px; visibility: visible; opacity: 0.999999; z-index: 1001;">';
  	html_str +='<a href="javascript:javascript:iprint(printframe);" ><img src="http://vmilaaget.dk/overlayassets/print_btn.png" style="cursor: pointer;" border="0" height="60" width="110"></a></div>';
	
	html_str +='<div id="ShadowBox" style="position: absolute; left: 189px; top: 57px; width: 730px; height: 670px; visibility: visible; z-index: 498; opacity: 0.999999;">';
  	html_str +='<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"><tbody><tr style="height: 25px;">';
    html_str +='<td style="width: 27px;"><img src="http://vmilaaget.dk/overlayassets/zoom-shadow1.png" style="display: block;" height="25" width="27"></td>';
    html_str +='<td background="http://vmilaaget.dk/overlayassets/zoom-shadow2.png"><img src="http://vmilaaget.dk/overlayassets/spacer.gif" style="display: block;" height="1" width="1"></td>';
    html_str +='<td style="width: 27px;"><img src="http://vmilaaget.dk/overlayassets/zoom-shadow3.png" style="display: block;" height="25" width="27"></td></tr>';
    html_str +='<tr><td background="http://vmilaaget.dk/overlayassets/zoom-shadow4.png"><img src="http://vmilaaget.dk/overlayassets/spacer.gif" style="display: block;" height="1" width="1"></td>';
    html_str +='<td bgcolor="#ffffff"><img src="http://vmilaaget.dk/overlayassets/spacer.gif" style="display: block;" height="1" width="1"></td>';
    html_str +='<td background="http://vmilaaget.dk/overlayassets/zoom-shadow5.png"><img src="http://vmilaaget.dk/overlayassets/spacer.gif" style="display: block;" height="1" width="1"></td></tr>';
    html_str +='<tr style="height: 26px;">';
    html_str +='<td style="width: 27px;"><img src="http://vmilaaget.dk/overlayassets/zoom-shadow6.png" style="display: block;" height="26" width="27"></td>';
    html_str +='<td background="http://vmilaaget.dk/overlayassets/zoom-shadow7.png"><img src="http://vmilaaget.dk/overlayassets/spacer.gif" style="display: block;" height="1" width="1"></td>';
    html_str +='<td style="width: 27px;"><img src="http://vmilaaget.dk/overlayassets/zoom-shadow8.png" style="display: block;" height="26" width="27"></td>';
    html_str +='</tr></tbody></table></div>';
	
	el.innerHTML =html_str;
	
	/*
	position: absolute;
	left: 50%;
	top: 10%;
	margin-top: 0px; 
	margin-left: -350px;
	width:700px;
	height:540px;
	background-color: #FFFFFF;
	color:#000000;
	border-color:#aeaeae;
	border:solid;
	border-width:1px
	font: 10px Arial, "Helvetica Neue", sans-serif;
	border:1px solid #aeaeae;
	padding:0px;
	*/
	eldiv.style['position'] = "absolute";
	eldiv.style['left'] = "50%";
	eldiv.style['top'] = "10%";
	eldiv.style['margin-top'] = "0px";
	eldiv.style['margin-left'] = "-350px";
	eldiv.style['width'] = "700px";
	eldiv.style['height'] = "540px";
	
	eldiv.style['border-width'] = "thin";
	eldiv.style['border-color'] = "#aeaeae";
	eldiv.style['border'] = "solid";
	
	
	eldiv.style['z-index'] = 1001;
	eldiv.focus();
	
}
function old_openprint(v){

	//document.getElementById("printoverlaydiv").innerHTML ='<a href="javascript:iprint(printframe);">[print]</a> <iframe id="printframe" name="printframe" src="printview/'+v+'" frameborder="0" marginheight="10" marginwidth="10" width="800" height="100%" scrolling="auto"> </iframe>';
	el = document.getElementById("printoverlay");
	el.style.visibility = "visible";
	el.style['z-index'] = 1000;
	eldiv= document.getElementById("printoverlaydiv");
	//<a href="javascript:iprint(printframe);">print</a> 
	//eldiv.innerHTML ='<iframe id="printframe" name="printframe" src="printview/'+v+'" frameborder="0" marginheight="10" marginwidth="10" width="800" height="100%" scrolling="auto"> </iframe>';
	// iframe  height="100%" 
	
	
	eldiv.innerHTML ='<table><tbody><tr><td><table width="700"><tbody><tr><td height="60px" width="1%"></td><td valign="top" width="50%"><a href="javascript:iprint(printframe);"><img src="http://vmilaaget.dk/http://vmilaaget.dk/overlayassets/print_btn.png" height="60" width="110"></a></td><td align="right" valign="top" width="49%"><a href="javascript:printoverlay();"><img src="http://vmilaaget.dk/http://vmilaaget.dk/overlayassets/printclose_btn.png" align="right" height="9" width="18"></a></td></tr></tbody></table><table width="700"><tbody><tr><td height="480px" valign="top" ><img src="http://vmilaaget.dk/http://vmilaaget.dk/overlayassets/spacer.gif" height="480px" width="1"></td><td colspan="2" valign="top" height="440" ><iframe valign="top" id="printframe" name="printframe" src="printview/'+v+'" frameborder="0" marginheight="10" marginwidth="10" width="680" height="480" scrolling="auto" /></td></tr></table></td></tr></table>';
	
	/*
	position: absolute;
	left: 50%;
	top: 10%;
	margin-top: 0px; 
	margin-left: -350px;
	width:700px;
	height:540px;
	background-color: #FFFFFF;
	color:#000000;
	border-color:#aeaeae;
	border:solid;
	border-width:1px
	font: 10px Arial, "Helvetica Neue", sans-serif;
	border:1px solid #aeaeae;
	padding:0px;
	*/
	eldiv.style['position'] = "absolute";
	eldiv.style['left'] = "50%";
	eldiv.style['top'] = "10%";
	eldiv.style['margin-top'] = "0px";
	eldiv.style['margin-left'] = "-350px";
	eldiv.style['width'] = "700px";
	eldiv.style['height'] = "540px";
	
	eldiv.style['border-width'] = "thin";
	eldiv.style['border-color'] = "#aeaeae";
	eldiv.style['border'] = "solid";
	
	
	eldiv.style['z-index'] = 1001;
	eldiv.focus();
	
}
function printoverlay() {
	//alert("overlay");
	
	el = document.getElementById("printoverlay");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
	
	el.style['z-index'] = 100;
	eldiv= document.getElementById("printoverlaydiv");
	eldiv.innerHTML ='';
	eldiv.style['z-index'] = 101;
	document.getElementById('content').focus();
	
	
}

function iprint(ptarget){
	ptarget.focus();
	ptarget.print();
} 
//alert("jeg er her");
