// min width ie6
function minWidth() {
	var winWidth = window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth;
	
	if (winWidth < 1000) {
		$('div.wrap, div.footer').css('width', '1000px');
	}
	else {
		$('div.wrap, div.footer').css('width', 'auto');
	}
}

// file input
function fileInput() {
	var file = $('div.elemBox.file input[type="file"]');
	var inputText = file.parent().next().children('input[type="text"]');
	
	file.change(function () {
		var fileVal = $(this).val();
		inputText.attr('value', fileVal);
	});
}

// placeholder
function placeholder() {
	if (!$.browser.webkit) {
		$('input[placeholder], textarea[placeholder]').blur(function(){

			if ($(this).val() == '') {
				$(this).val($(this).attr('placeholder'));
				$(this).addClass('m-placeholder');
			}

		}).focus(function(){

			$(this).removeClass('m-placeholder');
			if ($(this).val() == $(this).attr('placeholder')) {
				$(this).val('');
			}

		}).each(function(){

			if ( ($(this).val() == '') || ($(this).val() == $(this).attr('placeholder')) ) {
				$(this).val( $(this).attr('placeholder') );
				$(this).addClass('m-placeholder');
			}

			var form = $(this).closest('FORM');
			if (form.length) {
				form.submit(function(){
					if ($(this).val() == $(this).attr('placeholder')) {
						$(this).val('');
					}
				});
			}
		});
	}
}

function nClass() {
	$('.product li:nth-child(4n)').addClass('fourth');
}

// add last class
function lastClass() {
	$('.brandMenu li').last().addClass('last');
}

// main menu open
function menuOpen() {
	$('.mainMenu > li.drop > a').click(function(){
		$(this).parent('li').siblings('li').children('ul').slideUp('fast');
		$(this).parent('li').children('ul').slideDown('fast');
		
		$(this).parent('li').siblings('li').removeClass('select');
		$(this).parent('li').addClass('select');
		
		//return false;
	});
}

// providers hover
function providersHover() {
	$('.providers li').hover(
		function () {
			$(this).find('.color').stop(true, true);
			$(this).find('.color').fadeIn('fast');
		},
		function () {
			$(this).find('.color').fadeOut('fast');
		}
	);
}

// tab switch
function tabSwitch() {
	$('dl.tabs dt').click(function () {
		$(this).siblings().removeClass('select').end().next('dd').andSelf().addClass('select');
	});
}
