/*
	
	Yazar		: Tolga Gezginis
	Yazar URI	: http://www.tolgagezginis.com
	
	Dosya içerigi izinsiz bir sekilde kullanilamaz.
	Copyright Tolga Gezginis

*/

$(document).ready(function()
{
	$('#urunresimleri').galleryView({
		panel_width: 710,
		panel_height: 450,
		frame_width: 100,
		frame_height: 58,
		paused: true
	});


	var view = $( window );
	var sW = view.width();
	var startingLeftPos = 0;
	var startingDelta = 0;

	$( view ).everyTime (5000,'animatedBG',function(){
		startingLeftPos = startingLeftPos + 30;
		var bgPos2 = "-"+ startingLeftPos + "px 0px";
		var bgPos3 = "-"+ startingLeftPos + 30 + "px 0px";
		$("#cont").css("background-position", bgPos2);
	});


	//$(".box-250 ul li ul li.selected").corner("5px");
	//$(".box-250 ul li.selected").corner("5px");
	//$(".box-500").corner("10px");

	//$("#slider").corner("10px");
	//$(".sayfa_resim").corner("10px");

	//$(".box h2").corner("5px");

	$("#nav #menu .corner").corner("7px tr tl");
	$("#nav #menu li ul li:last").css("border","none");

	$("#nav #menu li .sub").corner("7px bl br");

	//$("#footer").corner("10px");
	//$("#header").corner("10px");
	//$("#container").corner("10px");
	//$("#urunbaslik").corner("5px tr tl");

	//$('#index-ref').cycle('fade');


	var config = {
		 sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)
		 interval: 50, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
		 timeout: 50, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};

	$("#nav #menu li .sub").css({'opacity':'0'}).css({'width':'666px'}); //Fade sub nav to 0 opacity on default
	$("#nav #menu li").hoverIntent(config);

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
		(function($) {
			//Function to calculate total width of all ul's
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() { //for each ul...
					rowWidth += $(this).width(); //Add each ul's width together
				});
			};
		})(jQuery); 

		if ( $(this).find(".row").length > 0 ) { //If row exists...

			var biggestRow = 0;	

			$(this).find(".row").each(function() {	//for each row...
				$(this).calcSubWidth(); //Call function to calculate width of all ul's
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});

			$(this).find(".sub").css({'width' :biggestRow}); //Set width
			$(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

		} else { //If row does not exist...

			$(this).calcSubWidth();  //Call function to calculate width of all ul's
			$(this).find(".sub").css({'width' : rowWidth}); //Set Width

		}
	}
	//On Hover Out
	function megaHoverOut(){
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		  $(this).hide();  //after fading, hide it
	  });
	}

//	$(".navigation li").click(function ()
//	{
//		$(".navigation li").removeClass("aktif");
//		$(this).addClass("aktif");
//	})
	
	

});

