﻿var i_like_it_hide_timeout;
var slider_renkler;
Event.observe($(window), "load", function() {
    //alert(window.location.hash);
    var strHashData = (window.location.hash.indexOf('#')>=0) ? window.location.hash.substr(1): '';
    if (strHashData.length>0) {
        var hash_dizi = strHashData.split('/');
        if(hash_dizi.length>=4)
        {
            urun_detay_goster(hash_dizi[0], hash_dizi[1], hash_dizi[2],hash_dizi[3], false);
        }
    }
});

function tiny_after_resize() {/*$('tinybox').setStyle({ 'filter': 'none' });*/  setTimeout('tooltip_ekle()', 500); }
function tiny_after_hide() {
    window.location.hash = 'urun-listesi';//olmayan hash
    if (window.document.oldtitle) {
        window.document.title = window.document.oldtitle;
    }
 }

 function urun_detay_goster(dil, urun_id, urun_kod, urun_adi, direkt_cagri) {

     if (typeof (pageTracker_kreatif) != "undefined") {
         pageTracker_kreatif._trackPageview("/" + dil + "/" + urun_id.toString()
        + "/" + urun_kod.toString() + "/" + urun_adi.toString());
     }

    TINY.box.show("urun-detay.aspx?dil=" + dil.toString() + "&urun_id=" + urun_id.toString(), true, 944, 535, true);


    if(direkt_cagri /*&& !document.all*/)
    {
        window.location.hash = dil.toString() + '/' + urun_id.toString() + '/' + urun_kod.toString() + '/' + urun_adi.toString();
    }
}//urun_detay_goster

function urun_detay_goster_tek_sayfada(dil, urun_id, urun_kod, urun_adi, direkt_cagri) {

    if (typeof (pageTracker_kreatif) != "undefined") {
        pageTracker_kreatif._trackPageview("/" + dil + "/" + urun_id.toString()
        + "/" + urun_kod.toString() + "/" + urun_adi.toString());
    }

    TINY.box.show("urun-detay-tek-sayfa.aspx?dil=" + dil.toString() + "&urun_id=" + urun_id.toString(), true, 944, 535, true);


    if (direkt_cagri) {
        window.location.hash = dil.toString() + '/' + urun_id.toString() + '/' + urun_kod.toString() + '/' + urun_adi.toString();
    }
}//urun_detay_goster_tek_sayfada

function tooltip_ekle() {   
    $$("#urun_ek_bilgileri .urun_sembol").each(function(link) {
        new Tooltip(link, { align:"left",backgroundColor: '#7F7F7F', maxWidth:500, mouseFollow: false, opacity: 0.95 });
    });

    if (document.getElementById('urun_renkler')) {
        var urun_renkler_yukseklik = $('urun_renkler').getDimensions().height;
        var urun_renkler_icerik_yukseklik = $('urun_renkler_icerik').getDimensions().height;
        var yukseklik_farki = urun_renkler_icerik_yukseklik - urun_renkler_yukseklik;
        //alert(yukseklik_farki);
        if (yukseklik_farki > 0) {
            $('urun_renkler_scroll').show();
            slider_renkler = new Control.Slider('urun_renkler_scroll_', 'urun_renkler_scroll_icerik'
                , { axis: 'vertical' });
            slider_renkler.options.onSlide = function(v) {
                $('urun_renkler_icerik').setStyle({ top: '-' + (v * yukseklik_farki).toString() + 'px' });
                //alert(v);
            };
            slider_renkler.options.onChange = function(v) {
                $('urun_renkler_icerik').setStyle({ top: '-' + (v * yukseklik_farki).toString() + 'px' });
            };
        } //if (yukseklik_farki > 0)
    }//urun_renkler

    window.document.oldtitle = window.document.title.toString();
    var strTitle = $('urun_adi_rengi').innerHTML.replace(/\<\w+\/{0,1}>/, ' / ').toString();
    //alert(strTitle);
    window.document.title = strTitle;
    
    if ($$('#urun_ek_bilgileri a.arkadasina_oner').length > 0) {
        Event.observe($$('#urun_ek_bilgileri a.arkadasina_oner')[0], "mouseover", function() {
            clearTimeout(i_like_it_hide_timeout);
            $('i_like_it').show();
        });
        Event.observe($$('#urun_ek_bilgileri a.arkadasina_oner')[0], "mouseout", function() {
            i_like_it_hide_timeout = setTimeout('i_like_it_hide()', 400);
        });
        $$('#i_like_it a').each(function(a) {
            Event.observe(a, "mouseover", function() {
                clearTimeout(i_like_it_hide_timeout);
            });
            Event.observe(a, "mouseout", function() {
                i_like_it_hide_timeout = setTimeout('i_like_it_hide()', 400);
            });
        });
    }

    if (document.getElementById('urun_renkler_icerik')) {
        // mozilla
        Event.observe('urun_renkler_icerik', 'DOMMouseScroll', wheel);
        // IE/Opera
        Event.observe('urun_renkler_icerik', 'mousewheel', wheel);
    }//urun_renkler_icerik
}

function i_like_it_hide() {
    $('i_like_it').hide();
}


// mouse wheel code from http://adomas.org/javascript-mouse-wheel/
function handle(delta) {
    slider_renkler.setValueBy(-delta);
}

/** Event handler for mouse wheel event. */
function wheel(event) {
    var delta = 0;
    if (!event) /* For IE. */
        event = window.event;
    if (event.wheelDelta) { /* IE/Opera. */
        delta = event.wheelDelta / 120;
        /** In Opera 9, delta differs in sign as compared to IE. */
        if (window.opera)
            delta = -delta;
    } else if (event.detail) { /** Mozilla case. */
        /** In Mozilla, sign of delta is different than in IE.
        * Also, delta is multiple of 3.
        */
        delta = -event.detail / 3;
    }

    /** If delta is nonzero, handle it.
    * Basically, delta is now positive if wheel was scrolled up,
    * and negative, if wheel was scrolled down.
    */
    if (delta)
        handle(delta);

    /** Prevent default actions caused by mouse wheel.
    * That might be ugly, but we handle scrolls somehow
    * anyway, so don't bother here..
    */
    if (event.preventDefault)
        event.preventDefault();

    event.returnValue = false;
}