 $(document).ready(function(){
    $("a[rel=galery]").fancybox({
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">'+ title +' - Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
			}
	});    
	
	
	$('#fadeshow').innerfade({ 		
		speed: 'slow', 
		timeout: 20000, 
		type: 'sequence', 
		containerheight: '172px' 
	});
	
 });


function get_entry_form(id){
	$.post('cms.php?cont='+ id +'&templ=ajax_gb_entry.tpl', function(data) {
	  $('#entry_form').html(data);
	});
	$("#gb_entry_add_container").hide('slow');	
	return false;
}

function get_comment_form(cont_id,gb_entry_id){
	$.post('cms.php?cont='+ cont_id +'&templ=ajax_gb_comment.tpl&gb_entry_id='+gb_entry_id, function(data) {
	  $('#par_'+gb_entry_id).after(data);
	});
	$("#par_"+gb_entry_id).hide('slow');	
	return false;
}

function close_comment_form(){
 	$("#gb_comment").hide('slow');
	window.location.reload();
	return false;
}

function gb_comment_submit_via_ajax(myform){	
	
	var dataString = 'name_sender_com='+ document.getElementById("name_sender").value 
	 + '&e_mail_com=' + document.getElementById("email_sender").value 
	 + '&message_com=' + document.getElementById("message").value
	 + '&send_com=1'
 	 + '&gb_entry_id=' + document.getElementById("gb_entry_id").value
	 + '&captcha=' + document.getElementById("captcha").value
	 + '&code=' + document.getElementById("code").value; 	
	
	$.ajax({  
   	   type: "POST",  
	   url: "cms.php?cont="+ document.getElementById("cont").value +"&templ=ajax_gb_comment.tpl",
	   data: dataString,
	   success: function(data) {  
    	 $('#gb_comment').html(data);
	   }  
	 });  
	
	return false;	
}

function close_entry_form(){
 	$("#gb_entry").hide('slow');
	$("#gb_entry_add_container").show('slow');
	window.location.reload();
	return false;
}

function gb_entry_submit_via_ajax(){
	var dataString = 'name_sender='+ document.getElementById("name_sender").value 
	 + '&e_mail=' + document.getElementById("email_sender").value 
	 + '&message=' + document.getElementById("message").value
	 + '&send=1'
	 + '&captcha=' + document.getElementById("captcha").value
	 + '&code=' + document.getElementById("code").value; 	
	
	//alert(dataString);	
	
	$.ajax({  
   	   type: "POST",  
	   url: "cms.php?cont="+ document.getElementById("cont").value +"&templ=ajax_gb_entry.tpl",
	   data: dataString,
	   success: function(data) {  
    	 $('#entry_form').html(data);
	   }  
	 });
	  
	
	return false;	
}
