﻿/***
(C) www.mantiksal.com.tr,  2011
Version:2.0	 
www.mantiksal.com.tr
***/

$(document).ready(function(){	
 
});//ready
$(window).resize(function(){
});





function bosluk_al(yazi){
return yazi.replace(/^\s+|\s+$/g,"");	
}
function trim(s) {
    return s.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}



function git(isim){
		window.location=isim;
}

/// Pencere olayları

var pencereAcikmi = false;
function pencereGoster(genislik,uzunluk,baslik,sayfa,veri) {
	$(document).ready(function(){  
	 	$("#pencereicerik").html('<span id="sepet_ust_loader"> <img src="images/loader.gif" width="18" alt="" /> </span>');
   /**/ var apSec = $("#pencere");
  	    var apSec1 = $("#pencereicerik");
    if(pencereAcikmi == false) {
        $("#karart").slideDown("slow");
	    var winH = $(window).height();
	    var winW = $(window).width();
        $("#pencerebasliksol").html(baslik);
        $("#pencereicerik").html("<div style='text-align: center;'><br /><br /><img src='"+aktif_tema+"images/ajax_loader.gif' /></div>");
	    $.ajax({
		    type: "POST",
		    url: aktif_tema+sayfa,
			data:'veri='+veri,
		    success: function(msg){
		       $("#pencereicerik").html( msg );
	       }
	    });
        apSec.css("width",genislik);
        apSec.css("height",uzunluk);
	    apSec.css('top',  winH/2-apSec.height()/2);
	    apSec.css('left', winW/2-apSec.width()/2);
        pencereAcikmi = true;
		
    }
    else {
        pencereAcikmi = false;
    }
    apSec.css("display","block");
	});
}
$(window).resize(function () {
    var winH = $(window).height();
    var winW = $(window).width();
    if(pencereAcikmi == true) {
        $("#pencere").css('top', winH/2-$("#pencere").height()/2);
        $("#pencere").css('left', winW/2-$("#pencere").width()/2);
    }
});

function pencereKapat() {
	$(document).ready(function(){  
		//window.location.reload();
    if(pencereAcikmi == true) {
        pencereAcikmi = false;
		$("#pencere").slideUp();
		$("#pencereicerik").css({'background':'#ffffff','height':'485px','overflow-y':'scroll'});
    }

	$("#karart").slideUp("slow");
	});
}
$(document).keyup(function(event){

    if (event.keyCode == 27) {
        if(pencereAcikmi == true) {
            pencereKapat();
        }
    }
});

// -pencere olayları





function resim_degis(id){
 var img = new Image();
 $(document).ready(function(){
 		$('#urun_genel_resim').html('<img style="position:relative; left:50%; top:50%;" src="images/loader.gif" alt="" />');
        $(img).load(function () {
            $(this).css('display', 'none');            
            $('#urun_genel_resim').html(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
			$('#urun_genel_resim').html('<img src="images/resimsiz.png" alt="" />');
        }).attr({ src:id , style:'border:0;'	 }); 
 });
}




function iletisim_gonder() {
		$('#loading').html('<img src="images/loader_pink.gif" width="32" alt="" align="center" border="0" />');
		$('#form_bilgileri').validate({
		rules: {
			isim: { required: true, minlength:3 },
			konu: { required: true, minlength:3 },
			mesaj: { required: true, minlength:3 },
			eposta: { required: true, email: true }
		
		},
		messages: {
			isim: { required: '',minlength:''  },
			konu: { required: '', minlength:'' },
			mesaj: { required: '', minlength:'' },
			eposta: { required: '' , email: '' }
		
		}
		 
		});
		sonuc = $('#form_bilgileri').valid();
		
		if(sonuc == true){
		$.ajax({
			type: "POST",
			url: aktif_tema+"islemler/iletisim_sonuc.php",
			data: $('form#form_bilgileri').serialize(),
			success: function(cvp){
				$('#loading').html('');
				cvp = bosluk_al(cvp);				
				$('#loading').html(cvp);
			 } 
		 });
				}else{
				$('#loading').html('');	
				}
}//iletisim_gonder


function yorum_yap() {
		$('#loading_yorum').html('<img src="images/loader_pink.gif" width="32" alt="" align="center" border="0" />');
		$('#yorum_form').validate({
		rules: {
			isim: { required: true, minlength:3 },
			mesaj: { required: true, minlength:3 },
			eposta: { required: true, email: true }
		
		},
		messages: {
			isim: { required: '',minlength:''  },
			mesaj: { required: '', minlength:'' },
			eposta: { required: '' , email: '' }
		
		}
		 
		});
		sonuc = $('#yorum_form').valid();
		
		if(sonuc == true){
		$.ajax({
			type: "POST",
			url: aktif_tema+"islemler/yorum_sonuc.php",
			data: $('form#yorum_form').serialize(),
			success: function(cvp){
				$('#loading_yorum').html('');
				cvp = bosluk_al(cvp);				
				$('#loading_yorum').html(cvp);
				document.getElementById("yorum_form").reset();
			 } 
		 });
				}else{
				$('#loading_yorum').html('');	
				}
}//iletisim_gonder

function  bulten_kayit(){
	$(document).ready(function(){
$('#ebulten_formu').validate({
rules: {
	ebulten: { required: true, email: true }
	
	},
	messages: {
	ebulten: { required: ' ' , email: '' }
	}	 
});
sonuc = $('#ebulten_formu').valid();
		if(sonuc == true){
			$.ajax({
				url: aktif_tema+'islemler/bulten_sonuc.php',
				data:$("#ebulten_formu").serialize(),
				type:'POST',
				success:function(cvp){
					$("#bulten_sonuc").text(cvp);
				}//scs
				
			});//ajax	
			
		}
	
	});//ready
}//end function

function tool_tip(div_id){
	$(document).ready(function(){
		$(div_id).tooltip({
			delay:0,
			showURL:false,
			track:true,
			top:-32,
			left:-69
		});
	});
	
}//tool_tip


/* anket */ 
function  anket_kayit(){
	$(document).ready(function(){
		$("#anket_sonuc").html('<img src="images/loader2.gif" alt="" />');
			$.ajax({ 
				url: aktif_tema+'islemler/anket_sonuc.php',
				data:$("#anket_formu").serialize(),
				type:'POST',
				success:function(cvp){
					$("#anket_alan").html(cvp);
				}//scs
				
			});//ajax	
		});//document		

}//end function

/* anket -------*/


//arama
function text_box_renk_cevir(id,renk){
	$(id).css({'color':renk });
}
function arama_yap2(deger){
	$(document).ready(function(){	
	aranacak_kelime1 = $('#s').val();
	if(aranacak_kelime1 == deger || aranacak_kelime1 ==''){
		text_box_renk_cevir('#s','#efa007');
		setTimeout("text_box_renk_cevir('#s','#aaa');",1000);
	}else{
	window.location='?sayfa=arama-&s='+aranacak_kelime1;	
	}
	});
}
function kutu_bosalt(k,deger) {
	kutu = $('#'+k);
    if(kutu.val() == deger)
		kutu.val('');
}
//arama ---
