function showSelected()
{
    return $("#region").multiselect("getChecked");
}

function showSelected2()
{
    return $("#specification").multiselect("getChecked");
}

function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}

function addSelectElements(id)
{
    $("#region option").each(function(){
        if($(this).val()==id)
        {
            var el;
            for(var i=allDistricts[id].length-1;i>=0;i--)
            {
                el=document.createElement("option");
                el.setAttribute("value", allDistricts[id][i]);
                el.innerHTML="  "+allDistrictsName[id][i];
                $(el).insertAfter(this);
            }
            $(this).attr("selected", "selected");
        }
    });
    $("#region").multiselect("refresh");
}

function addSelectElements2(id)
{
    $("#region option").each(function(){
        if($(this).val()==id)
        {
            var el;
            for(var i=allDistricts[id].length-1;i>=0;i--)
            {
                el=document.createElement("option");
                el.setAttribute("value", allDistricts[id][i]);
                el.setAttribute("selected", "selected");
                el.innerHTML="&nbsp;"+allDistrictsName[id][i];
                $(el).insertAfter(this);
            }
            $(this).attr("selected", "selected");
        }
    });
    $("#region").multiselect("refresh");
}

function removeSelectElements(id)
{
    $("#region option").each(function(){
        if($(this).val() in oc(allDistricts[id]))
        {
            $(this).remove();
        }
        if($(this).val()==id)
        {
            $(this).removeAttr("selected");
        }
    });
    $("#region").multiselect("refresh");
}

function removeSelectElementsAll()
{
    $("#region option").each(function(){
        if($(this).val().charAt(0)=='_')
        {
            $(this).remove();
        }
    });
    $("#region").multiselect("refresh");
}

function addSelectElementsAll()
{
    removeSelectElementsAll();
    for(var i=0;i<allRegions.length;i++)
    {
        addSelectElements2(allRegions[i]);
    }
}

function priceFormat(price)
{
	var str=$(price).val().replace(/\./g,"");
	if(str.length>3 && str.length<=6)
	{
		str=str.slice(0,(str.length-3))+"."+str.slice(-3);
	}
	else if(str.length>6)
	{
		str=str.slice(0,(str.length-6))+"."+str.slice(-6,-3)+"."+str.slice(-3);
	}
	$(price).val(str);
}

function telephoneFormat(tel)
{
	var str=$(tel).val().replace(/ /g,"");
	if(str.length>3 && str.length<=6)
	{
		str=str.slice(0,(str.length-3))+" "+str.slice(-3);
	}
	else if(str.length>6)
	{
		str=str.slice(0,(str.length-6))+" "+str.slice(-6,-3)+" "+str.slice(-3);
	}
	$(tel).val(str);
}

function disableSelect()
{
	$("select[name='subcategory'] option[value='']").attr("selected", true);
	$('#specification').attr('disabled', 'disabled');
}

function enableSelect()
{
	$('#specification').removeAttr('disabled');
}

function controlSelect(value)
{
	if(value==0)
	{
		$("#specification").load("/C/AJAX/form.php", {idCategory: value},function(){
                   $("#specification").multiselect("refresh");
                   $("#specification").multiselect("uncheckAll");
                   $("#specification").multiselect("disable");
                });
                $("#specification").multiselect("uncheckAll");
	}
	else
	{
		$("#specification").load("/C/AJAX/form.php", {idCategory: value},function(){
                   $("#specification").multiselect("refresh");
                   $("#specification").multiselect("uncheckAll"); 
                   $("#specification").multiselect("enable");
                });            
	}
}

function controlSelect2(value)
{
	switch(value)
	{
		case 1:/*
			$.get("C/AJAX/form3.php", { idSubcat: 1,name: "Dispozice bytu" }, function(data){
			$('#specialAttributes').html(data + '<div class="pvyhledavani3"><div class="pv_1a">Vlastnictví:</div><div class="pv_3b"><select name="ownership" class="pv_select_delka"><option value="" selected="selected">---</option><option value="1">osobní</option><option value="2">družstevní</option><option value="0">jiné</option></select></div><div class="pv_1a">Konstrukce budovy:</div><div class="pv_3b"><select name="buildingType" class="pv_select_delka"><option value="" selected="selected">---</option><option value="2">cihlová</option><option value="1">dřevostavba</option><option value="5">panelová</option><option value="0">jiné</option></select></div></div><div class="pvyhledavani3"><div class="pv_1a">Podlahová plocha od - do:</div><div class="pv_4b"><input name="usableAreaMin" type="text" class="pv_select_delka"> - <input name="usableAreaMax" type="text" class="pv_select_delka">m2</div></div>');});
			break;*/
                        $.get("C/AJAX/form4.php", {idSubcat: 1,name: "Dispozice bytu"}, function(data){
			$('#specialAttributes').html(data + '<div class="pvyhledavani3"><div class="pv_1a">Vlastnictví:</div><div class="pv_3b"><select name="ownership" class="pv_select_delka"><option value="" selected="selected">---</option><option value="1">osobní</option><option value="2">družstevní</option><option value="0">jiné</option></select></div><div class="pv_1a">Konstrukce budovy:</div><div class="pv_3b"><select name="buildingType" class="pv_select_delka"><option value="" selected="selected">---</option><option value="2">cihlová</option><option value="1">dřevostavba</option><option value="5">panelová</option><option value="0">jiné</option></select></div></div><div class="pvyhledavani3"><div class="pv_1a">Podlahová plocha od - do:</div><div class="pv_4b"><input name="usableAreaMin" type="text" class="pv_select_delka"> - <input name="usableAreaMax" type="text" class="pv_select_delka">m2</div></div>');});
			break;
		case 2:
			$('#specialAttributes').html('<div class="pvyhledavani3"><div class="pv_1a">Užitná plocha od - do:</div><div class="pv_4b"><input name="usableAreaMin" type="text" class="pv_select_delka"> - <input name="usableAreaMax" type="text" class="pv_select_delka">m2</div></div>');
			break;
		case 4:
			/*$.get("C/AJAX/form3.php", {idSubcat: 4,name: "Využití"}, function(data){
			$('#specialAttributes').html(data + '<div class="pvyhledavani3"><div class="pv_1a">Plocha pozemku od - do:</div><div class="pv_4b"><input name="usableAreaMin" type="text" class="pv_select_delka"> - <input name="usableAreaMax" type="text" class="pv_select_delka">m2</div></div>');});
			break;*/
                        $.get("C/AJAX/form5.php", {idSubcat: 4,name: "Využití"}, function(data){
			$('#specialAttributes').html(data + '<div class="pvyhledavani3"><div class="pv_1a">Plocha pozemku od - do:</div><div class="pv_4b"><input name="usableAreaMin" type="text" class="pv_select_delka"> - <input name="usableAreaMax" type="text" class="pv_select_delka">m2</div></div>');});
			break;
		default:
			$('#specialAttributes').html('');
			break;
	}
	
}

function quickSearch()
{
        var regions=showSelected();
        var specifications=showSelected2();
        var reg=new Array();
        var dist=new Array();
        var spec=new Array();
        for(var i=0;i<regions.length;i++)
        {
            if($(regions[i]).val().charAt(0)=='_')
            {
                dist.push($(regions[i]).val());         
            }
            else
            {
                reg.push($(regions[i]).val());
            }
        }
        for(var i=0;i<specifications.length;i++)
        {
            spec.push($(specifications[i]).val());
        }
	var val1=$("#category").val();
	var val2=$("#type").val();
	//var val3=$("#region").val();
	var val4=$("#specification").val();
	var val5=$("#priceMn").val();
	var val6=$("#priceMx").val();
	var val7=$("#language").val();
	$("#quickSearchResult").load("/C/AJAX/search.php", {idCategory: val1,idOfferType: val2,'idUirRegion[]': reg,'idUirDistrict[]': dist,'idSubcategory[]': spec,priceMin: val5,priceMax: val6,language:val7} );
}

function editShow()
{	
	$("#show").submit();
}

function districtControll(value)
{
	if($(value).is(':checked'))
	{
		var value=$(value).val();
		$.get("C/AJAX/form2.php", {idReg: value}, function(data){$("#districts").append(data);});
	}
	else
	{
		$('#districts' + $(value).val()).remove();
	}
}

function favourite(number)
{
	var name="offer"+number;
	createCookie(name,number,30);
	$('#countFavourites').html(parseInt($('#countFavourites').html())+1);
	var count=parseInt(readCookie("count"))+1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Odebrat z oblíbených"><img src="/C/images/pv_odebratoblibene.gif" border="0" alt="Odebrat z oblíbených" onClick="unfavourite('+ number +');return false"></a>');
}

function unfavourite(number)
{
	var name="offer"+number;
	eraseCookie(name);
	var n=parseInt($('#countFavourites').html())-1;
	if(n==0)
	{
		$('#countFavourites').html("0");
	}
	else
	{
		$('#countFavourites').html(parseInt($('#countFavourites').html())-1);
	}
	var count=parseInt(readCookie("count"))-1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Přidat do oblíbených"><img src="/C/images/detail_oblibene.gif" border="0" alt="Přidat do oblíbených" onClick="favourite('+ number +');return false"></a>');
}

function favourite2(number)
{
	var name="offer"+number;
	createCookie(name,number,30);
	$('#countFavourites').html(parseInt($('#countFavourites').html())+1);
	var count=parseInt(readCookie("count"))+1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Odebrat z oblíbených"><img src="/C/images/pv_odebratoblibene.gif" border="0" alt="Odebrat z oblíbených" onClick="unfavourite2('+ number +');return false"></a>');
}

function unfavourite2(number)
{
	var name="offer"+number;
	eraseCookie(name);
	var n=parseInt($('#countFavourites').html())-1;
	if(n==0)
	{
		$('#countFavourites').html("0");
	}
	else
	{
		$('#countFavourites').html(parseInt($('#countFavourites').html())-1);
	}
	var count=parseInt(readCookie("count"))-1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Přidat do oblíbených"><img src="/C/images/pv_oblibene.gif" border="0" alt="Přidat do oblíbených" onClick="favourite2('+ number +');return false"></a>');
}

function favourite3(number)
{
	var name="project"+number;
	createCookie(name,number,30);
	$('#countFavourites').html(parseInt($('#countFavourites').html())+1);
	var count=parseInt(readCookie("count"))+1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Odebrat z oblíbených"><img src="/C/images/pv_odebratoblibene.gif" border="0" alt="Odebrat z oblíbených" onClick="unfavourite('+ number +');return false"></a>');
}

function unfavourite3(number)
{
	var name="project"+number;
	eraseCookie(name);
	var n=parseInt($('#countFavourites').html())-1;
	if(n==0)
	{
		$('#countFavourites').html("0");
	}
	else
	{
		$('#countFavourites').html(parseInt($('#countFavourites').html())-1);
	}
	var count=parseInt(readCookie("count"))-1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Přidat do oblíbených"><img src="/C/images/detail_oblibene.gif" border="0" alt="Přidat do oblíbených" onClick="favourite('+ number +');return false"></a>');
}

function favourite4(number)
{
	var name="project"+number;
	createCookie(name,number,30);
	$('#countFavourites').html(parseInt($('#countFavourites').html())+1);
	var count=parseInt(readCookie("count"))+1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Odebrat z oblíbených"><img src="/C/images/pv_odebratoblibene.gif" border="0" alt="Odebrat z oblíbených" onClick="unfavourite2('+ number +');return false"></a>');
}

function unfavourite4(number)
{
	var name="project"+number;
	eraseCookie(name);
	var n=parseInt($('#countFavourites').html())-1;
	if(n==0)
	{
		$('#countFavourites').html("0");
	}
	else
	{
		$('#countFavourites').html(parseInt($('#countFavourites').html())-1);
	}
	var count=parseInt(readCookie("count"))-1;
	createCookie("count",count,30);
	$('#favouriteButton'+number).html('<a href="" title="Přidat do oblíbených"><img src="/C/images/pv_oblibene.gif" border="0" alt="Přidat do oblíbených" onClick="favourite2('+ number +');return false"></a>');
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return 0;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function addCompare(value)
{
	var v=$(value).val();
	var name="compare"+v;
	if($(value).is(':checked'))
	{
		createCookie(name,v,30);
	}
	else
	{
		eraseCookie(name);
	}
}

function removeFromFavourite(value)
{
	var name="offer"+value;
	if(readCookie(name)!=0)
	{
		eraseCookie(name);
		var n=parseInt($('#countFavourites').html())-1;
		if(n==0)
		{
			$('#countFavourites').html("0");
		}
		else
		{
			$('#countFavourites').html(parseInt($('#countFavourites').html())-1);
		}
		var count=parseInt(readCookie("count"))-1;
		createCookie("count",count,30);
	}
	$('#offer' + value).remove();
}

function checkForm01()
{
 var str="";
 var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
	$.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
	    	  if(tel.length!=9)
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("name").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím své jméno, je to povinný údaj.");
		    document.getElementById("name").focus();
		    return false;
		  } 
		  if(document.getElementById("telephone").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  } 
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(!$('#agree').is(':checked'))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Musíte souhlasit s obchodními podmínkami");
		    return false;
		  }
	}
  } 
  return true;
}

function checkForm02()
{
  var str="";
  var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
    $.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
	    	  if(tel.length!=9)
		  {
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("name").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím své jméno, je to povinný údaj.");
		    document.getElementById("name").focus();
		    return false;
		  } 
		  if(document.getElementById("telephone").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(document.getElementById("company").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím název společnosti, je to povinný údaj.");
		    document.getElementById("company").focus();
		    return false;
		  } 
		  if(document.getElementById("project").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím název projektu, je to povinný údaj.");
		    document.getElementById("project").focus();
		    return false;
		  }  
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(!$('#agree').is(':checked'))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Musíte souhlasit s obchodními podmínkami");
		    return false;
		  }
	}
  } 
  return true;
}

function checkForm03()
{
  var str="";
  var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
    $.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
	    	  if(tel.length!=9)
		  {
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("name").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím své jméno, je to povinný údaj.");
		    document.getElementById("name").focus();
		    return false;
		  } 
		  if(document.getElementById("telephone").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  }  
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(!$('#agree').is(':checked'))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Musíte souhlasit s obchodními podmínkami");
		    return false;
		  }
	}
  } 
  return true;
}

function checkForm04()
{
  var str="";
  var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
    $.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
	    	  if(tel.length!=9)
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("name").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím své jméno, je to povinný údaj.");
		    document.getElementById("name").focus();
		    return false;
		  } 
		  if(document.getElementById("telephone").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(document.getElementById("yourText").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím nějaký text, je to povinný údaj.");
		    document.getElementById("yourText").focus();
		    return false;
		  }  
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
	}
  } 
  return true;
}

function checkForm05()
{
  var str="";
  var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
    $.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
		  if(tel.length!=9)
		  {
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("telephone").value.length==0) {
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  } 
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
	}
  }
  return true;
}

function checkForm06()
{
  var str="";
  var c="code="+$("#code").val();
  var tel = document.getElementById("telephone").value.replace(/ /g,'');
  tel = document.getElementById("telephone").value.replace(/[^0-9]/g,'');
  if(document.getElementById("code").value.length==0) {
	 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();
    alert("Zadejte prosím kontrolní kód, je to povinný údaj.");
    document.getElementById("code").focus();
    return false;
  }
  else
  {
    $.ajax({
  url:"/C/AJAX/checkCapatcha.php",data: c, success:function(data){str = data;}, async:false
 });
	 if(str=="false")
	 {
		document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
	   	alert("Zadejte prosím správný kontrolní kód, v zadaném je chyba.");  
		return false;
	 }
	 else
	 {
	    	  if(tel.length!=9)
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadané telefoní číslo musí mít 9 čísel.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("name").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím své jméno, je to povinný údaj.");
		    document.getElementById("name").focus();
		    return false;
		  } 
		  if(document.getElementById("telephone").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj telefon, je to povinný údaj.");
		    document.getElementById("telephone").focus();
		    return false;
		  }
		  if(document.getElementById("email").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím svůj email, je to povinný údaj.");
		    document.getElementById("email").focus();
		    return false;
		  }
		  if(document.getElementById("yourText").value.length==0) {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    alert("Zadejte prosím nějaký text, je to povinný údaj.");
		    document.getElementById("yourText").focus();
		    return false;
		  }  
		  chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
		  if (!chars.test(document.getElementById("email").value))
		  {
			 document.getElementById('captcha').src = '/C/securimage/securimage_show.php?' + Math.random();$("#code").val("");
		    window.alert("Zadaná adresa není platným e-mailem!");
		    document.getElementById("email").focus();
		    return false;
		  }
	}
  } 
  return true;
}

function addEmail()
{
	chars=new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
	if (!chars.test(document.getElementById("emailLeft").value) || document.getElementById("emailLeft").value.length==0)
	{
		window.alert("Zadaná adresa není platným e-mailem!");
	}
	else
	{
		var value=$("#emailLeft").val();
		$.get("/C/AJAX/email.php", {str: value}, function(data){if(data=="true"){alert('Váš email byl přidán');$("#emailLeft").val('');}else if(data=="exist"){alert('Váš email je již v databázi uveden');$("#emailLeft").val('');}});
	}
	return false;
}


