
//
// Init popup windows for images
//
function popups_init()
{
    var ancs = document.getElementsByTagName("a");
    for (i=0; i<ancs.length; i++) {
        if ((ancs.item(i).className).indexOf("popup")!=-1) {
            // popup-width-height
            parts = ancs.item(i).className.split("-");
            addEvent(ancs.item(i), 'click', create_show_image_func(ancs.item(i).href, parts[1], parts[2], parts[4], ancs.item(i).title, parts[3]), false);
        }
    }
}

function create_show_image_func(href, width, height, id, alt, template)
{    
return function(e) { 
        if (e.preventDefault) {
            e.preventDefault();
        }
        show_image(href, width, height, id, alt, template); 
        return false;
    };
}

function show_image(href, width, height, id, alt, template)
{
        var left = (screen.width-width)/2;
        var top  = (screen.height-height)/2;

        
        if (template == 'feedback') {
          height = 160 + parseInt(height);
          width = 100 + parseInt(width);
        } else if (template == 'feedbackshop') {
          height = 160 + parseInt(height);
          width = 100 + parseInt(width);
        } else {
          height = 300 + parseInt(height);
          width = 200 + parseInt(width);
        }        
             
        if (alt == '') {alt = '&nbsp;'} 
        
        features = 'width='+width+', height='+height+', location=no, menubar=no, personalbar=no, resizable=yes, scrollbars=no, status=no, titlebar=yes, toolbar=no, left='+left+', top='+top;
		
    if (template == 'feedback') { 
      openedWindow = window.open('/feedback.php', 'mywind', features);
    } else if (template == 'feedbackshop') {
      openedWindow = window.open('/feedbackshop.php?id='+id, 'mywind', features);
    } else {
      openedWindow = window.open('/pic.php?p='+ template +'&a='+alt, 'mywind', features);
    }
		openedWindow.focus();
        return false;
}