$(document).ready(function() {
	
	$('#main-menu').css({
		backgroundImage:$.cookie("backgroundImage"),
		backgroundRepeat:$.cookie("backgroundRepeat"),
		backgroundColor:$.cookie("backgroundColor"),
		backgroundPosition:$.cookie("backgroundPosition"),
		backgroundAttachment:$.cookie("backgroundAttachment")
	});
	$('#footer2').css({
		'border-top-color':$.cookie("backgroundColor")
	});
	
	
  $('#style-switcher a.pattern-box').click(function(e){
		e.preventDefault();
		var patternUrl='url('+bloginfo+'/images/patern/'+$(this).attr('rel')+'.png)';
		$('#main-menu').css({backgroundImage:patternUrl,backgroundRepeat:"repeat"});
		$.cookie("backgroundImage",patternUrl);
		$.cookie("backgroundRepeat","repeat");
	});
	
	var switcher_skins=$('#style-switcher a.color-box');
	switcher_skins.click(function(e){
		var color=$(this).attr('rel');
		var defaultPattern="url("+bloginfo+"/images/patern/grid2.png)";	
		$('#main-menu').css({backgroundColor:'#'+color,backgroundImage:defaultPattern, 'background-repeat':'repeat'});
		$('#footer2').css({'border-top-color':'#'+color});
		$.cookie("backgroundColor",'#'+color);
		$.cookie("backgroundImage",defaultPattern);
		$.cookie("backgroundRepeat","repeat");
	});
	
	var switcher_bg=$('#style-switcher a.bg-box');
	switcher_bg.click(function(e){
		var bg=$(this).attr('rel');
		$('#main-menu').css({backgroundColor:'#000',backgroundImage:"url("+bloginfo+"/images/background/"+bg+".jpg)"});
		$.cookie("backgroundImage","url("+bloginfo+"/images/background/"+bg+".jpg)");
		if (bg=='bg1') {
			$('#main-menu').css({
				'backgroundColor':'#070916',
				'backgroundPosition':'center top',
				'backgroundRepeat':'no-repeat',
				'backgroundAttachment':'scroll'
			});
			$('#footer2').css({
				'border-top-color':'#070916',
			});
			
			$.cookie("backgroundColor",'#070916');
			$.cookie("backgroundPosition",'center top');
			$.cookie("backgroundRepeat","no-repeat");
			$.cookie("backgroundAttachment","scroll");
		} else if (bg=='bg2') {
			$('#main-menu').css({
				'backgroundColor':'#409cdf',
				'backgroundPosition':'center top',
				'backgroundRepeat':'no-repeat',
				'backgroundAttachment':'scroll'
			});
			$('#footer2').css({
				'border-top-color':'#409cdf',
			});
			
			$.cookie("backgroundColor",'#409cdf');
			$.cookie("backgroundPosition",'center top');
			$.cookie("backgroundRepeat","no-repeat");
			$.cookie("backgroundAttachment","scroll");
		} else if (bg=='bg3') {
			$('#main-menu').css({
				'backgroundColor':'#02010b',
				'backgroundPosition':'center top',
				'backgroundRepeat':'no-repeat',
				'backgroundAttachment':'scroll'
			});
			$('#footer2').css({
				'border-top-color':'#dddddd',
			});
			
			$.cookie("backgroundColor",'#02010b');
			$.cookie("backgroundPosition",'center top');
			$.cookie("backgroundRepeat","no-repeat");
			$.cookie("backgroundAttachment","scroll");
		}
	});
});

