function setupSearchTabs()
{
    $('.search-bar-tabs > li').each(function (i) {
        $(this).find('> a').attr('pos', i);
    });
    
    
    setTimeout(function(){$('.offer-gallery-bg').jScrollPane();},1000);
    

    $('.search-bar-tabs > li').each(function () {
        
        var poss = $(this).find('> a').attr('pos');
        
        if ($(this).find('> a').hasClass('active')) {
            $('.search-bar-tabs-content-posrel > div:nth-child('+(parseInt(poss)+1)+')').show();
        } else {
            $('.search-bar-tabs-content-posrel > div:nth-child('+(parseInt(poss)+1)+')').hide();
        }    
        
        $(this).find('> a').click(function () {
            var pos = $(this).attr('pos');
            $('.search-bar-tabs > li > a').removeClass('active');
            $(this).addClass('active');
            $('.search-bar-tabs-content-posrel > div').hide();
            $('.search-bar-tabs-content-posrel > div:nth-child('+(parseInt(pos)+1)+')').fadeIn('fast');
        });
    });
}

function setupPopup()
{   
    
    alert(1);
    $('.popup').each(function () {
        var height = parseInt( $(document).height() );
        
        $(this).height(height+'px');
    });
    
    $('.popup a.close').click(function () {
       $('.popup').hide(); 
    });
}


$(document).ready(function() {
//    $('#oki-mainpage-right-slide').cycle({
//        fx:      'fade',
//        speed:   500,
//        timeout: 4000
//    });
    setupSearchTabs();
   
});

function goTo(tagClass)
{
    $('html, body').animate({scrollTop: $("."+tagClass).offset().top}, 1000);
}

function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function browserBack()
{
    history.go(-1);
}

function centerFloats(objClass)
{
    $("."+objClass).each(function () {
        var parentWidth = parseInt($(this).parent().width());
        var objWidth = $(this).width();
        var marginLeft = parseInt((parentWidth - objWidth) / 2.0);

        if (marginLeft>0)
            $(this).css('margin-left', marginLeft+'px');        
    });
} 

function setupTopmenu()
{
    $('.topmenu li:first a').addClass('first');
    $('.topmenu li:last a').addClass('last');
}
