//sidebar navigation
function showNav(){
	$('.sidemode > ul > li:has(div.subnav)').hover(function(){
		$(this).addClass('on')
	},function(){
		$(this).removeClass('on')
	})
}

function stickyFoot(){
	$('#footerbar').stickyBar({
		imagesFolderPath : 'images'
	}); 
}

//make select 
function makeSelect(){	
	$('.make-select').each(function(){		
		$('<input class="make-input" type="text" value="" /><img class="make-img" src="/images/arr-b.gif" alt="" />').appendTo($(this));
		$('.make-input',$(this)).val($('select',$(this)).val());
		var s='';
		$('option',$(this)).each(function(){
			s += '<li>' + this.value + '</li>'
		});
		$('select',$(this)).hide();
		$('<ul class="make-option">' + s + '</ul>').appendTo($(this)).width($('.make-input',$(this)).outerWidth()-2);
		$('.make-option > li',$(this)).hover(function(){
			$(this).addClass('on')
		},function(){
			$(this).removeClass('on')
		});
		$('.make-img,.make-input',$(this)).click(function(event){
			event.stopPropagation();
			$('.make-option').not($(this).closest('.make-option')).hide();
			$('.make-option',$(this).closest('.make-select')).toggle();
			$('.make-option > li:first',$(this).closest('.make-select')).addClass('on');
			$('.make-option > li',$(this).closest('.make-select')).click(function(){
				var $index = $(this).index();				
				$('.make-option',$(this).closest('.make-select')).hide();
				$('.make-option li',$(this).closest('.make-select')).removeClass('on')
				$('.make-input',$(this).closest('.make-select')).val($(this).text())
				$('select',$(this).closest('.make-select')).eq($index).attr('checked','true')
			})
		})
	});
	$('body,html').click(function(){
		if('.make-option:visible'){
			$('.make-option').hide();
		}
	})
}

//make type = file
function makeFile(){
	$('<input class="makefile" type="text" value="" /><img src="/images/btn-browse.gif" alt="" />').prependTo($('#file'));
	$('#file .makefile').val($('#file .realfile').val());									
	$('#file .realfile').css('opacity','0').change(function(){
		$('#file .makefile').val($('#file .realfile').val());;
	});
}

//make type = file
function makeStyledFile(span){
    span.css({position:'relative',display:'block'});
	$('<input class="makefile" readonly="readonly" type="text" value="" /><img src="/images/btn-browse.gif" alt="" />').prependTo(span);
	var makefile = $('.makefile', span),
	    realfile = $('.realfile', span);
	makefile.val(realfile.val());									
	realfile.css({width: '75px',opacity:0}).change(function(){
		makefile.val(realfile.val());;
	});
}

//changed tr background
function changedTrBg(){
 	$('.flyers tr').hover(function(){
 		$(this).toggleClass('on')
 	})
}

//run
$(function(){
	showNav();
	stickyFoot();
	changedTrBg();
})

