$(document).ready(function() {
	// Rounded Corners - THIS USES jquery.corners and causes MAJOR issues in IE, sooooo we use another method for IE corners
	// This ensures we don't make these calls in IE

	if($.browser.msie==false)
	{
		$('#nav .tabs ul ').corner('top');
		$('.visit-profile  #nav .tabs ul li.profile').corner('tr');
		$('#builder .ui-state-default div, #builder .ui-widget-content #builder .ui-state-default div,#builder .ui-state-default, #builder .ui-widget-content #builder .ui-state-default,.customize-blog .success,div.warning,div.success,#activewidget,.cgbheading span,.system-widget .system-widget-box,.system-widget .system-widget-heading,.breadcrumbs, .welcome, .heading, .cgbsubmit , .cgbheading, .cgbbox, .box, .main ol.stream li p span, .toggle-click, .side-details, #footer .terms, .pub-opt-toggle, .capacity .progress, .capacity .used, form input, form textarea, #profile .details, #profile .rating p, #profile .rating span, #brochure .start .box form div, #widgets #layout #feature-widgets ul, #widgets #layout .your-blog, #widgets #layout .your-entries, p.quote,#blog #content .listing-info-container,.cgbnewstylewrapper').corner('6px');
		$('#pagination a, .post-link #thumbnail-creator, .post-listing #upload-image div.image, .sidebar .box ul span.numbers,.cgbavatar, .avatar, #widgets #features li, #widgets #layout li').corner('4px');
		$('form input.submit, .button, .button-alt,.button-needapproval, .close, #blog #content a.download,.customize-blog #themetable .submit,.system-widget-button,ul#postbar li a div').corner('12px');
		$('#brochure .start .box form input#check').corner('18px');
		$('.sidebar .vcard-box,#brochure .blue-box-top, #blog .blue-box-top,').corner('top','6px');
		$('#brochure .white-box-bottom, #blog .white-box-bottom,#content').corner('bottom','6px');
	}

	// Add .last 
	$('.sidebar .box ul.menu li:last, .sidebar .box ul.local-listings li:last, div.warning p:last, div.error p:last, div.success p:last, div.flag p:last, .post-link #thumbnail-creator p:last').addClass("last");
	$('.sidebar .box ul.menu li:last-child, .sidebar .box ul.stats li:last-child').addClass('last');
	$('div.tip p:last, #footer div:last.container').addClass("last");
	// Add .first to first li (remove margin)
	$('.sidebar .box ul li:first').addClass("first");
	$('.sidebar .box ul li:first-child').addClass("first");
	// Add .clearfix to .heading div
	$('.heading').addClass("clearfix");

	// Open and close div - toggle
	$(".toggle").hide();
	$('.toggle-click').addClass('open');
	$(".toggle-click").toggle(function(){
		$(this).removeClass('open').addClass('close');
		$('.toggle').slideDown();
	},function(){
		$(this).removeClass('close').addClass('open');
		$('.toggle').slideUp();
	});	

	// Show and hide publishing options div 
	$(".pub-opt-toggle").hide();
	$('a#pub-opt span').addClass('open');
	$("a#pub-opt").toggle(function(){
		$('a#pub-opt span').removeClass('open').addClass('close');
		$('.pub-opt-toggle').slideDown();
	},function(){
		$('a#pub-opt span').removeClass('close').addClass('open');
		$('.pub-opt-toggle').slideUp();
	});
	$(".prop-opt-toggle").hide();
	$('a#prop-opt span').addClass('open');
	$("a#prop-opt").toggle(function(){
		$('a#prop-opt span').removeClass('open').addClass('close');
		$('.prop-opt-toggle').slideDown();
	},function(){
		$('a#prop-opt span').removeClass('close').addClass('open');
		$('.prop-opt-toggle').slideUp();
	});
	
	// Show and hide payment options div 
	$(".pay-opt-toggle").hide();
	$('a#pay-opt span').addClass('open');
	$("a#pay-opt").toggle(function(){
		$('a#pay-opt span').removeClass('open').addClass('close');
		$('.pay-opt-toggle').slideDown();
	},function(){
		$('a#pay-opt span').removeClass('close').addClass('open');
		$('.pay-opt-toggle').slideUp();
	});
	
	// Tabs
//	$('#tabs').tabs( {
//	    select: function(event, ui) {
//	        var url = $.data(ui.tab, 'load.tabs');
//	        if( url ) {
//	            location.href = url;
//	            return false;
//	        }
//	        return true;
//	    }
//	}
//	);
	$('#tabs ul').removeClass('ui-corner-all');
	$('#tabs .template a:first-child').addClass('first');


	
	// Customize Blog {features & widgets}
	$("#features .features, #features .widgets").sortable({
		connectWith: '.active-features-widgets'
	}).disableSelection();
	$("#feature-widgets .active-features-widgets").sortable({
		connectWith: $('.features,.widgets')
	}).disableSelection();
	$('#features .features').droppable({accept:'.feature'});
	$('#features .widgets').droppable({accept:'.widget'});
	
	// Send Message Dialog
	$('#msg-dialog').dialog({
		title: 'Send message to Username',
		width: 645,
		height: 450,
		draggable: false,
		resizable: false,
		modal: true
	});
	
	// Brochure Slider
	if(jQuery.anythingSlider)
	{
		$('.anythingSlider').anythingSlider({
            easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 3000,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 600,             // How long the slide transition takes
            hashTags: false,                 // Should links change the hashtag in the URL?
            buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
    		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
    		startText: "Go",             // Start text
	        stopText: "Stop"               // Stop text
        });

		$('#create').click(function(){
			$('.start .search').slideUp();
			$('.start .create').slideDown();
			$('#find').removeClass('active');
			$(this).addClass('active');
			return false;
		});
		$('#find').click(function(){
			$('.start .create').slideUp();
			$('.start .search').slideDown();
			$('#create').removeClass('active');
			$(this).addClass('active');
			return false;
		});
		
		$('#feature-table a').hover(function(){
			var item = $(this).parent().parent().attr('id');
			$('#feature-info p').hide();
			$('#feature-info p.'+item).show();
		});
	}
	
// Date Picker
//$("#datepicker").datepicker();

	if ($("#publishday").html()) {
		$("#publishday").datepicker();
	}




	
});


Cufon.replace('#nav li a.topnav');
Cufon.replace('h1,h2,h3,h4');
Cufon.replace('.sidebar h3,#registration-process li');  
Cufon.replace('ul#footer-nav a'); 
Cufon.replace('#blog .sidebar .show-only label'); 


