

function confirmation(text)
{
    var text = text;
    if (!confirm(text)) {
        return false;
    } else {
        return true;
    }
}

function redirectConfirmation(url, text, doubleCheck)
{
    var text = text;
    var url = url;
    var doubleCheck = doubleCheck;
    
    if (!confirm(text)) {
        return false;
    } else {
        if (doubleCheck == 1) {
            if (!confirm('Wirklich?')) {
                return false;
            }
        }
        window.location = url;
        return true;
    }
}

function riddle()
{
    if(!confirm('Überleg Dir Deine Antwort gut. \n Bei falscher Antwort ist die Mission für Dich vorbei !')) return false;
	return true;
}
function del()
{
	if(!confirm('Soll der Löschvorgang wirklich fortgesetzt werden?')) return false;
	return true;
}
function mail_del()
{
	if (!confirm('Soll die Mail wirklich gelöscht werden?')) { return false; }
	return true;
}
function pate()
{
	if(!confirm('Willst Du wirklich deinen Patenstatus übertragen ?')) return false;
	return true;
}
function resetten()
{
	if(!confirm('Willst Du Deinen Account (Geld, Autos, ALLES !...) wirklich resetten ?')) return false;
	return true;
}
function sell()
{
	if(!confirm('Wirklich verkaufen?')) return false;
	return true;
}

function buy()
{
	if(!confirm('Wirklich kaufen?')) return false;
	return true;
}

function deny()
{
	if(!confirm('Willst du es wirklich zurckschicken?')) return false;
	return true;
}

function accept()
{
	if(!confirm('Willst du es wirklich annehmen?')) return false;
	return true;
}
function mission()
{
	if(!confirm('Willst du die Mission wirklich annehmen?')) return false;
	return true;
}
function yes()
{
	if(!confirm('Soll diese Sache für die User wirklich freigeschaltet werden?')) return false;
	return true;
}
function wakeup()
{
	if(!confirm('Hast Du Deinen Wecker wirklich gestellt?')) return false;
	return true;
}
function change()
{
	if(!confirm('Änderungen übernehmen?')) return false;
	return true;
}
function dismiss()
{
    if(!confirm('Willst Du Deinen Kämpfer wirklich entlassen ?')) return false;
    return true;
}


function MM_preloadImages() { //v3.0

    var d=document; 
    if(d.images){ 
        if(!d.MM_p) {
            d.MM_p=new Array();
        }
        
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ 
            d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
        }
    }
}


function getElementGeneral(element) {
    if (document.getElementById) {
        return document.getElementById(element);
    } else if (document.all) {
        return document.all.element;
    }
}


/*
*	Countdown_bar Script - negativer fortschrittsbalken
*/
function countdown_bar(seconds, id, start)
{
	var seconds = seconds;
	var id = id;
	var start = start;
	
	var finished = false;
	var time;
	var doc;
	
	var x1 = start/seconds;
	var bar = Math.floor(100/x1);
	var bar2 = 100-bar;
	
    doc = document.getElementById(id);
    if (!doc) {
        return false;
    }
    
	seconds -= 1;
	
	if (seconds == 1) {
		time = "Zeit abgelaufen";
		finished = true;
	} else if(bar == 100) {
		time = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\" class=\"countdowntable\"><tr class=\"countdowntr\"><td><img src=\"img/design1/status/status_links_full.gif\"></td><td width=\""+bar+"\" background=\"img/design1/status/status_mitte_full.gif\"></td><td width=\""+bar2+"\" background=\"img/design1/status/status_mitte_empty.gif\"></td><td><img src=\"img/design1/status/status_rechts_full.gif\"></td></tr></table>";
	} else {
		time = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\" class=\"countdowntable\"><tr class=\"countdowntr\"><td><img src=\"img/design1/status/status_links_full.gif\"></td><td width=\""+bar+"\" background=\"img/design1/status/status_mitte_full.gif\"></td><td width=\""+bar2+"\" background=\"img/design1/status/status_mitte_empty.gif\"></td><td><img src=\"img/design1/status/status_rechts_empty.gif\"></td></tr></table>";
	}
	
    doc.innerHTML = time;
	if (finished != true) {
		setTimeout("countdown_bar('"+seconds+"','"+id+"','"+start+"')", 1000);
	} /*else {
		location.reload();
	}*/   
}


/*
*	Countdown Script zB zum Anzeigen der restlichen Ausbauzeit
*/
function countdown(seconds, id)
{
	//alert(total_secs);
	var total_secs = seconds;
	var days = Math.floor(total_secs/(60*60*24));
	var hours = Math.floor((total_secs/3600)%24);
	var mins = Math.floor((total_secs/60)%60);
	var secs = Math.floor(total_secs%60);
	var id = id;
	var finished = false;
	var time;
	var doc;
	
    doc = document.getElementById(id);
    if (!doc) {
        return false;
    }
    
	total_secs -= 1;
	
	if (hours <= 9 && hours > -1) hours = "0" + hours;
	if (mins <= 9 && mins > -1) mins = "0" + mins;
	if (secs <= 9 && secs > -1) secs = "0" + secs;
	
	if (days < 1 && hours < 1 && mins < 1 && secs < 1) {
		time="Zeit abgelaufen";
		finished=true;
	} else if(days < 1) {
		time = "<table class=\"countdowntable\"><tr class=\"countdowntr\"><td class=\"countdowntd\">"+ hours +" : </td><td class=\"countdowntd\">"+ mins +" : </td><td class=\"countdowntd\">" + secs +"</td></tr></table>";
	} else {
		time = "<table class=\"countdowntable\"><tr class=\"countdowntr\"><td class=\"countdowntd\">"+ days +" Tage </td><td class=\"countdowntd\">"+ hours +" : </td><td class=\"countdowntd\">" + mins +" : </td><td class=\"countdowntd\">" + secs +"</td></tr></table>";  
	}
	
	doc.innerHTML = time;
	
	if(finished != true)
	{
		setTimeout("countdown('"+total_secs+"','"+id+"')", 1000);
	}/* else {
		location.reload();
	}*/
}

function open_profil_by_id(id, oid)
{
	var id = id;
	var oid = oid;
	var profil;
	
	//profil = window.open('index.php?group=user&action=profil&user_id='+id+'&owner_id='+oid,'+id+','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=300');
	profil = window.open('index.php?group=user&module=spy&action=popup&user_id='+id+'','','menubar=no,toolbar=no,scrollbars=yes,status=no,resizable=no,width=550,height=400');
	profil.focus();
}

function open_login_tracker(id)
{
    var id = id;
    var show_logins;
    
    show_logins = window.open('index.php?module=search&action=fake&id='+id+'','login_tracker','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=500,height=400');
    show_logins.focus();
}

function popup()
{
	var window_id = window_id;
	var popmessage;
	
	popmessage = window.open('index.php?group=user&action=message','','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=200');
	popmessage.focus();
}

function value_mission()
{
    var valuewindow;
    
    valuewindow = window.open('index.php?group=user&module=main&action=value_mission','value_mission','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=250');
    valuewindow.focus();
}

function open_mail(mail_id, box)
{
    var box = box;
    var mail_id = mail_id;
	var window_id = mail_id;
	var popmail;
	
    if (box == 'gang' && mail_id > 0) {
        popmail = window.open('index.php?group=user&module=mail&action=join_gang&gang_id='+mail_id,window_id,'menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=400,height=400');
        if (popmail) {
            popmail.focus();
        }
    } else if (mail_id > 0) {
        popmail = window.open('index.php?group=user&module=mail&action=mail&'+box+'_mail_id='+mail_id,window_id,'menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=400,height=400');
        if (popmail) {
            popmail.focus();
        }
    } else {
        popmail = window.open('index.php?group=user&module=mail&action=search','','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=400,height=420');
        if (popmail) {
            popmail.focus();
        }
    }
}

function open_new_mail(user_name)
{
    var user_name = user_name;
	var window_id = user_name;
	var popmail;
	
    if (user_name) {
        popmail = window.open('index.php?group=user&module=mail&action=search&name='+user_name,user_name,'menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=400,height=370');
        if (popmail) {
            popmail.focus();
        }
    }
}

function open_dismiss_pic(user_id)
{
	var user_id = user_id;
	var popmessage;
	
	popmessage = window.open('index.php?group=user&action=dismiss_pic&user_id='+user_id,'','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=200');
    if (popmessage) {   
	   popmessage.focus();
    }
}

function open_admin_dismiss_pic(user_id)
{
	var user_id = user_id;
	var popmessage;
	
	popmessage = window.open('index.php?module=main&action=dismiss_pic&user_id='+user_id,'','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=200');
	if (popmessage) {   
       popmessage.focus();
    }
}

function chart(drug_id, position)
{
    var drug_id = drug_id;
    var position = position;
    var chartpopup;
    
    chartpopup = window.open('index.php?group=user&action=chart&drug='+drug_id+'&position='+position,'chart','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=420,height=220');
    chartpopup.focus();
}

function fight(id)
{
	var popmessage;
	popmessage = window.open('index.php?group=user&module=redlight&action=fight_news&id='+id,'','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=600,height=400');
	if (popmessage) {   
        popmessage.focus();
    }
}

function myround(num)
{
    return Math.round(num * Math.pow(10, 2))/Math.pow(10, 2);
}

function tank(cur_amount, car_or_plane)
{
    var car_or_plane = car_or_plane;
    var cur_amount = cur_amount;
    
    if(car_or_plane == 'car') {
        var max_amount = 100;
        if(cur_amount < max_amount) {
            cur_amount += 0.03;
        }
        var rest_amount = max_amount - cur_amount;
        var bar = cur_amount;
        cur_amount = myround(cur_amount);
    } else if (car_or_plane == 'plane') {
        var max_amount = 10000;
        if(cur_amount < max_amount) {
            cur_amount += 0.1;
        }
        var rest_amount = max_amount - cur_amount;
        var bar = Math.round(cur_amount/100);
        cur_amount = myround(cur_amount);
    }
    
    var finished = false;
    
    var bar2 = 100 - bar;

    if(cur_amount == max_amount) {
        finished = true;
    } else if(bar == 100) {
        time = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\" class=\"countdowntable\"><tr class=\"countdowntr\"><td><img src=\"img/design1/status/status_links_full.gif\"></td><td width=\""+bar+"\" background=\"img/design1/status/status_mitte_full.gif\"></td><td width=\""+bar2+"\" background=\"img/design1/status/status_mitte_empty.gif\"></td><td><img src=\"img/design1/status/status_rechts_full.gif\"></td></tr></table>";
    } else {
        time = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\" class=\"countdowntable\"><tr class=\"countdowntr\"><td><img src=\"img/design1/status/status_links_full.gif\"></td><td width=\""+bar+"\" background=\"img/design1/status/status_mitte_full.gif\"></td><td width=\""+bar2+"\" background=\"img/design1/status/status_mitte_empty.gif\"></td><td><img src=\"img/design1/status/status_rechts_empty.gif\"></td></tr></table>";
    }
    
    if(cur_amount % 1 == 0) {
        cur_amount = cur_amount +'.00';
        //alert(cur_amount);
    } else if (cur_amount*10 % 1 == 0) {
        cur_amount = cur_amount +'0';
        //alert(cur_amount);
    }
    
    cur_display = document.getElementById('amount');
    cur_display.innerHTML = cur_amount;
    
    tankbar = document.getElementById('bar');
    tankbar.innerHTML = time;
    
    if(finished != true) {
        setTimeout("tank("+cur_amount+",'"+car_or_plane+"')", 100);
    } /*else {
        location.reload();
    }*/
}

function open_fight_report_admin(fight_id)
{
    var fight_id = fight_id;
    
    var popmessage;
    popmessage = window.open('index.php?module=search&action=report_popup&fight_id='+fight_id,'kampfbericht','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=400');
    if (popmessage) {   
       popmessage.focus();
    }
}

function open_fight_report(fight_id)
{
	var fight_id = fight_id;
	
    var popmessage;
    popmessage = window.open('index.php?group=user&module=police&action=report&fight_id='+fight_id,'kampfbericht','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=500');
    if (popmessage) {   
       popmessage.focus();
    }
}

function open_tournament_report(match_id)
{
    var match_id = match_id;
    
    var popmessage;
    popmessage = window.open('index.php?group=user&module=police&action=report&match_id='+match_id,'kampfbericht','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=500');
    if (popmessage) {   
       popmessage.focus();
    }
}

function open_tournament_report_admin(match_id)
{
    var match_id = match_id;
    
    var popmessage;
    popmessage = window.open('index.php?module=tournaments&action=report&match_id='+match_id,'kampfbericht','menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=600,height=500');
    if (popmessage) {   
       popmessage.focus();
    }
}


function open_police(id)
{
	var id = id;
	var police;
	
	//profil = window.open('index.php?group=user&action=profil&user_id='+id+'&owner_id='+oid,'+id+','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=300');
	//duell = window.open('index.php?group=user&moule=redlight&action=duell&id='+id,'','menubar=no,toolbar=no,status=no,resizable=no,width=550,height=400');
	//duell.focus();
    window.location = 'index.php?group=user&module=police&action=fightdata&id='+id;
}

function open_duell_admin(id)
{
	var id = id;
	var duell;

    window.location = 'index.php?module=search&action=fightdata&id='+id;
}


function open_duell(id)
{
    var id = id;
    var duell;

    window.location = 'index.php?group=user&module=redlight&action=fightdata&id='+id;
}


function car_img(id)
{
	var popmessage;
	popmessage = window.open('index.php?module=cars&action=img_edit&id='+id,'','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=300,height=200');
	if (popmessage) {   
       popmessage.focus();
    }
}

function openPopup(url, wName, wWidth, wHeight) {
    var popup;
    popup = window.open(url, wName, 'menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width='+wWidth+',height='+wHeight);
    if (popup) {   
       popup.focus();
    }
}

function openGangMail(id)
{
    var id = id;
    var gangMail;
    gangMail = window.open('index.php?group=user&module=gangnew&action=mailpopup&mailId='+id,'gangMail','menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=400,height=300');
    if (gangMail) {   
       gangMail.focus();
    }
}