/**
 * PShelper.com 
 * Base Store Version javascript
 * 
 * Notes:
 * 
 * When creating text box inputs, always apply both 
 * a value and default attribute (the same value)
 *
 * For rollovers use attribute 'hoversrc' to define the
 * rollover image source
 * 
 **/
$(document).ready(function(){
	//input textbox handling
	$('input[type="text"]').focus(function(){
        if($(this).val()==$(this).attr('default'))
        {
            $(this).val('');
        }
    }).blur(function(){
        if($(this).val()=='')
        {
            $(this).val($(this).attr('default'));
        }
    });
    //top nav menu handling
	$('#topNavMenu').insertAfter('#mainWrapper'); //<=IE6 fix, #topNavMenu must be absolute to the body
    $('ul.parent li').hover(
        //mouse over
        function(){
           $(this).find('ul.sub').css({'zIndex':9999}).show();
        },
        //mouse out
        function(){
           $(this).find('ul.sub').hide();
        }).each(function(){
            $(this).find('ul.sub').hide();
        });
     //rollover image handling
     $preload = new Array();
     $iterator = 0;
     $('img').each(function(){
        //preloader
        if($(this).attr('hoversrc'))
        {
            $preload[$iterator] = $('<img src="'+$(this).attr('hoversrc')+'"/>');
            $iterator++;
        }
        $(this).hover(
        //mouse over
        function(){
            $(this).attr({'default':$(this).attr('src'),'src':$(this).attr('hoversrc')});
        },
        //mouse out
        function(){
            $(this).attr({'src':$(this).attr('default')});
            $(this).removeAttr('default');
        });
     });
});
