﻿jQuery(document).ready( function() {
	
	if ( jQuery('#list1a').length > 0 )
	{
		jQuery('#list1a').accordion({
			header: '.listbaslik',
			active: '.selected',
			autoheight: false,
			alwaysOpen: false
		});
	}
	
	jQuery(".catalogListText:last").css("border","none");
	
	jQuery("#menuContainer a:last").css({ background:"none", paddingRight:0  });
	//jQuery("#seninDunyan .seninDunyanBox:last").css({ border:"none" });
	
	var withi = jQuery("#menuContainer a:contains('i'), .Level1CssBegin > a:contains('i'), #leftTitle:contains('i'), #katalogMenu2 a:contains('i'), .ItemStyleCssClass a:contains('i')");
	var withall = jQuery("#menuContainer a, .Level1CssBegin > a, #leftTitle, #katalogMenu2 a, .ItemStyleCssClass a:contains('i')");	
	
	withi.each(function(){
		
		jQuery(this).text(jQuery(this).text().replace(/i/ig,'İ'));
	  
	});
	
	withall.each( function() {
		
		jQuery(this).text(jQuery(this).text().toUpperCase());
		
	});
	
	jQuery("h1, h2, .helvatica, .detailedSearchTitle, .quicksand, #contentTitle, #leftTitle, #leftMenu li a, #leCatalogueProductName, .characterListItemText, #katalogMenu1 a").css("visibility","visible");
	
	//jQuery("#menuContainer a").css("fontSize","13px");
	
	jQuery(".pagerStyleCSS a").each( function() {
		
		if ( jQuery(this).text() == "..." )
		{
			jQuery(this).addClass("firstLast");
		}
		
	});
	
	jQuery(".pagerStyleCSS td").each( function() {
		
		if (jQuery(this).find("a").length <= 0)
		{
			jQuery(this).wrapInner("<b />")
		}
		
	});
	
	if ( jQuery(".firstLast").size() > 1 )
	{
		jQuery(".firstLast:first").parent().prev().remove();
		jQuery(".firstLast:first").html("<img src='/images/button/button_prev.png' />");
		jQuery(".firstLast:last").parent().next().remove();
		jQuery(".firstLast:last").html("<img src='/images/button/button_next.png' />");
	}
	else
	{
		if ( jQuery(".firstLast:first").parent().prev().text() == "<<" )
		{
			jQuery(".firstLast:first").parent().prev().remove();
			jQuery(".firstLast:first").html("<img src='/images/button/button_prev.png' />");
		}
		else
		{
			jQuery(".firstLast:last").parent().next().remove();
			jQuery(".firstLast:last").html("<img src='/images/button/button_next.png' />");	
		}
	}
	
	Cufon.replace('.helvatica, #menuContainer a, .detailedSearchTitle' , { fontFamily: 'helvatica', hover: true });
	Cufon.replace('.quicksand, #contentTitle, #leftArea a, .contentTitle, #productPageDetail a, #productsearchPageDetail a, .characterListItemText, .listPageTitle, .lblCurrentPage' , { fontFamily: 'quicksand', hover: true });
	Cufon.replace('#leftTitle' , { fontFamily: 'quicksand', hover: true, color: '-linear-gradient(#FFF, 0.95=#d2d2d2)', textShadow: '2px 2px #1d5097' });
	Cufon.replace('#katalogMenu1 a' , { fontFamily: 'quicksand', hover: true, color: '-linear-gradient(#FFF, 0.95=#d2d2d2)', textShadow: '2px 2px #1d5097' });
	Cufon.replace('#leCatalogueProductName' , { fontFamily: 'quicksand', hover: true, textShadow: '2px 2px #c7c5bb' });
	
	var timeoutFlash;
	
	jQuery(".flashContent").each(function() {
							
		jQuery(this).unwrap().unwrap();
	
	});
	jQuery(".flashContent:first").prev().remove();
	jQuery(".flashContent:first").unwrap().unwrap();
	
	jQuery("#flashContent > div").each( function(i,selected) {
		
		jQuery(this).children("a").attr("href",jQuery(this).children("span").text());
		jQuery(this).children("span").remove();
		jQuery("#flashNavigation").append("<div>" + ( i + 1 ) + "</div>");
		
	});
	
	jQuery("#flashNavigation > div").click( function() {
		
		jQuery("#flashNavigation > div").removeClass("active");
		jQuery(this).addClass("active");
		
		var flashindex = jQuery("#flashNavigation > div").index( jQuery(this) );
		jQuery("#flashContent").animate({ marginTop: ( 0 - (flashindex * 264 ) ) });
		
		clearTimeout(timeoutFlash);
		timeoutFlash = setTimeout( function() {
			
			var nextElement = jQuery("#flashNavigation > .active").next();
			if ( nextElement.length > 0 )
			{
				nextElement.click();
			}
			else
			{
				jQuery(jQuery("#flashNavigation > div")[0]).click();
			}
			
		},5000);
		
	});
	
	jQuery(jQuery("#flashNavigation > div")[0]).click();
	
	
	
	
	jQuery("#sonCikanlarContent > div").each( function(i,selected) {
		
		jQuery("#sonCikanlarNavigation").append("<div>" + ( i + 1 ) + "</div>");
		
	});
	
	jQuery("#sonCikanlarNavigation > div").click( function() {
		
		jQuery("#sonCikanlarNavigation > div").removeClass("active");
		jQuery(this).addClass("active");
		
		var tabindex = jQuery("#sonCikanlarNavigation > div").index( jQuery(this) );
		jQuery("#sonCikanlarContent > div").fadeOut(500);
		jQuery(jQuery("#sonCikanlarContent > div")[tabindex]).fadeIn(500);
		
	});
	
	jQuery(jQuery("#sonCikanlarNavigation > div")[0]).click();
	
	if ( jQuery("a.zoom").length > 0 )
	{
		jQuery("a.zoom").fancybox({
			'overlayOpacity'	:	0.8,
			'zoomSpeedIn'		:	500,
			'zoomSpeedOut'		:	500
		});	
	}
	
	//jQuery(".slideMenuDiv2").removeAttr("style");
	jQuery(".slideMenuDiv2").css("height","");
	
	jQuery("#leCatalogueProductDetailThumbs div").click( function() {
		
		str = jQuery(this).children("img").attr("src").replace("/thumbnailsmallest/","/thumbnail/");
		strTitle = jQuery(this).children("img").attr("title");
		jQuery("#leCatalogueProductDetailImage").children("img").attr("src",str);
		jQuery("#leCatalogueProductDetailImage").children("img").attr("title",strTitle);
		jQuery("#leCatalogueProductDetailImage").children("img").attr("alt",strTitle);
	
	});
	
	jQuery("#CatalogTree1_treeCategories tr:empty").remove();
	
	jQuery("#CatalogTree1_treeCategories a img").each(function() {
		
		var parrent = jQuery(this).parent().parent();
		parrent.insertAfter(parrent.next());
		parrent.css("width","20px");
		
	});
	
	jQuery("#katalogMenu1 table").attr("cellpadding","0px").attr("cellspacing","0px").attr("border","0px");
	
	jQuery("td.leafNodeStyle").each( function() {
		
		jQuery(this).prev().remove();
		jQuery(this).prev().remove();
		jQuery(this).prev().remove();
		
	});
	
	var setTimeoutSlider = setTimeout( function() {
			
		var sliderLeft = jQuery("#characterLeft");
		var sliderContent = jQuery("#characterContentWrapper");
		var sliderRight = jQuery("#characterRight");
		
		var sliderContentWidth = jQuery("#characterContentWrapper").width();
		var sliderContentTableWidth = jQuery("#characterContentWrapper table").width();
		var sliderContentDiff = sliderContentTableWidth % sliderContentWidth;
		
		var slideRatio = parseInt(sliderContentTableWidth / sliderContentWidth);
		var slideNumber = 0;
		
		sliderContentWidth -= ( sliderContentWidth - sliderContentDiff ) / slideRatio;
		
		sliderLeft.click( function() {
			
			slideNumber--;
			if ( slideNumber < 0 )
			{
				slideNumber = slideRatio;
			}
			
			sliderContent.children("div").animate( {
				marginLeft: 0 - ( sliderContentWidth * slideNumber )
			},800);
			
		});
		
		sliderRight.click( function() {
			
			slideNumber++;
			if ( slideNumber > slideRatio )
			{
				slideNumber = 0;
			}
			
			sliderContent.children("div").animate( {
				marginLeft: 0 - ( sliderContentWidth * slideNumber )
			},800);
			
		});
			
	},1000);
	
});

function checkEnter(e){ 
var characterCode;

if(e && e.which) 
{ 
	e = e;
	characterCode = e.which; 
}

else
{
	e = event;
	characterCode = e.keyCode; 
}


if(characterCode == 13){

    var objTemp = document.getElementById('aramaText');
    if(objTemp!=null)
    {
        window.location.href = '/arama/arama.aspx?keyword=' + objTemp.value;
        return false;
    }
}

}
function SubmitSearch()
{
    var objTemp = document.getElementById('aramaText');
    if(objTemp!=null)
    {
        window.location.href = '/arama/arama.aspx?keyword=' + objTemp.value;
    }
}
