var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
    var xmlHttp;
    try
    {
        xmlHttp = new XMLHttpRequest();
    }
    catch(e)
    {
        var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP');
        for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
        {
            try
            {
                xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
            }
            catch(e) {}
        }
    }
    if(xmlHttp){
        return xmlHttp;
    }
}

function invalidLogin(){
	$("login").style.borderColor='#B57575';
	$("password").style.borderColor='#B57575';
}

function pass_power()
{
    var source = $("reg_pass").value;
    var cel = $("reg_pass");
		var pkt   = 0;
		
		if (source.length<5)
		{
			pkt = (pkt+3);
		}
		else if (source.length>4 && source.length<8)
		{
			pkt = (pkt+6);
		}
		else if (source.length>7 && source.length<16)
		{
			pkt = (pkt+12);
		}
		else if (source.length>15)
		{
			pkt = (pkt+18);
		}
		
		if (source.match(/[a-z]/))
		{
			pkt = (pkt+1);
		}
		
		if (source.match(/[A-Z]/))
		{
			pkt = (pkt+5);
		}
		if (source.match(/\d+/))
		{
			pkt = (pkt+5);
		}
		
		if (source.match(/(.*[0-9].*[0-9].*[0-9])/))
		{
			pkt = (pkt+5);
		}
		
		
		if (source.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
		{
			pkt = (pkt+5);
		}
		if (source.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			pkt = (pkt+5);
		}
	
		if (source.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
		{
			pkt = (pkt+2);
		}

		if (source.match(/([a-zA-Z])/) && source.match(/([0-9])/))
		{
			pkt = (pkt+2);
		}

		if (source.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			pkt = (pkt+2);
		}
	        if(source.length>5){
		if (pkt < 16)
		{
		   cel.style.borderColor='#B57575';
		}
		else if (pkt > 15 && pkt < 25)
		{
		   cel.style.borderColor='#d3c056';
		}
		else if (pkt > 34)
		{
		   cel.style.borderColor='#7DB575';
		}
		}else{
                   cel.style.borderColor='#BBBBBB';
                }
}

function checkPass(id)
{
    var pass1 = $("reg_pass").value;
    var pass2 = $("reg_pass2").value;
    var cel = $("reg_pass2");
    if(pass1 != pass2){
        cel.style.borderColor='#B57575';
    }else{
        cel.style.borderColor='#7DB575';
    }
}

function register()
{
    var login = $("reg_login").value;
    var pass = $("reg_pass").value;
    var pass2 = $("reg_pass2").value;
    var email = $("reg_email").value;
    var txt_login = $("reg_login");
    var txt_pass2 = $("reg_pass2");
    var txt_email = $("reg_email");
    if($("accept").className=='uncheckedBox'){
	    var accept = 0;
    }else{
	    var accept = 1;
    }
    if(accept == 1 && login.length > 3 && pass.length >3 && pass2 == pass && email.length > 5){
    if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "login=" + enco(login) + "&email=" + enco(email) + "&pass=" + enco(pass) + "&pass2=" + enco(pass2) + "&sid=" + Math.random();
        xmlHttp.open("POST", "register2", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
		$("msg_reg").innerHTML=FOLang['WAIT'];
            }
            if(xmlHttp.readyState == 2){
		    $("msg_reg").innerHTML='';
            }
            if(xmlHttp.readyState == 4)
            {
                var dane = xmlHttp.responseText;
               if(dane == '123'){
                   //wszystko zle
                   txt_login.style.borderColor='#B57575';
                   txt_pass2.style.borderColor='#B57575';
                   txt_email.style.borderColor='#B57575';
               }else if(dane == '12'){
                   // login i email
                   txt_login.style.borderColor='#B57575';
                   txt_email.style.borderColor='#B57575';
               }else if(dane == '1'){
                   // login
                   txt_login.style.borderColor='#B57575';
               }else if(dane == '23'){
                   // email i passy
                   txt_email.style.borderColor='#B57575';
                   txt_pass2.style.borderColor='#B57575';
                   cel.innerHTML = fail;
               }else if(dane == '2'){
                   // email
                   txt_email.style.borderColor='#B57575';
               }else if(dane == '13'){
                   // login i pasy
                   txt_pass2.style.borderColor='#B57575';
                   txt_login.style.borderColor='#B57575';
                   cel.innerHTML = fail;
               }else if(dane == '3'){
                   // pasy
                   txt_pass2.style.borderColor='#B57575';
               }else{
                   // wszystko dobrze
                   GoTo('activation');
		   //GoTo('news');
               }

               }
               }
}
  xmlHttp.send(param); }
    }
}

function openWind(what,id,w){
	if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "id=" + id + "&w=" + w + "&sid=" + Math.random();
        xmlHttp.open("POST", "hit", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
		    window.open(what);
               }
               }
}
  xmlHttp.send(param); }
	
}

function change_sth(w){
	if(w == 1){
		// haslo
		var d=0;
		var newS = $("newpass").value; var newS2 = $("newpass2").value; var old = $("oldpass").value;
		if(newS != newS2){
			alert(FOLang['DIFF_PASS']);
		}else if(newS == newS2 && old == ''){
			alert(FOLang['ENTER_OLD_PASS']);
		}else{
			var d = 1;
		}
	}else{
		//email
		var d=0;
		var newS = $("newemail").value; var newS2 = $("newemail2").value; var old = $("curpass").value; 
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(newS) && newS.length > 5){
		if(newS != newS2){
			alert(FOLang['DIFF_EMAIL']);
		}else if(newS == newS2 && old == ''){
			alert(FOLang['ENTER_CURR_PASS']);
		}else{
			var d = 1;
		}
		}else{
			alert(FOLang['INVALID_EMAIL']);
		}
		
	}
	   if(xmlHttp && d == 1) // dostep
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "old=" + enco(old) + "&new=" + enco(newS) + "&w=" + enco(w) + "&sid=" + Math.random();
        xmlHttp.open("POST", "ch_pass", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
         if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                var dane = xmlHttp.responseText;
                if(dane == '1'){
               	alert(FOLang['OPERATION_COMPLETED']);
               }else{
               	alert(FOLang['INVALID_PASS']);
               }
               }
               }
}
  xmlHttp.send(param); }
}

function activation()
{
    var source = $("act_code").value;
    var cel = $("act_code");
    if(source == ''){
        cel.style.borderColor='#B57575';
    }else{
        if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "code=" + source + "&sid=" + Math.random();
        xmlHttp.open("POST", "activation2", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
         if(xmlHttp.readyState == 1 || 0){
		$("msg_reg").innerHTML=FOLang['WAIT'];
            }
            if(xmlHttp.readyState == 2){
		    $("msg_reg").innerHTML='';
            }
            if(xmlHttp.readyState == 4)
            {
                var dane = xmlHttp.responseText;
                
                if(dane == '1'){
                   cel.style.borderColor='#B57575';
                }else if(dane == '2'){
                   cel.style.borderColor='#B57575';
                }else{
                    cel.style.borderColor='#7DB575';
                   GoTo('news');
                }

               }
               }
}
  xmlHttp.send(param); }
    }
}

function init(){
	var i = 2;
	t = setTimeout(function(){ startFlash(i);},timeout);
	
}
function $(id)
{
	if(document.getElementById) return document.getElementById(id);
}

function enco(str)
{
	return encodeURIComponent(str);
}

var t;
function startFlash(i){
	if(i == '' || i == 6){
		var i = 1;
	}else if(i < 0){
		var i = 6;
	}
	$("flash_1_").style.backgroundImage='url('+img_flash[i-1]+')';
	$("title_flash").innerHTML=title_flash[i-1];
	$("flash_1_").className='fla_'+i;
	i++;
	t = setTimeout(function(){ startFlash(i);},timeout);
}

function goByFlash(){
	var s = getSelected();
	GoTo('news:'+ident_flash[s-1]);
}

function getSelected(){
	var to = $("flash_1_").className;
	var d = parseInt(to.slice(4));
	return d;
}
function goFlash(y){
	clearTimeout(t);
	var i = getSelected();
	if(y > 0){
		startFlash(i+1);
	}else{
		if(i == 1){
			$("flash_1_").style.backgroundImage='url('+img_flash[4]+')';
			$("title_flash").innerHTML=title_flash[4];
			$("flash_1_").className='fla_5';
			t = setTimeout(function(){ startFlash(i);},timeout);
		}else{
			startFlash(i-1);
		}
	}
}

function changeCheckBox(id)
{
	if($(id).className=='uncheckedBox'){
		$(id).className='checkedBox';
	}else{
		$(id).className='uncheckedBox';
	}
}

function chLang(lang){
	document.cookie='lang='+lang;
	refresh();
}

function refresh(){
	return window.location.reload();
}

function loguj()
{
     if(xmlHttp)
    {
        var cel = $("user");
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var login = $("login").value;
        var password = $("password").value;
	if($("remeberBox").className=='uncheckedBox'){
		var r = 0;
	}else{
		var r = 1;
	}
	var param = "login=" + enco(login) + "&password=" + enco(password) + "&r=" + r + "&sid=" + Math.random();
        xmlHttp.open("POST", "loguj", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 4)
            {
		    if(xmlHttp.responseText != 'false'){
			   refresh();
		    }else{
			    //blad
			    invalidLogin();
		    }
               }
               }
            }
  xmlHttp.send(param); 
} 
}

function wyloguj()
{
    document.cookie='fo_log=0';
    document.cookie='fo_log2=0';
    GoTo('news');
}

function radioCheck(x,max)
{
    var all = x.split("_");
    for(var i=1;i<=max;i++){
	    $("an_"+all[1]+"_"+i).className='radioUn';
    }
    $(x).className='radioChecked';
}

function reply(id)
{
	var tit = $("sub_"+id).innerHTML;
	var aut = $("autor_"+id).innerHTML;
	$("receiver").value=aut;
	$("prv_msg_title").value='RE:'+tit;
	//$("content_prv_msg").value='';
}

function edit_msg(id)
{
	$("me_for").innerHTML =id;
	var tit = $("sub_"+id).innerHTML;
	var aut = $("autor_"+id).innerHTML;
	var cont = $("cont_"+id).innerHTML;
	$("receiver").value=aut;
	$("prv_msg_title").value=tit;
	$("content_prv_msg").innerHTML=cont;
}

function send_prv_msg(id)
{
    var content = $("content_prv_msg").value;
    var receiver = $("receiver").value;
    var subject = $("prv_msg_title").value;
    var ta = 0;
    if(subject == ''){
	    $("prv_msg_title").style.borderColor='#B57575';
	    var ta = 1;
    }
    if(receiver == ''){
	    $("receiver").style.borderColor='#B57575';
	    var ta = 1;
    }
    var hid = $("me_for").innerHTML;
     if(xmlHttp && ta != 1)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "pm=" + enco(id) + "&prv_msg_title=" + enco(subject) + "&content_prv_msg=" + enco(content) + "&receiver=" + enco(receiver) + "&co=" + enco(hid) + "&sid=" + Math.random();
        xmlHttp.open("POST", "prv_msg_send", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                if(id == 1){
                   GoTo('pm:2');
		}else{
                       GoTo('pm:3');
                   }
               }
               }
}
  xmlHttp.send(param); } 
}

function friend(w, id)
{
       if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "w=" + enco(w) + "&id=" + enco(id) + "&sid=" + Math.random();
        xmlHttp.open("POST", "friends", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();

               }
               }
}
  xmlHttp.send(param); }
}

function getSelFrien(max){
	for(var i=0;i<=max;i++){
		if($("friend_"+i).style.display=='block'){
			var sel = i;
		}
	}
	return sel;
}

function moveF(w,max){
	var zaz = getSelFrien(max);
	if(w > 0){
		var next = zaz +1;
		$("friend_"+next).style.display='block';
		$("friend_"+zaz).style.display='none';
		if(next == max){
			$("friend_right").style.display='none';
			$("friend_left").style.display='block';
		}
	}else{
		var back = zaz -1;
		$("friend_"+back).style.display='block';
		$("friend_"+zaz).style.display='none';
		if(back == 0){
			$("friend_right").style.display='block';
			$("friend_left").style.display='none';
		}
	}
}

function change_status_msg(id)
{
	 if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "pm=" + enco(id) + "&sid=" + Math.random();
        xmlHttp.open("POST", "change_status_msg", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   $("sub_"+id).style.fontWeight='normal';
               }
               }
}
  xmlHttp.send(param); }
}

function glosuj(id,max)
{
	var cel = $("cont_562");
	for(var i=1;i<=max;i++){
		if($("an_"+id+"_"+i).className=='radioChecked'){
			var odp = i;
		}
	}
	if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        xmlHttp.open("GET", "glosuj?id=" + enco(id) + "&odp=" + enco(odp) + "&sid=" + Math.random(), false);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                refresh();
                
               }
               }
}
  xmlHttp.send(null); }
    
    
}

function showDetails(id)
{
    if($("detal_"+id).style.display == 'none'){
        $("detal_"+id).style.display='';
    }else{
          $("detal_"+id).style.display='none';
    }
}

function showDetail(id)
{
    if($("detal_"+id).style.display == 'none'){
        $("detal_"+id).style.display='block';
    }else{
          $("detal_"+id).style.display='none';
    }
}

function send_edit_blog(id)
{
    var content = $("content_edit_blog_"+id).value;
    var subject = $("blog_title_"+id).value;
     if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "blog_title=" + enco(subject) + "&content_edit_blog=" + enco(content) + "&blog_id=" + enco(id)  + "&sid=" + Math.random();
        xmlHttp.open("POST", "edit_blog", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                refresh();
                
               }
               }
}
  xmlHttp.send(param); } }
  
function delete_blog(id)
{
    var del=confirm(FOLang['CONFIRM_DEL'])
    if (del==true){
     if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "id=" + enco(id) + "&sid=" + Math.random();
        xmlHttp.open("POST", "delete_blog", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
         xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                refresh();
                
               }
               }
}
  xmlHttp.send(param); }
  }
}

function send_new_blog()
{
    var content = $("content_new_blog").value;
    var subject = $("blog_title").value;
     if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "blog_title=" + enco(subject) + "&content_new_blog=" + enco(content) + "&sid=" + Math.random();
        xmlHttp.open("POST", "new_blog_send", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                refresh();
               }
               }
}
  xmlHttp.send(param); } }
  
function radioPlec(x)
{
	var dan = x.split("_", 2);
	
	$(x).className='radioChecked';
	if(dan[1] == 0){
		$(dan[0]+"_1").className='radioUn';
	}else{
		$(dan[0]+"_0").className='radioUn';
	}
}

function set_norm()
{
	var lok = $("lokalizacja").value;var imie = $("imie_set").value;var nazwisko = $("nazwisko_set").value;var ur_set = $("ur_set").value;
	var pl0 = $("plec_0");var pl1 = $("plec_1");var gg = $("gg_set").value;
	if(pl0.className == 'radioChecked'){
		var plec = 0;
	}else{
		var plec = 1;
	}
	if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "plec=" + enco(plec) + "&lok=" + enco(lok) + "&imie=" + enco(imie) + "&nazwisko=" + enco(nazwisko) + "&ur_set=" + enco(ur_set) + "&gg_set=" + enco(gg) + "&sid=" + Math.random();
        xmlHttp.open("POST", "set_norm", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();

               }
               }
}
  xmlHttp.send(param); }
}

function set_aa()
{
	var tracker = $("tracker_set").value;
	if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "tracker=" + enco(tracker) + "&sid=" + Math.random();
        xmlHttp.open("POST", "set_aa", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();

               }
               }
}
  xmlHttp.send(param); }
}

function set_conf()
{
	var limit = $("limit_com").value;
	var style = $("style_com").value;
	if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "limit_com=" + enco(limit) + "&style=" + style + "&sid=" + Math.random();
        xmlHttp.open("POST", "set_conf", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();

               }
               }
}
  xmlHttp.send(param); }
}

function set_adv()
{
   if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var cpu = $("procesor_set").value;var gfx = $("kartagraf_set").value;var monitor = $("monitor_set").value;var mouse = $("myszka_set").value;var headphones = $("sluchawki_set").value;var player = $("gracz_set").value;var music = $("muzyka_set").value;var book = $("ksiazka_set").value;var sport = $("sport_set").value;
        var motherboard = $("plytagl_set").value;var memory = $("pamiecram_set").value;var hardware = $("dysk_set").value;var mousepad = $("podkladka_set").value;var hobby = $("hobby_set").value;var team = $("klan_set").value;var movie = $("film_set").value;var car = $("samochod_set").value;var meal = $("potrawa_set").value;
        var param = "cpu=" + enco(cpu) + "&gfx=" + enco(gfx) + "&monitor=" + enco(monitor) + "&mouse=" + enco(mouse) + "&headphones=" + enco(headphones) + "&player=" + enco(player) + "&music=" + enco(music) + "&book=" + enco(book) + "&sport=" + enco(sport) + "&motherboard=" + enco(motherboard) + "&memory=" + enco(memory) + "&hardware=" + enco(hardware) + "&mousepad=" + enco(mousepad) + "&hobby=" + enco(hobby) + "&team=" + enco(team) + "&movie=" + enco(movie) + "&car=" + enco(car) + "&meal=" + enco(meal) + "&sid=" + Math.random();
        xmlHttp.open("POST", "set_adv", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();

               }
               }
}
  xmlHttp.send(param); }
}

function delete_prv_msg(id)
{
    var del=confirm(FOLang['CONFIRM_DEL'])
    if (del==true){
     if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "id=" + enco(id) + "&sid=" + Math.random();
        xmlHttp.open("POST", "delete_prv_msg", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                refresh();
                
               }
               }
}
  xmlHttp.send(param); }
  }
}

function add_comment(com, w)
{
    var tresc = $("content_com").value;
    if(tresc != ''){
    if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "w=" + enco(w) + "&tresc=" + enco(tresc) + "&gb=" + enco(com) + "&sid=" + Math.random();
        xmlHttp.open("POST", "add_comment", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();
               }
               }
  xmlHttp.send(param);} }
    }
}

function add_propos()
{
	if($("link") != ''){
		alert(FOLang['THANKS_PROPOSITION']);
	}
}
function ch_lig(id){
	var val = $("ch_lig").value;
	GoTo('matches:'+id+':'+val);
}

function ch_liga(id){
	var val = $("ch_lig").value;
	GoTo('bets:'+id+':'+val);
}

function ch_ligs(id,p){
	var val = $("ch_lig").value;
	GoTo('bets2:'+p+':'+id+':'+val);
}

function moveSB(w,max){
	if(w < 0){
		if($("sb_c2").style.display=='block'){
			$("sb_c1").style.display='block';
			$("sb_c2").style.display='none';
			$("sb_arr_1").style.display='none';
		}else{
			$("sb_c2").style.display='block';
			$("sb_c3").style.display='none';
			$("sb_arr_1").style.display='';
			$("sb_arr_2").style.display='';
		}
	}else{
		if($("sb_c2").style.display=='block'){
			$("sb_c2").style.display='none';
			$("sb_c3").style.display='block';
			$("sb_arr_2").style.display='none';
			$("sb_arr_1").style.display='';
		}else{
			$("sb_c2").style.display='block';
			$("sb_c1").style.display='none';
			$("sb_arr_2").style.display='';
			$("sb_arr_1").style.display='';
		}
	}
}

function quote(id,m)
{
    var cel = $("content_com");
    var source = $("src_"+id);
    var all = source.innerHTML;
    var all = all.replace(/&gt;/, ">");
    var all = all.replace(/&lt;/, "<");
    var all = all.replace(/<br>/,"\n");
    cel.value += '[quote='+m+']'+all+'[/quote]\n';
}

function edit(id)
{
	if($("edit_"+id).style.display=='none'){
		$("edit_"+id).style.display='block';
	}else{
		$("edit_"+id).style.display='none';
	}
}

function edit_comment(gb,id,w)
{
    var tresc = $("edit_cont_"+gb).value;
    if(tresc != ''){
    if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "w=" + enco(w) + "&tresc=" + enco(tresc) + "&gb=" + enco(id) + "&sid=" + Math.random();
        xmlHttp.open("POST", "edit_comment", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
                   refresh();
               }
               }
  xmlHttp.send(param);} }
  }
}

function checkLogin(id)
{
     var login = $("reg_login").value;
     var cel = $("reg_login");
     if(login.length >= 3){
     if(xmlHttp)
    {
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {
        var param = "login=" + enco(login) + "&sid=" + Math.random();
        xmlHttp.open("POST", "check_login", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 4)
            {
                if(xmlHttp.responseText == '1'){
                      cel.style.borderColor='#B57575';
                }else{
                    cel.style.borderColor='#7DB575';
                }
               }
               }
}
  xmlHttp.send(param);
  }
     }else if(login.length == 0){
	     cel.style.borderColor='#BBBBBB';
  }else{
       cel.style.borderColor='#B57575';
  }
}

function checkEmail(id)
{
	var source = $("reg_email").value;
	var cel = $("reg_email");
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(source) && source != '' && source.length > 5){
              cel.style.borderColor='#7DB575';
	}else if(source.length == 0){
		cel.style.borderColor='#BBBBBB';
        }else{
             cel.style.borderColor='#B57575';
        }
}

function inputFocus(to){
	to.style.borderColor='#a8a8a8';
}
function inputBlur(to){
	to.style.borderColor='#bbbbbb';
}

function search()
{
	var s = $("search_input").value;
	if(s != ''){
	GoTo("search:"+s);
	}
}

function bet_rate(ad1, ad2, ad3)
{
    var m = $("kwota_bet").value;
    var cel = $("new_rate");
    if($("bet_1").className=='radioChecked') {
        var odp = 1;
        var ad = ad1;
    }else if($("bet_2").className=='radioChecked'){
        var odp = 2;
        var ad = ad2;
    }else if($("bet_3").className=='radioChecked'){
        var odp = 3;
        var ad = ad3;
    }else{
        var odp = 0;
        var ad = 0;
    }
        var rate = (ad * m);
	var rate = rate.toFixed(2);
        if(isNaN(rate)){
            rate = 0.00;
        }
        cel.innerHTML = "&euro;"+rate;
}

function checkRadio(x, k)
{
    $(x).className='radioChecked';
    var m = $("kwota_bet").value;
    var cel = $("new_rate");
    var dane = x.split("_",2);
    switch(dane[1]){
        case "1":
        $("bet_2").className='radioUn';
        $("bet_3").className='radioUn';
        break
        case "2":
        $("bet_1").className='radioUn';
        $("bet_3").className='radioUn';
        break
        case "3":
        $("bet_1").className='radioUn';
        $("bet_2").className='radioUn';
        break
    }
    var rate = (k * m);
    var rate = rate.toFixed(2);
        if(isNaN(rate)){
            rate = 0.00;
        }
        cel.innerHTML = "&euro;"+rate;
    
}

function check_bet()
{
	var bet1 = $("bet_1");
	var bet2 = $("bet_2");
	var bet3 = $("bet_3");
	if(bet1.className == 'radioChecked'){
		var o = 1;
	}else if(bet2.className == 'radioChecked'){
		var o = 2;
	}else if(bet3.className == 'radioChecked'){
		var o = 3;
	}else{
		var o = 0;
	}
	return o;
}

function bet(id, m)
{
	var cel2 = $("bet_button");
	var cel = $("kwota_bet");
	var kwota = $("kwota_bet").value;
	var o = check_bet();
	if(o != 0){
	if(kwota != '' && Number(kwota) && kwota <= m && kwota > 1){
	if(xmlHttp)
	{
        if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
        {

        var param = "id="  + enco(id) + "&kwota="  + enco(kwota) + "&o="  + enco(o) + "&sid=" + Math.random();
        xmlHttp.open("POST", "bet", true);
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", param.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.onreadystatechange = function()
        {
        if(xmlHttp.readyState == 1 || 0){
            }
            if(xmlHttp.readyState == 2){
            }
            if(xmlHttp.readyState == 4)
            {
		    cel.style.borderColor='#BBBBBB';
                   refresh();
               }
               }
	}
	xmlHttp.send(param); }
	}else if(kwota > m){
		cel.style.borderColor='#B57575'; // nie masz tyle kasy
	}else if(kwota < 1){
		cel.style.borderColor='#B57575';   //  'Minimalna stawka to 1 PLN';
	}else{
		cel.style.borderColor='#B57575';
	}
	}else{
		alert(FOLang['CHOOSE_TEAM']);
	}
}

function GoTo(id)
{
    window.location.href='/' + id;
}
