jQuery(document).ready(function() {
	// cancel default event
	function cancel(e){
		//e.cancelBubble is supported by IE - this will kill the bubbling process.
		e.cancelBubble = true;
		e.returnValue = false;
		//e.stopPropagation works only in Firefox.
		if (e.stopPropagation) {
			e.stopPropagation();
			e.preventDefault();
		};
	};


	// assign keyboard event and shortcuts
	var isCtrl = false;
	var isShift = false;
	jQuery(document).keyup(function (e) {
		if(e.which == 17) isCtrl=false;
		if(e.which == 16) isShift=false;
	}).keydown(function (e) {
		if(e.which == 17) isCtrl=true;
		if(e.which == 16) isShift=true;
		if(e.which == 71 && isCtrl == true && isShift == true) {
			toggle_grid();
			return false;
		};
	});

	// show / hide grid
	var grid = "off";
	function toggle_grid(){
		if (grid == "off"){
			jQuery("#grid").css({display: "block"});
			grid = "on";
		} else {
			jQuery("#grid").css({display: "none"});
			grid = "off";
		};
	};
	
	// cover fader and info display
	$(".cover").hover(
	  function () {
	    cover_fade(this.id);
		// show_content(this.id);
		// show_shadow(this);
		$(this).css("z-index", "10");
	  }, 
	  function () {
		cover_norm();
		reset_zindex();
		hide_content();
		// hide_shadow(this);
	  }
	);
	
	var	displayed_content = "#freebirds";
	
	function cover_fade(exclude){
		if (exclude != "jetlife_img"){
			$("#jetlife_img #fader").stop();
			$("#jetlife_img #fader").fadeTo("fast", 0.75);
		};
		if (exclude != "ncm_img"){
			$("#ncm_img #fader").stop(); 
			$("#ncm_img #fader").fadeTo("fast", 0.75);
		};
		if (exclude != "caretta_img"){ 
			$("#caretta_img #fader").stop();
			$("#caretta_img #fader").fadeTo("fast", 0.75);
		};
		if (exclude != "moment_img"){ 
			$("#moment_img #fader").stop();
			$("#moment_img #fader").fadeTo("fast", 0.75);
		};
		if (exclude != "emlak_img"){ 
			$("#emlak_img #fader").stop();
			$("#emlak_img #fader").fadeTo("fast", 0.75);
		};
	};
	function cover_norm(){
		// alert($("#jetlife_img #fader").css('display'));
		$("#jetlife_img #fader").fadeTo("fast", 0);
		$("#ncm_img #fader").fadeTo("fast", 0);
		$("#caretta_img #fader").fadeTo("fast", 0);
		$("#moment_img #fader").fadeTo("fast", 0);
		$("#emlak_img #fader").fadeTo("fast", 0);
	};
	// function show_content(div_id){
	// 	var target_div = "#"+div_id.substr(0,div_id.length-4);
	// 	$(displayed_content).css({display: "none"});
	// 	$(target_div).css({display: "block"});
	// 	displayed_content = target_div;
	// };
	function hide_content(){
		$(displayed_content).css({display: "none"});
		$("#freebirds").css({display: "block"});
		displayed_content = "#freebirds";
	};
	function reset_zindex(){
		$("#jetlife_img").css("z-index", "1");
		$("#ncm_img").css("z-index", "2");
		$("#caretta_img").css("z-index", "3");
		$("#moment_img").css("z-index", "4");
		$("#emlak_img").css("z-index", "5");
	};
	
	
	// adv name display
	$(".adv").hover(
	  function () {
		$(".adv_header").html(this.firstChild.alt);
	  }, 
	  function () {
		$(".adv_header").html('Dergilerimizde yayınlanan reklamlar');
	  }
	);
});
