var newwindow;
function MM_openBrWindow(theURL,winName,features) {
  newwindow=window.open(theURL,winName,features);
  if (window.focus) {
    newwindow.focus()
  }
}

function zoom(img)
{
	MM_openBrWindow('/bin/zoom.php?img='+img,'araneszoom','width=537,height=798,scrollbars=1');	
}

function phpcode2(token)
{
	var output = '';
	output += '<'+'?='+' lg(\''+token+'\')'+' ?'+'>\n';
	output += 'lg(\''+token+'\')\n';
	output += '<'+'?='+' lg(\''+token+'\',\'\',false)'+' ?'+'>\n';
	output += 'lg(\''+token+'\',\'\',false)\n';
	document.getElementById('phpcode').value = output;
}

function adminpopup(url)
{
	window.opener.SetUrl(url); 
	window.close(); 
	window.opener.focus();
	
}


function windowwidth () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function windowheight () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}


function AccessLog(mod_id,mod,account_id){
	
	var elements='mod_id='+mod_id+'&mod='+mod+'&account_id='+account_id+'&f=ajax';
	new Ajax.Request(	'/bin/accesslog.php',
						{	method: 'post', 
							parameters: elements
						}
					);
		
}

function doNextImg(direction)
{
    var start=parseInt(document.getElementById('start').value);
    var end=parseInt(document.getElementById('end').value);
    var aktuell=parseInt(document.getElementById('aktuell').value);
    var position=parseInt(0);
    
    if(direction == 'back'){
        position=parseInt(aktuell-1);    
    }else if(direction == 'forward'){
        position=parseInt(aktuell+1);     
    }else if(direction == 'now'){ 
       position=aktuell;
    }
    
    if(position == 0) {
        position=parseInt(end-1);  
    } else if(position >= end) {
        position=parseInt(start);    
    }
    
    var bild =document.getElementById('zoom_'+position).src;
    var main = bild.replace("_t.jpg","_z.jpg");
    var title =document.getElementById('zoom_'+position).title;
    var description =document.getElementById('zoom_'+position).alt;

    document.getElementById('aktuell').value=position;
    document.getElementById('mainimg').src=main;
   
    
}

function LightviewConfig(lg)
{
    Lightview.options.imgNumberTemplate = 'Bild #{position} / #{total}'; 
}

