function confirmSubmit()
{
	var agree=confirm("Na pewno usunąć ten element?");
	if (agree)
			return true ;
	else
			return false ;

}

function show(dv)
{
	$("#"+dv).show("fast");
}
function hide(dv)
{
	$("#"+dv).hide("fast");
}

function rtoggle(dv)
{
	adiv=document.getElementById(dv);
	if (adiv.style.display!='none')
	{
		$("#menu217").hide("fast");
		$("#menu221").hide("fast");
		$("#menu225").hide("fast");
		$("#"+dv).hide("fast");
	}
	else
	{
		$("#menu217").hide("fast");
		$("#menu221").hide("fast");
		$("#menu225").hide("fast");
		$("#"+dv).show("fast");
	}
}
function toggle(dv)
{
	adiv=document.getElementById(dv);
	if (adiv.style.display!='none')
	{
		$("#"+dv).hide("fast");
//		adiv.style.display='none';
	}
	else
	{
		$("#"+dv).show("fast");
		//adiv.style.display='';
	}
}

function PrintContent()
{
      var DocumentContainer = document.getElementById('printContent');
      var WindowObject = window.open('', "TrackHistoryData",
      "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
      WindowObject.document.writeln(DocumentContainer.innerHTML);
      WindowObject.document.close();
      WindowObject.focus();
      WindowObject.print();
      WindowObject.close();
}

function showRegisterFields()
{
	$("#loginFields").hide("slow");
    $("#registerButton").hide();
	$("#registerFields").show();
}


function checkLogin()
{
	login=$("#regLogin")[0].value;
    $.ajax({
            method:"get",
            url:"templates/checkData.php",
            data:"login="+login,
            success: function(html)
           {
				$("#regLoginDiv")[0].innerHTML=html;
           }
    });
}

function loadStatic(pageName,targetDiv)
{
	if ($("#"+targetDiv)[0].style.display=='block')
	{
			$("#"+targetDiv).hide("fast");
	}
	else
	{
	$.ajax({
		method:"get",
		cache: false,
		url:"templates/static/"+pageName,
		success:function(html)
		{
			$("#"+targetDiv).html(html);
			$("#"+targetDiv).show("fast");
		}
	});
	}
}

function setContactBoxData(target,content)
{
    $("#contactBox").focus();
    $("#contactBox").click();
    if ($("#contactBox")[0].style.display=='block')
    {
            $("#contactBox").hide("fast");
    }
	else
	{
			if (content!="")
			{
				$("#wiadomosc").val(content);
			}
			if (target!="")
			{
				$('#cel').val(target);
			}
	}
}

function loadReq(pageName,targetDiv,internet,telefon,tv,dek)
{
	$("#contactBox").focus();
	$("#contactBox").click();
    if ($("#"+targetDiv)[0].style.display=='block')
    {
            $("#"+targetDiv).hide("fast");
    }
    else
    {
    $.ajax({
        method:"get",
        url:"templates/static/"+pageName,
        success:function(html)
        {
            $("#"+targetDiv).html(html);
            $("#"+targetDiv).show("fast");
		if (internet!="")
		{
			$('#kinternet').val(internet);
		}
		if (telefon!="")
		{
			$('#ktelefon').val(telefon);
		}
		if (tv!="")
		{
			$('#ktv').val(tv);
		}
		if (dek!="")
		{
			$('#kdekoder').val(dek);
		}
		if (tv=="0" || tv=="")
		{
			$('#kdekoder').val("0");
		}
		if ($("#npak").attr('checked') && rTV=="1") {$("#wiadomosc").html("Pakiet kanałów N");}
        }
    });
    }
}

function checkMail()
{
	mail=$("#regMail")[0].value;
    $.ajax({
            method:"get",
            url:"templates/checkData.php",
            data:"mail="+mail,
            success: function(html)
           {
				$("#regMailDiv")[0].innerHTML=html;
           }
    });
}

function checkRegisterData()
{
	pass=$("#regPassword")[0].value;
	pass2=$("#regPassword2")[0].value;
	ml=$("#regMail")[0].value;
	lg=$("#regLogin")[0].value;
	mail=$("#regMailDiv")[0].innerHTML;
	login=$("#regLoginDiv")[0].innerHTML;
	if (mail.search("ok.png")!="-1") {} else {return false;}
	if (login.search("ok.png")!="-1") {} else {return false;}
	if (pass=="" || pass2=="") {$("#resDiv")[0].innerHTML='<font color="red">Uzupełnij hasła</font>'; return false;}
	if (pass!=pass2) {$("#resDiv")[0].innerHTML='<font color="red">Podane hasła nie są takie same</font>'; return false;}
    if (ml=="") { $("#resDiv")[0].innerHTML='<font color="red">Uzupełnij adres email</font>'; return false;}
    if (lg=="") { $("#resDiv")[0].innerHTML='<font color="red">Uzupełnij login</font>'; return false;}

	return true;
}


