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;
    if(document.getElementById('maintitle')){
        document.getElementById('maintitle').innerHTML=title;    
    }
    if(document.getElementById('maindescription')){
        document.getElementById('maindescription').innerHTML=description;    
    }
    
}

var mentor_cmsid='';
var mentor_modus='';
var mentor_mentor_id='';

function startInterval(cms_id,modus,mentor_id)
{
    mentor_cmsid=cms_id;
    mentor_modus=modus;
    mentor_mentor_id=mentor_id;
    
    setInterval(mentorRequest,30000);  
}

function mentorRequest() 
{
    var elements='?cms_id='+mentor_cmsid+'&modus='+mentor_modus+'&mentor_id='+mentor_mentor_id;
    new Ajax.Request(
        '/bin/mentorRequest.php',
        {
            method: 'post', 
            parameters: elements, 
            onSuccess: UpdateMentor
        }
    );
   
}

function UpdateMentor(request)
{
    //alert(mentor_modus);
    if(mentor_modus == 'list'){
        document.getElementById('mentor_request_list').innerHTML = request.responseText;    
    } else if(mentor_modus == 'detail'){
        document.getElementById('mentor_request_image').innerHTML = request.responseText;
    } else if(mentor_modus == 'toplist'){
        document.getElementById('beraterlist').innerHTML = request.responseText;
    } else if(mentor_modus == 'alllist'){
        document.getElementById('mentor_request_list').innerHTML = request.responseText;
    }
     
}

function installFlashPlayerByFile(mp3_file,goon)
{
    var flashvars = { file:mp3_file, repeat:"false", autostart: goon };
    var params = {  };
    var attributes = {  };
    swfobject.embedSWF("/ARANESLIB/jwplayer4.2/player-licensed.swf", "mediaplayer", 202, 20, "9.0.0","/ARANESLIB/expressInstall.swf", flashvars, params, attributes);   
}


var container = '';
function startTombolaInterval(id)
{
    container = id;
    setInterval(TombolaRequest,20000);  
}

function TombolaRequest() 
{
    var elements='';
    new Ajax.Request(
        '/bin/tombolaRequest.php',
        {
            method: 'post', 
            parameters: elements, 
            onSuccess: UpdateTombola
        }
    );
   
}


function UpdateTombola(request)
{
    document.getElementById(container).innerHTML = request.responseText;    
   
}
