var browser = {
    dom:(document.getElementById != null),
    ie:(document.all && parseInt(navigator.appVersion) >= 4),
    ns:(document.layers && parseInt(navigator.appVersion) >= 4)
}

function getLayer(name) 
{
    if (browser.dom) return document.getElementById(name);
    else if (browser.ie) return document.all[name];
    else if (browser.ns) return document.layers[name];
}
            
var _panel_showed = null;
            
function swap_panel(ipanel) 
{
    if (_panel_showed != null) 
    {
        _panel = getLayer("box" + _panel_showed);
        if (_panel != null) _panel.style.display = "none";
                    
        _btn = getLayer("btn" + _panel_showed);
        if (_btn != null) _btn.className = "orgBtn";
    }
    if (ipanel != _panel_showed) 
    {
        _panel = getLayer("box" + ipanel);    
        if (_panel != null) _panel.style.display = "block";
                    
        _btn = getLayer("btn" + ipanel);
        if (_btn != null) _btn.className = "orgBtn_selected";

        _panel_showed = ipanel;
    } else {
        _panel_showed = null;
    }
}

var _contact_showed = null;
            
function swap_contact(icontact) 
{
    if (_contact_showed != null) 
    {
        _contact = getLayer("contacts" + _contact_showed);
        if (_contact != null) _contact.style.display = "none";
                    
        _headline = getLayer("headline" + _contact_showed);
        if (_headline != null) _headline.className = "headline";
    }
    if (icontact != _contact_showed) 
    {
        _contact = getLayer("contacts" + icontact);    
        if (_contact != null) _contact.style.display = "block";
                    
        _headline = getLayer("headline" + icontact);
        if (_headline != null) _headline.className = "headline_selected";

        _contact_showed = icontact;
    } else {
        _contact_showed = null;
    }
}
function openImage (winLoc, imgWidth, imgHeight)
{
    var winWidth         = 100;
    var winHeight         = 100;
    var screenHeight     = screen.availHeight;
    var screenWidth        = screen.availWidth;
    
    if (imgWidth>screenWidth)        winWidth = screenWidth; else winWidth = imgWidth;
    if (imgHeight>screenHeight)        winHeight = screenHeight; else winHeight = imgHeight;
    var winSet  = 'resizable=1,top=0,left=0,width='+ winWidth +',height='+ winHeight;
    window.open (winLoc, '_img', winSet);
}
function popupWindow(name, url, imgWidth, imgHeight, options) {
    var winWidth         = 100;
    var winHeight         = 100;
    var screenHeight     = screen.availHeight;
    var screenWidth        = screen.availWidth;
    
    if (imgWidth>screenWidth)        winWidth = screenWidth; else winWidth = imgWidth;
    if (imgHeight>screenHeight)        winHeight = screenHeight; else winHeight = imgHeight;
    
    var params = "width=" + winWidth + ", height=" + winHeight;
    params += options ? ", " + options.join(",") : "";
    var popup = window.open(url, name, params);
    return popup;
}
function documentWindow(name, content, width, height, scroll) {
    var options = [];
    options.push("scrollbars=" + (scroll ? "yes" : "no"));
    var popup = popupWindow(name, "", width, height, options);
    popup.document.open();
    popup.document.write(content);
    popup.document.close();
    popup.focus();
}
function imageWindow(title, src, width, height, alt) 
{   
    width = width+18;
    height = height+18;
    var name = 'img';
    var html = "<html>";
    html += "<head><title>" + title + "</title></head><body style=\"margin:0px\">";
    html += "<a href=\"javascript:close()\"/><img src=\"" + src + "\" border=\"0\" alt=\"" + (alt != undefined ? alt : '') + "\" /></a>";
    html += "</body></html>";
    documentWindow(name, html, width, height, true);
}
function share(id){
    var url = location.href;
    var title = document.title;
    var width = 800; 
    var height = 380;
    
    switch (id) {
      case 'fb': 
          link = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title);
          width = 626; 
          height = 436;
          break;
      case 'twit': 
          link = 'http://www.twitter.com/home?status='+url;
          break;
      case 'sme': 
          link = 'http://vybrali.sme.sk/sub.php?url='+encodeURIComponent(url);
          width = 626; 
          height = 436;
          break;
    }
    if (link) window.open(link, 'share_'+id, 'toolbar=0,status=0,width='+ width +',height='+height);
    return false;
}

