$(document).ready(function() {	

  var cmsh = screen.height/2+200;
  $("#open-cms").attr({rel:'width:900;height:'+cmsh+';'});
  
  //INNER FADE
  $('.innerfade').innerfade({ speed: 'slow', timeout: 10000 });   
  
  //EASY
  $.easy.tooltip();
  $.easy.popup({closeText:'Chiudi finestra'});
  $.easy.forms({err:'Campo obbligatorio',errEmail:'Indirizzo mail obbligatorio'});
  
  //CONTACT FORM
  $('#contact').ajaxForm({target:'.contact_fieldset'});
  
  //POPUP PICT
  $("a[rel^='prettyPhoto']").prettyPhoto({
  	theme: 'light_square'
  });
	
	//SMS MASK
	$("#sms").mask("+99.999.9999999");	
	
	//PRINT PAGE
	$("#print-page").click(function() {
		window.print();
		return false;
	});
	
	//SEARCH FORM
	function googleSearch() {
		$("#g-src-btn").click(function() {
			var val = $("#g-src-val").val();
			if(val.length>0) {
  			$("#body").html("<div class='left20 width500' id='g-src-res'></div>");  			
  			$("#g-src-res").gSearch({
        	search_text : val,
        	//count : 5,
        	site : 'vetsrl.it',
        	pagination : true	
        });  			
  			$("#g-src-val").val('');
			}			
			return false;
		});
	} googleSearch();
		
	//LOGIN FORM
	function loginForm() {
		$('#area-riservata').ajaxForm({
			//target:'#page-wrapper',
			target:'#body',
			success: function() {
				loginForm();
				$.easy.forms({err:'Campo obbligatorio',errEmail:'Indirizzo mail obbligatorio'});
			}
		});
	} loginForm();
	
	//SIGNUP FORM
	function signupForm() {
		$('#signup').ajaxForm({
			target:'.signup_fieldset',
			success: function() {
				signupForm();
				$.easy.forms({err:'Campo obbligatorio',errEmail:'Indirizzo mail obbligatorio'});
			}
		});
	} signupForm();
	
	//PAGINATE
	function paginate() {
		$('#news-container').pajinate({
			items_per_page: 4,
			//num_page_links_to_display: 2,
			nav_label_first: '',
			nav_label_last: '',
			nav_label_next: '>',
			nav_label_prev: '<'
		});
	} paginate();
	
});
