$().ready(function(){
    /* subcribe box */
    /*
    $('.subcribe .flash').html('<div id="FlashSubcribe"></div>');
    var FlashSubcribe = new SWFObject("swf/subcribe.swf?imgSrc="+$('.logo-row .subcribe img').attr('src'),"FlashSubcribe","95","120","9");
        FlashSubcribe.addParam("allowfullscreen","false");
        FlashSubcribe.addParam("allowscriptaccess","always");
        FlashSubcribe.addParam("wmode","transparent");
        FlashSubcribe.addParam("menu","true");
        FlashSubcribe.write("FlashSubcribe");
    $('.subcribe img').remove();
    */

    /* top menu*/
    $('.top-menu li').hover(function(){ $(this).children('a:first').addClass('mark'); $(this).children('div').show();},function(){ $(this).children('a:first').removeClass('mark'); $(this).children('div').hide();})
    $('.top-menu a').click(function(event){
        if($(this).attr('href')=='#' || $(this).attr('href')==''){
            event.preventDefault();
        }
    });
    
    /* search box */
    if( $('input#q').length>0 )
    {
        $('div.top-search label[for="q"],div.top-search2 label[for="q"]').overlabel();

        /*        
        $("#searchcategories").css({
             'left':Math.round($('input#q').offset().left)+'px'
             ,'top':Math.round($('input#q').offset().top+$('input#q').height()+17)+'px'
        });
        */
        $("#searchcategories").css({
             'left':0
             ,'top':'32px'
             ,'display':'none'
        }).find('li').find('label').css({'float':'none','display':'block','text-align':'left'});
        
        $('input#q').click(function(){
            $("#searchcategories").toggle();
        });
        $("#searchcategories").mouseup(function() {
            return false;
        });
    }
    $(document).mouseup(function(e) {
        if($(e.target).parent("#searchInputText").length==0) {
            $("#searchcategories").hide();
        }
    });  
    $('#searchcategories input[type="checkbox"]').click(function(e){
        var checked = $('#searchcategories input[type="checkbox"]').is(':checked');
        var radios = $('#searchcategories input[type="radio"]');
        if(checked ){
            $('#searchcategories input[type="radio"]').removeAttr('checked');
            $(radios).attr('disabled','disabled');
        }else{
            $(radios).removeAttr('disabled');
            if( !$('#searchcategories input[type="radio"]:checked').length>0 ){
                
                $(radios[0]).attr('checked','checked');
            }
        }
    });
	
    $('a.ustegonder').click(function (event) { 
        event.preventDefault();
        $('#buyuk-resim').attr('src',$(this).attr('href'));

	});
 
    $('div.shoplist-product').mouseover(function()
    {
    	$(this).css('border','4px solid #880E0B');
	});	 
	$('div.shoplist-product').mouseout(function()
	 {
		$(this).css('border','4px solid #E0DCD3');
	});	


/*
	var msie6 = $.browser.msie && $.browser.version<7 ? true : false;
	$('.topmenu ul li.menu').hover(function(){
                $(this).addClass('top-menu-selected');
                $(this).children('ul').fadeIn(300);
				},function(){
					$(this).removeClass('top-menu-selected');
					$(this).children('ul').fadeOut(250);
    });
    if (typeof _activeTabClass !== "undefined" && _activeTabClass != ""){
        $('.topmenu ul li.'+_activeTabClass+'').addClass('def_top-menu-selected');
    }
*/

/*Select option */
var selectAnims = {borderTopColor: '#C00', borderRightColor: '#C00', borderBottomColor: '#C00', borderLeftColor: '#C00'};
var selectAnimsBack = {borderTopColor: '#CCC', borderRightColor: '#CCC', borderBottomColor: '#CCC', borderLeftColor: '#CCC'};
function altSelectYap(el, altEl, degerler) {
    $(function(){
        $(el).change( function(){
			$(altEl).removeOption(/./);
			if($(el).val()>0){
                if(degerler[$(el).val()]){
				    $(altEl).addOption(degerler[$(el).val()] , false);
                }
                $(altEl).val('').change();
			}
			$(altEl).animate(selectAnims, 300, function() {
				$(altEl).animate(selectAnimsBack, 250);
			});
		});
    });
}

    /*font Textsize*/
    $('.textsize li').click(function(){
    		$('.textsize').removeClass('a1');
    		$('.textsize').removeClass('a2');
    		$('.textsize').removeClass('a3');
    		$('.textsize').removeClass('a4');
    		$('.textsize').addClass($(this).attr('id'));
    		$('.content-resize').css('font-size',$(this).attr('title') + 'px');
    
    });


    /* listings more */
    $("li.seemore a").click(function(event){
        event.preventDefault();
        $('#lists_seemorebox').remove();
        $('body').append('<div id="lists_seemorebox" class="hide listing-select"><div class="listing-select"><div class="menu"><ul></ul></div></div></div>');
        //$('body').append('');
        
        $(this).parents('ul:first').find('li[class!="seemore"]').clone().removeClass().appendTo( $('#lists_seemorebox ul') );
        $('a.lists_seemorebox').click();
        //$(this).parents('ul:first').find('li').removeClass();
        //$(this).parents('li:first').remove();
    });
    
    $('.lstrmcntrl:not(:has(li))').prev('div:first').hide();
    $('.lstrmcntrl:not(:has(li))').hide();
    
});


/*COOKIE*/
function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());}
function setCookieTime(c_name,value,minutes){var exdate=new Date();exdate.setTime( exdate.getTime() );var exdate = new Date( exdate.getTime() + (minutes * 1000 * 60) );document.cookie=c_name+ "=" +escape(value)+((minutes==null) ? "" : ";expires="+exdate.toGMTString());}
function randomString(length){var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');if (! length) {length = Math.floor(Math.random() * chars.length);}
    var str = '';for (var i = 0; i < length; i++) {str += chars[Math.floor(Math.random() * chars.length)];}return str;
}	



/* Üye Favori */
function favoriekle(modul,pageContentId) {
    var url = location.href;
    var title = $('title').html();
	var postveri = 'modul='+modul+'&pageContentId='+pageContentId+'&url='+url+'&title='+title+'&ac=favoriekle';
	$.ajax({
		type: "POST",
		url: "ajax_fonksiyonlar.php",
		data: postveri,
		success: function(msg){
			
			if(msg=="ok"){
				pencereCagir("pencereAlert","linkplysmsjx","<div id='linkplysmsjx'><strong style='color:red'>Added to Favorites</strong></div>");
			}if(msg=="ekli"){
				pencereCagir("pencereAlert","linkplyshtmsjx","<div id='linkplyshtmsjx'><strong style='color:red !important'>ERROR! Previously Added !</strong></div>");
			}if(msg=="hata"){
				pencereCagir("pencereAlert","linkplyshtmsjx","<div id='linkplyshtmsjx'><strong style='color:red !important'>ERROR! This process is specific to members !</strong></div>");
			}
		}
	});	
}
/* Üye Favori */

/* Üye Favori Sil */
function favorisil(favID) {
	var postveri = 'favID='+favID+'&ac=favorisil';
	$.ajax({
		type: "POST",
		url: "ajax_fonksiyonlar.php",
		data: postveri,
		success: function(msg){
			if(msg=="ok"){
				pencereCagir("pencereAlert","fvrkldrmsjx","<div id='fvrkldrmsjx'>Sayfa Favori Listeninizden Kaldırıldı!</div>");
				location.reload();
			} else {
				pencereCagir("pencereAlert","uyegrszrnlmsjjy","<div id='uyegrszrnlmsjjy'>Üye Girişi Yapmanız Gerekli!</div>");
			}
		}
	});	
}
/* Üye Favori Sil */

/* display-news */
$(document).ready(function(){
 if( $('#display-news-slider-container').html()!=null ){
 if($.browser.msie && jQuery.browser.version<7){
    $('#display-news-fillet1,#display-news-fillet2').ifixpng();
    $('#display-news-slider-little li:last').css('margin-right','2px');
 }

 var crslPluses,SlideSayisi;
 var SlideTxts=Array();
 $.timer(8000, function (timer) { if( crslPluses!='display-news-slider' ){$('#display-news-slider-container .next').click();} });
 var IlkTxt = '<h6>'+$('#display-news-slider-little li:first img').attr('alt')+'</h6>'+'<p>'+$('#display-news-slider-little li:first img').attr('title')+'</p>'+'<a href="'+$('#display-news-slider-little li:first a').attr('href')+'" class="readmore">'+$('#display-news-slider-little li:first img').attr('rel')+'</a>';


$('#display-news-slider-little li:first a').addClass('current');
$('#display-news-info-text').html(IlkTxt);
Cufon.replace('#display-news-info-text h6', { fontFamily: 'MartenCyr-Grotesque',color:'#000'});

$('#display-news-info').fadeTo(0,.9);
$('#display-news-info-text').show();
$('#display-news-slider-container').show();        


 var clss=Array();
 var a = $('#display-news-slider-little a');
 SlideSayisi = a.length;
 for (var i = 0; i < a.length; i++) {
 $(a[i]).addClass("a"+i);
 clss[i]='#display-news-slider-little .a'+(i);
 SlideTxts[i]='<h6>'+$(a[i]).children('img').attr('alt')+'</h6>'+'<p>'+$(a[i]).children('img').attr('title')+'</p>'+'<a href="'+$(a[i]).attr('href')+'" class="readmore">'+$(a[i]).children('img').attr('rel')+'</a>';
 
 $(a[i]).children('img').attr('alt','');
 $(a[i]).children('img').attr('title','');
 }
 $("#display-news-slider-wrapper")
 .jCarouselLite({mouseWheel:true,vertical:false,visible:1,auto:null,speed:500,btnNext:'#display-news-slider-container .next',btnPrev:'#display-news-slider-container .prev',
 btnGo:clss,
 beforeStart:function(a){
 $('#display-news-info-text').hide();
 $('#display-news-info').fadeTo('fast',0);
 },
 afterEnd:function(a){
 GorunenAdet = 1;
 SlideGenisligi = 685;
 SlideGenisligi = SlideGenisligi * GorunenAdet;
 GecerliPixel = Number($(a).parent().css('left').replace(/px/gi, ""))*-1;
 if(GecerliPixel==0){Slayt=SlideSayisi;}else{Slayt=GecerliPixel/SlideGenisligi>SlideSayisi?GecerliPixel/SlideGenisligi-SlideSayisi:GecerliPixel/SlideGenisligi;}
 $('#display-news-slider-little li a').removeClass('current');
 $('#display-news-slider-little li a.a'+(Slayt-1)).addClass('current');
 $('#display-news-info').fadeTo('fast',0.8);
 $('#display-news-info-text').show().html(SlideTxts[Slayt-1]);
 Cufon.replace('#display-news-info-text h6', { fontFamily: 'MartenCyr-Grotesque',color:'#000'});
 }
 });
 $("#headline-container").mouseover(function(){ crslPluses='display-news-slider'; }).mouseout(function() { crslPluses=''; });
 }

});
/* display-news */ 

/* makale detail slider */
$(document).ready(function(){
    if( $(".article-detail-img-long div.Slider li").length > 1 )
    {
        $('.article-detail-img-long').hover(function(){$('.article-detail-img-long .SlideNav').fadeTo(100,.4)},function(){$('.article-detail-img-long .SlideNav').fadeTo(100,0)});
        $('.article-detail-img-long .SlideNav').hover(function(){$(this).fadeTo(100,.8)},function(){$(this).fadeTo(100,.4)});
        $(".article-detail-img-long div.Slider").jCarouselLite({mouseWheel:true,vertical:false,visible:1,auto:null,speed:500,
            btnNext:'.article-detail-img-long div.next a',btnPrev:'.article-detail-img-long div.prev a'});
    }
});
/* makale detail slider */

/* Mekan detail slider */
$(document).ready(function(){
    if( $(".listing-detail-img-long div.Slider li").length > 1 )
    {
        $('.listing-detail-img-long').hover(function(){$('.listing-detail-img-long .SlideNav').fadeTo(100,.4)},function(){$('.listing-detail-img-long .SlideNav').fadeTo(100,0)});
        $('.listing-detail-img-long .SlideNav').hover(function(){$(this).fadeTo(100,.8)},function(){$(this).fadeTo(100,.4)});
        $(".listing-detail-img-long div.Slider").jCarouselLite({mouseWheel:true,vertical:false,visible:1,auto:null,speed:500,
            btnNext:'.listing-detail-img-long div.next a',btnPrev:'.listing-detail-img-long div.prev a'});
    }
});
/* makale detail slider */


/* swapImages */
function swapImages(target, url, thumbDiv, thumbID)
{
    var mThumbDiv = document.getElementById(thumbDiv);
    var workingNode = 0;
    var imgSrc = "";
    
    for (k=0; k< mThumbDiv.childNodes.length; k++)
    {
         if (mThumbDiv.childNodes[k].tagName == "A")
         {
            workingNode++;
            
            if (workingNode == thumbID)
            {
                 mThumbDiv.childNodes[k].className = "current";
                 
                 try
                 {
                    imgSrc = mThumbDiv.childNodes[k].childNodes[1].getAttribute("src");
                 } catch (ex) {
                    imgSrc = mThumbDiv.childNodes[k].childNodes[0].src;
                 }
            }else
                mThumbDiv.childNodes[k].className = "";
            
         }
    }
    
    document.getElementById("bigImage").setAttribute("src", imgSrc);
}

/* swapImages */
