// JavaScript Document
$(document).ready(function() {

/* Search form Action */
$("#search").submit(function(){
	var action = $('#search').attr('action') + $("#text").val();
	$('#search').attr('action', action)
});
 
 /*$("a.grouped_elements, a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
       */
 /**
   *    NASTAVENI ODSAZENI OBRAZKU V OBSAHU PODLE TOHO NA KTEROU STRANU JE ZAROVNANY  
   */     

	var images = $('#content img');
	
	$.each(images, function(i, img){                                                                                                                                                                              
		var value = null;
		switch ( $(img).css( 'float' ) ){
		case 'right':
			value = "0px 0px 5px 10px";
			break;
		case 'left':
			value = "0px 10px 5px 0px";
			break;
		default:
			value = "0px auto";
			break;
		}
		$(img).css( 'margin', value );
	});
 /**
   *    
   */ 
   
   	$(".slider-controll a").click(function(){ 
		$("#slider img.slider").fadeOut();
		$(".slider-controll a").removeClass("active"); 
		$("#slider ."+$(this).attr('class')).fadeIn();
		$(this).attr("class", $(this).attr("class") + " active");
		return false;   
	});
    /* PAGINATOR */
   /* photoCount = $("#content .gallery-info .allphotos").text();
    $("#gallery-paginator").pagination(photoCount, {
        items_per_page:9,
        next_text: "Další stránka",
        prev_text: "Předchozí stránka",
        next_show_always: true,
        prev_show_always: true,
        num_display_entries: 0,
        callback:handlePaginationClick
	});
	
	pagesCount = 0;
	
	$("#Searchresult .photoContainer").each(function(i, l){
	    	if(i>8) {
				$(this).css("display","none");
			}
			pagesCount++;
	});
	if(pagesCount) {
		$("#content .gallery-info .all").text(Math.ceil(pagesCount/9));
	}
	 */
    /* NOVINKY CONTROLL */   
	$("#content .news .new h3 a").click(function(){
		$(this).parent().find("span.date").animate({height: "toggle"}, 1);

		$(this).parent().parent().find(".closer").slideToggle('slow', function() {
		  // Animation complete.
		});
		return false;
	});	
	
	/* search box */
	$(".searchBox").click(function(){
		text = $("#text").val();
		if(text == "Hledaný text") {
			$("#text").val("");	
		}		
	});
	
	$(".searchBox").focusout(function(){
		text = $("#text").val();
		if(text == "") {
			$("#text").val("Hledaný text");	
		}	
	});
	
//Prozatimni stranka


 $("a.grouped_elements, a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true		
	});
	// Carousel with pagination
	$(".carousel").carousel({
	     dispItems: 4,
		 pagination: false,
		 autoSlide: true,
		 autoSlideInterval: 5000,
		 animSpeed: "slow"
	});
	
	$("input.carousel-control").attr("value","");
	
	$("a.button").click(function(){
		$(".form, .form form").slideToggle(100);
		return false;
	});
  
 /**
   *    FUNKCE PRO OVLADANI FORMULARE     
   */
    $(".form form").submit(function(){
    	text = $(".text").val();
    	area = $(".area").val();
    	type = "";
    	
    	$('input:checkbox').each( function() {
			if(this.checked) {
				type += this.value + ", ";
			}
		});
    	
	  	$.ajax({
	        type: "POST",
	        url: "http://www.increo.cz/scripts/formular.php",
	        data: 'mail='+text+'&text='+area+'&type='+ type,
	        success: function(msg){
	        	$(".error-div").html(msg);   
	        }
	    });
	    
	    //$(".area").html("Zde specifikujte Vaší poptávku ...");
	    //$(".text").val("Zadejte Váš e-mail");
	    
	    return false;
    });
	                    
	$(".text").click(function(){
		text = $(".text").val();
		if(text == "Zadejte Váš e-mail") {
			$(".text").val("");	
		}		
	});
	
	$(".text").focusout(function(){
		text = $(".text").val();
		if(text == "") {
			$(".text").val("Zadejte Váš e-mail");	
		}		
	});
	
	
	$(".area").click(function() {		
		area = $(".area").text();	
		if(area == "Zde specifikujte Vaší poptávku ...") {
			$(".area").html("");	
		}		
		return false;
	});
	
	$(".area").focusout(function(){
		area = $(".area").html();
		if(area == "") {
			$(".area").html("Zde specifikujte Vaší poptávku ...");	
		}		
	});		
	
	
	
	
	
	
	
	
	
	
			
//END	
});
 /*
function handlePaginationClick(new_page_index, pagination_container) {
    array = [];

    counter=0;
	$("#Searchresult .photoContainer").css("display","none");
	$("#Searchresult .photoContainer").each(function(i, l){
    	counter++;
		if((i >= (new_page_index*9)) && (i <= photoCount) ) {
    		    if(counter < (((new_page_index+1)*9)+1))
				$(this).css("display","block");
				$("#content .gallery-info .actual").text(new_page_index+1);
		}
	});
	              
    return false;   
}
*/


