
$(function(){

    var $el, leftPos, newWidth,
        $mainNav = $("#example-one"),
        $mainNav2 = $("#example-two");

    $mainNav2.append("<li id='magic-line-two'></li>");
    $("#headerCenter li a").click(function() {
 		var iclang=$(this).attr("rel");
		if(iclang!="tr") {
			document.forms.langform.action=ic_self_location
			document.forms.langform.seticlanguage.value=iclang
			document.forms.langform.submit()
		}
	});
    
    var $magicLineTwo = $("#magic-line-two");

	if($(".current_page_item_two").width() != null) {
    $magicLineTwo
        .width($(".current_page_item_two").width())
        .height($mainNav2.height())
        .css("left", $(".current_page_item_two a").position().left)
        .data("origLeft", $(".current_page_item_two a").position().left)
        .data("origWidth", $magicLineTwo.width())
        .data("origColor", $(".current_page_item_two a").attr("rel"));
   	} else {
    $magicLineTwo
        .width(45)
        .height($mainNav2.height())
        .css("left", 0)
        .data("origLeft", 0)
        .data("origWidth", $magicLineTwo.width())
        .data("origColor", "#e3e3e3");
	}
    $("#example-two li a").hover(function() {
		$el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        $magicLineTwo.stop().animate({
            left: leftPos,
            width: newWidth,
            backgroundColor: $el.attr("rel")
        })
    }, function() {
        $magicLineTwo.stop().animate({
            left: $magicLineTwo.data("origLeft"),
            width: $magicLineTwo.data("origWidth"),
            backgroundColor: $magicLineTwo.data("origColor")
        });    
    });
});
