jQuery.fn.extend({
  haccordion: function(params){
    var jQ = jQuery;
    var params = jQ.extend({
      speed: 500,
      headerclass: "header",
      contentclass: "content",
      event: "click",
	  contentwidth: 570
    },params);
    return this.each(function(){
     this.opened = jQ("."+params.contentclass,this).filter(".visible").prev();
      jQ("."+params.headerclass,this).click(function(){
        var p = jQ(this).parent()[0];
        if (p.opened != "undefined"){
          jQ(p.opened).next("div."+params.contentclass).animate({
            width: "0px"
          },params.speed);
        }
        p.opened = this;
        jQ(this).next("div."+params.contentclass).animate({
          width: params.contentwidth + "px"
        }, params.speed);
      });
    });
  }
});

	$(function(){
		$(".haccordion").haccordion();
	});
	$(document).ready(function(){
	
		$(".image img").fadeTo("slow", 0.8); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$(".image img").hover(function(){
			$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("slow", 0.8); // This should set the opacity back to 60% on mouseout
		});
    $("#wrapper-outer").hide();
    $("#wrapper-outer").animate({height: ['toggle', 'swing'],opacity: 'toggle'},5000,'linear');
    
	});
	$(document).ready(function() {
		$("a[rel=gallery_group1]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	
    $(".popupp").fancybox({
      'width'				: 620,
      'height'			: 600,
      'autoScale'     	: true,
      'autoDimensions': false,
      'transitionIn'		: 'none',
      'transitionOut'		: 'none',
      'type'				: 'iframe'
    });
    
    $("#contactform").submit(function() {
      var hata = 0;
      var isim = encodeURIComponent($("#isim").val()).replace(/%20/g, "+");
      var eposta = $("#eposta").val();
      var telefon = $("#telefon").val();
      var konu = $("#konu").val();
      var mesaj = $("#mesaj").val();
      if (isim == "") {alert("Lütfen adınızı yazın");$("#isim").focus();hata=1}
      if (hata == 0 && eposta == "") {alert("Lütfen eposta adresinizi yazın");$("#eposta").focus();hata=1}
      if (hata == 0 && telefon == "") {alert("Lütfen telefon nuamranızı yazın");$("#telefon").focus();hata=1}
      if (hata == 0 && konu == "") {alert("Lütfen konuyu yazın");$("#konu").focus();hata=1}
      if (hata == 0 && mesaj == "") {alert("Lütfen mesajınızı yazın");$("#mesaj").focus();hata=1}
      
      if (hata == 0 ) {
        $.ajax({
          type: "POST",
          url: "gonder.asp?isim="+isim+"&eposta="+eposta+"&telefon="+telefon+"&konu="+konu+"&mesaj="+mesaj,
          success: function(html){
            $("#sonuc").html(html);
           }
        });
        
        $("#contactform").hide("slow");
        $("#sonuc").show("slow");
      }
      
      return false;
    });
    
	});
