 $(document).ready(function () {
            var date = new Date();
            function initOp() {
                var data = new Object();
                data.key = $("#productName").val();
                data.banner = $("#bannerName").val();
                data.languageID = $("#language").val();
                var view = "month";
                var DATA_FEED_URL = GLOBAL_BASE_PATH + "/campaign/ajaxcampaignList/";
                var op = {
                    view: view,
                    theme: 2,
                    showday: date,
                    skipDay: 3,
                    weekstartday: 0,
                    paramData: data,
                    colorCodeShow: true,
                    nonMonthView: true,
                    autoload: true,
                    url: DATA_FEED_URL
                };
                var $dv = $("#calhead");
                var _MH = document.documentElement.clientHeight;
                var dvH = $dv.height() + 2;
                op.height = _MH - dvH;
                op.eventItems = [];
                return op;
            }
            Date.prototype.monthNames = [
            january, february, march,
            april, may, june,
            july, august, september,
            october, november, december];

            Date.prototype.getMonthName = function () {
                return this.monthNames[this.getMonth()];
            };

            var p = $("#gridcontainer").bcalendar(initOp()).BcalGetOp();
            if (p && p.datestrshow) {
                $("#txtdatetimeshow").text((p.showday).getMonthName() + " " + ((p.showday).getFullYear()));
            }
            $("#caltoolbar").noSelect();
            $("#productSearch").click(function () { 
                //if($("#productName").val()!='' || $("#bannerName").val()!='' || $("#language").val()!='')
                //{
                op = initOp();
                op.showday = ($("#gridcontainer").BcalGetOp()).showday;
                var p = $("#gridcontainer").bcalendar(op).BcalGetOp();
                $("#txtdatetimeshow").text((p.showday).getMonthName() + " " + ((p.showday).getFullYear()));
                //}
            });
            //go to today
            $("#showtodaybtn").click(function (e) {
                var p = $("#gridcontainer").gotoDate().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text((p.showday).getMonthName() + " " + ((p.showday).getFullYear()));
                }
            });
            //previous date range
            $("#sfprevbtn").click(function (e) {
                $("#txtdatetimeshow").text('Loading..');
                var p = $("#gridcontainer").previousRange().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text((p.showday).getMonthName() + " " + ((p.showday).getFullYear()));
                }
            });
            //next date range
            $("#sfnextbtn").click(function (e) {
                $("#txtdatetimeshow").text('Loading..');
                var p = $("#gridcontainer").nextRange().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text((p.showday).getMonthName() + " " + ((p.showday).getFullYear()));
                }
            });
            $(document).on('mouseenter','.sortable',function () {
                $(".sortable").sortable({
                    placeholder: "ui-state-highlight"
                });
                $("#sortable").disableSelection();
            });

            $(document).on('mouseenter',".dataClass",function () {
                //console.log()
                $(this).closest('div').find('a').show();
            });
            $("#productName,#bannerName").keyup(function (e) {
                if (e.which == 13) {
                    $("#productSearch").trigger('click');
                }
            });
            $(document).on('click',".delete01",function () {
                var campaignID = $(this).attr('id');
                jConfirm(confirmMsg, lblAlert,function (r) {
                    if (r == true) {
                        var data = new Object();
                        data.campaignID = campaignID;
                        $.ajax({
                            type: "POST",
                            url: GLOBAL_BASE_PATH + "/campaign/ajaxdestroy/",
                            data: data,
                            beforeSend: function () {
                                $('#gridcontainer').block({
                                    message: $('#blockUILoader'),
                                    css: {
                                        padding: 0,
                                        margin: 0,
                                        width: '30%',
                                        top: '40%',
                                        left: '35%',
                                        textAlign: 'center',
                                        color: '#000',
                                        border: '0',
                                        backgroundColor: 'none',
                                        cursor: 'wait'
                                    },
                                    overlayCSS: {
                                        backgroundColor: '#000',
                                        opacity: 0.6
                                    }
                                });
                            },
                            success: function (msg) {
                                $('#gridcontainer').unblock({
                                    message: null
                                });
                                $("#gridcontainer").reload();
								location.reload();
                            }
                        });
                    }
                });
            });
            $(document).on('mouseenter',".preview01",function () {
                $(".preview01").colorbox({
                    iframe: true,
                    innerWidth: "65%",
                    innerHeight: "80%"
                });

            });
            if(showAddLink=="1")
			{
				$(document).on('mouseenter',".st-dtitle",function () {
					var cdate = ($(this).attr('abbr')).split("/");
					if (dateCompare(cdate[2] + formatDate(cdate[0]) + formatDate(cdate[1]))) $(this).find('span').html("<span style='cursor:pointer;background-color:#EBF4FB'>" + addCampaign + "</span>");
				}).live('mouseleave', function () {
					$(this).find('span').html(($(this).attr('abbr')).split("/")[1]);
				}).live('click', function () {
					var cdate = ($(this).attr('abbr')).split("/");
					if (dateCompare(cdate[2] + formatDate(cdate[0]) + formatDate(cdate[1]))) window.location = GLOBAL_BASE_PATH + "/campaign/index/cdate/" + (cdate[1] + ":" + cdate[0] + ":" + cdate[2]) + "/";
				});
			}	
        });
        function formatDate(val) {
            return val < 10 ? ('0' + val) : val;
        }
        function dateCompare(dateValue) {
            //temporary Date-- need to get from server
            var now = new Date();
            var y = (now.getFullYear()).toString();
            var m = (now.getMonth() + 1).toString();
            var d = (now.getDate()).toString();
            var todayDate = y + formatDate(m) + formatDate(d);
            return (parseInt(dateValue) >= parseInt(todayDate));
        }