jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox({
        loading_image : 'images/loading.gif',
        close_image   : 'images/closelabel.gif'
      }); 


	$('input#search').click(function() {
		if ($(this).val()=='Search...') $(this).val('');
	}).blur(function() {
		if ($(this).val()=='') $(this).val('Search...');		
	});
	
	$('a#edit').click(function() {
		$('.hiddenForm').show();
		$('#formContent').hide();
	});
	
	$('input#profileCancel').click(function() {
		$('.hiddenForm').hide();
		$('#formContent').show();
	});

});


function expand(id) {

	if ($('#ex-'+id).css('display')=='block') {
		$('#ex-'+id).slideUp('slow');	
		$('#t-'+id).css('background','url(images/iconPlus.gif) no-repeat 20px center');
	} else {
		$('#ex-'+id).slideDown('slow');
		$('#t-'+id).css('background','url(images/iconMinus.gif) no-repeat 20px center'); 
	}

	
}

$(document).ready(function () {	


	$('a.publish').click(function () {

		if (confirm('Are you sure you want to publish this post?')) {
		
			var data = 'id=' + $(this).attr('rel');
			var item_id = '#item_' + $(this).attr('rel');

			$.ajax({
		
				url: "publish.php",	
				type: "GET",	
				data: data,		
				cache: false,
				success: function (html) {				

					if (html==1) {					

						$(item_id).fadeTo('fast', 0.3);					
					} else alert('Sorry, unexpected error. Please try again later.');				
				}		
			});
		
			return false;
		}
	});
	
	$('a.remove').click(function () {

		if (confirm('Are you sure you want to delete this post?')) {
		
			var data = 'id=' + $(this).attr('rel');
			var item_id = '#item_' + $(this).attr('rel');

			$.ajax({
		
				url: "remove.php",	
				type: "GET",	
				data: data,		
				cache: false,
				success: function (html) {				

					if (html==1) {					
						$(item_id).slideUp('fast');	
					} else alert('Sorry, unexpected error. Please try again later.');				
				}		
			});
		
			return false;
		}
	});
	
	$('a.paging').click(function () {

		var page = $(this).attr('href').split('-');
		var url = $(this).attr('rel');
		var data = 'id=' + page[0] + '&start=' + page[1] + '&total=' + page[2];
		
		$('a.paging').removeClass('selected');
		$(this).addClass('selected');

		$.ajax({
		
			url: url + "comment.php",	
			type: "GET",	
			data: data,		
			cache: false,
			success: function (html) {				

				$('div.comment').html(html);
							
			}		
		});

		return false;
	});
	
});




function t(s,status,id) {
	if (status==1) {
		tooltip.show('<div class=\'tips\'>' + s + '</div>');		
		$('#lnk-' + id).css('color','#4d829a');
	} else if (status==0) {
		tooltip.hide();
		$('#lnk-' + id).css('color','#c0c0b5');
	}
}

function externalLinks() {
if (!document.getElementsByTagName && document.getElementById) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks; 


$(document).ready(function() {	


  //Get all the LI from the #tabMenu UL
  $('#tabMenu > li').click(function(){
    
    //perform the actions when it's not selected
    if (!$(this).hasClass('selected')) {    
           
    //remove the selected class from all LI    
    $('#tabMenu > li').removeClass('selected');
    
    //Reassign the LI
    $(this).addClass('selected');
    
    //Hide all the DIV in .boxBody
    $('.boxBody div').slideUp('1500');
    
    //Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
    $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
    
  }
    
  }).mouseover(function() {

    //Add and remove class, Personally I dont think this is the right way to do it, anyone please suggest    
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
    
  }).mouseout(function() {
    
    //Add and remove class
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });

	//Mouseover with animate Effect for Category menu list
  $('.boxBody #category li').mouseover(function() {

    //Change background color and animate the padding
    $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
  }).mouseout(function() {
    
    //Change background color and animate the padding
    $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
  });  
	
	
});
