//JQUERY Settings

jQuery(document).ready(function(){
	
	//pokreni head galeriju
	jQuery('#head_gallery_imgs').cycle({ 
    fx:     'fade', 
    speed:  1000, 
    timeout: 3000, 
    next:   '#gal_next', 
    prev:   '#gal_prev'
    });

    jQuery("ul.gallery").prettyGallery({
        itemsPerPage: 6,
        of_label: ' / ' /* The content in the page "1 of 2" */
    });

    $("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal', /* fast/slow/normal */
        padding: 40, /* padding for each side of the picture */
        opacity: 0.35, /* Value betwee 0 and 1 */
        showTitle: true, /* true/false */
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function() { }
    });

    
    //makni prvu crtu na lijevoj listi
    jQuery('.left_box_list3 ul li:first').css({background: 'none'});
    jQuery('.left_box_dogadjaji3 ul li:last').css({background: 'none'}).find("a").css({paddingBottom:'0'});
    
    //pokreni main menu
    //$("ul.sf-menu").superfish({ 
    //        pathClass:  'current'
    //    });

    jQuery("#page_mail").click(function() {
        $("html").scrollTo( { top:'0px', left:'0px'}, 500, {onAfter:function(){
            jQuery("#sendtofriend").slideToggle("slow");
            }});
        
        return false;
    });
    
    jQuery("#sendtofriend_close1").click(function() {
        jQuery("#sendtofriend").slideToggle("slow");
        return false;
    });	
    
	//objekt tabovi
	var vrijednostObjektTaba;
	jQuery("#content_objekt_tab1 a, #content_objekt_tab2 a").click(function () {
     	jQuery("#content_objekt_tab1 a, #content_objekt_tab2 a").removeClass("content_objekt_tab_active");
     	jQuery(this).addClass("content_objekt_tab_active");
     	vrijednostTaba = jQuery(this).attr('rel');
		jQuery('#objekt_tab2, #objekt_tab1').css({ display: 'none' });
		jQuery("#" + vrijednostTaba).css({ display: 'block' });
     });
     //dodaj kraj na zadnji tab
    // jQuery(".content_objekt_box_line2 ul li:last").addClass("content_objekt_tab_last");
     
     jQuery("#objekt_tab2,#objekt_tab3").css({ display: 'none' });

     // Reset Font Size
  var originalFontSize = $('body').css('font-size');
    $(".resetFont").click(function(){
    $('body').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $("#page_plus").click(function(){
    //var currentFontSize = $('.content_objekt_box2, .content_box2').css('font-size');
    //var currentFontSizeNum = parseFloat(currentFontSize, 10);
    //var newFontSize = currentFontSizeNum*1.2;
    $('.content_objekt_box2, .content_box2').css('font-size', '1.2em');
    return false;
  });
  // Decrease Font Size
  $("#page_minus").click(function(){
    //var currentFontSize = $('.content_objekt_box2, .content_box2').css('font-size');
    //var currentFontSizeNum = parseFloat(currentFontSize, 10);
    //var newFontSize = currentFontSizeNum*0.85;
    $('.content_objekt_box2, .content_box2').css('font-size', '1em');
    return false;
  });

  //SendToFriend
  var bojaErrora = "#ff0000";
  $("#sendtofriend_submit").click(function() {
      $(".error").hide();
      var hasError = false;
      var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

      var sendEmailPosiljateljaVal = $("#sendEmailPosiljatelja").val();
      if (sendEmailPosiljateljaVal == '') {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      } else if (!emailReg.test(sendEmailPosiljateljaVal)) {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      }


      var sendEmailPrimateljaVal = $("#sendEmailPrimatelja").val();
      if (sendEmailPrimateljaVal == '') {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      } else if (!emailReg.test(sendEmailPrimateljaVal)) {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      }


      var sendImePosiljateljaVal = $("#sendImePosiljatelja").val();
      if (sendImePosiljateljaVal == '') {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      }


      var sendEmailPorukaVal = $("#sendEmailPoruka").val();
      if (sendEmailPorukaVal == '') {
          $("span.alert").css({ color: bojaErrora });
          hasError = true;
      }



      if (hasError == false) {

          $("p.sendtofriendButton").append("<img class='loadingImg' src='../images/loading2.gif' alt='Loading' id='loading' />");

          $.post("sendFriend.aspx",
   				{ sendEmailPosiljatelja: sendEmailPosiljateljaVal, sendEmailPrimatelja: sendEmailPrimateljaVal, sendImePosiljatelja: sendImePosiljateljaVal, sendEmailPoruka: sendEmailPorukaVal },
   					function(data) {
   					    $("img.loadingImg").hide();
   					    $("p.sendtofriendSent").append('<img src="../images/mailsent2.png" alt="" id="" />');
   					    $("p.sendtofriendSent").animate({ opacity: 1.0 }, 1500)
   					    $("p.sendtofriendSent").fadeOut('fast', function() {

   					        $("#sendtofriend").slideToggle("slow");
   					        pobrisiSendToFriendFormu();
   					    });
   					}
				 );

      }
      return false;
  });

  //SendToFriend END

//kraj
});

