$(document).ready(function(){
	
	$(".populate").populate();
	$("#top_link").click(function(){
		$(document).scrollTo($("#wrapper"));
	});
	
	jQuery(".popup-btn").popup({
	    width: 520,
	    height: 430,
	    titlebar: false,
	    status: false,
	    resizable: false,
	    toolbar: false,
	    scrollbars: true,
	    menubar: false
	});
	
	$("#btn-quick-contact").click(function(){
		sendForm('quick_contact');
	});
	
	$("#nav li").mouseover(function(){
		if(!$(this).hasClass("active")){
			$(this).find("img").css("marginLeft","-100%");
		}
	});
	$("#nav li").mouseout(function(){
		if(!$(this).hasClass("active")){
			$(this).find("img").css("marginLeft","0px");
		}
	});
	
	$("#footer .list_content").find("ul:last").addClass("no_margin");
	
});

function sendBulletinSubscriptionForm(){
	if(checkFormFields('form_newsletter',1,0,'#868686','#FFF')){
		$('#form_newsletter').addAjaxLoader();
		var vars = $('#form_newsletter').serializeForm();
		$.ajax({
			   async: true,
			   type: "POST",
			   url: "_ajax.php",
			   data: "opc=sendBulletinSubscriptionForm&"+vars,
			   success: function(data){
					$.ajax({
						   async: true,
						   type: "POST",
						   url: "_ajax.php",
						   data: "opc=translate&word="+(parseInt(data)==1?"newsletter_registration_successfull":"existent_account"),
						   success: function(message){
								showAlertMessage(message,parseInt(data)==1?"info":"error");
								$('#form_newsletter').removeAjaxLoader();
								$('#form_newsletter').clearForm();
						   }
					 });
					
			   }
		 });
	}
}
