$j(document).ready(function(){
	$j("#header li img").navRollovers();
	$j('#header').topNavDropDowns();
});

jQuery.fn.navRollovers = function() {

    $j("#header li img").hover(
		function () {

			var imgSrc = $j(this).attr("src");
			if (imgSrc.indexOf("_off") != -1) {
				var img_on = imgSrc.replace("_off", "_on");
				$j(this).attr("src", img_on);
			} 
		}, 
		function () {
			var imgSrc = $j(this).attr("src");

			if ( $j(this).hasClass("nav_locked") ) { 
				//used to ensure menu dropdown button states are not changed on mouse out.	  
			} else {
			
				if (imgSrc.indexOf("_on") != -1) {
					var img_off = imgSrc.replace("_on", "_off");
					$j(this).attr("src", img_off);				
				}
			}
		}
    );
}

var ro = {
	delay: 100,
	urunler: {
		isOver: false,
		isactive: false,		
		intervalID: null
	},

	closeMenuDropDown: function(isactive, isOver, intervalID, selector, menuID)
	{
		if(!isOver)
		{
			// nav image to off state	
			var img_src_raw = $j(selector).attr("src");
			if (isactive) {
				var img_on = img_src_raw.replace("_don", "_active");
			} else {
				var img_on = img_src_raw.replace("_don", "_off");			
			}
			$j(selector).attr("src", img_on);		
			
			clearInterval(intervalID);
			$j("#" + menuID).addClass("hide");
			intervalID = null;
			isOver = false;
			return;
		}
	}
};

jQuery.fn.topNavDropDowns = function() {
	
	$j("#main_nav_urunler img").mouseover(
		function () {
			if(!$j("#urunler_drop_down:visible").length)
			{				
				var imgSrc = $j(this).attr("src");
				if (imgSrc.indexOf("_active") != -1) {
					var img_off = imgSrc.replace("_active", "_don");
					ro.urunler.isactive = 1;
				} else {
					var img_off = imgSrc.replace("_on", "_don");
			
				}
				$j(this).attr("src", img_off);
				$j("#urunler_drop_down").removeClass("hide");	
				hideLanguageDropDown();
				hideLoginDropDown();
				ro.urunler.isOver = true;
			}
	}).mouseout(	
		function () {
			ro.urunler.isOver = false;
			clearInterval(ro.urunler.intervalID);
			ro.urunler.intervalID = setInterval("ro.closeMenuDropDown( ro.urunler.isactive, ro.urunler.isOver,ro.urunler.intervalID,'#main_nav_urunler img','urunler_drop_down')", ro.delay);
		}		
	);
	
	
	$j("#urunler_drop_down").mouseover(function() {
		ro.urunler.isOver = true;
	}).mouseout(function() {
		ro.urunler.isOver = false;
	});
	
	
    $j("#urunler_kolon_1 li").hover(
		function () {
			$j("#urunler_kolon_1 li").removeClass('current');	
			$j(this).addClass('current');
			var link_id = this.id;
			var link_id_length = link_id.length;
			var section_id = link_id.substring(0, (link_id_length - 5) );
			var section_id_element = '#' + section_id;
			$j(".urunler_kolon_2").addClass('hide');
			$j(section_id_element).removeClass('hide');
		}, 
		function () {

		}
    );

}



// ürünler last tab
function dashstrip_last() {
	var mods = $$('.module');
	mods.each(function(mod){
		var last = mod.getElementsByTagName('LI');
		var len = last.length;
		for (i = 0; i < len; i++) {
			if (i == (len-1)) {
				if (!last[i].hasClassName('last')) {
					last[i].toggleClassName('last');
				}
			} else {
				if (last[i].hasClassName('last')) {
					last[i].toggleClassName('last');
				}
			}
		} 
	});
}

function init() {
	dashstrip_last();
}
