function check_Add_Ads(formularz)
{
	var form_name = formularz.ads_name.value;
	var form_email = formularz.ads_email.value;
	var form_phone = formularz.ads_phone.value;
	var form_skype = formularz.ads_skype.value;
	var form_gg = formularz.ads_gg.value;
	var form_location = formularz.ads_location.value;
	var form_id_subcategory = formularz.ads_id_subcategory.value;
	var form_body = formularz.ads_body.value;
	var mistake = 0;
	
	if (check_name(form_name) == false) mistake++;
	if (check_email(form_email) == false) mistake++;
	if (check_location(form_location) == false) mistake++;
	if (check_id_subcategory(form_id_subcategory) == false) mistake++;
	if (check_body(form_body) == false) mistake++;
	
	if (mistake > 0) return false;

	return true;
}

function check_name(name)
{
	if (name == "") { alert("Prosze podac imie !!!"); return false; }
	if (name.length < 2) { alert("Imie musi zawierac przynajmniej 2 znaki !!!"); return false; }
}


function check_email(email)
{
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;

	if (email.length < 1) return true;

	if (regex.test(email)) return true;

	alert("Bledny adres e-mail - prosze poprawic wprowadzony adres e-mail !!!");
	return false;
}

function check_location(location)
{
	if (location == "") { alert("Prosze podac lokalizacje dla ogloszenia !!!"); return false; }
	if (location.length < 2) { alert("Lokalizacja musi zawierac przynajmniej 2 znaki !!!"); return false; }
}

function check_id_subcategory(id_subcategory)
{
	if (id_subcategory == 0) { alert("Prosze wybrac kategorie !!!"); return false; }
}

function check_body(form_body)
{
	if (form_body.length < 21) { alert("Tresc musi zawierac przynajmniej 20 znakow !!!"); return false; }
}

function print_ShowBoxPopup(targetDivID)
{
	var orgin_div_content=document.getElementById(targetDivID).innerHTML;
	
	showBoxPopupWin = window.open(targetDivID,'print_ad','height=300,width=650,screenX=50,screenY=50,scrollbars=yes');
	showBoxPopupWin.document.close();
	showBoxPopupWin.document.open();
	showBoxPopupWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
	'<html xmlns="http://www.w3.org/1999/xhtml">'+
	'<head><title>'+targetDivID+'</title>'+
	'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'+
	'<meta http-equiv="cache-control" content="no-cache" />'+
	'<meta http-equiv="pragma" content="no-cache" />'+
	'<meta http-equiv="expires" content="0" />'+
	'<script type="text/javascript">'+
	'function print_ShowBoxPopup()'+
	'{'+
		'window.print();'+
	'}'+
	'</script>'+
	'<style type="text/css">'+
		'.ads_show{margin:0 auto;}'+
		'ol,ul{list-style:none;}'+
		'.clear-both{clear:both;}'+
		'img{border:0;}'+
		'@media screen {'+
			'body,body *,ads_show,ads_show *,*{font-family:Verdana,Trebuchet,Helvetica,Sans-Serif;font-size:12px;}'+
			'.ads_show{width:550px;max-width:550px;}'+
			'.ads_show > ul{padding:10px 10px 0px 10px;border:2px solid #EEEEEE;margin-bottom:15px;font-size:11px;width:100%;text-align:left;}'+
			'.ads_show li{clear:both;margin-bottom:10px;}'+
			'.ads_show .photo img{max-width:80px;max-height:100px;margin-right:10px;}'+
			'.ads_show p{margin-top:2px;}'+
			'.ads_show .ads_show_email img{margin-left:3px;}'+
		'}'+
		'@media print {'+
			'body,body *,ads_show,ads_show *,*{font-family:Verdana,Trebuchet,Helvetica,Sans-Serif;font-size:14pt;}'+
			'.ads_show{width:15cm;max-width:15cm;}'+
			'.ads_show > ul{border:1 solid black;padding:10pt 10pt 0pt 10pt;border:2pt solid #EEEEEE;margin-bottom:15pt;font-size:13pt;width:100%;text-align:left;}'+
			'.ads_show li{clear:both;margin-bottom:10pt;}'+
			'.ads_show .photo img{max-width:80px;max-height:100px;margin-right:10pt;}'+
			'.ads_show p{margin-top:2pt;}'+
			'.ads_show .ads_show_email img{margin-left:3pt;}'+
		'}'+
		'.ads_show li > div{display:inline;}'+
		'.ads_show .category_and_subcategory,.ads_show .date_created{color:#6699CC;font-weight:bold;}'+
		'.ads_show .name{color:#6699CC;}'+
		'.ads_show .date_created{float:right;}'+
		'.ads_show .photo,.ads_show .body{text-align:justify;vertical-align:middle;display:table-cell;}'+
		'.ads_show .body{line-height:120%;}'+
		'.ads_show a{text-decoration:none;color:#000000;}'+
		'.ads_show a:hover{text-decoration:underline;}'+
		'.ads_show div.information_box,.ads_show div.features_box{display:block;}'+
		'.ads_show div.fb-google-like{vertical-align:middle;display:table-cell;width:300px;max-width:300px;}'+
		'.ads_show div.print-tell-a-friend{vertical-align:bottom;display:table-cell;width:250px;max-width:250px;}'+
		'.ads_show div.like_button,.ads_show div.google_button{width:280px;max-width:280px;}'+
		'.ads_show div.print,.ads_show div.tell-a-friend{float:right;cursor:pointer;}'+
		'.ads_show div.tell-a-friend{margin-right:5px;}'+
	'</style>'+
	'</head><body>'+
	
	//'<div id="fb-root"></div>'+
    //'<script>(function(d, s, id) {'+
	//   'var js, fjs = d.getElementsByTagName(s)[0];'+
	//    'if (d.getElementById(id)) return;'+
	//    'js = d.createElement(s); js.id = id;'+
	//    'js.src = "//connect.facebook.net/<?=lang(\'lang_facebook\')?>/all.js#xfbml=1&appId=292743967425870";'+
	//    'fjs.parentNode.insertBefore(js, fjs);'+
	//    '}(document, \'script\', \'facebook-jssdk\'));'+
	//'</script>'+
	
	
		'<div class="ads_show"><ul>'+orgin_div_content+'</ul></div>'+
	'</body</html>');
	showBoxPopupWin.document.close();
	if (window.focus) {showBoxPopupWin.focus(); showBoxPopupWin.print();}
	
}

