﻿
$(function(){
//       $('div').pngFix();
//       $(document).pngFix();



//functions to hide/show relatively positioned elements - for IE browsers
//******************************************************************   
    showPositioned = function(){
        $('#content-wrapper *').each(function(){
            if($(this).css('position') == 'relative'){
                $(this).show();
            }
        });
    }
    
    hidePositioned = function(){
        $('#content-wrapper *').each(function(){
            if($(this).css('position') == 'relative'){
                $(this).fadeOut(200);
            }
        });
    }
//******************************************************************   

    
    $('#view-bg-bottom').click(function(){
        if($('#content-wrapper').css('display') == 'block'){                       
            $('#content-wrapper').slideUp(800);
            
            //hide positioned for IE
            if($.browser.msie){
                hidePositioned();
            } 
            
            $('#view-bg-link input').attr('src', btnOpen ).attr('alt', 'Open the page');
            return false;
        }
    });
    
    $('#view-bg-link input').click(function(){
        
        if($('#content-wrapper').css('display') == 'block'){
            $(this).attr('src', btnOpen ).attr('alt', 'Open the page');
            
            $('#content-wrapper').slideUp(800);
            
            //hide positioned for IE
            if($.browser.msie){
                hidePositioned();
            } 
            
            return false;
        }
        else if($('#content-wrapper').css('display') == 'none'){
            $(this).attr('src', btnClose ).attr('alt', 'View the background wall');
            
            if(!$.browser.msie){
                $('#content-wrapper').slideDown(800);
            }
            
            //show positioned for IE
            if($.browser.msie){
                $('#content-wrapper').slideDown(500, showPositioned);
            }
            
            return false;
        }
    });

    
//        if(!($.browser.msie) & !($.browser.version == '6.0')){
        $('#menu ul li').hover(function(){
            $(this).children('a').css('color', '#fff');
            li_index = $(this).parent('ul').children('li').index(this);
//            alert(li_index);
            offset = '0px -' + 48 * (1 + li_index) + 'px';
//            alert(offset);
            $(this).parent('ul').css('background-position', offset);
            
        }, function(){
            $(this).children('a').css('color', '#333');
            $(this).parent('ul').css('background-position', '0px 0px');
        }
        );
//         }
    
    //file upload formatting
    
        $('.file-style .actual').css({
            opacity: '0.0',
            position: 'absolute',
            left: '0px',
            top: '0px'
        });
        
        $('.file-style .visual').css('display', 'block');
        
        if($.browser.mozilla && $.browser.msie){
        
            $('.file-style .actual input').mouseout(function(){
                $('input#text-replace').val($(this).val());
            
            });
        }
        else{
        
            $('.file-style .actual input').change(function(){
                $('input#text-replace').val($(this).val());
            
            });
        }
        
    $('#onsale-box').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
    $('#tweet-box').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
    
    //process XML function
        $.fn.buildTicker = function() {
            var text = $(this).text()
            $('<span></span>')
            .html(text)
            .appendTo('#ticker');
        }
    
});
					
