//jQuery.noConflict();



jQuery(document).ready(

	function($)

	{

		$("#visit").hover(

			function() {

				$("#sites").show();
				$("#sites359").show();

			},

			function() {

				return true;

			}	

		);

		

		$("#visit").click(

			function() {

				$("#sites").hide();
				$("#sites359").hide();

			}	

		);

		/*$("#wrap359").hover(

			function() {

				$("#sites").show();
				$("#sites359").fadeIn('slow');
			},

			function() {

				return true;

			}	

		);

		

		$("#wrap359").click(

			function() {

				$("#sites").hide();
				$("#sites359").fadeOut('slow');

			}	

		);
*/
				


		$("#sites").hover(

			function() {

				return true;

			},

			function() {

				$("#sites").hide();

			}	

		);

		$("#sites359").hover( 

			function() {

				return true;

			},

			function() { 

				$("#sites359").fadeOut('slow');

			}	

		);


		$("#otziv").click(

			function() {

				$("#otzivBox").show('fast');

			}

		);

		

		$(".closeOtzivBox, #closeButton").click(

			function() {

				$("#otzivBox").hide('fast');

				$("#otzivBoxThanks").hide('fast');
				
				
			}

		);
		
		$(".closeSites, .closeForUs").click(

			function() {
				
				$("#sites359").hide('fast');
				$("#for_us").hide('fast');

			}

		);
		$("#show_for_us").click(

			function() {
				$("#for_us").show('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("Моля, попълнете някое от полета отбелязани в червено!");

				}

			}

		);

	}

);
