function fnFollowLink(oLink)	
{
	aLinkIDData = oLink.id.split("_");
  iLinkID     = aLinkIDData[1];  
  
  WinURL = "/dialogs/golink.php?linkid=" + iLinkID;  
  if(document.images) 
  {
     (new Image()).src = WinURL;
     
  }
  
  return true;
}

// unobtrusive JavaScript implementation 
// popups from links page
function preparePopupLinks()
{
  if( document.getElementById && document.getElementsByTagName )
  {
  	var links = document.getElementsByTagName( 'a' );
  	for( var i=0; i < links.length; i++ )
    {
    	if (links[i].className == 'popuplink')
    	{
    		links[i].onclick = function()
    		{
          return fnFollowLink(this);
        };
    	}
    }
  }
}


function fnOpenCaLink(sCode)
{	
  WinURL = "/dialogs/link_red.php?cid=" + sCode;
  OpenWindow(WinURL, 'CampingLinkDialog', xClientWidth(), xClientHeight(), ',toolbar=yes,menubar=yes,location=yes,scrollbars=yes, resizable=yes');  
}

function fnOpenInspectorDialog(WinURL)
{	
	var WinWidth  = 400;
	var WinHeight = 400;
	
	OpenWindow(WinURL, 'InspectorDialog', WinWidth, WinHeight);
}

function fnOpenRouteDialog(iCampingID)
{
	 sWinURL = "/xserver/index.php?campingID=" + iCampingID;
	 OpenWindow(sWinURL, 'RouteDialog', 800, 600, ",toolbar=no,menubar=no,statusbar=yes,scrollbars=yes,resizable=yes");
}

function fnOpenGoogleRouteDialog(iCampingID)
{
	sWinURL = "/dialogs/google_route.php?ca_=" + iCampingID;	
	OpenWindow(sWinURL, 'RouteDialog', 800, 800, ",toolbar=no,menubar=no,statusbar=yes,scrollbars=yes,resizable=yes");
}

function fnOpenPrintDialog(sWinURL)
{
	OpenWindow(sWinURL, 'printinfo', 700, 500, ",scrollbars=yes,toolbar=no,menubar=yes,statusbar=no");
}

function fnOpenLink(sWinURL)
{
	OpenWindow(sWinURL, 'Link', (xClientWidth()-20), (xClientHeight()-20), ',toolbar=yes,menubar=yes,location=yes,scrollbars=yes, resizable=yes' );
}

function fnOpenLegend()
{
	sWinURL = "/dialogs/pop_legend.php";
 	OpenWindow(sWinURL, 'LegendDialog', 400, 300, ",toolbar=no,menubar=no,statusbar=yes,scrollbars=yes,resizable=yes");
}

function fnOpenConditions(sWinURL)
{
	OpenWindow(sWinURL, 'ConditionsDialog', 700, 500, ",toolbar=no,menubar=no,statusbar=yes,scrollbars=yes,resizable=yes");
}


function OpenWindow(URL, Name, Width, Height, ExtraParams )
{
	// Center Popup
	var ObjNewWindow;
	var WinTop  = (xClientHeight() - Height) / 2;
	var WinLeft = (xClientWidth() - Width) / 2;
	var reWork = new RegExp('object','gi');	// Regular expression
	
	if (typeof(ExtraParams) == 'undefined')
	ExtraParams = '';
			
	try {
		ObjNewWindow = window.open(URL,Name,'height='+Height+',width='+Width+',Top='+WinTop+',Left='+WinLeft+ExtraParams);		
	}
	catch(e) {  }
		
	if(!reWork.test(String(ObjNewWindow)))
	{
		fnPopupInfoDialog(); //Aanzetten als vertalingen er zijn		
		scroll(0,0);
	}
	else if (window.focus) ObjNewWindow.focus();
}

function fnPopupInfoDialog()
{
	var iHeight  = 340;
	var iWidth   = 350;
	var iWinTop  = (xClientHeight() - iHeight) / 2;
	var iWinLeft = (xClientWidth() - iWidth) / 2;	
	var sURL = '/dialogs/pop_popupblocker.html';
	fnOpenDivDialog(sURL, iWidth, iHeight, iWinLeft, iWinTop);
}

function fnOpenDivDialog(sURL, iWidth, iHeight, iWinLeft, iWinTop)
{
	 var body = document.getElementsByTagName("body")[0];
	  	 
	 // creates a <div> element
   var oDiv	= document.createElement("div");
   oDiv.id  = 'PopupDiv';
   oDiv.style.width  	= iWidth   + 'px';
	 oDiv.style.height 	= iHeight  + 'px';
   oDiv.style.left   	= iWinLeft + 'px';
	 oDiv.style.top    	= iWinTop  + 'px';
   oDiv.style.position = 'absolute';
   oDiv.style.backgroundColor = '#fff';
   oDiv.style.border   = '6px solid red';
   oDiv.style.padding  = '10px';
   
   var oNavigationDiv = document.createElement("div");   
   oNavigationDiv.id = 'Navigation';
   oNavigationDiv.style.width = '100%';
   oNavigationDiv.style.padding = '6px';
   oNavigationDiv.style.margin = '0px 0px 10px 0px';
   oNavigationDiv.style.backgroundColor = '#fff';
   oNavigationDiv.innerHTML   = '<a href="#" onclick="closeDivDialog()"><img src="/imagelib/acsi.eu/nav/close.gif" border="0" alt="Close" style="float: right;" /></a><br /><br /><hr>';

// Make Iframe
// var oIframe = document.createElement("iframe");   
// oIframe.setAttribute("src", sURL);
// oIframe.style.width  	= '80%';
// oIframe.style.height 	= '80%';
// oIframe.style.border 	= '1px solid #fff';
// oIframe.frameborder    = 0;
// oIframe.marginheight   = 0;
// oIframe.marginwidth    = 0;      
   
   // put the navigation <div> in the parent <div>
   oDiv.appendChild(oNavigationDiv);
   
   // put the <iframe> in the <div>
   //oDiv.appendChild(oIframe);
   
   oDiv.innerHTML   = oDiv.innerHTML + '<iframe name="myframe" src="'+sURL+'" height="100%" width="100%" frameborder="0" scrolling="no" style="border: none; border-width: 0px; padding: 0px"></iframe>';
   
   // Add content to body
   body.appendChild(oDiv);
}

function closeDivDialog()
{
	var oBody = document.getElementsByTagName("body")[0];	
	oPopupDiv = document.getElementById("PopupDiv");
	oBody.removeChild(oPopupDiv);
}
