AdminCouponCampaignsGridJsParams = "width=360,height=320,scrollbars=yes";

function AdminCouponCampaignsGridModify( uid ) {
	window.open( 'edit.php?mode=modify&uid='+uid , '_blank' , AdminCouponCampaignsGridJsParams );
}

function AdminCouponCampaignsGridAction( n , action , params ) {
	if ($("#"+FNTHSuperGrid_ToolbarId( n , action )).hasClass( "dsb" )) return;
	switch (action) {
	case "new":
		window.open( 'edit.php?mode=new' , '_blank' , AdminCouponCampaignsGridJsParams );break;
	case "modify":
		AdminCouponCampaignsGridModify( $("#"+n).data( "selecteds" )[0] , AdminCouponCampaignsGridJsParams );
		break;
	case "delete":
		if (!window.confirm( aJSLangDefs.articles_confirm_Delete_article )) return;
		BGAction( n , action );
		break;
	case "filter":
		$("#frm_AdminCouponCampaignsGrid").append( "<input type=\"hidden\" name=\"task\" value=\"filter\" />" );
		document.frm_AdminCouponCampaignsGrid.submit();
		break;
	case "export":
		window.open( 'export.php?coupon_campaign_id='+$("#"+n).data("selecteds")[0] , '_blank' );
		break;
	case "dlg_add_coupons":
		AdminCouponCampaignsAddCouponsDialog( params.coupon_campaign_id );
	}
}

function AdminCouponCampaignsGridSelectionChanged( tblid , chk , id ) {
	BGSelectionChanged( tblid , chk , id );
	BGSelectionChangedDefaultAMD( tblid , chk , id );
	var t = $("#"+tblid );
	var a = t.data( "selecteds" );
	if (a.length==1) {
		$("#"+tblid+"_tbrbutton_export").removeClass( "dsb" );
	} else {
		$("#"+tblid+"_tbrbutton_export").addClass( "dsb" );
	}
}

function AdminCouponCampaignsSelect( article_url , funcnum ) {
	window.opener.CKEDITOR.tools.callFunction( funcnum , article_url );
	window.close();
}

function AdminCouponCampaignsAddCoupons( cc_id ) {
	document.frm_add_coupons.cc_id.value = cc_id;
	document.frm_add_coupons.submit();
}

function AdminCouponCampaignsCancelDialog() {
	$("#dlg_add_coupons").dialog( "close" );
	$("#dlg_add_coupons").dialog( "destroy" );
}

function AdminCouponCampaignsAddCouponsDialog( cc_id ) {
	var btns = {};
	btns[aJSLangDefs.Add] = function() { AdminCouponCampaignsAddCoupons( cc_id ); }
	btns[aJSLangDefs.Cancel] = function() { AdminCouponCampaignsCancelDialog( ); }
	$("#dlg_add_coupons").dialog(
		{
			modal : true,
			title : aJSLangDefs.coupons_Add_coupons,
			buttons : btns,
			width : 320,
			height: 200
		}
	);
}
