jQuery.noConflict();

jQuery(document).ready(
	function($)
	{
		$("#otziv").click(
			function() {
				if($("#pdfBox").css("display") == "block") { $("#pdfBox").hide('fast');}
				$("#otzivBox").show('fast');
			}
		);
		
		$(".closeOtzivBox, #closeButton").click(
			function() {
				$("#otzivBox").hide('fast');
				$("#otzivBoxThanks").hide('fast');
			}
		);
		
		$("#submitOtzivForm").click(
			function() {
				hasError = false;
				
				$("#rationH").removeClass("red");
				$("#commentH").removeClass("red");
				for (i=0;i<document.freview.ratingOtzivForm.length;i++) {	
				      if (document.freview.ratingOtzivForm[i].checked) {
				    	  var ratingValueVal = document.freview.ratingOtzivForm[i].value;
				      }
				}
				var commentVal = $("#commentOtzivForm").val();
				if(commentVal == '' && !ratingValueVal) {
					$("#rationH").addClass("red");
					$("#commentH").addClass("red");
					hasError = true;
				}
				
				if(hasError == false) {
					$.post("/ajax/ajax_save_otziv.php",
					   { 
						comment: commentVal,
						rating: ratingValueVal,
						youare: $("#youareOtzivForm").val(),
						contacts: $("#contactsOtzivForm").val()
					   },
					   	function(result){
						  	if(result == 'true'){
						  		$('#otzivBox').hide();
						  		$('#otzivBoxThanks').show();
							}
						  	else {
						  		
							}
						}
					);
				}
				else {
					alert("Моля, попълнете някое от полета отбелязани в червено!");
				}
			}
		);
		
		
		$(".attention").bind(
				'click',
				function() {
					$('#reportBox').show();
				}
		);
		
		$(".attentionClose").bind(
				'click',
				function() {
					$('#reportBox').hide();
				}
		);
		
		$('#reportSubmit').bind(
				'click',
				function() {
					$.post("/ajax/ajax_reportMap_save.php",
					   { 
						text: $("#reportText").val()
					   },
					   	function(result) {
						   //	alert(result);
						  	//if(result == 'true') {
						  		$('#reportForm').hide();
						  		$('#reportSent').show();
							//}
						 // 	else {
						 // 		$("#captchaText").addClass("error");
							//}
						  	
						}
					);
				}	
			);
		
		$("#pdf_download").click(
			function() {
				pdf_name = $(this).attr('pdf_name');
							pregion_id = $(this).attr('pregion_id');
							pcity_id = $(this).attr('pcity_id');
							web_site = 'www.bgvakancia.com';
							pdf_btn_click=$(this).attr('pdf_btn_click');
							pdf_click=$(this).attr('pdf_click');
							from_offer=$(this).attr('from_offer');
							
							$.post("/ajax/ajax_set_pdf_click.php",
							   { 
								pdf_name: pdf_name,
								pregion_id: pregion_id,
								pcity_id: pcity_id,
								web_site: web_site,
								from_offer: from_offer,
								pdf_btn_click: pdf_btn_click,
								 pdf_click: pdf_click
							   }, 
								function(result) {//alert(result);
								   result = result.split("|"); 
									if(result[0] == 'true'){
									}
								}
								
				);	/**/
				if($("#otzivBox").css("display") == "block") { $("#otzivBox").hide('fast');}
				$("#pdfBox").show('fast');
			}
		);
		
		$(".closepdfBox").click(
			function() {
				$("#pdfBox").hide('fast');
			}
		);
		
	}
);
