fadeColor = "#171274";  // color to fade to
fadeColorMenu = "#eeeeee";  // color to fade to in menu
stepIn = 17; // delay when fading in
stepOut = 25; // delay when fading out
autoFade = true;
sloppyClass = true;
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
//document.onmouseover = domouseover;
//document.onmouseout = domouseout;

fadeColor = dehexize(fadeColor.toLowerCase());
fadeColorMenu = dehexize(fadeColorMenu.toLowerCase());

var fadeId = new Array();

function gc_show_ajax() {
	return overlib(OLresponseAJAX,FULLHTML,OFFSETY,-10,STICKY,ABOVE,RIGHT,NOCLOSE,MOUSEOFF,TIMEOUT,10000,OFFDELAY,100);
}

function gc_show_ajax_js() {
	var response = OLresponseAJAX;
	//alert(response);
	var response1 = response.split("########")[0];
	//alert(response1);
	var response2 = response.split("########")[1];
	//alert(response2);
	overlib(response2,STICKY,ABOVE,RIGHT,OFFDELAY,500,CAPTION,'Sticky Popup');
	eval(response1);
	return true;
}


function dehexize(Color){
        var colorArr = new makearray(3);
        for (i=1; i<7; i++){
                for (j=0; j<16; j++){
                        if (Color.charAt(i) == hexa[j]){
                                if (i%2 !=0)
                                        colorArr[Math.floor((i-1)/2)]=eval(j)*16;
                                else
                                        colorArr[Math.floor((i-1)/2)]+=eval(j);
                        }
                }
        }
        return colorArr;
}

function domouseover() {
        if(document.all){
                var srcElement = event.srcElement;
                if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
                                if (!srcElement.startColor) {
                                        srcElement.startColor = (srcElement.style.color)? srcElement.style.color: srcElement.currentStyle.color;
                                        srcElement.startColor = dehexize(srcElement.startColor.toLowerCase());
                                }
                        if (srcElement.className == "menu") {
                                fade(srcElement.startColor,fadeColorMenu,srcElement.uniqueID,stepIn);
                        }
                        else {
                                fade(srcElement.startColor,fadeColor,srcElement.uniqueID,stepIn);
                        }
                }
        }
}

function domouseout() {
        if (document.all){
                var srcElement = event.srcElement;
                if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
                        if (srcElement.className == "menu") {
                                fade(fadeColorMenu,srcElement.startColor,srcElement.uniqueID,stepIn);
                        }
                        else {
                                fade(fadeColor,srcElement.startColor,srcElement.uniqueID,stepIn);
                        }
                }
        }
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e,element,step) {
        var sr = s[0]; var sg = s[1]; var sb = s[2];
        var er = e[0]; var eg = e[1]; var eb = e[2];

        if (fadeId[0] != null && fade[0] != element) {
                var orig = eval(fadeId[0]);
                setColor(orig.startColor[0],orig.startColor[1],orig.startColor[2],orig);
                var i = 1;
                while(i < fadeId.length) {
                        clearTimeout(fadeId[i]);
                        i++;
                }
        }

        for(var i = 0; i <= step; i++) {
                fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
                        step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
                        ")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
        }
        fadeId[0] = element;
}

function popUp(URL,fenster,width,height) {
        day = new Date();
        id = day.getTime();
        eval("page" + id + " = window.open(URL, '" + fenster + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left=1,top=1');");
        eval("if (page" + id + ") page" + id + ".focus();");
}

function popUpPic(URL) {
        var windowPIC = open("popup.pic.php?pic="+URL,'popUpPic','scrollbars=1,toolbar=no,location=no,directories=no,status=no,copyhistory=no,width=900,height=700,resizable=yes');
}
function popUpScreen(id,match) {
        var windowPIC = open("popup.screen.php?id="+id+"&match="+match,'popUpScreen','scrollbars=0,toolbar=no,location=no,directories=no,status=no,copyhistory=no,width=680,height=600,resizable=yes');
}

function countdownstart() {
        startdatum = new Date();
        countdownloop();
}

function countdownloop() {
        jetztdatum = new Date();
        diff = 300 - Math.floor((jetztdatum.getTime() - startdatum.getTime())/1000);
        if (diff >= 0) {
                setTimeout("countdownloop()", 1);
                if(document.getElementById('countdown'))
                   document.getElementById("countdown").innerHTML = diff;
        } else {
                if(document.getElementById('countdown'))
                   document.getElementById("countdown").innerHTML = "";
                if(document.getElementById('c1'))
                   document.getElementById("c1").innerHTML = "";
                if(document.getElementById('c2'))
                   document.getElementById("c2").innerHTML = "";
                alert("If you did not open a new window with Gamez-Club the past 5 minutes your session was expired for security reasons rigth now.");
        }
}

function calc() {
        m1s1=parseInt(document.all.m1s1.value);
        m2s1=parseInt(document.all.m2s1.value);
        m1s2=parseInt(document.all.m1s2.value);
        m2s2=parseInt(document.all.m2s2.value);
        if(isNaN(m1s1)) m1s1=0;
        if(isNaN(m2s1)) m2s1=0;
        if(isNaN(m1s2)) m1s2=0;
        if(isNaN(m2s2)) m2s2=0;
        document.all.m1s1.value=m1s1;
        document.all.m2s1.value=m2s1;
        document.all.m1s2.value=m1s2;
        document.all.m2s2.value=m2s2;
        document.all.meinAbsatz.innerHTML=m1s1+m2s1;
        document.all.deinAbsatz.innerHTML=m1s2+m2s2;
}

function news(id) {
        if (document.getElementById('news' + id).style.display == 'none') {
                document.getElementById('news'     + id).style.display = '';
                document.getElementById('newslink' + id).style.display = 'none';
        } else {
                document.getElementById('news'     + id).style.display = 'none';
                document.getElementById('newslink' + id).style.display = '';
        }
}


        var sel_start;
        var sel_end;
        
        function gimme_selection(area)
        {
        	var firefox = (navigator.userAgent.toLowerCase().indexOf('firefox')!=-1);
        	if (firefox)
                {
                	selection = area.value.substring(area.selectionStart,area.selectionEnd);
                }
                else
                {
	                //if (window.getSelection) {selection = window.getSelection();}
	                //   else if (document.getSelection) {selection = document.getSelection();}
	                selection = document.selection.createRange().text;
	                if (selection != '')
	                {
	                document.selection.createRange().text = 'inshere' + selection + 'fininshere';
	                sel_start = area.value.search(document.selection.createRange().text);
	                sel_end = sel_start + selection.length;  
	                document.selection.createRange().text = selection;
	                }
                }
           return selection;
        }
        
        function set_selection(area,text)
        {
        	var firefox = (navigator.userAgent.toLowerCase().indexOf('firefox')!=-1);
                	if (firefox)
                	{
                		area.value = area.value.substring(0,area.selectionStart) + text + area.value.substring(area.selectionEnd,area.value.length); 
                	}
                	else
                	{
                        area.value = area.value.substring(0,sel_start) + text + area.value.substring(sel_end,area.value.length);
                	}
        }
        
        function CodeX1(codecode,tail)
        {
                var area = document.getElementById('message1');
				//selection = gimme_selection(area);
                
                if (selection)
                {
                	set_selection(area,'[' + codecode + tail + ']' + selection + '[/' + codecode + ']');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '['+ codecode + tail + ']' + area.value + '[/'+ codecode + ']';
                        }
                        else
                        {
                                alert('Please write the text first and then press the buttons.');
                        }
                }
                area.focus();
                return true;
        }
        
        function Code1(codecode)
        {
                var area = document.getElementById('message1');
				selection = gimme_selection(area);
                
                if (selection)
                {
                	set_selection(area,'[' + codecode + ']' + selection + '[/' + codecode + ']');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '['+ codecode + ']' + area.value + '[/'+ codecode + ']';
                        }
                        else
                        {
                                alert('Please write the text first and then press the buttons.');
                        }
                }
                area.focus();
                return true;
        }

        function CodeFont1()
        {
                var area  = document.getElementById('message1');
                var color = document.getElementById('fontcolor1');
                
                selection = gimme_selection(area);
                if (selection)
                {
                        set_selection(area,'[#'+ color.value + ']' + selection + '[/#]');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '[#'+ color.value + ']' + area.value + '[/#]';
                        }
                        else
                        {
                                alert('Bitte erst Text schreiben, dann Buttons drücken.');
                        }
                }
                area.focus();
                color.value = '';
                return true;
        }

        function CodeFontSize1()
        {
                var area  = document.getElementById('message1');
                var size  = document.getElementById('fontsize1');
                selection = gimme_selection(area);
                if (selection)
                {
                        set_selection(area,'[size=' + size.value + ']' + selection + '[/size]');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '[size=' + size.value + ']' + area.value + '[/size]';
                        }
                        else
                        {
                                alert('Bitte erst Text schreiben, dann Buttons drücken.');
                        }
                }
                area.focus();
                size.value = '0';
                return true;
        }
        
        var sel_start;
        var sel_end;
        
        function gimme_selection(area)
        {
        	var firefox = (navigator.userAgent.toLowerCase().indexOf('firefox')!=-1);
        	if (firefox)
                {
                	selection = area.value.substring(area.selectionStart,area.selectionEnd);
                }
                else
                {
	                //if (window.getSelection) {selection = window.getSelection();}
	                //   else if (document.getSelection) {selection = document.getSelection();}
	                selection = document.selection.createRange().text;
	                if (selection != '')
	                {
	                document.selection.createRange().text = 'inshere' + selection + 'fininshere';
	                sel_start = area.value.search(document.selection.createRange().text);
	                sel_end = sel_start + selection.length;  
	                document.selection.createRange().text = selection;
	                }
                }
           return selection;
        }
        
        function set_selection(area,text)
        {
        	var firefox = (navigator.userAgent.toLowerCase().indexOf('firefox')!=-1);
                	if (firefox)
                	{
                		area.value = area.value.substring(0,area.selectionStart) + text + area.value.substring(area.selectionEnd,area.value.length); 
                	}
                	else
                	{
                        area.value = area.value.substring(0,sel_start) + text + area.value.substring(sel_end,area.value.length);
                	}
        }
        
        function CodeX2(codecode,tail)
        {
                var area = document.getElementById('message2');
				//selection = gimme_selection(area);
                
                if (selection)
                {
                	set_selection(area,'[' + codecode + tail + ']' + selection + '[/' + codecode + ']');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '['+ codecode + tail + ']' + area.value + '[/'+ codecode + ']';
                        }
                        else
                        {
                                alert('Please write the text first and then press the buttons.');
                        }
                }
                area.focus();
                return true;
        }
        
        function Code2(codecode)
        {
                var area = document.getElementById('message2');
				selection = gimme_selection(area);
                
                if (selection)
                {
                	set_selection(area,'[' + codecode + ']' + selection + '[/' + codecode + ']');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '['+ codecode + ']' + area.value + '[/'+ codecode + ']';
                        }
                        else
                        {
                                alert('Please write the text first and then press the buttons.');
                        }
                }
                area.focus();
                return true;
        }

        function CodeFont2()
        {
                var area  = document.getElementById('message2');
                var color = document.getElementById('fontcolor2');
                
                selection = gimme_selection(area);
                if (selection)
                {
                        set_selection(area,'[#'+ color.value + ']' + selection + '[/#]');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '[#'+ color.value + ']' + area.value + '[/#]';
                        }
                        else
                        {
                                alert('Bitte erst Text schreiben, dann Buttons drücken.');
                        }
                }
                area.focus();
                color.value = '';
                return true;
        }

        function CodeFontSize2()
        {
                var area  = document.getElementById('message2');
                var size  = document.getElementById('fontsize2');
                selection = gimme_selection(area);
                if (selection)
                {
                        set_selection(area,'[size=' + size.value + ']' + selection + '[/size]');
                }
                else
                {
                        if (area.value)
                        {
                                area.value = '[size=' + size.value + ']' + area.value + '[/size]';
                        }
                        else
                        {
                                alert('Bitte erst Text schreiben, dann Buttons drücken.');
                        }
                }
                area.focus();
                size.value = '0';
                return true;
        }
        