// The below code is property of ipbforumskins.com and may not be copied without permission

jQuery.noConflict();

jQuery(document).ready(function($){

	$("#show_login").click(function(){
		$("#quick_login_overlay").fadeIn(100);
		$("#quick_login").fadeIn();
		$("#username").focus();
		return false;
	});
			
	$("#close_login").click(function(){
		$("#quick_login_overlay").fadeOut(100);
		$("#quick_login").fadeOut();
		return false;
	});
	
	$(".forum_name").hover(function() {
		$(this).next(".forum_desc_pos").children(".forum_desc_con").stop()
		.animate({left: "0", opacity:1}, "fast")
		.css("display","block")

	}, function() {
		$(this).next(".forum_desc_pos").children(".forum_desc_con").stop()
		.animate({left: "10", opacity: 0}, "fast", function(){
			$(this).hide();
		})
	});
	
	$(".rounded-avatar img").each(function() {
		$(this).wrap(function(){
		  return '<span class="rounded-img" style="background:url(' + $(this).attr('src') + ') no-repeat center center;" />';
		});
		$(this).css("opacity","0");
	  });
	
	$("#nav_search").click(function(){
		$("#toggle_background").slideUp();
		$("#toggle_search").slideToggle();
		$("#main_search").focus();
	});
	
	$("#nav_background").click(function(){
		$("#toggle_search").slideUp();
		$("#toggle_background").slideToggle();
	});
	
	$("#nav_categorybox").click(function(){
		 $("#category_box").fadeIn();
	});
	
	$(".category_box_close").click(function(){
		 $("#category_box").fadeOut();
	});

	$("#custom_background span").click(function(){
		$.cookie('custom_url',null,{ expires: -5, path: '/'});
		var bgid = $(this).attr("id");
		$.cookie('custombg',bgid,{ expires: 365, path: '/'});
		$("body").removeClass().addClass(bgid);
	});
	
	$("'[placeholder]'").focus(function() {
	  var input = $(this);
	  if (input.val() == input.attr("'placeholder'")) {
		input.val("''");
		input.removeClass("'placeholder'");
	  }
	}).blur(function() {
	  var input = $(this);
	  if (input.val() == "''" || input.val() == input.attr("'placeholder'")) {
		input.addClass("'placeholder'");
		input.val(input.attr("'placeholder'"));
	  }
	}).blur();
	
	$("#custom_submit").click(function(){
		$.cookie('custombg',"bg_custom",{ expires: 365, path: '/'});
		var customurl = $("#custom_input").val();
		$.cookie('custom_url',customurl,{ expires: 365, path: '/'});
		$("<style type='text/css'>body.bg_custom, .bg_custom .forum_icon, .bg_custom .maintitle, .bg_custom #branding, .bg_custom #user_navigation ul#user_link_menucontent{ background-image: url(" + customurl + ")}</style>").appendTo("head");
		$("body").removeClass().addClass("bg_custom");
	});
		
	if ( ($.cookie('custombg') != null))	{
		$("body").addClass($.cookie('custombg'));
	}
	else{
		$("body").addClass("bg1");
	}
	
	if ( ($.cookie('custom_url') != null))	{
		$("<style type='text/css'>body.bg_custom, .bg_custom .forum_icon, .bg_custom .maintitle, .bg_custom #branding, .bg_custom #user_navigation ul#user_link_menucontent{ background-image: url(" + $.cookie('custom_url') + ")}</style>").appendTo("head");
		$("body").addClass("bg_custom");
	}
	
	$('#ctv_stbasic').click(function(){
		$(this).addClass("active");
		$('#ctv_stdetailed').removeClass("active");
		$("#customize_topic").addClass("ctv_basic");
		$.cookie('ctv','basic',{ expires: 365, path: '/'});
	});
	
	$('#ctv_stdetailed').click(function(){
		$(this).addClass("active");
		$('#ctv_stbasic').removeClass("active");
		$("#customize_topic").removeClass("ctv_basic");
		$.cookie('ctv',null,{ expires: -1, path: '/'});
	});
	
	if ( ($.cookie('ctv') != null))	{
		$("#customize_topic").addClass("ctv_basic");
		$("#ctv_stbasic").addClass("active");
	}
	else{
		$("#ctv_stdetailed").addClass("active");
	}
	
	$("#section_links img, .rep_bar a, .user_controls a").tipTip({delay:0, edgeOffset:6, defaultPosition:"top", fadeIn:0, fadeOut:0});
	$(".category_box_close").tipTip({delay:0, edgeOffset:0, defaultPosition:"left", fadeIn:0, fadeOut:0});
	$(".qn_new, .qn_nonew").tipTip({delay:0, edgeOffset:4, defaultPosition:"left", fadeIn:0, fadeOut:0});

});
