﻿var rootpath = 'http://'+getURL();

function getURL()
{
    root = document.URL;
    root = root.substring(root.indexOf('/')+2);
    root = root.substring(0, root.indexOf('/'));
    return root;
}

function checkimage(topic) 
{ 
    url = rootpath+'/Resources/repositories/images/'+topic+'/find-more.jpg';
    if(fileExists(url))
    {
        return false;
     }
     else
     {
        loadDefaultImage(topic);
     }
} 

function loadDefaultImage(topic)
{
    if(rootpath.length > 0)
    {
        if(document.getElementById(topic + '-fm') !== null)
        {
            document.getElementById(topic + '-fm').src = rootpath+'/Resources/img/find-more.jpg';
        }
        if(document.getElementById(topic + '-im') !== null)
        {
            document.getElementById(topic + '-im').src = rootpath+'/Resources/img/find-more.jpg';
        }
     }
}

function fileExists(strURL)
{
    //oHttp = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
    oHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); 
    oHttp.open("HEAD", strURL, false);
    oHttp.send();
    return (oHttp.status==404) ? false : true;
}

function googleMapLoad(zoom,x,y,nodeLabel) {
    if (GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById("googlemap"));
          map.setCenter(new GLatLng(x,y), zoom);
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
                             
          output = "<b>" + nodeLabel + "</b>";
         
          map.openInfoWindowHtml(map.getCenter(), output);
      }
}