﻿
function givelinks(foo)
{

$(document.body).getElements('a.ajaxcall').addEvents({
    'click': function(){        
        this.set('html',"<img border='0' src='../i/global/progress_t1.gif' />");
        new Request.HTML({url:this.get('turl') + '&nocache=' + Math.random(), 
        update:$(this.get('tdiv')), onComplete: function(response) {
       givelinks('oncomplete');
     //  alert(Milkbox);
       Milkbox.initialize();

        }  }).get();
        //return false;        
    }
});
 
 
$(document.body).getElements('select.pager').addEvents({
    'change': function(){                
        new Request.HTML({url:this.get('turl') + '&_page=' + this.get('value') + '&nocache=' + Math.random(), update:$(this.get('tdiv')), onComplete: function(response) {givelinks('oncomplete');  Milkbox.initialize();}  }).get();
        //return false;     
    }
});


$(document.body).getElements('select.pagesizer').addEvents({
    'change': function(){                
        new Request.HTML({url:this.get('turl') + '&_size=' + this.get('value') + '&nocache=' + Math.random(), update:$(this.get('tdiv')), onComplete: function(response) {givelinks('oncomplete');Milkbox.initialize();}  }).get();
        //return false;        
    }
});


}


function addbasket(product)
{
    var _url = 'ajax.aspx?action=addbasket&_product=' + product + '&_quantity=1&nocache=' + Math.random();    
    new Request.HTML({url:_url, evalScripts:true, evalResponse:true, onComplete: function(response){ window.location.href='basket.aspx?p=dutyfreepreorder'; } }).get();    
}


function scrollToAnchor(obj)
{    
    window.location.hash=obj.options[obj.selectedIndex].value;
}

function simpleSearch()
{
    var _url = 'gate.aspx?_id=Search&_keyword=' + encodeURIComponent($('txtSearch').get('value')) + '&_cat=-1&_page=1&_size=15';        
    new Request.HTML({url:_url + '&nocache=' + Math.random(), update:$('uDiv_List'), onComplete: function(response) {givelinks();}  }).get();

}


function advSearch()
{
    var url = 'gate.aspx?_id=Search&_keyword=' + encodeURIComponent($('txtAdvSearch').get('value')) + '&_cat=' + $('cmbAdvSearchCat').get('value') + '&_page=1&_size=15';    
    new Request.HTML({url:_url + '&nocache=' + Math.random(), update:$('uDiv_List'), onComplete: function(response) {givelinks();}  }).get();

}

function PageInit()
{BannerInit();
 //   var bi = (function() {BannerInit()}).periodical(10000);
    
    /* Duty Free Sayfaları */
    if (window.location.href.indexOf('dutyfree')>-1)
    {        
        givelinks('page init');            
    }    
}


function BannerInit()
{   
    var d_ajaxload = $(document.body).getElements('div.ajaxload');
    
    for(var i=0; i<d_ajaxload.length; i++)
    {new Request.HTML({url:'../banner.aspx?nocache=' + Math.random() + '&area=' + d_ajaxload[i].get('area'), update:$(d_ajaxload[i].get('id'))}).get();}    

}

function toggleUnit(unit)
{
    if ($(unit).getStyle('display')=="none")
        $(unit).setStyle('display','block');
    else
        $(unit).setStyle('display','none');
    
    return false;
}

