$(document).ready(function(){
		$('.hover').mouseover(function() {
			//Set "selected" the LI clicked
			$('.hover').each(function(){
			$(this).removeClass("isover");
			});
			$(this).addClass("isover");
		});
		
		$(".option_btn").click(function(){
			if($("#option_wrapper").css("left")!="0px"){
				$("#option_wrapper").animate({left:"0px"},{duration:300});
				$(this).animate({left:"215px"},{duration:300});
				$(this).removeClass("settings-close").addClass("settings-open");
			}else{
				$("#option_wrapper").animate({left:"-222px"},{duration:300});
				$(".option_btn").animate({left:"-5px"},{duration:300});
				$(this).removeClass("settings-open").addClass("settings-close");
			}
		});
		
		
		//Change header background color
		$("#bg_header_preview").ColorPicker({
			color:$("#pp_header_bg").val(),
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$("#pp_header_bg").val($("#bg_header_preview").css("background-color"));
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("#top-panel-topless").css("background","#"+b);
				$("#top-panel").css("background","#"+b);
				$("#bg_header_preview").css("background","#"+b);
			}
		});
		
		//Change header background image
		$("#bg_header_image a").click(function(){
			$("#top-panel-topless").css("background", "url("+$(this).attr('rel')+") 0 0 no-repeat");
			$("#top-panel-topless").css("background-size", "100%");
			$("#top-panel-topless").css("opacity", 0);
				$("#top-panel-topless").animate({
					'opacity': 1
				}, 1000);
			$("#top-panel").css("background", "url("+$(this).attr('rel')+") 0 0 no-repeat");
			$("#top-panel").css("background-size", "100%");
			$("#top-panel").css("opacity", 0);
				$("#top-panel").animate({
					'opacity': 1
				}, 1000);

		});

		//Change logo size
		$('#slider_logo_size').slider({
        value:70,
        min: 20,
        max: 100,
        step: 2,
        slide: function( event, ui ) {
            $('#logo_size').val(ui.value + " px");
            $('#logo a').css('font-size', ui.value);
        }
    });
    $('#logo_size').val($('#slider_logo_size').slider('value') + ' px');
		
		//Change logo color
		$("#logo_color_preview").ColorPicker({
			color:"#fff",
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("#logo a").css("color","#"+b);
				$("#logo_color_preview").css("background","#"+b);
			}
		});
		
		//Change menu size
		$('#slider_menu_size').slider({
        value:14,
        min: 8,
        max: 30,
        step: 1,
        slide: function( event, ui ) {
            $('#menu_size').val(ui.value + " px");
            $('#menu-div > ul > li > a').css('font-size', ui.value);
        }
    });
    $('#menu_size').val($('#slider_menu_size').slider('value') + ' px');
		
		//Change menu color
		$("#menu_color_preview").ColorPicker({
			color:"#fff",
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("#menu-div > ul > li > a").css("color","#"+b);
				$("#menu_color_preview").css("background","#"+b);
			}
		});
		
		
		//Change body background color
		$("#bg_body_preview").ColorPicker({
			color:$("#pp_body_bg").val(),
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$("#pp_body_bg").val($("#bg_body_preview").css("background-color"));
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("body").css("background","#"+b);
				$("#bg_body_preview").css("background","#"+b);
			}
		});
		
		//Change body background image
		$("#bg_body_image a").click(function(){
			//$("body").css("background", "url("+$(this).attr('rel')+")");
			$.backstretch($(this).attr('rel'));
			$('.fade-image').load(function(){
				$(this).animate({
					'opacity': 1
				}, 1000);
			});
		});
		
		//Change body background pattern
		$("#bg_body_pattern a").click(function(){
			$("body").css("background", "url("+$(this).attr('rel')+") repeat");
		});
		
		//Change heading size
		$('#slider_heading_size').slider({
        value:14,
        min: 10,
        max: 100,
        step: 2,
        slide: function( event, ui ) {
            $('#heading_size').val(ui.value + " px");
            $('.page_name h1').css('font-size', ui.value);
            $(".divider-description h6").css("font-size", ui.value);
            $(".noslider-topbar-1 h4").css("font-size", ui.value);
            
        }
    });
    $('#heading_size').val($('#slider_heading_size').slider('value') + ' px');
		
		//Change heading color
		$("#heading_color_preview").ColorPicker({
			color:"#fff",
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$(".page_name h1").css("color","#"+b);
				$(".divider-description h6").css("color","#"+b);
				$(".noslider-topbar-1 h4").css("color","#"+b);
				$(".full-hr").css("background","#"+b);
				$("#heading_color_preview").css("background","#"+b);
			}
		});
		
		//Change headings color
		$("#headings_color_preview").ColorPicker({
			color:"#fff",
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("h2, h3, h4, h5, h6").css("color","#"+b);
			}
		});
		
		//Change footer background color
		$("#bg_footer_preview").ColorPicker({
			color:$("#pp_footer_bg").val(),
			onShow:function(a){
				$(a).fadeIn(500);
				return false
			},
			onHide:function(a){
				$("#pp_footer_bg").val($("#bg_footer_preview").css("background-color"));
				$(a).fadeOut(500);
				return false
			},
			onChange:function(a,b,c){
				$("#footer").css("background","#"+b);
				$(".clear_bottom").css("background","#"+b);
				$("#bg_footer_preview").css("background","#"+b);
			}
		});
		
		//Change footer background pattern
		$("#bg_footer_pattern a").click(function(){
			$("#footer").css("background", "url("+$(this).attr('rel')+") repeat scroll center top transparent");
			$(".clear_bottom").css("background", "url("+$(this).attr('rel')+") repeat scroll center top transparent");
			$("#footer, .clear_bottom").css("opacity", 0);
				$("#footer, .clear_bottom").animate({
					'opacity': 1
				}, 1000);
		});	
	});