// CCC JS

$(function () {

	$('#widgetarea').sortable({
		containment: '#widgetarea',
		tolerance: 'pointer',
		items: 'div.widget',
		handle: 'h2',
		helper: 'original',
		forceHelperSize: true,
		placeholder: 'widgethelper',
		forcePlaceholderSize: true,
		connectWith: 'div.widgets',
		scroll: true,
		scrollSensitivity: 40,
		scrollSpeed: 40,
		revert: true
	});
	
	//Widget State Saving Module
	$('#widgetarea').bind('sortupdate', function(event, ui) {
	var sorting_order="";
	var items = $("div.widget");
	for(var x=0; x<items.length; x++)   
	{
	    if(x==0)
	    {
	        sorting_order=items[x].id;
	    }
	    else
	    {
	        sorting_order=sorting_order+","+items[x].id;
	    }
		
	}
	
	if(ipage==1)
    {
        $.post("ajaxHandler.aspx",{WOrder:sorting_order},function(data){})
    }
    else
    {
    
        $.post("../ajaxHandler.aspx",{WOrder:sorting_order},function(data){})
    }
    
	//alert(sorting_order);
	});
	
	
	/* News Section display */
	$('div.news dd, dl.linklist dd').not('div.news dd:first').css('display', 'none');
	
	$('div.news dt:first')
		.find('strong a').attr('title', 'close')
				.find('span').html('&ndash;');
	
	$('div.news dt, dl.linklist dt').bind('click', function () {
		
		var n = $(this).next('dd').css('display');
		
		$(this)
		.parent('dl')
		.find('dt strong a').attr('title', 'expand')
		.find('span').html('+');
		
		$(this)
		.parent('dl')
		.find('dd').css('display', 'none')
		
		if (n != 'block') {
			$(this).next('dd').css('display', 'block');
			$(this).find('strong a').attr('title', 'close')
				.find('span').html('&ndash;');
		}
		
	});
	
	$('input, textarea').not('input.submit').not('.button').not('div').bind('focus', function () {
		
		$(this).val('').unbind('focus');
		
	});
	
});