var initTMR;

$(document).ready(function(){
	start();
	$('#clock').jclock();
});

function start(){
	$("*").ajaxComplete(function(event,request, settings){
		if(initTMR){
			clearTimeout(initTMR);
		}
		initTMR = setTimeout("init();", 800);
	});
	
	init();
	$('[rel=SayfaRe]').hover(function(){
    SayfaReOver(this);
    },function(){
        SayfaReOut(this);
    });

    function SayfaReOver(me){
    var id = $(me).attr("id");
    $("#"+id+" img").fadeIn();

    }

    function SayfaReOut(me){
    var id = $(me).attr("id");
    $("#"+id+" img").fadeOut();
    }

}

function init(){
	$("#myslidemenu li ul").each(function(){
		$(this).prev().attr("href", "#").click(function(){
			return false;
		});
	});
	$("#myslidemenu").find("li:last a").css("border", "0");
	galeriYap("[rel=lightbox]");
	
	if($("#haberSlide")){
		$("#haberSlide").cycle({ 
			fx:      'scrollUp',
			easeIn:  'easeInSine',
			easeOut: 'easeOutBounce', 
			speed:   1000, 
			timeout: 5000, 
			pause:   1
		});
	}
	
	$("#hSlide").cycle({ 
			fx:      'scrollUp',
			easeIn:  'easeInSine',
			easeOut: 'easeOutBounce', 
			speed:   1000, 
			timeout: 5000, 
			pause:   1
		});
	/*$('.tipsy').remove();
	$('[title][g=n]').tipsy({
		gravity: 'n'
	});
	$('[title][g=w]').tipsy({
		gravity: 'w'
	});
	$('[title][g=s]').tipsy({
		gravity: 's'
	});
	$('[title][g=e]').tipsy({
		gravity: 'e'
	});
	$('[title][g!=n][g!=w][g!=s][g!=e]').tipsy({
		gravity: 's'
	});
	
	$("[tarih=1]").mask("99.99.9999");
	
	$("[numeric=1]").numeric("0123456789");
	$("[numeric=2]").numeric(".");
	
	$(".ajaxForm").unbind("submit").submit(function(){
		return ajaxForm(this);
	});*/
}

/*
	$(function(){
		$("[numeric=1]").numeric('1234567890');
		$("[numeric=2]").numeric('.');
	});
*/


function sayfaDegis(adres){
	window.location.href = adres;
}

function galeriYap(str){
	$(str).lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.7,
		imageLoading: 'JS/jQuery/lightbox/images/lightbox-ico-loading.gif',
		imageBtnClose: 'JS/jQuery/lightbox/images/lightbox-btn-close.gif',
		imageBtnPrev: 'JS/jQuery/lightbox/images/lightbox-btn-prev.gif',
		imageBtnNext: 'JS/jQuery/lightbox/images/lightbox-btn-next.gif',
		containerResizeSpeed: 350 /*,
		txtImage: 'Imagem',
		txtOf: 'de'*/
	});
}

function secAll(me){
	var val = $(me).attr("checked");
	var grup = $(me).attr("grup");
	$("input[grup="+ grup +"]").attr("checked", val);
}

function ajaxDiyalog(adres, options, ajaxOptions){
	$('.dialog-content').css("overflow-x", null).css("overflow-y", null);
	$.weeboxs.open('Lütfen Bekleyiniz...',{
		title: 'Lütfen Bekleyiniz...'
	});
	
	if(ajaxOptions){
		if(ajaxOptions.method == "post"){
			$.post(adres, ajaxOptions, function(data){
				$.weeboxs.close();
				$.weeboxs.open(data, options);
			});
		}else{
			$.get(adres, ajaxOptions, function(data){
				$.weeboxs.close();
				$.weeboxs.open(data, options);
			});
		}
	}else{
		$.get(adres, function(data){
			$.weeboxs.close();
			$.weeboxs.open(data, options);
		});
	}
}

function frameDiyalog(baslik, adres){
	$.weeboxs.open('<iframe width="600" height="500" style="border:0; margin:0px 0px 0px 0px; padding:0px 0px 0px 0px;" scrolling="auto" src="'+ adres +'">',{
		title: baslik,
		width:606
	});
	$('.dialog-content').css("overflow-x", "hidden").css("overflow-y", "hidden");
}

