$(function(){
// For making a page live or not live 
$('.page_status').live('click',function(){
    var page_id = this.id;
    var status = this.name;
    $.ajax({
	async: false,
	type: "POST",
	url: "ajax_actions.php",
	data: "action=change_status&page_id="+page_id+"&status="+status,
	success: function(msg){
		alert(msg);
	} 
    });
    change_image = "";
    if(status == 1){
	status = 2;
	change_image = "../../images/no.png";
    }else{
	status = 1;
	change_image = "../../images/yes.png";
    }
    $(this).attr("src",change_image);
    $(this).attr("name",status);
})

// Form validation
$('#pageform').submit(function(){
    if($("#title").val() == ""){
	alert("Please enter title");
	return false;
    }else if($("#type").val() == ""){
	alert("Please select type");
	return false;
    }
    else if($("#description").val() == ""){
	//alert("Please enter description");
	return false;
    }else{
	return true;
    }
    
})

}) // End of main function