$(function(){
	$('ul#gNav > li').hover(
		function() {
			$(this).find('> a').addClass('hover');
			$(this).find('> .sNav').show();
		},
		function() {
			$(this).find('> a').removeClass('hover');
			$(this).find('> .sNav').hide();
		}
	);

	var profiles = {
		winShop: {
			height: 685,
			width: 640,
			center: 1,
			toolbar: 1,
			menubar: 1,
			scrollbars: 1,
			createnew: 0
		}
	};
	
	$("#popupBtn a").popupwindow(profiles);

	/* scroll */
	$('a[href^=#]').click(function(){
		var $t = $(this.hash);
		if (this.hash.length > 1 && $t.length) {
			$.scrollTo($t,600);
			return false;
		}
	});

	// set css
	var fontBase = $('#header #hFontSize');
	
	fontBase.show();
	var $alt_css = $('link[rel=alternate stylesheet]');
	var setCss = function(title) {
		var $css = $alt_css.filter('[title=' + title + ']');
		if ($css.length) {
			$alt_css.attr('disabled', 'disabled');
			$css.removeAttr('disabled');
			var date = new Date();
			date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
			$.cookie('css', title, {path: '/', expires: date});
		}
	};
	
	// default css
	setCss($.cookie('css'));
	fontBase.find('dd a').unbind('click').click(function() {
		var fontsize = $(this).attr('href').replace(/^#/, '');
		setCss(fontsize);
		return false;
	});
	
	$('a[rel=lightpop]').lightpop({overlayBgColor:'#fff',contentBorder:'1px solid silver'});

	// set input placeholder
	$('input.placeholder').each(function() {
		if (!$(this).val() || $(this).val() == $(this).attr('title')) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).focus(function() {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('').removeClass('empty');
		}
	}).blur(function() {
		if (!$(this).val().length) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).parents('form').submit(function() {
		$(this).find('input.placeholder').each(function() {
				if ($(this).val() == $(this).attr('title')) {
					$(this).val('');
				}
		});
	});

	$("#sCarBnrMain")
		.find('a img')
		.css({'width':220,'height':62})
		.end()
		.carouFredSel({
			circular: false,
			infinite: true,
			auto 	: 4000,
			scroll	: {
				items	: "page",
				duration: 500,
				pauseOnHover: true
			},
			pagination: "#sCarBnrPager"
		});
});

