var BASEURL = 'http://localhost/imcuttingedge/Code/admin/';
$(document).ready(function(){
    $("#news").validate({
        rules: {
            "data[News][title]" : {required : true, maxlength: 255},
            "data[News][description]" : {required : true}
        },
        messages: {
            "data[News][title]" : {required : "Title is required.", maxlength: "Title should be not more than 255 characters."},
            "data[News][description]" : {required : "Description is required."}
        }
    });

    $("#twitters").validate({
        rules: {
            "data[TwitterFeeds][title]" : {required : true, maxlength: 255},
            "data[TwitterFeeds][description]" : {required : true}
        },
        messages: {
            "data[TwitterFeeds][title]" : {required : "Title is required.", maxlength: "Title should be not more than 255 characters."},
            "data[TwitterFeeds][description]" : {required : "Description is required."}
        }
    });

    $("#Testimonials").validate({
        rules: {
            "data[Testimonials][testimonial]" : {required : true},
            "data[Testimonials][by]" : {required : true, maxlength: 50}
        },
        messages: {
            "data[Testimonials][testimonial]" : {required : "Testimonial is required."},
            "data[Testimonials][by]" : {required : "This is required.", maxlength: "Testimonial By should be not more than 50 characters."}
        }
    });

    $("#adminCms").validate({
        rules: {
            "data[Cms][title]" : {required : true, maxlength: 255},
            "data[Cms][description]" : {required : true},
            "data[Cms][blog_video]": {accept : "flv"}
        },
        messages: {
            "data[Cms][title]" : {required : "Title is required.", maxlength: "Title should be not more than 255 characters."},
            "data[Cms][description]" : {required : "Description is required."},
            "data[Cms][blog_video]" : { accept : "Please upload video in flv format"}
        }
    });
});

function validateContentForm(frm,instanceName,errorTxt,errorId){
    try{
        var EditorInstance = FCKeditorAPI.GetInstance(instanceName) ; //message is name of field to be validate
        if(EditorInstance.GetXHTML(true) == ''){
            return false;
        }
    }catch(e){}
    return true;
}

function fetchsubcat(id){
    $('#carbonActivityHeadPreloader').show();
    $.ajax({
        type: "get",
        url: BASEURL+"cms/fetchsubcats/"+id,
        success: function(msg){
            $("#subpage").html(msg)
            $('#carbonActivityHeadPreloader').hide();
        }
    });
}

function delete_video(id){
    $.ajax({
        type: "get",
        url: BASEURL+"cms/delete_video/"+id,
        success: function(msg){
            if(msg == "true"){
                $('#delete_video').hide();
            }
        }
    });
}

